doc: Move sections under "GNU Distribution" one level higher.
[jackhill/guix/guix.git] / doc / guix.texi
1 \input texinfo
2 @c -*-texinfo-*-
3
4 @c %**start of header
5 @setfilename guix.info
6 @documentencoding UTF-8
7 @settitle GNU Guix Reference Manual
8 @c %**end of header
9
10 @include version.texi
11
12 @c Identifier of the OpenPGP key used to sign tarballs and such.
13 @set OPENPGP-SIGNING-KEY-ID 3CE464558A84FDC69DB40CFB090B11993D9AEBB5
14 @set KEY-SERVER pool.sks-keyservers.net
15
16 @c The official substitute server used by default.
17 @set SUBSTITUTE-SERVER ci.guix.info
18
19 @copying
20 Copyright @copyright{} 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 Ludovic Courtès@*
21 Copyright @copyright{} 2013, 2014, 2016 Andreas Enge@*
22 Copyright @copyright{} 2013 Nikita Karetnikov@*
23 Copyright @copyright{} 2014, 2015, 2016 Alex Kost@*
24 Copyright @copyright{} 2015, 2016 Mathieu Lirzin@*
25 Copyright @copyright{} 2014 Pierre-Antoine Rault@*
26 Copyright @copyright{} 2015 Taylan Ulrich Bayırlı/Kammer@*
27 Copyright @copyright{} 2015, 2016, 2017 Leo Famulari@*
28 Copyright @copyright{} 2015, 2016, 2017, 2018, 2019 Ricardo Wurmus@*
29 Copyright @copyright{} 2016 Ben Woodcroft@*
30 Copyright @copyright{} 2016, 2017, 2018 Chris Marusich@*
31 Copyright @copyright{} 2016, 2017, 2018 Efraim Flashner@*
32 Copyright @copyright{} 2016 John Darrington@*
33 Copyright @copyright{} 2016, 2017 Nils Gillmann@*
34 Copyright @copyright{} 2016, 2017, 2018 Jan Nieuwenhuizen@*
35 Copyright @copyright{} 2016 Julien Lepiller@*
36 Copyright @copyright{} 2016 Alex ter Weele@*
37 Copyright @copyright{} 2017, 2018 Clément Lassieur@*
38 Copyright @copyright{} 2017, 2018 Mathieu Othacehe@*
39 Copyright @copyright{} 2017 Federico Beffa@*
40 Copyright @copyright{} 2017, 2018 Carlo Zancanaro@*
41 Copyright @copyright{} 2017 Thomas Danckaert@*
42 Copyright @copyright{} 2017 humanitiesNerd@*
43 Copyright @copyright{} 2017 Christopher Allan Webber@*
44 Copyright @copyright{} 2017, 2018 Marius Bakke@*
45 Copyright @copyright{} 2017 Hartmut Goebel@*
46 Copyright @copyright{} 2017 Maxim Cournoyer@*
47 Copyright @copyright{} 2017, 2018 Tobias Geerinckx-Rice@*
48 Copyright @copyright{} 2017 George Clemmer@*
49 Copyright @copyright{} 2017 Andy Wingo@*
50 Copyright @copyright{} 2017, 2018 Arun Isaac@*
51 Copyright @copyright{} 2017 nee@*
52 Copyright @copyright{} 2018 Rutger Helling@*
53 Copyright @copyright{} 2018 Oleg Pykhalov@*
54 Copyright @copyright{} 2018 Mike Gerwitz@*
55 Copyright @copyright{} 2018 Pierre-Antoine Rouby@*
56 Copyright @copyright{} 2018 Gábor Boskovits@*
57 Copyright @copyright{} 2018 Florian Pelz@*
58 Copyright @copyright{} 2018 Laura Lazzati@*
59 Copyright @copyright{} 2018 Alex Vong@*
60
61 Permission is granted to copy, distribute and/or modify this document
62 under the terms of the GNU Free Documentation License, Version 1.3 or
63 any later version published by the Free Software Foundation; with no
64 Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A
65 copy of the license is included in the section entitled ``GNU Free
66 Documentation License''.
67 @end copying
68
69 @dircategory System administration
70 @direntry
71 * Guix: (guix). Manage installed software and system configuration.
72 * guix package: (guix)Invoking guix package. Installing, removing, and upgrading packages.
73 * guix gc: (guix)Invoking guix gc. Reclaiming unused disk space.
74 * guix pull: (guix)Invoking guix pull. Update the list of available packages.
75 * guix system: (guix)Invoking guix system. Manage the operating system configuration.
76 @end direntry
77
78 @dircategory Software development
79 @direntry
80 * guix environment: (guix)Invoking guix environment. Building development environments with Guix.
81 * guix build: (guix)Invoking guix build. Building packages.
82 * guix pack: (guix)Invoking guix pack. Creating binary bundles.
83 @end direntry
84
85 @titlepage
86 @title GNU Guix Reference Manual
87 @subtitle Using the GNU Guix Functional Package Manager
88 @author The GNU Guix Developers
89
90 @page
91 @vskip 0pt plus 1filll
92 Edition @value{EDITION} @*
93 @value{UPDATED} @*
94
95 @insertcopying
96 @end titlepage
97
98 @contents
99
100 @c *********************************************************************
101 @node Top
102 @top GNU Guix
103
104 This document describes GNU Guix version @value{VERSION}, a functional
105 package management tool written for the GNU system.
106
107 @c TRANSLATORS: You can replace the following paragraph with information on
108 @c how to join your own translation team and how to report issues with the
109 @c translation.
110 This manual is also available in French (@pxref{Top,,, guix.fr, Manuel de
111 référence de GNU Guix}) and German (@pxref{Top,,, guix.de, Referenzhandbuch
112 zu GNU Guix}). If you would like to translate it in your native language,
113 consider joining the
114 @uref{https://translationproject.org/domain/guix-manual.html, Translation
115 Project}.
116
117 @menu
118 * Introduction:: What is Guix about?
119 * Installation:: Installing Guix.
120 * Package Management:: Package installation, upgrade, etc.
121 * Programming Interface:: Using Guix in Scheme.
122 * Utilities:: Package management commands.
123 * System Installation:: Installing the whole operating system.
124 * System Configuration:: Configuring the operating system.
125 * Documentation:: Browsing software user manuals.
126 * Installing Debugging Files:: Feeding the debugger.
127 * Security Updates:: Deploying security fixes quickly.
128 * Package Modules:: Packages from the programmer's viewpoint.
129 * Packaging Guidelines:: Growing the distribution.
130 * Bootstrapping:: GNU/Linux built from scratch.
131 * Porting:: Targeting another platform or kernel.
132 * Contributing:: Your help needed!
133
134 * Acknowledgments:: Thanks!
135 * GNU Free Documentation License:: The license of this manual.
136 * Concept Index:: Concepts.
137 * Programming Index:: Data types, functions, and variables.
138
139 @detailmenu
140 --- The Detailed Node Listing ---
141
142 Installation
143
144 * Binary Installation:: Getting Guix running in no time!
145 * Requirements:: Software needed to build and run Guix.
146 * Running the Test Suite:: Testing Guix.
147 * Setting Up the Daemon:: Preparing the build daemon's environment.
148 * Invoking guix-daemon:: Running the build daemon.
149 * Application Setup:: Application-specific setup.
150
151 Setting Up the Daemon
152
153 * Build Environment Setup:: Preparing the isolated build environment.
154 * Daemon Offload Setup:: Offloading builds to remote machines.
155 * SELinux Support:: Using an SELinux policy for the daemon.
156
157 Package Management
158
159 * Features:: How Guix will make your life brighter.
160 * Invoking guix package:: Package installation, removal, etc.
161 * Substitutes:: Downloading pre-built binaries.
162 * Packages with Multiple Outputs:: Single source package, multiple outputs.
163 * Invoking guix gc:: Running the garbage collector.
164 * Invoking guix pull:: Fetching the latest Guix and distribution.
165 * Channels:: Customizing the package collection.
166 * Inferiors:: Interacting with another revision of Guix.
167 * Invoking guix describe:: Display information about your Guix revision.
168 * Invoking guix pack:: Creating software bundles.
169 * Invoking guix archive:: Exporting and importing store files.
170
171 Substitutes
172
173 * Official Substitute Server:: One particular source of substitutes.
174 * Substitute Server Authorization:: How to enable or disable substitutes.
175 * Substitute Authentication:: How Guix verifies substitutes.
176 * Proxy Settings:: How to get substitutes via proxy.
177 * Substitution Failure:: What happens when substitution fails.
178 * On Trusting Binaries:: How can you trust that binary blob?
179
180 Programming Interface
181
182 * Defining Packages:: Defining new packages.
183 * Build Systems:: Specifying how packages are built.
184 * The Store:: Manipulating the package store.
185 * Derivations:: Low-level interface to package derivations.
186 * The Store Monad:: Purely functional interface to the store.
187 * G-Expressions:: Manipulating build expressions.
188 * Invoking guix repl:: Fiddling with Guix interactively.
189
190 Defining Packages
191
192 * package Reference:: The package data type.
193 * origin Reference:: The origin data type.
194
195 Utilities
196
197 * Invoking guix build:: Building packages from the command line.
198 * Invoking guix edit:: Editing package definitions.
199 * Invoking guix download:: Downloading a file and printing its hash.
200 * Invoking guix hash:: Computing the cryptographic hash of a file.
201 * Invoking guix import:: Importing package definitions.
202 * Invoking guix refresh:: Updating package definitions.
203 * Invoking guix lint:: Finding errors in package definitions.
204 * Invoking guix size:: Profiling disk usage.
205 * Invoking guix graph:: Visualizing the graph of packages.
206 * Invoking guix environment:: Setting up development environments.
207 * Invoking guix publish:: Sharing substitutes.
208 * Invoking guix challenge:: Challenging substitute servers.
209 * Invoking guix copy:: Copying to and from a remote store.
210 * Invoking guix container:: Process isolation.
211 * Invoking guix weather:: Assessing substitute availability.
212 * Invoking guix processes:: Listing client processes.
213
214 Invoking @command{guix build}
215
216 * Common Build Options:: Build options for most commands.
217 * Package Transformation Options:: Creating variants of packages.
218 * Additional Build Options:: Options specific to 'guix build'.
219 * Debugging Build Failures:: Real life packaging experience.
220
221 System Installation
222
223 * Limitations:: What you can expect.
224 * Hardware Considerations:: Supported hardware.
225 * USB Stick and DVD Installation:: Preparing the installation medium.
226 * Preparing for Installation:: Networking, partitioning, etc.
227 * Proceeding with the Installation:: The real thing.
228 * Installing GuixSD in a VM:: GuixSD playground.
229 * Building the Installation Image:: How this comes to be.
230
231 System Configuration
232
233 * Using the Configuration System:: Customizing your GNU system.
234 * operating-system Reference:: Detail of operating-system declarations.
235 * File Systems:: Configuring file system mounts.
236 * Mapped Devices:: Block device extra processing.
237 * User Accounts:: Specifying user accounts.
238 * Locales:: Language and cultural convention settings.
239 * Services:: Specifying system services.
240 * Setuid Programs:: Programs running with root privileges.
241 * X.509 Certificates:: Authenticating HTTPS servers.
242 * Name Service Switch:: Configuring libc's name service switch.
243 * Initial RAM Disk:: Linux-Libre bootstrapping.
244 * Bootloader Configuration:: Configuring the boot loader.
245 * Invoking guix system:: Instantiating a system configuration.
246 * Running GuixSD in a VM:: How to run GuixSD in a virtual machine.
247 * Defining Services:: Adding new service definitions.
248
249 Services
250
251 * Base Services:: Essential system services.
252 * Scheduled Job Execution:: The mcron service.
253 * Log Rotation:: The rottlog service.
254 * Networking Services:: Network setup, SSH daemon, etc.
255 * X Window:: Graphical display.
256 * Printing Services:: Local and remote printer support.
257 * Desktop Services:: D-Bus and desktop services.
258 * Sound Services:: ALSA and Pulseaudio services.
259 * Database Services:: SQL databases, key-value stores, etc.
260 * Mail Services:: IMAP, POP3, SMTP, and all that.
261 * Messaging Services:: Messaging services.
262 * Telephony Services:: Telephony services.
263 * Monitoring Services:: Monitoring services.
264 * Kerberos Services:: Kerberos services.
265 * Web Services:: Web servers.
266 * Certificate Services:: TLS certificates via Let's Encrypt.
267 * DNS Services:: DNS daemons.
268 * VPN Services:: VPN daemons.
269 * Network File System:: NFS related services.
270 * Continuous Integration:: The Cuirass service.
271 * Power Management Services:: Extending battery life.
272 * Audio Services:: The MPD.
273 * Virtualization Services:: Virtualization services.
274 * Version Control Services:: Providing remote access to Git repositories.
275 * Game Services:: Game servers.
276 * Miscellaneous Services:: Other services.
277
278 Defining Services
279
280 * Service Composition:: The model for composing services.
281 * Service Types and Services:: Types and services.
282 * Service Reference:: API reference.
283 * Shepherd Services:: A particular type of service.
284
285 Packaging Guidelines
286
287 * Software Freedom:: What may go into the distribution.
288 * Package Naming:: What's in a name?
289 * Version Numbers:: When the name is not enough.
290 * Synopses and Descriptions:: Helping users find the right package.
291 * Python Modules:: A touch of British comedy.
292 * Perl Modules:: Little pearls.
293 * Java Packages:: Coffee break.
294 * Fonts:: Fond of fonts.
295
296 @end detailmenu
297 @end menu
298
299 @c *********************************************************************
300 @node Introduction
301 @chapter Introduction
302
303 @cindex purpose
304 GNU Guix@footnote{``Guix'' is pronounced like ``geeks'', or ``ɡiːks''
305 using the international phonetic alphabet (IPA).} is a package
306 management tool for and distribution of the GNU system.
307 Guix makes it easy for unprivileged
308 users to install, upgrade, or remove software packages, to roll back to a
309 previous package set, to build packages from source, and generally
310 assists with the creation and maintenance of software environments.
311
312 @cindex Guix System
313 @cindex GuixSD
314 You can install GNU@tie{}Guix on top of an existing GNU/Linux system where it
315 complements the available tools without interference (@pxref{Installation}),
316 or you can use it as a standalone operating system distribution,
317 @dfn{Guix@tie{}System} (@pxref{GNU Distribution}).
318
319 @node Managing Software the Guix Way
320 @section Managing Software the Guix Way
321
322 @cindex user interfaces
323 Guix provides a command-line package management interface
324 (@pxref{Invoking guix package}), a set of command-line utilities
325 (@pxref{Utilities}), as well as Scheme programming interfaces
326 (@pxref{Programming Interface}).
327 @cindex build daemon
328 Its @dfn{build daemon} is responsible for building packages on behalf of
329 users (@pxref{Setting Up the Daemon}) and for downloading pre-built
330 binaries from authorized sources (@pxref{Substitutes}).
331
332 @cindex extensibility of the distribution
333 @cindex customization, of packages
334 Guix includes package definitions for many GNU and non-GNU packages, all
335 of which @uref{https://www.gnu.org/philosophy/free-sw.html, respect the
336 user's computing freedom}. It is @emph{extensible}: users can write
337 their own package definitions (@pxref{Defining Packages}) and make them
338 available as independent package modules (@pxref{Package Modules}). It
339 is also @emph{customizable}: users can @emph{derive} specialized package
340 definitions from existing ones, including from the command line
341 (@pxref{Package Transformation Options}).
342
343 @cindex functional package management
344 @cindex isolation
345 Under the hood, Guix implements the @dfn{functional package management}
346 discipline pioneered by Nix (@pxref{Acknowledgments}).
347 In Guix, the package build and installation process is seen
348 as a @emph{function}, in the mathematical sense. That function takes inputs,
349 such as build scripts, a compiler, and libraries, and
350 returns an installed package. As a pure function, its result depends
351 solely on its inputs---for instance, it cannot refer to software or
352 scripts that were not explicitly passed as inputs. A build function
353 always produces the same result when passed a given set of inputs. It
354 cannot alter the environment of the running system in
355 any way; for instance, it cannot create, modify, or delete files outside
356 of its build and installation directories. This is achieved by running
357 build processes in isolated environments (or @dfn{containers}), where only their
358 explicit inputs are visible.
359
360 @cindex store
361 The result of package build functions is @dfn{cached} in the file
362 system, in a special directory called @dfn{the store} (@pxref{The
363 Store}). Each package is installed in a directory of its own in the
364 store---by default under @file{/gnu/store}. The directory name contains
365 a hash of all the inputs used to build that package; thus, changing an
366 input yields a different directory name.
367
368 This approach is the foundation for the salient features of Guix: support
369 for transactional package upgrade and rollback, per-user installation, and
370 garbage collection of packages (@pxref{Features}).
371
372
373 @node GNU Distribution
374 @section GNU Distribution
375
376 @cindex Guix System
377 @cindex GuixSD
378 Guix comes with a distribution of the GNU system consisting entirely of
379 free software@footnote{The term ``free'' here refers to the
380 @url{http://www.gnu.org/philosophy/free-sw.html,freedom provided to
381 users of that software}.}. The
382 distribution can be installed on its own (@pxref{System Installation}),
383 but it is also possible to install Guix as a package manager on top of
384 an installed GNU/Linux system (@pxref{Installation}). When we need to
385 distinguish between the two, we refer to the standalone distribution as
386 Guix@tie{}System.
387
388 The distribution provides core GNU packages such as GNU libc, GCC, and
389 Binutils, as well as many GNU and non-GNU applications. The complete
390 list of available packages can be browsed
391 @url{http://www.gnu.org/software/guix/packages,on-line} or by
392 running @command{guix package} (@pxref{Invoking guix package}):
393
394 @example
395 guix package --list-available
396 @end example
397
398 Our goal is to provide a practical 100% free software distribution of
399 Linux-based and other variants of GNU, with a focus on the promotion and
400 tight integration of GNU components, and an emphasis on programs and
401 tools that help users exert that freedom.
402
403 Packages are currently available on the following platforms:
404
405 @table @code
406
407 @item x86_64-linux
408 Intel/AMD @code{x86_64} architecture, Linux-Libre kernel;
409
410 @item i686-linux
411 Intel 32-bit architecture (IA32), Linux-Libre kernel;
412
413 @item armhf-linux
414 ARMv7-A architecture with hard float, Thumb-2 and NEON,
415 using the EABI hard-float application binary interface (ABI),
416 and Linux-Libre kernel.
417
418 @item aarch64-linux
419 little-endian 64-bit ARMv8-A processors, Linux-Libre kernel. This is
420 currently in an experimental stage, with limited support.
421 @xref{Contributing}, for how to help!
422
423 @item mips64el-linux
424 little-endian 64-bit MIPS processors, specifically the Loongson series,
425 n32 ABI, and Linux-Libre kernel.
426
427 @end table
428
429 With Guix@tie{}System, you @emph{declare} all aspects of the operating system
430 configuration and Guix takes care of instantiating the configuration in a
431 transactional, reproducible, and stateless fashion (@pxref{System
432 Configuration}). Guix System uses the Linux-libre kernel, the Shepherd
433 initialization system (@pxref{Introduction,,, shepherd, The GNU Shepherd
434 Manual}), the well-known GNU utilities and tool chain, as well as the
435 graphical environment or system services of your choice.
436
437 Guix System is available on all the above platforms except
438 @code{mips64el-linux}.
439
440 @noindent
441 For information on porting to other architectures or kernels,
442 @pxref{Porting}.
443
444 Building this distribution is a cooperative effort, and you are invited
445 to join! @xref{Contributing}, for information about how you can help.
446
447
448 @c *********************************************************************
449 @node Installation
450 @chapter Installation
451
452 @cindex installing Guix
453
454 @quotation Note
455 We recommend the use of this
456 @uref{https://git.savannah.gnu.org/cgit/guix.git/plain/etc/guix-install.sh,
457 shell installer script} to install Guix on top of a running GNU/Linux system,
458 thereafter called a @dfn{foreign distro}.@footnote{This section is concerned
459 with the installation of the package manager, which can be done on top of a
460 running GNU/Linux system. If, instead, you want to install the complete GNU
461 operating system, @pxref{System Installation}.} The script automates the
462 download, installation, and initial configuration of Guix. It should be run
463 as the root user.
464 @end quotation
465
466 @cindex foreign distro
467 @cindex directories related to foreign distro
468 When installed on a foreign distro, GNU@tie{}Guix complements the available
469 tools without interference. Its data lives exclusively in two directories,
470 usually @file{/gnu/store} and @file{/var/guix}; other files on your system,
471 such as @file{/etc}, are left untouched.
472
473 Once installed, Guix can be updated by running @command{guix pull}
474 (@pxref{Invoking guix pull}).
475
476 If you prefer to perform the installation steps manually or want to tweak
477 them, you may find the following subsections useful. They describe the
478 software requirements of Guix, as well as how to install it manually and get
479 ready to use it.
480
481 @menu
482 * Binary Installation:: Getting Guix running in no time!
483 * Requirements:: Software needed to build and run Guix.
484 * Running the Test Suite:: Testing Guix.
485 * Setting Up the Daemon:: Preparing the build daemon's environment.
486 * Invoking guix-daemon:: Running the build daemon.
487 * Application Setup:: Application-specific setup.
488 @end menu
489
490 @node Binary Installation
491 @section Binary Installation
492
493 @cindex installing Guix from binaries
494 @cindex installer script
495 This section describes how to install Guix on an arbitrary system from a
496 self-contained tarball providing binaries for Guix and for all its
497 dependencies. This is often quicker than installing from source, which
498 is described in the next sections. The only requirement is to have
499 GNU@tie{}tar and Xz.
500
501 Installing goes along these lines:
502
503 @enumerate
504 @item
505 @cindex downloading Guix binary
506 Download the binary tarball from
507 @indicateurl{https://alpha.gnu.org/gnu/guix/guix-binary-@value{VERSION}.@var{system}.tar.xz},
508 where @var{system} is @code{x86_64-linux} for an @code{x86_64} machine
509 already running the kernel Linux, and so on.
510
511 @c The following is somewhat duplicated in ``System Installation''.
512 Make sure to download the associated @file{.sig} file and to verify the
513 authenticity of the tarball against it, along these lines:
514
515 @example
516 $ wget https://alpha.gnu.org/gnu/guix/guix-binary-@value{VERSION}.@var{system}.tar.xz.sig
517 $ gpg --verify guix-binary-@value{VERSION}.@var{system}.tar.xz.sig
518 @end example
519
520 If that command fails because you do not have the required public key,
521 then run this command to import it:
522
523 @example
524 $ gpg --keyserver @value{KEY-SERVER} \
525 --recv-keys @value{OPENPGP-SIGNING-KEY-ID}
526 @end example
527
528 @noindent
529 and rerun the @code{gpg --verify} command.
530 @c end authentication part
531
532 @item
533 Now, you need to become the @code{root} user. Depending on your distribution,
534 you may have to run @code{su -} or @code{sudo -i}. As @code{root}, run:
535
536 @example
537 # cd /tmp
538 # tar --warning=no-timestamp -xf \
539 guix-binary-@value{VERSION}.@var{system}.tar.xz
540 # mv var/guix /var/ && mv gnu /
541 @end example
542
543 This creates @file{/gnu/store} (@pxref{The Store}) and @file{/var/guix}.
544 The latter contains a ready-to-use profile for @code{root} (see next
545 step.)
546
547 Do @emph{not} unpack the tarball on a working Guix system since that
548 would overwrite its own essential files.
549
550 The @code{--warning=no-timestamp} option makes sure GNU@tie{}tar does
551 not emit warnings about ``implausibly old time stamps'' (such
552 warnings were triggered by GNU@tie{}tar 1.26 and older; recent
553 versions are fine.)
554 They stem from the fact that all the
555 files in the archive have their modification time set to zero (which
556 means January 1st, 1970.) This is done on purpose to make sure the
557 archive content is independent of its creation time, thus making it
558 reproducible.
559
560 @item
561 Make the profile available under @file{~root/.config/guix/current}, which is
562 where @command{guix pull} will install updates (@pxref{Invoking guix pull}):
563
564 @example
565 # mkdir -p ~root/.config/guix
566 # ln -sf /var/guix/profiles/per-user/root/current-guix \
567 ~root/.config/guix/current
568 @end example
569
570 Source @file{etc/profile} to augment @code{PATH} and other relevant
571 environment variables:
572
573 @example
574 # GUIX_PROFILE="`echo ~root`/.config/guix/current" ; \
575 source $GUIX_PROFILE/etc/profile
576 @end example
577
578 @item
579 Create the group and user accounts for build users as explained below
580 (@pxref{Build Environment Setup}).
581
582 @item
583 Run the daemon, and set it to automatically start on boot.
584
585 If your host distro uses the systemd init system, this can be achieved
586 with these commands:
587
588 @c Versions of systemd that supported symlinked service files are not
589 @c yet widely deployed, so we should suggest that users copy the service
590 @c files into place.
591 @c
592 @c See this thread for more information:
593 @c http://lists.gnu.org/archive/html/guix-devel/2017-01/msg01199.html
594
595 @example
596 # cp ~root/.config/guix/current/lib/systemd/system/guix-daemon.service \
597 /etc/systemd/system/
598 # systemctl start guix-daemon && systemctl enable guix-daemon
599 @end example
600
601 If your host distro uses the Upstart init system:
602
603 @example
604 # initctl reload-configuration
605 # cp ~root/.config/guix/current/lib/upstart/system/guix-daemon.conf \
606 /etc/init/
607 # start guix-daemon
608 @end example
609
610 Otherwise, you can still start the daemon manually with:
611
612 @example
613 # ~root/.config/guix/current/bin/guix-daemon \
614 --build-users-group=guixbuild
615 @end example
616
617 @item
618 Make the @command{guix} command available to other users on the machine,
619 for instance with:
620
621 @example
622 # mkdir -p /usr/local/bin
623 # cd /usr/local/bin
624 # ln -s /var/guix/profiles/per-user/root/current-guix/bin/guix
625 @end example
626
627 It is also a good idea to make the Info version of this manual available
628 there:
629
630 @example
631 # mkdir -p /usr/local/share/info
632 # cd /usr/local/share/info
633 # for i in /var/guix/profiles/per-user/root/current-guix/share/info/* ;
634 do ln -s $i ; done
635 @end example
636
637 That way, assuming @file{/usr/local/share/info} is in the search path,
638 running @command{info guix} will open this manual (@pxref{Other Info
639 Directories,,, texinfo, GNU Texinfo}, for more details on changing the
640 Info search path.)
641
642 @item
643 @cindex substitutes, authorization thereof
644 To use substitutes from @code{@value{SUBSTITUTE-SERVER}} or one of its mirrors
645 (@pxref{Substitutes}), authorize them:
646
647 @example
648 # guix archive --authorize < \
649 ~root/.config/guix/current/share/guix/@value{SUBSTITUTE-SERVER}.pub
650 @end example
651
652 @item
653 Each user may need to perform a few additional steps to make their Guix
654 environment ready for use, @pxref{Application Setup}.
655 @end enumerate
656
657 Voilà, the installation is complete!
658
659 You can confirm that Guix is working by installing a sample package into
660 the root profile:
661
662 @example
663 # guix package -i hello
664 @end example
665
666 The @code{guix} package must remain available in @code{root}'s profile,
667 or it would become subject to garbage collection---in which case you
668 would find yourself badly handicapped by the lack of the @command{guix}
669 command. In other words, do not remove @code{guix} by running
670 @code{guix package -r guix}.
671
672 The binary installation tarball can be (re)produced and verified simply
673 by running the following command in the Guix source tree:
674
675 @example
676 make guix-binary.@var{system}.tar.xz
677 @end example
678
679 @noindent
680 ...@: which, in turn, runs:
681
682 @example
683 guix pack -s @var{system} --localstatedir \
684 --profile-name=current-guix guix
685 @end example
686
687 @xref{Invoking guix pack}, for more info on this handy tool.
688
689 @node Requirements
690 @section Requirements
691
692 This section lists requirements when building Guix from source. The
693 build procedure for Guix is the same as for other GNU software, and is
694 not covered here. Please see the files @file{README} and @file{INSTALL}
695 in the Guix source tree for additional details.
696
697 @cindex official website
698 GNU Guix is available for download from its website at
699 @url{https://www.gnu.org/software/guix/}.
700
701 GNU Guix depends on the following packages:
702
703 @itemize
704 @item @url{http://gnu.org/software/guile/, GNU Guile}, version 2.2.x;
705 @item @url{https://notabug.org/cwebber/guile-gcrypt, Guile-Gcrypt}, version
706 0.1.0 or later;
707 @item
708 @uref{http://gnutls.org/, GnuTLS}, specifically its Guile bindings
709 (@pxref{Guile Preparations, how to install the GnuTLS bindings for
710 Guile,, gnutls-guile, GnuTLS-Guile});
711 @item
712 @uref{https://notabug.org/guile-sqlite3/guile-sqlite3, Guile-SQLite3}, version 0.1.0
713 or later;
714 @item
715 @c FIXME: Specify a version number once a release has been made.
716 @uref{https://gitlab.com/guile-git/guile-git, Guile-Git}, from August
717 2017 or later;
718 @item @uref{https://savannah.nongnu.org/projects/guile-json/, Guile-JSON};
719 @item @url{http://zlib.net, zlib};
720 @item @url{http://www.gnu.org/software/make/, GNU Make}.
721 @end itemize
722
723 The following dependencies are optional:
724
725 @itemize
726 @item
727 @c Note: We need at least 0.10.2 for 'channel-send-eof'.
728 Support for build offloading (@pxref{Daemon Offload Setup}) and
729 @command{guix copy} (@pxref{Invoking guix copy}) depends on
730 @uref{https://github.com/artyom-poptsov/guile-ssh, Guile-SSH},
731 version 0.10.2 or later.
732
733 @item
734 When @url{http://www.bzip.org, libbz2} is available,
735 @command{guix-daemon} can use it to compress build logs.
736 @end itemize
737
738 Unless @code{--disable-daemon} was passed to @command{configure}, the
739 following packages are also needed:
740
741 @itemize
742 @item @url{http://gnupg.org/, GNU libgcrypt};
743 @item @url{http://sqlite.org, SQLite 3};
744 @item @url{http://gcc.gnu.org, GCC's g++}, with support for the
745 C++11 standard.
746 @end itemize
747
748 @cindex state directory
749 When configuring Guix on a system that already has a Guix installation,
750 be sure to specify the same state directory as the existing installation
751 using the @code{--localstatedir} option of the @command{configure}
752 script (@pxref{Directory Variables, @code{localstatedir},, standards,
753 GNU Coding Standards}). The @command{configure} script protects against
754 unintended misconfiguration of @var{localstatedir} so you do not
755 inadvertently corrupt your store (@pxref{The Store}).
756
757 @cindex Nix, compatibility
758 When a working installation of @url{http://nixos.org/nix/, the Nix package
759 manager} is available, you
760 can instead configure Guix with @code{--disable-daemon}. In that case,
761 Nix replaces the three dependencies above.
762
763 Guix is compatible with Nix, so it is possible to share the same store
764 between both. To do so, you must pass @command{configure} not only the
765 same @code{--with-store-dir} value, but also the same
766 @code{--localstatedir} value. The latter is essential because it
767 specifies where the database that stores metadata about the store is
768 located, among other things. The default values for Nix are
769 @code{--with-store-dir=/nix/store} and @code{--localstatedir=/nix/var}.
770 Note that @code{--disable-daemon} is not required if
771 your goal is to share the store with Nix.
772
773 @node Running the Test Suite
774 @section Running the Test Suite
775
776 @cindex test suite
777 After a successful @command{configure} and @code{make} run, it is a good
778 idea to run the test suite. It can help catch issues with the setup or
779 environment, or bugs in Guix itself---and really, reporting test
780 failures is a good way to help improve the software. To run the test
781 suite, type:
782
783 @example
784 make check
785 @end example
786
787 Test cases can run in parallel: you can use the @code{-j} option of
788 GNU@tie{}make to speed things up. The first run may take a few minutes
789 on a recent machine; subsequent runs will be faster because the store
790 that is created for test purposes will already have various things in
791 cache.
792
793 It is also possible to run a subset of the tests by defining the
794 @code{TESTS} makefile variable as in this example:
795
796 @example
797 make check TESTS="tests/store.scm tests/cpio.scm"
798 @end example
799
800 By default, tests results are displayed at a file level. In order to
801 see the details of every individual test cases, it is possible to define
802 the @code{SCM_LOG_DRIVER_FLAGS} makefile variable as in this example:
803
804 @example
805 make check TESTS="tests/base64.scm" SCM_LOG_DRIVER_FLAGS="--brief=no"
806 @end example
807
808 Upon failure, please email @email{bug-guix@@gnu.org} and attach the
809 @file{test-suite.log} file. Please specify the Guix version being used
810 as well as version numbers of the dependencies (@pxref{Requirements}) in
811 your message.
812
813 Guix also comes with a whole-system test suite that tests complete
814 GuixSD operating system instances. It can only run on systems where
815 Guix is already installed, using:
816
817 @example
818 make check-system
819 @end example
820
821 @noindent
822 or, again, by defining @code{TESTS} to select a subset of tests to run:
823
824 @example
825 make check-system TESTS="basic mcron"
826 @end example
827
828 These system tests are defined in the @code{(gnu tests @dots{})}
829 modules. They work by running the operating systems under test with
830 lightweight instrumentation in a virtual machine (VM). They can be
831 computationally intensive or rather cheap, depending on whether
832 substitutes are available for their dependencies (@pxref{Substitutes}).
833 Some of them require a lot of storage space to hold VM images.
834
835 Again in case of test failures, please send @email{bug-guix@@gnu.org}
836 all the details.
837
838 @node Setting Up the Daemon
839 @section Setting Up the Daemon
840
841 @cindex daemon
842 Operations such as building a package or running the garbage collector
843 are all performed by a specialized process, the @dfn{build daemon}, on
844 behalf of clients. Only the daemon may access the store and its
845 associated database. Thus, any operation that manipulates the store
846 goes through the daemon. For instance, command-line tools such as
847 @command{guix package} and @command{guix build} communicate with the
848 daemon (@i{via} remote procedure calls) to instruct it what to do.
849
850 The following sections explain how to prepare the build daemon's
851 environment. See also @ref{Substitutes}, for information on how to allow
852 the daemon to download pre-built binaries.
853
854 @menu
855 * Build Environment Setup:: Preparing the isolated build environment.
856 * Daemon Offload Setup:: Offloading builds to remote machines.
857 * SELinux Support:: Using an SELinux policy for the daemon.
858 @end menu
859
860 @node Build Environment Setup
861 @subsection Build Environment Setup
862
863 @cindex build environment
864 In a standard multi-user setup, Guix and its daemon---the
865 @command{guix-daemon} program---are installed by the system
866 administrator; @file{/gnu/store} is owned by @code{root} and
867 @command{guix-daemon} runs as @code{root}. Unprivileged users may use
868 Guix tools to build packages or otherwise access the store, and the
869 daemon will do it on their behalf, ensuring that the store is kept in a
870 consistent state, and allowing built packages to be shared among users.
871
872 @cindex build users
873 When @command{guix-daemon} runs as @code{root}, you may not want package
874 build processes themselves to run as @code{root} too, for obvious
875 security reasons. To avoid that, a special pool of @dfn{build users}
876 should be created for use by build processes started by the daemon.
877 These build users need not have a shell and a home directory: they will
878 just be used when the daemon drops @code{root} privileges in build
879 processes. Having several such users allows the daemon to launch
880 distinct build processes under separate UIDs, which guarantees that they
881 do not interfere with each other---an essential feature since builds are
882 regarded as pure functions (@pxref{Introduction}).
883
884 On a GNU/Linux system, a build user pool may be created like this (using
885 Bash syntax and the @code{shadow} commands):
886
887 @c See http://lists.gnu.org/archive/html/bug-guix/2013-01/msg00239.html
888 @c for why `-G' is needed.
889 @example
890 # groupadd --system guixbuild
891 # for i in `seq -w 1 10`;
892 do
893 useradd -g guixbuild -G guixbuild \
894 -d /var/empty -s `which nologin` \
895 -c "Guix build user $i" --system \
896 guixbuilder$i;
897 done
898 @end example
899
900 @noindent
901 The number of build users determines how many build jobs may run in
902 parallel, as specified by the @option{--max-jobs} option
903 (@pxref{Invoking guix-daemon, @option{--max-jobs}}). To use
904 @command{guix system vm} and related commands, you may need to add the
905 build users to the @code{kvm} group so they can access @file{/dev/kvm},
906 using @code{-G guixbuild,kvm} instead of @code{-G guixbuild}
907 (@pxref{Invoking guix system}).
908
909 The @code{guix-daemon} program may then be run as @code{root} with the
910 following command@footnote{If your machine uses the systemd init system,
911 dropping the @file{@var{prefix}/lib/systemd/system/guix-daemon.service}
912 file in @file{/etc/systemd/system} will ensure that
913 @command{guix-daemon} is automatically started. Similarly, if your
914 machine uses the Upstart init system, drop the
915 @file{@var{prefix}/lib/upstart/system/guix-daemon.conf}
916 file in @file{/etc/init}.}:
917
918 @example
919 # guix-daemon --build-users-group=guixbuild
920 @end example
921
922 @cindex chroot
923 @noindent
924 This way, the daemon starts build processes in a chroot, under one of
925 the @code{guixbuilder} users. On GNU/Linux, by default, the chroot
926 environment contains nothing but:
927
928 @c Keep this list in sync with libstore/build.cc! -----------------------
929 @itemize
930 @item
931 a minimal @code{/dev} directory, created mostly independently from the
932 host @code{/dev}@footnote{``Mostly'', because while the set of files
933 that appear in the chroot's @code{/dev} is fixed, most of these files
934 can only be created if the host has them.};
935
936 @item
937 the @code{/proc} directory; it only shows the processes of the container
938 since a separate PID name space is used;
939
940 @item
941 @file{/etc/passwd} with an entry for the current user and an entry for
942 user @file{nobody};
943
944 @item
945 @file{/etc/group} with an entry for the user's group;
946
947 @item
948 @file{/etc/hosts} with an entry that maps @code{localhost} to
949 @code{127.0.0.1};
950
951 @item
952 a writable @file{/tmp} directory.
953 @end itemize
954
955 You can influence the directory where the daemon stores build trees
956 @i{via} the @code{TMPDIR} environment variable. However, the build tree
957 within the chroot is always called @file{/tmp/guix-build-@var{name}.drv-0},
958 where @var{name} is the derivation name---e.g., @code{coreutils-8.24}.
959 This way, the value of @code{TMPDIR} does not leak inside build
960 environments, which avoids discrepancies in cases where build processes
961 capture the name of their build tree.
962
963 @vindex http_proxy
964 The daemon also honors the @code{http_proxy} environment variable for
965 HTTP downloads it performs, be it for fixed-output derivations
966 (@pxref{Derivations}) or for substitutes (@pxref{Substitutes}).
967
968 If you are installing Guix as an unprivileged user, it is still possible
969 to run @command{guix-daemon} provided you pass @code{--disable-chroot}.
970 However, build processes will not be isolated from one another, and not
971 from the rest of the system. Thus, build processes may interfere with
972 each other, and may access programs, libraries, and other files
973 available on the system---making it much harder to view them as
974 @emph{pure} functions.
975
976
977 @node Daemon Offload Setup
978 @subsection Using the Offload Facility
979
980 @cindex offloading
981 @cindex build hook
982 When desired, the build daemon can @dfn{offload} derivation builds to
983 other machines running Guix, using the @code{offload} @dfn{build
984 hook}@footnote{This feature is available only when
985 @uref{https://github.com/artyom-poptsov/guile-ssh, Guile-SSH} is
986 present.}. When that
987 feature is enabled, a list of user-specified build machines is read from
988 @file{/etc/guix/machines.scm}; every time a build is requested, for
989 instance via @code{guix build}, the daemon attempts to offload it to one
990 of the machines that satisfy the constraints of the derivation, in
991 particular its system type---e.g., @file{x86_64-linux}. Missing
992 prerequisites for the build are copied over SSH to the target machine,
993 which then proceeds with the build; upon success the output(s) of the
994 build are copied back to the initial machine.
995
996 The @file{/etc/guix/machines.scm} file typically looks like this:
997
998 @example
999 (list (build-machine
1000 (name "eightysix.example.org")
1001 (system "x86_64-linux")
1002 (host-key "ssh-ed25519 AAAAC3Nza@dots{}")
1003 (user "bob")
1004 (speed 2.)) ;incredibly fast!
1005
1006 (build-machine
1007 (name "meeps.example.org")
1008 (system "mips64el-linux")
1009 (host-key "ssh-rsa AAAAB3Nza@dots{}")
1010 (user "alice")
1011 (private-key
1012 (string-append (getenv "HOME")
1013 "/.ssh/identity-for-guix"))))
1014 @end example
1015
1016 @noindent
1017 In the example above we specify a list of two build machines, one for
1018 the @code{x86_64} architecture and one for the @code{mips64el}
1019 architecture.
1020
1021 In fact, this file is---not surprisingly!---a Scheme file that is
1022 evaluated when the @code{offload} hook is started. Its return value
1023 must be a list of @code{build-machine} objects. While this example
1024 shows a fixed list of build machines, one could imagine, say, using
1025 DNS-SD to return a list of potential build machines discovered in the
1026 local network (@pxref{Introduction, Guile-Avahi,, guile-avahi, Using
1027 Avahi in Guile Scheme Programs}). The @code{build-machine} data type is
1028 detailed below.
1029
1030 @deftp {Data Type} build-machine
1031 This data type represents build machines to which the daemon may offload
1032 builds. The important fields are:
1033
1034 @table @code
1035
1036 @item name
1037 The host name of the remote machine.
1038
1039 @item system
1040 The system type of the remote machine---e.g., @code{"x86_64-linux"}.
1041
1042 @item user
1043 The user account to use when connecting to the remote machine over SSH.
1044 Note that the SSH key pair must @emph{not} be passphrase-protected, to
1045 allow non-interactive logins.
1046
1047 @item host-key
1048 This must be the machine's SSH @dfn{public host key} in OpenSSH format.
1049 This is used to authenticate the machine when we connect to it. It is a
1050 long string that looks like this:
1051
1052 @example
1053 ssh-ed25519 AAAAC3NzaC@dots{}mde+UhL hint@@example.org
1054 @end example
1055
1056 If the machine is running the OpenSSH daemon, @command{sshd}, the host
1057 key can be found in a file such as
1058 @file{/etc/ssh/ssh_host_ed25519_key.pub}.
1059
1060 If the machine is running the SSH daemon of GNU@tie{}lsh,
1061 @command{lshd}, the host key is in @file{/etc/lsh/host-key.pub} or a
1062 similar file. It can be converted to the OpenSSH format using
1063 @command{lsh-export-key} (@pxref{Converting keys,,, lsh, LSH Manual}):
1064
1065 @example
1066 $ lsh-export-key --openssh < /etc/lsh/host-key.pub
1067 ssh-rsa AAAAB3NzaC1yc2EAAAAEOp8FoQAAAQEAs1eB46LV@dots{}
1068 @end example
1069
1070 @end table
1071
1072 A number of optional fields may be specified:
1073
1074 @table @asis
1075
1076 @item @code{port} (default: @code{22})
1077 Port number of SSH server on the machine.
1078
1079 @item @code{private-key} (default: @file{~root/.ssh/id_rsa})
1080 The SSH private key file to use when connecting to the machine, in
1081 OpenSSH format. This key must not be protected with a passphrase.
1082
1083 Note that the default value is the private key @emph{of the root
1084 account}. Make sure it exists if you use the default.
1085
1086 @item @code{compression} (default: @code{"zlib@@openssh.com,zlib"})
1087 @itemx @code{compression-level} (default: @code{3})
1088 The SSH-level compression methods and compression level requested.
1089
1090 Note that offloading relies on SSH compression to reduce bandwidth usage
1091 when transferring files to and from build machines.
1092
1093 @item @code{daemon-socket} (default: @code{"/var/guix/daemon-socket/socket"})
1094 File name of the Unix-domain socket @command{guix-daemon} is listening
1095 to on that machine.
1096
1097 @item @code{parallel-builds} (default: @code{1})
1098 The number of builds that may run in parallel on the machine.
1099
1100 @item @code{speed} (default: @code{1.0})
1101 A ``relative speed factor''. The offload scheduler will tend to prefer
1102 machines with a higher speed factor.
1103
1104 @item @code{features} (default: @code{'()})
1105 A list of strings denoting specific features supported by the machine.
1106 An example is @code{"kvm"} for machines that have the KVM Linux modules
1107 and corresponding hardware support. Derivations can request features by
1108 name, and they will be scheduled on matching build machines.
1109
1110 @end table
1111 @end deftp
1112
1113 The @command{guix} command must be in the search path on the build
1114 machines. You can check whether this is the case by running:
1115
1116 @example
1117 ssh build-machine guix repl --version
1118 @end example
1119
1120 There is one last thing to do once @file{machines.scm} is in place. As
1121 explained above, when offloading, files are transferred back and forth
1122 between the machine stores. For this to work, you first need to
1123 generate a key pair on each machine to allow the daemon to export signed
1124 archives of files from the store (@pxref{Invoking guix archive}):
1125
1126 @example
1127 # guix archive --generate-key
1128 @end example
1129
1130 @noindent
1131 Each build machine must authorize the key of the master machine so that
1132 it accepts store items it receives from the master:
1133
1134 @example
1135 # guix archive --authorize < master-public-key.txt
1136 @end example
1137
1138 @noindent
1139 Likewise, the master machine must authorize the key of each build machine.
1140
1141 All the fuss with keys is here to express pairwise mutual trust
1142 relations between the master and the build machines. Concretely, when
1143 the master receives files from a build machine (and @i{vice versa}), its
1144 build daemon can make sure they are genuine, have not been tampered
1145 with, and that they are signed by an authorized key.
1146
1147 @cindex offload test
1148 To test whether your setup is operational, run this command on the
1149 master node:
1150
1151 @example
1152 # guix offload test
1153 @end example
1154
1155 This will attempt to connect to each of the build machines specified in
1156 @file{/etc/guix/machines.scm}, make sure Guile and the Guix modules are
1157 available on each machine, attempt to export to the machine and import
1158 from it, and report any error in the process.
1159
1160 If you want to test a different machine file, just specify it on the
1161 command line:
1162
1163 @example
1164 # guix offload test machines-qualif.scm
1165 @end example
1166
1167 Last, you can test the subset of the machines whose name matches a
1168 regular expression like this:
1169
1170 @example
1171 # guix offload test machines.scm '\.gnu\.org$'
1172 @end example
1173
1174 @cindex offload status
1175 To display the current load of all build hosts, run this command on the
1176 main node:
1177
1178 @example
1179 # guix offload status
1180 @end example
1181
1182
1183 @node SELinux Support
1184 @subsection SELinux Support
1185
1186 @cindex SELinux, daemon policy
1187 @cindex mandatory access control, SELinux
1188 @cindex security, guix-daemon
1189 Guix includes an SELinux policy file at @file{etc/guix-daemon.cil} that
1190 can be installed on a system where SELinux is enabled, in order to label
1191 Guix files and to specify the expected behavior of the daemon. Since
1192 GuixSD does not provide an SELinux base policy, the daemon policy cannot
1193 be used on GuixSD.
1194
1195 @subsubsection Installing the SELinux policy
1196 @cindex SELinux, policy installation
1197 To install the policy run this command as root:
1198
1199 @example
1200 semodule -i etc/guix-daemon.cil
1201 @end example
1202
1203 Then relabel the file system with @code{restorecon} or by a different
1204 mechanism provided by your system.
1205
1206 Once the policy is installed, the file system has been relabeled, and
1207 the daemon has been restarted, it should be running in the
1208 @code{guix_daemon_t} context. You can confirm this with the following
1209 command:
1210
1211 @example
1212 ps -Zax | grep guix-daemon
1213 @end example
1214
1215 Monitor the SELinux log files as you run a command like @code{guix build
1216 hello} to convince yourself that SELinux permits all necessary
1217 operations.
1218
1219 @subsubsection Limitations
1220 @cindex SELinux, limitations
1221
1222 This policy is not perfect. Here is a list of limitations or quirks
1223 that should be considered when deploying the provided SELinux policy for
1224 the Guix daemon.
1225
1226 @enumerate
1227 @item
1228 @code{guix_daemon_socket_t} isn’t actually used. None of the socket
1229 operations involve contexts that have anything to do with
1230 @code{guix_daemon_socket_t}. It doesn’t hurt to have this unused label,
1231 but it would be preferrable to define socket rules for only this label.
1232
1233 @item
1234 @code{guix gc} cannot access arbitrary links to profiles. By design,
1235 the file label of the destination of a symlink is independent of the
1236 file label of the link itself. Although all profiles under
1237 $localstatedir are labelled, the links to these profiles inherit the
1238 label of the directory they are in. For links in the user’s home
1239 directory this will be @code{user_home_t}. But for links from the root
1240 user’s home directory, or @file{/tmp}, or the HTTP server’s working
1241 directory, etc, this won’t work. @code{guix gc} would be prevented from
1242 reading and following these links.
1243
1244 @item
1245 The daemon’s feature to listen for TCP connections might no longer work.
1246 This might require extra rules, because SELinux treats network sockets
1247 differently from files.
1248
1249 @item
1250 Currently all files with a name matching the regular expression
1251 @code{/gnu/store/.+-(guix-.+|profile)/bin/guix-daemon} are assigned the
1252 label @code{guix_daemon_exec_t}; this means that @emph{any} file with
1253 that name in any profile would be permitted to run in the
1254 @code{guix_daemon_t} domain. This is not ideal. An attacker could
1255 build a package that provides this executable and convince a user to
1256 install and run it, which lifts it into the @code{guix_daemon_t} domain.
1257 At that point SELinux could not prevent it from accessing files that are
1258 allowed for processes in that domain.
1259
1260 We could generate a much more restrictive policy at installation time,
1261 so that only the @emph{exact} file name of the currently installed
1262 @code{guix-daemon} executable would be labelled with
1263 @code{guix_daemon_exec_t}, instead of using a broad regular expression.
1264 The downside is that root would have to install or upgrade the policy at
1265 installation time whenever the Guix package that provides the
1266 effectively running @code{guix-daemon} executable is upgraded.
1267 @end enumerate
1268
1269 @node Invoking guix-daemon
1270 @section Invoking @command{guix-daemon}
1271
1272 The @command{guix-daemon} program implements all the functionality to
1273 access the store. This includes launching build processes, running the
1274 garbage collector, querying the availability of a build result, etc. It
1275 is normally run as @code{root} like this:
1276
1277 @example
1278 # guix-daemon --build-users-group=guixbuild
1279 @end example
1280
1281 @noindent
1282 For details on how to set it up, @pxref{Setting Up the Daemon}.
1283
1284 @cindex chroot
1285 @cindex container, build environment
1286 @cindex build environment
1287 @cindex reproducible builds
1288 By default, @command{guix-daemon} launches build processes under
1289 different UIDs, taken from the build group specified with
1290 @code{--build-users-group}. In addition, each build process is run in a
1291 chroot environment that only contains the subset of the store that the
1292 build process depends on, as specified by its derivation
1293 (@pxref{Programming Interface, derivation}), plus a set of specific
1294 system directories. By default, the latter contains @file{/dev} and
1295 @file{/dev/pts}. Furthermore, on GNU/Linux, the build environment is a
1296 @dfn{container}: in addition to having its own file system tree, it has
1297 a separate mount name space, its own PID name space, network name space,
1298 etc. This helps achieve reproducible builds (@pxref{Features}).
1299
1300 When the daemon performs a build on behalf of the user, it creates a
1301 build directory under @file{/tmp} or under the directory specified by
1302 its @code{TMPDIR} environment variable. This directory is shared with
1303 the container for the duration of the build, though within the container,
1304 the build tree is always called @file{/tmp/guix-build-@var{name}.drv-0}.
1305
1306 The build directory is automatically deleted upon completion, unless the
1307 build failed and the client specified @option{--keep-failed}
1308 (@pxref{Invoking guix build, @option{--keep-failed}}).
1309
1310 The daemon listens for connections and spawns one sub-process for each session
1311 started by a client (one of the @command{guix} sub-commands.) The
1312 @command{guix processes} command allows you to get an overview of the activity
1313 on your system by viewing each of the active sessions and clients.
1314 @xref{Invoking guix processes}, for more information.
1315
1316 The following command-line options are supported:
1317
1318 @table @code
1319 @item --build-users-group=@var{group}
1320 Take users from @var{group} to run build processes (@pxref{Setting Up
1321 the Daemon, build users}).
1322
1323 @item --no-substitutes
1324 @cindex substitutes
1325 Do not use substitutes for build products. That is, always build things
1326 locally instead of allowing downloads of pre-built binaries
1327 (@pxref{Substitutes}).
1328
1329 When the daemon runs with @code{--no-substitutes}, clients can still
1330 explicitly enable substitution @i{via} the @code{set-build-options}
1331 remote procedure call (@pxref{The Store}).
1332
1333 @item --substitute-urls=@var{urls}
1334 @anchor{daemon-substitute-urls}
1335 Consider @var{urls} the default whitespace-separated list of substitute
1336 source URLs. When this option is omitted,
1337 @indicateurl{https://@value{SUBSTITUTE-SERVER}} is used.
1338
1339 This means that substitutes may be downloaded from @var{urls}, as long
1340 as they are signed by a trusted signature (@pxref{Substitutes}).
1341
1342 @cindex build hook
1343 @item --no-build-hook
1344 Do not use the @dfn{build hook}.
1345
1346 The build hook is a helper program that the daemon can start and to
1347 which it submits build requests. This mechanism is used to offload
1348 builds to other machines (@pxref{Daemon Offload Setup}).
1349
1350 @item --cache-failures
1351 Cache build failures. By default, only successful builds are cached.
1352
1353 When this option is used, @command{guix gc --list-failures} can be used
1354 to query the set of store items marked as failed; @command{guix gc
1355 --clear-failures} removes store items from the set of cached failures.
1356 @xref{Invoking guix gc}.
1357
1358 @item --cores=@var{n}
1359 @itemx -c @var{n}
1360 Use @var{n} CPU cores to build each derivation; @code{0} means as many
1361 as available.
1362
1363 The default value is @code{0}, but it may be overridden by clients, such
1364 as the @code{--cores} option of @command{guix build} (@pxref{Invoking
1365 guix build}).
1366
1367 The effect is to define the @code{NIX_BUILD_CORES} environment variable
1368 in the build process, which can then use it to exploit internal
1369 parallelism---for instance, by running @code{make -j$NIX_BUILD_CORES}.
1370
1371 @item --max-jobs=@var{n}
1372 @itemx -M @var{n}
1373 Allow at most @var{n} build jobs in parallel. The default value is
1374 @code{1}. Setting it to @code{0} means that no builds will be performed
1375 locally; instead, the daemon will offload builds (@pxref{Daemon Offload
1376 Setup}), or simply fail.
1377
1378 @item --max-silent-time=@var{seconds}
1379 When the build or substitution process remains silent for more than
1380 @var{seconds}, terminate it and report a build failure.
1381
1382 The default value is @code{0}, which disables the timeout.
1383
1384 The value specified here can be overridden by clients (@pxref{Common
1385 Build Options, @code{--max-silent-time}}).
1386
1387 @item --timeout=@var{seconds}
1388 Likewise, when the build or substitution process lasts for more than
1389 @var{seconds}, terminate it and report a build failure.
1390
1391 The default value is @code{0}, which disables the timeout.
1392
1393 The value specified here can be overridden by clients (@pxref{Common
1394 Build Options, @code{--timeout}}).
1395
1396 @item --rounds=@var{N}
1397 Build each derivation @var{n} times in a row, and raise an error if
1398 consecutive build results are not bit-for-bit identical. Note that this
1399 setting can be overridden by clients such as @command{guix build}
1400 (@pxref{Invoking guix build}).
1401
1402 When used in conjunction with @option{--keep-failed}, the differing
1403 output is kept in the store, under @file{/gnu/store/@dots{}-check}.
1404 This makes it easy to look for differences between the two results.
1405
1406 @item --debug
1407 Produce debugging output.
1408
1409 This is useful to debug daemon start-up issues, but then it may be
1410 overridden by clients, for example the @code{--verbosity} option of
1411 @command{guix build} (@pxref{Invoking guix build}).
1412
1413 @item --chroot-directory=@var{dir}
1414 Add @var{dir} to the build chroot.
1415
1416 Doing this may change the result of build processes---for instance if
1417 they use optional dependencies found in @var{dir} when it is available,
1418 and not otherwise. For that reason, it is not recommended to do so.
1419 Instead, make sure that each derivation declares all the inputs that it
1420 needs.
1421
1422 @item --disable-chroot
1423 Disable chroot builds.
1424
1425 Using this option is not recommended since, again, it would allow build
1426 processes to gain access to undeclared dependencies. It is necessary,
1427 though, when @command{guix-daemon} is running under an unprivileged user
1428 account.
1429
1430 @item --log-compression=@var{type}
1431 Compress build logs according to @var{type}, one of @code{gzip},
1432 @code{bzip2}, or @code{none}.
1433
1434 Unless @code{--lose-logs} is used, all the build logs are kept in the
1435 @var{localstatedir}. To save space, the daemon automatically compresses
1436 them with bzip2 by default.
1437
1438 @item --disable-deduplication
1439 @cindex deduplication
1440 Disable automatic file ``deduplication'' in the store.
1441
1442 By default, files added to the store are automatically ``deduplicated'':
1443 if a newly added file is identical to another one found in the store,
1444 the daemon makes the new file a hard link to the other file. This can
1445 noticeably reduce disk usage, at the expense of slightly increased
1446 input/output load at the end of a build process. This option disables
1447 this optimization.
1448
1449 @item --gc-keep-outputs[=yes|no]
1450 Tell whether the garbage collector (GC) must keep outputs of live
1451 derivations.
1452
1453 @cindex GC roots
1454 @cindex garbage collector roots
1455 When set to ``yes'', the GC will keep the outputs of any live derivation
1456 available in the store---the @code{.drv} files. The default is ``no'',
1457 meaning that derivation outputs are kept only if they are reachable from a GC
1458 root. @xref{Invoking guix gc}, for more on GC roots.
1459
1460 @item --gc-keep-derivations[=yes|no]
1461 Tell whether the garbage collector (GC) must keep derivations
1462 corresponding to live outputs.
1463
1464 When set to ``yes'', as is the case by default, the GC keeps
1465 derivations---i.e., @code{.drv} files---as long as at least one of their
1466 outputs is live. This allows users to keep track of the origins of
1467 items in their store. Setting it to ``no'' saves a bit of disk space.
1468
1469 In this way, setting @code{--gc-keep-derivations} to ``yes'' causes liveness
1470 to flow from outputs to derivations, and setting @code{--gc-keep-outputs} to
1471 ``yes'' causes liveness to flow from derivations to outputs. When both are
1472 set to ``yes'', the effect is to keep all the build prerequisites (the
1473 sources, compiler, libraries, and other build-time tools) of live objects in
1474 the store, regardless of whether these prerequisites are reachable from a GC
1475 root. This is convenient for developers since it saves rebuilds or downloads.
1476
1477 @item --impersonate-linux-2.6
1478 On Linux-based systems, impersonate Linux 2.6. This means that the
1479 kernel's @code{uname} system call will report 2.6 as the release number.
1480
1481 This might be helpful to build programs that (usually wrongfully) depend
1482 on the kernel version number.
1483
1484 @item --lose-logs
1485 Do not keep build logs. By default they are kept under
1486 @code{@var{localstatedir}/guix/log}.
1487
1488 @item --system=@var{system}
1489 Assume @var{system} as the current system type. By default it is the
1490 architecture/kernel pair found at configure time, such as
1491 @code{x86_64-linux}.
1492
1493 @item --listen=@var{endpoint}
1494 Listen for connections on @var{endpoint}. @var{endpoint} is interpreted
1495 as the file name of a Unix-domain socket if it starts with
1496 @code{/} (slash sign). Otherwise, @var{endpoint} is interpreted as a
1497 host name or host name and port to listen to. Here are a few examples:
1498
1499 @table @code
1500 @item --listen=/gnu/var/daemon
1501 Listen for connections on the @file{/gnu/var/daemon} Unix-domain socket,
1502 creating it if needed.
1503
1504 @item --listen=localhost
1505 @cindex daemon, remote access
1506 @cindex remote access to the daemon
1507 @cindex daemon, cluster setup
1508 @cindex clusters, daemon setup
1509 Listen for TCP connections on the network interface corresponding to
1510 @code{localhost}, on port 44146.
1511
1512 @item --listen=128.0.0.42:1234
1513 Listen for TCP connections on the network interface corresponding to
1514 @code{128.0.0.42}, on port 1234.
1515 @end table
1516
1517 This option can be repeated multiple times, in which case
1518 @command{guix-daemon} accepts connections on all the specified
1519 endpoints. Users can tell client commands what endpoint to connect to
1520 by setting the @code{GUIX_DAEMON_SOCKET} environment variable
1521 (@pxref{The Store, @code{GUIX_DAEMON_SOCKET}}).
1522
1523 @quotation Note
1524 The daemon protocol is @emph{unauthenticated and unencrypted}. Using
1525 @code{--listen=@var{host}} is suitable on local networks, such as
1526 clusters, where only trusted nodes may connect to the build daemon. In
1527 other cases where remote access to the daemon is needed, we recommend
1528 using Unix-domain sockets along with SSH.
1529 @end quotation
1530
1531 When @code{--listen} is omitted, @command{guix-daemon} listens for
1532 connections on the Unix-domain socket located at
1533 @file{@var{localstatedir}/guix/daemon-socket/socket}.
1534 @end table
1535
1536
1537 @node Application Setup
1538 @section Application Setup
1539
1540 @cindex foreign distro
1541 When using Guix on top of GNU/Linux distribution other than GuixSD---a
1542 so-called @dfn{foreign distro}---a few additional steps are needed to
1543 get everything in place. Here are some of them.
1544
1545 @subsection Locales
1546
1547 @anchor{locales-and-locpath}
1548 @cindex locales, when not on GuixSD
1549 @vindex LOCPATH
1550 @vindex GUIX_LOCPATH
1551 Packages installed @i{via} Guix will not use the locale data of the
1552 host system. Instead, you must first install one of the locale packages
1553 available with Guix and then define the @code{GUIX_LOCPATH} environment
1554 variable:
1555
1556 @example
1557 $ guix package -i glibc-locales
1558 $ export GUIX_LOCPATH=$HOME/.guix-profile/lib/locale
1559 @end example
1560
1561 Note that the @code{glibc-locales} package contains data for all the
1562 locales supported by the GNU@tie{}libc and weighs in at around
1563 110@tie{}MiB. Alternatively, the @code{glibc-utf8-locales} is smaller but
1564 limited to a few UTF-8 locales.
1565
1566 The @code{GUIX_LOCPATH} variable plays a role similar to @code{LOCPATH}
1567 (@pxref{Locale Names, @code{LOCPATH},, libc, The GNU C Library Reference
1568 Manual}). There are two important differences though:
1569
1570 @enumerate
1571 @item
1572 @code{GUIX_LOCPATH} is honored only by the libc in Guix, and not by the libc
1573 provided by foreign distros. Thus, using @code{GUIX_LOCPATH} allows you
1574 to make sure the programs of the foreign distro will not end up loading
1575 incompatible locale data.
1576
1577 @item
1578 libc suffixes each entry of @code{GUIX_LOCPATH} with @code{/X.Y}, where
1579 @code{X.Y} is the libc version---e.g., @code{2.22}. This means that,
1580 should your Guix profile contain a mixture of programs linked against
1581 different libc version, each libc version will only try to load locale
1582 data in the right format.
1583 @end enumerate
1584
1585 This is important because the locale data format used by different libc
1586 versions may be incompatible.
1587
1588 @subsection Name Service Switch
1589
1590 @cindex name service switch, glibc
1591 @cindex NSS (name service switch), glibc
1592 @cindex nscd (name service caching daemon)
1593 @cindex name service caching daemon (nscd)
1594 When using Guix on a foreign distro, we @emph{strongly recommend} that
1595 the system run the GNU C library's @dfn{name service cache daemon},
1596 @command{nscd}, which should be listening on the
1597 @file{/var/run/nscd/socket} socket. Failing to do that, applications
1598 installed with Guix may fail to look up host names or user accounts, or
1599 may even crash. The next paragraphs explain why.
1600
1601 @cindex @file{nsswitch.conf}
1602 The GNU C library implements a @dfn{name service switch} (NSS), which is
1603 an extensible mechanism for ``name lookups'' in general: host name
1604 resolution, user accounts, and more (@pxref{Name Service Switch,,, libc,
1605 The GNU C Library Reference Manual}).
1606
1607 @cindex Network information service (NIS)
1608 @cindex NIS (Network information service)
1609 Being extensible, the NSS supports @dfn{plugins}, which provide new name
1610 lookup implementations: for example, the @code{nss-mdns} plugin allow
1611 resolution of @code{.local} host names, the @code{nis} plugin allows
1612 user account lookup using the Network information service (NIS), and so
1613 on. These extra ``lookup services'' are configured system-wide in
1614 @file{/etc/nsswitch.conf}, and all the programs running on the system
1615 honor those settings (@pxref{NSS Configuration File,,, libc, The GNU C
1616 Reference Manual}).
1617
1618 When they perform a name lookup---for instance by calling the
1619 @code{getaddrinfo} function in C---applications first try to connect to
1620 the nscd; on success, nscd performs name lookups on their behalf. If
1621 the nscd is not running, then they perform the name lookup by
1622 themselves, by loading the name lookup services into their own address
1623 space and running it. These name lookup services---the
1624 @file{libnss_*.so} files---are @code{dlopen}'d, but they may come from
1625 the host system's C library, rather than from the C library the
1626 application is linked against (the C library coming from Guix).
1627
1628 And this is where the problem is: if your application is linked against
1629 Guix's C library (say, glibc 2.24) and tries to load NSS plugins from
1630 another C library (say, @code{libnss_mdns.so} for glibc 2.22), it will
1631 likely crash or have its name lookups fail unexpectedly.
1632
1633 Running @command{nscd} on the system, among other advantages, eliminates
1634 this binary incompatibility problem because those @code{libnss_*.so}
1635 files are loaded in the @command{nscd} process, not in applications
1636 themselves.
1637
1638 @subsection X11 Fonts
1639
1640 @cindex fonts
1641 The majority of graphical applications use Fontconfig to locate and
1642 load fonts and perform X11-client-side rendering. The @code{fontconfig}
1643 package in Guix looks for fonts in @file{$HOME/.guix-profile}
1644 by default. Thus, to allow graphical applications installed with Guix
1645 to display fonts, you have to install fonts with Guix as well.
1646 Essential font packages include @code{gs-fonts}, @code{font-dejavu}, and
1647 @code{font-gnu-freefont-ttf}.
1648
1649 To display text written in Chinese languages, Japanese, or Korean in
1650 graphical applications, consider installing
1651 @code{font-adobe-source-han-sans} or @code{font-wqy-zenhei}. The former
1652 has multiple outputs, one per language family (@pxref{Packages with
1653 Multiple Outputs}). For instance, the following command installs fonts
1654 for Chinese languages:
1655
1656 @example
1657 guix package -i font-adobe-source-han-sans:cn
1658 @end example
1659
1660 @cindex @code{xterm}
1661 Older programs such as @command{xterm} do not use Fontconfig and instead
1662 rely on server-side font rendering. Such programs require to specify a
1663 full name of a font using XLFD (X Logical Font Description), like this:
1664
1665 @example
1666 -*-dejavu sans-medium-r-normal-*-*-100-*-*-*-*-*-1
1667 @end example
1668
1669 To be able to use such full names for the TrueType fonts installed in
1670 your Guix profile, you need to extend the font path of the X server:
1671
1672 @c Note: 'xset' does not accept symlinks so the trick below arranges to
1673 @c get at the real directory. See <https://bugs.gnu.org/30655>.
1674 @example
1675 xset +fp $(dirname $(readlink -f ~/.guix-profile/share/fonts/truetype/fonts.dir))
1676 @end example
1677
1678 @cindex @code{xlsfonts}
1679 After that, you can run @code{xlsfonts} (from @code{xlsfonts} package)
1680 to make sure your TrueType fonts are listed there.
1681
1682 @cindex @code{fc-cache}
1683 @cindex font cache
1684 After installing fonts you may have to refresh the font cache to use
1685 them in applications. The same applies when applications installed via
1686 Guix do not seem to find fonts. To force rebuilding of the font cache
1687 run @code{fc-cache -f}. The @code{fc-cache} command is provided by the
1688 @code{fontconfig} package.
1689
1690 @subsection X.509 Certificates
1691
1692 @cindex @code{nss-certs}
1693 The @code{nss-certs} package provides X.509 certificates, which allow
1694 programs to authenticate Web servers accessed over HTTPS.
1695
1696 When using Guix on a foreign distro, you can install this package and
1697 define the relevant environment variables so that packages know where to
1698 look for certificates. @xref{X.509 Certificates}, for detailed
1699 information.
1700
1701 @subsection Emacs Packages
1702
1703 @cindex @code{emacs}
1704 When you install Emacs packages with Guix, the elisp files may be placed
1705 either in @file{$HOME/.guix-profile/share/emacs/site-lisp/} or in
1706 sub-directories of
1707 @file{$HOME/.guix-profile/share/emacs/site-lisp/guix.d/}. The latter
1708 directory exists because potentially there may exist thousands of Emacs
1709 packages and storing all their files in a single directory may not be
1710 reliable (because of name conflicts). So we think using a separate
1711 directory for each package is a good idea. It is very similar to how
1712 the Emacs package system organizes the file structure (@pxref{Package
1713 Files,,, emacs, The GNU Emacs Manual}).
1714
1715 By default, Emacs (installed with Guix) ``knows'' where these packages
1716 are placed, so you do not need to perform any configuration. If, for
1717 some reason, you want to avoid auto-loading Emacs packages installed
1718 with Guix, you can do so by running Emacs with @code{--no-site-file}
1719 option (@pxref{Init File,,, emacs, The GNU Emacs Manual}).
1720
1721 @subsection The GCC toolchain
1722
1723 @cindex GCC
1724 @cindex ld-wrapper
1725
1726 Guix offers individual compiler packages such as @code{gcc} but if you
1727 are in need of a complete toolchain for compiling and linking source
1728 code what you really want is the @code{gcc-toolchain} package. This
1729 package provides a complete GCC toolchain for C/C++ development,
1730 including GCC itself, the GNU C Library (headers and binaries, plus
1731 debugging symbols in the @code{debug} output), Binutils, and a linker
1732 wrapper.
1733
1734 @cindex attempt to use impure library, error message
1735
1736 The wrapper's purpose is to inspect the @code{-L} and @code{-l} switches
1737 passed to the linker, add corresponding @code{-rpath} arguments, and
1738 invoke the actual linker with this new set of arguments. By default,
1739 the linker wrapper refuses to link to libraries outside the store to
1740 ensure ``purity''. This can be annoying when using the toolchain to
1741 link with local libraries. To allow references to libraries outside the
1742 store you need to define the environment variable
1743 @code{GUIX_LD_WRAPPER_ALLOW_IMPURITIES}.
1744
1745 @c TODO What else?
1746
1747 @c *********************************************************************
1748 @node Package Management
1749 @chapter Package Management
1750
1751 @cindex packages
1752 The purpose of GNU Guix is to allow users to easily install, upgrade, and
1753 remove software packages, without having to know about their build
1754 procedures or dependencies. Guix also goes beyond this obvious set of
1755 features.
1756
1757 This chapter describes the main features of Guix, as well as the
1758 package management tools it provides. Along with the command-line
1759 interface described below (@pxref{Invoking guix package, @code{guix
1760 package}}), you may also use the Emacs-Guix interface (@pxref{Top,,,
1761 emacs-guix, The Emacs-Guix Reference Manual}), after installing
1762 @code{emacs-guix} package (run @kbd{M-x guix-help} command to start
1763 with it):
1764
1765 @example
1766 guix package -i emacs-guix
1767 @end example
1768
1769 @menu
1770 * Features:: How Guix will make your life brighter.
1771 * Invoking guix package:: Package installation, removal, etc.
1772 * Substitutes:: Downloading pre-built binaries.
1773 * Packages with Multiple Outputs:: Single source package, multiple outputs.
1774 * Invoking guix gc:: Running the garbage collector.
1775 * Invoking guix pull:: Fetching the latest Guix and distribution.
1776 * Channels:: Customizing the package collection.
1777 * Inferiors:: Interacting with another revision of Guix.
1778 * Invoking guix describe:: Display information about your Guix revision.
1779 * Invoking guix pack:: Creating software bundles.
1780 * Invoking guix archive:: Exporting and importing store files.
1781 @end menu
1782
1783 @node Features
1784 @section Features
1785
1786 When using Guix, each package ends up in the @dfn{package store}, in its
1787 own directory---something that resembles
1788 @file{/gnu/store/xxx-package-1.2}, where @code{xxx} is a base32 string.
1789
1790 Instead of referring to these directories, users have their own
1791 @dfn{profile}, which points to the packages that they actually want to
1792 use. These profiles are stored within each user's home directory, at
1793 @code{$HOME/.guix-profile}.
1794
1795 For example, @code{alice} installs GCC 4.7.2. As a result,
1796 @file{/home/alice/.guix-profile/bin/gcc} points to
1797 @file{/gnu/store/@dots{}-gcc-4.7.2/bin/gcc}. Now, on the same machine,
1798 @code{bob} had already installed GCC 4.8.0. The profile of @code{bob}
1799 simply continues to point to
1800 @file{/gnu/store/@dots{}-gcc-4.8.0/bin/gcc}---i.e., both versions of GCC
1801 coexist on the same system without any interference.
1802
1803 The @command{guix package} command is the central tool to manage
1804 packages (@pxref{Invoking guix package}). It operates on the per-user
1805 profiles, and can be used @emph{with normal user privileges}.
1806
1807 @cindex transactions
1808 The command provides the obvious install, remove, and upgrade
1809 operations. Each invocation is actually a @emph{transaction}: either
1810 the specified operation succeeds, or nothing happens. Thus, if the
1811 @command{guix package} process is terminated during the transaction,
1812 or if a power outage occurs during the transaction, then the user's
1813 profile remains in its previous state, and remains usable.
1814
1815 In addition, any package transaction may be @emph{rolled back}. So, if,
1816 for example, an upgrade installs a new version of a package that turns
1817 out to have a serious bug, users may roll back to the previous instance
1818 of their profile, which was known to work well. Similarly, the global
1819 system configuration on GuixSD is subject to
1820 transactional upgrades and roll-back
1821 (@pxref{Using the Configuration System}).
1822
1823 All packages in the package store may be @emph{garbage-collected}.
1824 Guix can determine which packages are still referenced by user
1825 profiles, and remove those that are provably no longer referenced
1826 (@pxref{Invoking guix gc}). Users may also explicitly remove old
1827 generations of their profile so that the packages they refer to can be
1828 collected.
1829
1830 @cindex reproducibility
1831 @cindex reproducible builds
1832 Guix takes a @dfn{purely functional} approach to package
1833 management, as described in the introduction (@pxref{Introduction}).
1834 Each @file{/gnu/store} package directory name contains a hash of all the
1835 inputs that were used to build that package---compiler, libraries, build
1836 scripts, etc. This direct correspondence allows users to make sure a
1837 given package installation matches the current state of their
1838 distribution. It also helps maximize @dfn{build reproducibility}:
1839 thanks to the isolated build environments that are used, a given build
1840 is likely to yield bit-identical files when performed on different
1841 machines (@pxref{Invoking guix-daemon, container}).
1842
1843 @cindex substitutes
1844 This foundation allows Guix to support @dfn{transparent binary/source
1845 deployment}. When a pre-built binary for a @file{/gnu/store} item is
1846 available from an external source---a @dfn{substitute}, Guix just
1847 downloads it and unpacks it;
1848 otherwise, it builds the package from source, locally
1849 (@pxref{Substitutes}). Because build results are usually bit-for-bit
1850 reproducible, users do not have to trust servers that provide
1851 substitutes: they can force a local build and @emph{challenge} providers
1852 (@pxref{Invoking guix challenge}).
1853
1854 Control over the build environment is a feature that is also useful for
1855 developers. The @command{guix environment} command allows developers of
1856 a package to quickly set up the right development environment for their
1857 package, without having to manually install the dependencies of the
1858 package into their profile (@pxref{Invoking guix environment}).
1859
1860 @cindex replication, of software environments
1861 @cindex provenance tracking, of software artifacts
1862 All of Guix and its package definitions is version-controlled, and
1863 @command{guix pull} allows you to ``travel in time'' on the history of Guix
1864 itself (@pxref{Invoking guix pull}). This makes it possible to replicate a
1865 Guix instance on a different machine or at a later point in time, which in
1866 turn allows you to @emph{replicate complete software environments}, while
1867 retaining precise @dfn{provenance tracking} of the software.
1868
1869 @node Invoking guix package
1870 @section Invoking @command{guix package}
1871
1872 @cindex installing packages
1873 @cindex removing packages
1874 @cindex package installation
1875 @cindex package removal
1876 The @command{guix package} command is the tool that allows users to
1877 install, upgrade, and remove packages, as well as rolling back to
1878 previous configurations. It operates only on the user's own profile,
1879 and works with normal user privileges (@pxref{Features}). Its syntax
1880 is:
1881
1882 @example
1883 guix package @var{options}
1884 @end example
1885 @cindex transactions
1886 Primarily, @var{options} specifies the operations to be performed during
1887 the transaction. Upon completion, a new profile is created, but
1888 previous @dfn{generations} of the profile remain available, should the user
1889 want to roll back.
1890
1891 For example, to remove @code{lua} and install @code{guile} and
1892 @code{guile-cairo} in a single transaction:
1893
1894 @example
1895 guix package -r lua -i guile guile-cairo
1896 @end example
1897
1898 @command{guix package} also supports a @dfn{declarative approach}
1899 whereby the user specifies the exact set of packages to be available and
1900 passes it @i{via} the @option{--manifest} option
1901 (@pxref{profile-manifest, @option{--manifest}}).
1902
1903 @cindex profile
1904 For each user, a symlink to the user's default profile is automatically
1905 created in @file{$HOME/.guix-profile}. This symlink always points to the
1906 current generation of the user's default profile. Thus, users can add
1907 @file{$HOME/.guix-profile/bin} to their @code{PATH} environment
1908 variable, and so on.
1909 @cindex search paths
1910 If you are not using the Guix System Distribution, consider adding the
1911 following lines to your @file{~/.bash_profile} (@pxref{Bash Startup
1912 Files,,, bash, The GNU Bash Reference Manual}) so that newly-spawned
1913 shells get all the right environment variable definitions:
1914
1915 @example
1916 GUIX_PROFILE="$HOME/.guix-profile" ; \
1917 source "$HOME/.guix-profile/etc/profile"
1918 @end example
1919
1920 In a multi-user setup, user profiles are stored in a place registered as
1921 a @dfn{garbage-collector root}, which @file{$HOME/.guix-profile} points
1922 to (@pxref{Invoking guix gc}). That directory is normally
1923 @code{@var{localstatedir}/guix/profiles/per-user/@var{user}}, where
1924 @var{localstatedir} is the value passed to @code{configure} as
1925 @code{--localstatedir}, and @var{user} is the user name. The
1926 @file{per-user} directory is created when @command{guix-daemon} is
1927 started, and the @var{user} sub-directory is created by @command{guix
1928 package}.
1929
1930 The @var{options} can be among the following:
1931
1932 @table @code
1933
1934 @item --install=@var{package} @dots{}
1935 @itemx -i @var{package} @dots{}
1936 Install the specified @var{package}s.
1937
1938 Each @var{package} may specify either a simple package name, such as
1939 @code{guile}, or a package name followed by an at-sign and version number,
1940 such as @code{guile@@1.8.8} or simply @code{guile@@1.8} (in the latter
1941 case, the newest version prefixed by @code{1.8} is selected.)
1942
1943 If no version number is specified, the
1944 newest available version will be selected. In addition, @var{package}
1945 may contain a colon, followed by the name of one of the outputs of the
1946 package, as in @code{gcc:doc} or @code{binutils@@2.22:lib}
1947 (@pxref{Packages with Multiple Outputs}). Packages with a corresponding
1948 name (and optionally version) are searched for among the GNU
1949 distribution modules (@pxref{Package Modules}).
1950
1951 @cindex propagated inputs
1952 Sometimes packages have @dfn{propagated inputs}: these are dependencies
1953 that automatically get installed along with the required package
1954 (@pxref{package-propagated-inputs, @code{propagated-inputs} in
1955 @code{package} objects}, for information about propagated inputs in
1956 package definitions).
1957
1958 @anchor{package-cmd-propagated-inputs}
1959 An example is the GNU MPC library: its C header files refer to those of
1960 the GNU MPFR library, which in turn refer to those of the GMP library.
1961 Thus, when installing MPC, the MPFR and GMP libraries also get installed
1962 in the profile; removing MPC also removes MPFR and GMP---unless they had
1963 also been explicitly installed by the user.
1964
1965 Besides, packages sometimes rely on the definition of environment
1966 variables for their search paths (see explanation of
1967 @code{--search-paths} below). Any missing or possibly incorrect
1968 environment variable definitions are reported here.
1969
1970 @item --install-from-expression=@var{exp}
1971 @itemx -e @var{exp}
1972 Install the package @var{exp} evaluates to.
1973
1974 @var{exp} must be a Scheme expression that evaluates to a
1975 @code{<package>} object. This option is notably useful to disambiguate
1976 between same-named variants of a package, with expressions such as
1977 @code{(@@ (gnu packages base) guile-final)}.
1978
1979 Note that this option installs the first output of the specified
1980 package, which may be insufficient when needing a specific output of a
1981 multiple-output package.
1982
1983 @item --install-from-file=@var{file}
1984 @itemx -f @var{file}
1985 Install the package that the code within @var{file} evaluates to.
1986
1987 As an example, @var{file} might contain a definition like this
1988 (@pxref{Defining Packages}):
1989
1990 @example
1991 @verbatiminclude package-hello.scm
1992 @end example
1993
1994 Developers may find it useful to include such a @file{guix.scm} file
1995 in the root of their project source tree that can be used to test
1996 development snapshots and create reproducible development environments
1997 (@pxref{Invoking guix environment}).
1998
1999 @item --remove=@var{package} @dots{}
2000 @itemx -r @var{package} @dots{}
2001 Remove the specified @var{package}s.
2002
2003 As for @code{--install}, each @var{package} may specify a version number
2004 and/or output name in addition to the package name. For instance,
2005 @code{-r glibc:debug} would remove the @code{debug} output of
2006 @code{glibc}.
2007
2008 @item --upgrade[=@var{regexp} @dots{}]
2009 @itemx -u [@var{regexp} @dots{}]
2010 @cindex upgrading packages
2011 Upgrade all the installed packages. If one or more @var{regexp}s are
2012 specified, upgrade only installed packages whose name matches a
2013 @var{regexp}. Also see the @code{--do-not-upgrade} option below.
2014
2015 Note that this upgrades package to the latest version of packages found
2016 in the distribution currently installed. To update your distribution,
2017 you should regularly run @command{guix pull} (@pxref{Invoking guix
2018 pull}).
2019
2020 @item --do-not-upgrade[=@var{regexp} @dots{}]
2021 When used together with the @code{--upgrade} option, do @emph{not}
2022 upgrade any packages whose name matches a @var{regexp}. For example, to
2023 upgrade all packages in the current profile except those containing the
2024 substring ``emacs'':
2025
2026 @example
2027 $ guix package --upgrade . --do-not-upgrade emacs
2028 @end example
2029
2030 @item @anchor{profile-manifest}--manifest=@var{file}
2031 @itemx -m @var{file}
2032 @cindex profile declaration
2033 @cindex profile manifest
2034 Create a new generation of the profile from the manifest object
2035 returned by the Scheme code in @var{file}.
2036
2037 This allows you to @emph{declare} the profile's contents rather than
2038 constructing it through a sequence of @code{--install} and similar
2039 commands. The advantage is that @var{file} can be put under version
2040 control, copied to different machines to reproduce the same profile, and
2041 so on.
2042
2043 @c FIXME: Add reference to (guix profile) documentation when available.
2044 @var{file} must return a @dfn{manifest} object, which is roughly a list
2045 of packages:
2046
2047 @findex packages->manifest
2048 @example
2049 (use-package-modules guile emacs)
2050
2051 (packages->manifest
2052 (list emacs
2053 guile-2.0
2054 ;; Use a specific package output.
2055 (list guile-2.0 "debug")))
2056 @end example
2057
2058 @findex specifications->manifest
2059 In this example we have to know which modules define the @code{emacs}
2060 and @code{guile-2.0} variables to provide the right
2061 @code{use-package-modules} line, which can be cumbersome. We can
2062 instead provide regular package specifications and let
2063 @code{specifications->manifest} look up the corresponding package
2064 objects, like this:
2065
2066 @example
2067 (specifications->manifest
2068 '("emacs" "guile@@2.2" "guile@@2.2:debug"))
2069 @end example
2070
2071 @item --roll-back
2072 @cindex rolling back
2073 @cindex undoing transactions
2074 @cindex transactions, undoing
2075 Roll back to the previous @dfn{generation} of the profile---i.e., undo
2076 the last transaction.
2077
2078 When combined with options such as @code{--install}, roll back occurs
2079 before any other actions.
2080
2081 When rolling back from the first generation that actually contains
2082 installed packages, the profile is made to point to the @dfn{zeroth
2083 generation}, which contains no files apart from its own metadata.
2084
2085 After having rolled back, installing, removing, or upgrading packages
2086 overwrites previous future generations. Thus, the history of the
2087 generations in a profile is always linear.
2088
2089 @item --switch-generation=@var{pattern}
2090 @itemx -S @var{pattern}
2091 @cindex generations
2092 Switch to a particular generation defined by @var{pattern}.
2093
2094 @var{pattern} may be either a generation number or a number prefixed
2095 with ``+'' or ``-''. The latter means: move forward/backward by a
2096 specified number of generations. For example, if you want to return to
2097 the latest generation after @code{--roll-back}, use
2098 @code{--switch-generation=+1}.
2099
2100 The difference between @code{--roll-back} and
2101 @code{--switch-generation=-1} is that @code{--switch-generation} will
2102 not make a zeroth generation, so if a specified generation does not
2103 exist, the current generation will not be changed.
2104
2105 @item --search-paths[=@var{kind}]
2106 @cindex search paths
2107 Report environment variable definitions, in Bash syntax, that may be
2108 needed in order to use the set of installed packages. These environment
2109 variables are used to specify @dfn{search paths} for files used by some
2110 of the installed packages.
2111
2112 For example, GCC needs the @code{CPATH} and @code{LIBRARY_PATH}
2113 environment variables to be defined so it can look for headers and
2114 libraries in the user's profile (@pxref{Environment Variables,,, gcc,
2115 Using the GNU Compiler Collection (GCC)}). If GCC and, say, the C
2116 library are installed in the profile, then @code{--search-paths} will
2117 suggest setting these variables to @code{@var{profile}/include} and
2118 @code{@var{profile}/lib}, respectively.
2119
2120 The typical use case is to define these environment variables in the
2121 shell:
2122
2123 @example
2124 $ eval `guix package --search-paths`
2125 @end example
2126
2127 @var{kind} may be one of @code{exact}, @code{prefix}, or @code{suffix},
2128 meaning that the returned environment variable definitions will either
2129 be exact settings, or prefixes or suffixes of the current value of these
2130 variables. When omitted, @var{kind} defaults to @code{exact}.
2131
2132 This option can also be used to compute the @emph{combined} search paths
2133 of several profiles. Consider this example:
2134
2135 @example
2136 $ guix package -p foo -i guile
2137 $ guix package -p bar -i guile-json
2138 $ guix package -p foo -p bar --search-paths
2139 @end example
2140
2141 The last command above reports about the @code{GUILE_LOAD_PATH}
2142 variable, even though, taken individually, neither @file{foo} nor
2143 @file{bar} would lead to that recommendation.
2144
2145
2146 @item --profile=@var{profile}
2147 @itemx -p @var{profile}
2148 Use @var{profile} instead of the user's default profile.
2149
2150 @cindex collisions, in a profile
2151 @cindex colliding packages in profiles
2152 @cindex profile collisions
2153 @item --allow-collisions
2154 Allow colliding packages in the new profile. Use at your own risk!
2155
2156 By default, @command{guix package} reports as an error @dfn{collisions}
2157 in the profile. Collisions happen when two or more different versions
2158 or variants of a given package end up in the profile.
2159
2160 @item --bootstrap
2161 Use the bootstrap Guile to build the profile. This option is only
2162 useful to distribution developers.
2163
2164 @end table
2165
2166 In addition to these actions, @command{guix package} supports the
2167 following options to query the current state of a profile, or the
2168 availability of packages:
2169
2170 @table @option
2171
2172 @item --search=@var{regexp}
2173 @itemx -s @var{regexp}
2174 @cindex searching for packages
2175 List the available packages whose name, synopsis, or description matches
2176 @var{regexp} (in a case-insensitive fashion), sorted by relevance.
2177 Print all the metadata of matching packages in
2178 @code{recutils} format (@pxref{Top, GNU recutils databases,, recutils,
2179 GNU recutils manual}).
2180
2181 This allows specific fields to be extracted using the @command{recsel}
2182 command, for instance:
2183
2184 @example
2185 $ guix package -s malloc | recsel -p name,version,relevance
2186 name: jemalloc
2187 version: 4.5.0
2188 relevance: 6
2189
2190 name: glibc
2191 version: 2.25
2192 relevance: 1
2193
2194 name: libgc
2195 version: 7.6.0
2196 relevance: 1
2197 @end example
2198
2199 Similarly, to show the name of all the packages available under the
2200 terms of the GNU@tie{}LGPL version 3:
2201
2202 @example
2203 $ guix package -s "" | recsel -p name -e 'license ~ "LGPL 3"'
2204 name: elfutils
2205
2206 name: gmp
2207 @dots{}
2208 @end example
2209
2210 It is also possible to refine search results using several @code{-s}
2211 flags. For example, the following command returns a list of board
2212 games:
2213
2214 @example
2215 $ guix package -s '\<board\>' -s game | recsel -p name
2216 name: gnubg
2217 @dots{}
2218 @end example
2219
2220 If we were to omit @code{-s game}, we would also get software packages
2221 that deal with printed circuit boards; removing the angle brackets
2222 around @code{board} would further add packages that have to do with
2223 keyboards.
2224
2225 And now for a more elaborate example. The following command searches
2226 for cryptographic libraries, filters out Haskell, Perl, Python, and Ruby
2227 libraries, and prints the name and synopsis of the matching packages:
2228
2229 @example
2230 $ guix package -s crypto -s library | \
2231 recsel -e '! (name ~ "^(ghc|perl|python|ruby)")' -p name,synopsis
2232 @end example
2233
2234 @noindent
2235 @xref{Selection Expressions,,, recutils, GNU recutils manual}, for more
2236 information on @dfn{selection expressions} for @code{recsel -e}.
2237
2238 @item --show=@var{package}
2239 Show details about @var{package}, taken from the list of available packages, in
2240 @code{recutils} format (@pxref{Top, GNU recutils databases,, recutils, GNU
2241 recutils manual}).
2242
2243 @example
2244 $ guix package --show=python | recsel -p name,version
2245 name: python
2246 version: 2.7.6
2247
2248 name: python
2249 version: 3.3.5
2250 @end example
2251
2252 You may also specify the full name of a package to only get details about a
2253 specific version of it:
2254 @example
2255 $ guix package --show=python@@3.4 | recsel -p name,version
2256 name: python
2257 version: 3.4.3
2258 @end example
2259
2260
2261
2262 @item --list-installed[=@var{regexp}]
2263 @itemx -I [@var{regexp}]
2264 List the currently installed packages in the specified profile, with the
2265 most recently installed packages shown last. When @var{regexp} is
2266 specified, list only installed packages whose name matches @var{regexp}.
2267
2268 For each installed package, print the following items, separated by
2269 tabs: the package name, its version string, the part of the package that
2270 is installed (for instance, @code{out} for the default output,
2271 @code{include} for its headers, etc.), and the path of this package in
2272 the store.
2273
2274 @item --list-available[=@var{regexp}]
2275 @itemx -A [@var{regexp}]
2276 List packages currently available in the distribution for this system
2277 (@pxref{GNU Distribution}). When @var{regexp} is specified, list only
2278 installed packages whose name matches @var{regexp}.
2279
2280 For each package, print the following items separated by tabs: its name,
2281 its version string, the parts of the package (@pxref{Packages with
2282 Multiple Outputs}), and the source location of its definition.
2283
2284 @item --list-generations[=@var{pattern}]
2285 @itemx -l [@var{pattern}]
2286 @cindex generations
2287 Return a list of generations along with their creation dates; for each
2288 generation, show the installed packages, with the most recently
2289 installed packages shown last. Note that the zeroth generation is never
2290 shown.
2291
2292 For each installed package, print the following items, separated by
2293 tabs: the name of a package, its version string, the part of the package
2294 that is installed (@pxref{Packages with Multiple Outputs}), and the
2295 location of this package in the store.
2296
2297 When @var{pattern} is used, the command returns only matching
2298 generations. Valid patterns include:
2299
2300 @itemize
2301 @item @emph{Integers and comma-separated integers}. Both patterns denote
2302 generation numbers. For instance, @code{--list-generations=1} returns
2303 the first one.
2304
2305 And @code{--list-generations=1,8,2} outputs three generations in the
2306 specified order. Neither spaces nor trailing commas are allowed.
2307
2308 @item @emph{Ranges}. @code{--list-generations=2..9} prints the
2309 specified generations and everything in between. Note that the start of
2310 a range must be smaller than its end.
2311
2312 It is also possible to omit the endpoint. For example,
2313 @code{--list-generations=2..}, returns all generations starting from the
2314 second one.
2315
2316 @item @emph{Durations}. You can also get the last @emph{N}@tie{}days, weeks,
2317 or months by passing an integer along with the first letter of the
2318 duration. For example, @code{--list-generations=20d} lists generations
2319 that are up to 20 days old.
2320 @end itemize
2321
2322 @item --delete-generations[=@var{pattern}]
2323 @itemx -d [@var{pattern}]
2324 When @var{pattern} is omitted, delete all generations except the current
2325 one.
2326
2327 This command accepts the same patterns as @option{--list-generations}.
2328 When @var{pattern} is specified, delete the matching generations. When
2329 @var{pattern} specifies a duration, generations @emph{older} than the
2330 specified duration match. For instance, @code{--delete-generations=1m}
2331 deletes generations that are more than one month old.
2332
2333 If the current generation matches, it is @emph{not} deleted. Also, the
2334 zeroth generation is never deleted.
2335
2336 Note that deleting generations prevents rolling back to them.
2337 Consequently, this command must be used with care.
2338
2339 @end table
2340
2341 Finally, since @command{guix package} may actually start build
2342 processes, it supports all the common build options (@pxref{Common Build
2343 Options}). It also supports package transformation options, such as
2344 @option{--with-source} (@pxref{Package Transformation Options}).
2345 However, note that package transformations are lost when upgrading; to
2346 preserve transformations across upgrades, you should define your own
2347 package variant in a Guile module and add it to @code{GUIX_PACKAGE_PATH}
2348 (@pxref{Defining Packages}).
2349
2350 @node Substitutes
2351 @section Substitutes
2352
2353 @cindex substitutes
2354 @cindex pre-built binaries
2355 Guix supports transparent source/binary deployment, which means that it
2356 can either build things locally, or download pre-built items from a
2357 server, or both. We call these pre-built items @dfn{substitutes}---they
2358 are substitutes for local build results. In many cases, downloading a
2359 substitute is much faster than building things locally.
2360
2361 Substitutes can be anything resulting from a derivation build
2362 (@pxref{Derivations}). Of course, in the common case, they are
2363 pre-built package binaries, but source tarballs, for instance, which
2364 also result from derivation builds, can be available as substitutes.
2365
2366 @menu
2367 * Official Substitute Server:: One particular source of substitutes.
2368 * Substitute Server Authorization:: How to enable or disable substitutes.
2369 * Substitute Authentication:: How Guix verifies substitutes.
2370 * Proxy Settings:: How to get substitutes via proxy.
2371 * Substitution Failure:: What happens when substitution fails.
2372 * On Trusting Binaries:: How can you trust that binary blob?
2373 @end menu
2374
2375 @node Official Substitute Server
2376 @subsection Official Substitute Server
2377
2378 @cindex hydra
2379 @cindex build farm
2380 The @code{@value{SUBSTITUTE-SERVER}} server is a front-end to an official build farm
2381 that builds packages from Guix continuously for some
2382 architectures, and makes them available as substitutes. This is the
2383 default source of substitutes; it can be overridden by passing the
2384 @option{--substitute-urls} option either to @command{guix-daemon}
2385 (@pxref{daemon-substitute-urls,, @code{guix-daemon --substitute-urls}})
2386 or to client tools such as @command{guix package}
2387 (@pxref{client-substitute-urls,, client @option{--substitute-urls}
2388 option}).
2389
2390 Substitute URLs can be either HTTP or HTTPS.
2391 HTTPS is recommended because communications are encrypted; conversely,
2392 using HTTP makes all communications visible to an eavesdropper, who
2393 could use the information gathered to determine, for instance, whether
2394 your system has unpatched security vulnerabilities.
2395
2396 Substitutes from the official build farm are enabled by default when
2397 using the Guix System Distribution (@pxref{GNU Distribution}). However,
2398 they are disabled by default when using Guix on a foreign distribution,
2399 unless you have explicitly enabled them via one of the recommended
2400 installation steps (@pxref{Installation}). The following paragraphs
2401 describe how to enable or disable substitutes for the official build
2402 farm; the same procedure can also be used to enable substitutes for any
2403 other substitute server.
2404
2405 @node Substitute Server Authorization
2406 @subsection Substitute Server Authorization
2407
2408 @cindex security
2409 @cindex substitutes, authorization thereof
2410 @cindex access control list (ACL), for substitutes
2411 @cindex ACL (access control list), for substitutes
2412 To allow Guix to download substitutes from @code{@value{SUBSTITUTE-SERVER}} or a
2413 mirror thereof, you
2414 must add its public key to the access control list (ACL) of archive
2415 imports, using the @command{guix archive} command (@pxref{Invoking guix
2416 archive}). Doing so implies that you trust @code{@value{SUBSTITUTE-SERVER}} to not
2417 be compromised and to serve genuine substitutes.
2418
2419 The public key for @code{@value{SUBSTITUTE-SERVER}} is installed along with Guix, in
2420 @code{@var{prefix}/share/guix/@value{SUBSTITUTE-SERVER}.pub}, where @var{prefix} is
2421 the installation prefix of Guix. If you installed Guix from source,
2422 make sure you checked the GPG signature of
2423 @file{guix-@value{VERSION}.tar.gz}, which contains this public key file.
2424 Then, you can run something like this:
2425
2426 @example
2427 # guix archive --authorize < @var{prefix}/share/guix/@value{SUBSTITUTE-SERVER}.pub
2428 @end example
2429
2430 @quotation Note
2431 Similarly, the @file{hydra.gnu.org.pub} file contains the public key
2432 of an independent build farm also run by the project, reachable at
2433 @indicateurl{https://mirror.hydra.gnu.org}.
2434 @end quotation
2435
2436 Once this is in place, the output of a command like @code{guix build}
2437 should change from something like:
2438
2439 @example
2440 $ guix build emacs --dry-run
2441 The following derivations would be built:
2442 /gnu/store/yr7bnx8xwcayd6j95r2clmkdl1qh688w-emacs-24.3.drv
2443 /gnu/store/x8qsh1hlhgjx6cwsjyvybnfv2i37z23w-dbus-1.6.4.tar.gz.drv
2444 /gnu/store/1ixwp12fl950d15h2cj11c73733jay0z-alsa-lib-1.0.27.1.tar.bz2.drv
2445 /gnu/store/nlma1pw0p603fpfiqy7kn4zm105r5dmw-util-linux-2.21.drv
2446 @dots{}
2447 @end example
2448
2449 @noindent
2450 to something like:
2451
2452 @example
2453 $ guix build emacs --dry-run
2454 112.3 MB would be downloaded:
2455 /gnu/store/pk3n22lbq6ydamyymqkkz7i69wiwjiwi-emacs-24.3
2456 /gnu/store/2ygn4ncnhrpr61rssa6z0d9x22si0va3-libjpeg-8d
2457 /gnu/store/71yz6lgx4dazma9dwn2mcjxaah9w77jq-cairo-1.12.16
2458 /gnu/store/7zdhgp0n1518lvfn8mb96sxqfmvqrl7v-libxrender-0.9.7
2459 @dots{}
2460 @end example
2461
2462 @noindent
2463 This indicates that substitutes from @code{@value{SUBSTITUTE-SERVER}} are usable and
2464 will be downloaded, when possible, for future builds.
2465
2466 @cindex substitutes, how to disable
2467 The substitute mechanism can be disabled globally by running
2468 @code{guix-daemon} with @code{--no-substitutes} (@pxref{Invoking
2469 guix-daemon}). It can also be disabled temporarily by passing the
2470 @code{--no-substitutes} option to @command{guix package}, @command{guix
2471 build}, and other command-line tools.
2472
2473 @node Substitute Authentication
2474 @subsection Substitute Authentication
2475
2476 @cindex digital signatures
2477 Guix detects and raises an error when attempting to use a substitute
2478 that has been tampered with. Likewise, it ignores substitutes that are
2479 not signed, or that are not signed by one of the keys listed in the ACL.
2480
2481 There is one exception though: if an unauthorized server provides
2482 substitutes that are @emph{bit-for-bit identical} to those provided by
2483 an authorized server, then the unauthorized server becomes eligible for
2484 downloads. For example, assume we have chosen two substitute servers
2485 with this option:
2486
2487 @example
2488 --substitute-urls="https://a.example.org https://b.example.org"
2489 @end example
2490
2491 @noindent
2492 @cindex reproducible builds
2493 If the ACL contains only the key for @code{b.example.org}, and if
2494 @code{a.example.org} happens to serve the @emph{exact same} substitutes,
2495 then Guix will download substitutes from @code{a.example.org} because it
2496 comes first in the list and can be considered a mirror of
2497 @code{b.example.org}. In practice, independent build machines usually
2498 produce the same binaries, thanks to bit-reproducible builds (see
2499 below).
2500
2501 When using HTTPS, the server's X.509 certificate is @emph{not} validated
2502 (in other words, the server is not authenticated), contrary to what
2503 HTTPS clients such as Web browsers usually do. This is because Guix
2504 authenticates substitute information itself, as explained above, which
2505 is what we care about (whereas X.509 certificates are about
2506 authenticating bindings between domain names and public keys.)
2507
2508 @node Proxy Settings
2509 @subsection Proxy Settings
2510
2511 @vindex http_proxy
2512 Substitutes are downloaded over HTTP or HTTPS.
2513 The @code{http_proxy} environment
2514 variable can be set in the environment of @command{guix-daemon} and is
2515 honored for downloads of substitutes. Note that the value of
2516 @code{http_proxy} in the environment where @command{guix build},
2517 @command{guix package}, and other client commands are run has
2518 @emph{absolutely no effect}.
2519
2520 @node Substitution Failure
2521 @subsection Substitution Failure
2522
2523 Even when a substitute for a derivation is available, sometimes the
2524 substitution attempt will fail. This can happen for a variety of
2525 reasons: the substitute server might be offline, the substitute may
2526 recently have been deleted, the connection might have been interrupted,
2527 etc.
2528
2529 When substitutes are enabled and a substitute for a derivation is
2530 available, but the substitution attempt fails, Guix will attempt to
2531 build the derivation locally depending on whether or not
2532 @code{--fallback} was given (@pxref{fallback-option,, common build
2533 option @code{--fallback}}). Specifically, if @code{--fallback} was
2534 omitted, then no local build will be performed, and the derivation is
2535 considered to have failed. However, if @code{--fallback} was given,
2536 then Guix will attempt to build the derivation locally, and the success
2537 or failure of the derivation depends on the success or failure of the
2538 local build. Note that when substitutes are disabled or no substitute
2539 is available for the derivation in question, a local build will
2540 @emph{always} be performed, regardless of whether or not
2541 @code{--fallback} was given.
2542
2543 To get an idea of how many substitutes are available right now, you can
2544 try running the @command{guix weather} command (@pxref{Invoking guix
2545 weather}). This command provides statistics on the substitutes provided
2546 by a server.
2547
2548 @node On Trusting Binaries
2549 @subsection On Trusting Binaries
2550
2551 @cindex trust, of pre-built binaries
2552 Today, each individual's control over their own computing is at the
2553 mercy of institutions, corporations, and groups with enough power and
2554 determination to subvert the computing infrastructure and exploit its
2555 weaknesses. While using @code{@value{SUBSTITUTE-SERVER}} substitutes can be
2556 convenient, we encourage users to also build on their own, or even run
2557 their own build farm, such that @code{@value{SUBSTITUTE-SERVER}} is less of an
2558 interesting target. One way to help is by publishing the software you
2559 build using @command{guix publish} so that others have one more choice
2560 of server to download substitutes from (@pxref{Invoking guix publish}).
2561
2562 Guix has the foundations to maximize build reproducibility
2563 (@pxref{Features}). In most cases, independent builds of a given
2564 package or derivation should yield bit-identical results. Thus, through
2565 a diverse set of independent package builds, we can strengthen the
2566 integrity of our systems. The @command{guix challenge} command aims to
2567 help users assess substitute servers, and to assist developers in
2568 finding out about non-deterministic package builds (@pxref{Invoking guix
2569 challenge}). Similarly, the @option{--check} option of @command{guix
2570 build} allows users to check whether previously-installed substitutes
2571 are genuine by rebuilding them locally (@pxref{build-check,
2572 @command{guix build --check}}).
2573
2574 In the future, we want Guix to have support to publish and retrieve
2575 binaries to/from other users, in a peer-to-peer fashion. If you would
2576 like to discuss this project, join us on @email{guix-devel@@gnu.org}.
2577
2578 @node Packages with Multiple Outputs
2579 @section Packages with Multiple Outputs
2580
2581 @cindex multiple-output packages
2582 @cindex package outputs
2583 @cindex outputs
2584
2585 Often, packages defined in Guix have a single @dfn{output}---i.e., the
2586 source package leads to exactly one directory in the store. When running
2587 @command{guix package -i glibc}, one installs the default output of the
2588 GNU libc package; the default output is called @code{out}, but its name
2589 can be omitted as shown in this command. In this particular case, the
2590 default output of @code{glibc} contains all the C header files, shared
2591 libraries, static libraries, Info documentation, and other supporting
2592 files.
2593
2594 Sometimes it is more appropriate to separate the various types of files
2595 produced from a single source package into separate outputs. For
2596 instance, the GLib C library (used by GTK+ and related packages)
2597 installs more than 20 MiB of reference documentation as HTML pages.
2598 To save space for users who do not need it, the documentation goes to a
2599 separate output, called @code{doc}. To install the main GLib output,
2600 which contains everything but the documentation, one would run:
2601
2602 @example
2603 guix package -i glib
2604 @end example
2605
2606 @cindex documentation
2607 The command to install its documentation is:
2608
2609 @example
2610 guix package -i glib:doc
2611 @end example
2612
2613 Some packages install programs with different ``dependency footprints''.
2614 For instance, the WordNet package installs both command-line tools and
2615 graphical user interfaces (GUIs). The former depend solely on the C
2616 library, whereas the latter depend on Tcl/Tk and the underlying X
2617 libraries. In this case, we leave the command-line tools in the default
2618 output, whereas the GUIs are in a separate output. This allows users
2619 who do not need the GUIs to save space. The @command{guix size} command
2620 can help find out about such situations (@pxref{Invoking guix size}).
2621 @command{guix graph} can also be helpful (@pxref{Invoking guix graph}).
2622
2623 There are several such multiple-output packages in the GNU distribution.
2624 Other conventional output names include @code{lib} for libraries and
2625 possibly header files, @code{bin} for stand-alone programs, and
2626 @code{debug} for debugging information (@pxref{Installing Debugging
2627 Files}). The outputs of a packages are listed in the third column of
2628 the output of @command{guix package --list-available} (@pxref{Invoking
2629 guix package}).
2630
2631
2632 @node Invoking guix gc
2633 @section Invoking @command{guix gc}
2634
2635 @cindex garbage collector
2636 @cindex disk space
2637 Packages that are installed, but not used, may be @dfn{garbage-collected}.
2638 The @command{guix gc} command allows users to explicitly run the garbage
2639 collector to reclaim space from the @file{/gnu/store} directory. It is
2640 the @emph{only} way to remove files from @file{/gnu/store}---removing
2641 files or directories manually may break it beyond repair!
2642
2643 @cindex GC roots
2644 @cindex garbage collector roots
2645 The garbage collector has a set of known @dfn{roots}: any file under
2646 @file{/gnu/store} reachable from a root is considered @dfn{live} and
2647 cannot be deleted; any other file is considered @dfn{dead} and may be
2648 deleted. The set of garbage collector roots (``GC roots'' for short)
2649 includes default user profiles; by default, the symlinks under
2650 @file{/var/guix/gcroots} represent these GC roots. New GC roots can be
2651 added with @command{guix build --root}, for example (@pxref{Invoking
2652 guix build}).
2653
2654 Prior to running @code{guix gc --collect-garbage} to make space, it is
2655 often useful to remove old generations from user profiles; that way, old
2656 package builds referenced by those generations can be reclaimed. This
2657 is achieved by running @code{guix package --delete-generations}
2658 (@pxref{Invoking guix package}).
2659
2660 Our recommendation is to run a garbage collection periodically, or when
2661 you are short on disk space. For instance, to guarantee that at least
2662 5@tie{}GB are available on your disk, simply run:
2663
2664 @example
2665 guix gc -F 5G
2666 @end example
2667
2668 It is perfectly safe to run as a non-interactive periodic job
2669 (@pxref{Scheduled Job Execution}, for how to set up such a job on
2670 GuixSD). Running @command{guix gc} with no arguments will collect as
2671 much garbage as it can, but that is often inconvenient: you may find
2672 yourself having to rebuild or re-download software that is ``dead'' from
2673 the GC viewpoint but that is necessary to build other pieces of
2674 software---e.g., the compiler tool chain.
2675
2676 The @command{guix gc} command has three modes of operation: it can be
2677 used to garbage-collect any dead files (the default), to delete specific
2678 files (the @code{--delete} option), to print garbage-collector
2679 information, or for more advanced queries. The garbage collection
2680 options are as follows:
2681
2682 @table @code
2683 @item --collect-garbage[=@var{min}]
2684 @itemx -C [@var{min}]
2685 Collect garbage---i.e., unreachable @file{/gnu/store} files and
2686 sub-directories. This is the default operation when no option is
2687 specified.
2688
2689 When @var{min} is given, stop once @var{min} bytes have been collected.
2690 @var{min} may be a number of bytes, or it may include a unit as a
2691 suffix, such as @code{MiB} for mebibytes and @code{GB} for gigabytes
2692 (@pxref{Block size, size specifications,, coreutils, GNU Coreutils}).
2693
2694 When @var{min} is omitted, collect all the garbage.
2695
2696 @item --free-space=@var{free}
2697 @itemx -F @var{free}
2698 Collect garbage until @var{free} space is available under
2699 @file{/gnu/store}, if possible; @var{free} denotes storage space, such
2700 as @code{500MiB}, as described above.
2701
2702 When @var{free} or more is already available in @file{/gnu/store}, do
2703 nothing and exit immediately.
2704
2705 @item --delete
2706 @itemx -d
2707 Attempt to delete all the store files and directories specified as
2708 arguments. This fails if some of the files are not in the store, or if
2709 they are still live.
2710
2711 @item --list-failures
2712 List store items corresponding to cached build failures.
2713
2714 This prints nothing unless the daemon was started with
2715 @option{--cache-failures} (@pxref{Invoking guix-daemon,
2716 @option{--cache-failures}}).
2717
2718 @item --clear-failures
2719 Remove the specified store items from the failed-build cache.
2720
2721 Again, this option only makes sense when the daemon is started with
2722 @option{--cache-failures}. Otherwise, it does nothing.
2723
2724 @item --list-dead
2725 Show the list of dead files and directories still present in the
2726 store---i.e., files and directories no longer reachable from any root.
2727
2728 @item --list-live
2729 Show the list of live store files and directories.
2730
2731 @end table
2732
2733 In addition, the references among existing store files can be queried:
2734
2735 @table @code
2736
2737 @item --references
2738 @itemx --referrers
2739 @cindex package dependencies
2740 List the references (respectively, the referrers) of store files given
2741 as arguments.
2742
2743 @item --requisites
2744 @itemx -R
2745 @cindex closure
2746 List the requisites of the store files passed as arguments. Requisites
2747 include the store files themselves, their references, and the references
2748 of these, recursively. In other words, the returned list is the
2749 @dfn{transitive closure} of the store files.
2750
2751 @xref{Invoking guix size}, for a tool to profile the size of the closure
2752 of an element. @xref{Invoking guix graph}, for a tool to visualize
2753 the graph of references.
2754
2755 @item --derivers
2756 @cindex derivation
2757 Return the derivation(s) leading to the given store items
2758 (@pxref{Derivations}).
2759
2760 For example, this command:
2761
2762 @example
2763 guix gc --derivers `guix package -I ^emacs$ | cut -f4`
2764 @end example
2765
2766 @noindent
2767 returns the @file{.drv} file(s) leading to the @code{emacs} package
2768 installed in your profile.
2769
2770 Note that there may be zero matching @file{.drv} files, for instance
2771 because these files have been garbage-collected. There can also be more
2772 than one matching @file{.drv} due to fixed-output derivations.
2773 @end table
2774
2775 Lastly, the following options allow you to check the integrity of the
2776 store and to control disk usage.
2777
2778 @table @option
2779
2780 @item --verify[=@var{options}]
2781 @cindex integrity, of the store
2782 @cindex integrity checking
2783 Verify the integrity of the store.
2784
2785 By default, make sure that all the store items marked as valid in the
2786 database of the daemon actually exist in @file{/gnu/store}.
2787
2788 When provided, @var{options} must be a comma-separated list containing one
2789 or more of @code{contents} and @code{repair}.
2790
2791 When passing @option{--verify=contents}, the daemon computes the
2792 content hash of each store item and compares it against its hash in the
2793 database. Hash mismatches are reported as data corruptions. Because it
2794 traverses @emph{all the files in the store}, this command can take a
2795 long time, especially on systems with a slow disk drive.
2796
2797 @cindex repairing the store
2798 @cindex corruption, recovering from
2799 Using @option{--verify=repair} or @option{--verify=contents,repair}
2800 causes the daemon to try to repair corrupt store items by fetching
2801 substitutes for them (@pxref{Substitutes}). Because repairing is not
2802 atomic, and thus potentially dangerous, it is available only to the
2803 system administrator. A lightweight alternative, when you know exactly
2804 which items in the store are corrupt, is @command{guix build --repair}
2805 (@pxref{Invoking guix build}).
2806
2807 @item --optimize
2808 @cindex deduplication
2809 Optimize the store by hard-linking identical files---this is
2810 @dfn{deduplication}.
2811
2812 The daemon performs deduplication after each successful build or archive
2813 import, unless it was started with @code{--disable-deduplication}
2814 (@pxref{Invoking guix-daemon, @code{--disable-deduplication}}). Thus,
2815 this option is primarily useful when the daemon was running with
2816 @code{--disable-deduplication}.
2817
2818 @end table
2819
2820 @node Invoking guix pull
2821 @section Invoking @command{guix pull}
2822
2823 @cindex upgrading Guix
2824 @cindex updating Guix
2825 @cindex @command{guix pull}
2826 @cindex pull
2827 Packages are installed or upgraded to the latest version available in
2828 the distribution currently available on your local machine. To update
2829 that distribution, along with the Guix tools, you must run @command{guix
2830 pull}: the command downloads the latest Guix source code and package
2831 descriptions, and deploys it. Source code is downloaded from a
2832 @uref{https://git-scm.com, Git} repository, by default the official
2833 GNU@tie{}Guix repository, though this can be customized.
2834
2835 On completion, @command{guix package} will use packages and package
2836 versions from this just-retrieved copy of Guix. Not only that, but all
2837 the Guix commands and Scheme modules will also be taken from that latest
2838 version. New @command{guix} sub-commands added by the update also
2839 become available.
2840
2841 Any user can update their Guix copy using @command{guix pull}, and the
2842 effect is limited to the user who run @command{guix pull}. For
2843 instance, when user @code{root} runs @command{guix pull}, this has no
2844 effect on the version of Guix that user @code{alice} sees, and vice
2845 versa.
2846
2847 The result of running @command{guix pull} is a @dfn{profile} available
2848 under @file{~/.config/guix/current} containing the latest Guix. Thus,
2849 make sure to add it to the beginning of your search path so that you use
2850 the latest version, and similarly for the Info manual
2851 (@pxref{Documentation}):
2852
2853 @example
2854 export PATH="$HOME/.config/guix/current/bin:$PATH"
2855 export INFOPATH="$HOME/.config/guix/current/share/info:$INFOPATH"
2856 @end example
2857
2858 The @code{--list-generations} or @code{-l} option lists past generations
2859 produced by @command{guix pull}, along with details about their provenance:
2860
2861 @example
2862 $ guix pull -l
2863 Generation 1 Jun 10 2018 00:18:18
2864 guix 65956ad
2865 repository URL: https://git.savannah.gnu.org/git/guix.git
2866 branch: origin/master
2867 commit: 65956ad3526ba09e1f7a40722c96c6ef7c0936fe
2868
2869 Generation 2 Jun 11 2018 11:02:49
2870 guix e0cc7f6
2871 repository URL: https://git.savannah.gnu.org/git/guix.git
2872 branch: origin/master
2873 commit: e0cc7f669bec22c37481dd03a7941c7d11a64f1d
2874 2 new packages: keepalived, libnfnetlink
2875 6 packages upgraded: emacs-nix-mode@@2.0.4,
2876 guile2.0-guix@@0.14.0-12.77a1aac, guix@@0.14.0-12.77a1aac,
2877 heimdal@@7.5.0, milkytracker@@1.02.00, nix@@2.0.4
2878
2879 Generation 3 Jun 13 2018 23:31:07 (current)
2880 guix 844cc1c
2881 repository URL: https://git.savannah.gnu.org/git/guix.git
2882 branch: origin/master
2883 commit: 844cc1c8f394f03b404c5bb3aee086922373490c
2884 28 new packages: emacs-helm-ls-git, emacs-helm-mu, @dots{}
2885 69 packages upgraded: borg@@1.1.6, cheese@@3.28.0, @dots{}
2886 @end example
2887
2888 @ref{Invoking guix describe, @command{guix describe}}, for other ways to
2889 describe the current status of Guix.
2890
2891 This @code{~/.config/guix/current} profile works like any other profile
2892 created by @command{guix package} (@pxref{Invoking guix package}). That
2893 is, you can list generations, roll back to the previous
2894 generation---i.e., the previous Guix---and so on:
2895
2896 @example
2897 $ guix package -p ~/.config/guix/current --roll-back
2898 switched from generation 3 to 2
2899 $ guix package -p ~/.config/guix/current --delete-generations=1
2900 deleting /var/guix/profiles/per-user/charlie/current-guix-1-link
2901 @end example
2902
2903 The @command{guix pull} command is usually invoked with no arguments,
2904 but it supports the following options:
2905
2906 @table @code
2907 @item --url=@var{url}
2908 @itemx --commit=@var{commit}
2909 @itemx --branch=@var{branch}
2910 Download code from the specified @var{url}, at the given @var{commit} (a valid
2911 Git commit ID represented as a hexadecimal string), or @var{branch}.
2912
2913 @cindex @file{channels.scm}, configuration file
2914 @cindex configuration file for channels
2915 These options are provided for convenience, but you can also specify your
2916 configuration in the @file{~/.config/guix/channels.scm} file or using the
2917 @option{--channels} option (see below).
2918
2919 @item --channels=@var{file}
2920 @itemx -C @var{file}
2921 Read the list of channels from @var{file} instead of
2922 @file{~/.config/guix/channels.scm}. @var{file} must contain Scheme code that
2923 evaluates to a list of channel objects. @xref{Channels}, for more
2924 information.
2925
2926 @item --list-generations[=@var{pattern}]
2927 @itemx -l [@var{pattern}]
2928 List all the generations of @file{~/.config/guix/current} or, if @var{pattern}
2929 is provided, the subset of generations that match @var{pattern}.
2930 The syntax of @var{pattern} is the same as with @code{guix package
2931 --list-generations} (@pxref{Invoking guix package}).
2932
2933 @ref{Invoking guix describe}, for a way to display information about the
2934 current generation only.
2935
2936 @item --profile=@var{profile}
2937 @itemx -p @var{profile}
2938 Use @var{profile} instead of @file{~/.config/guix/current}.
2939
2940 @item --dry-run
2941 @itemx -n
2942 Show which channel commit(s) would be used and what would be built or
2943 substituted but do not actually do it.
2944
2945 @item --system=@var{system}
2946 @itemx -s @var{system}
2947 Attempt to build for @var{system}---e.g., @code{i686-linux}---instead of
2948 the system type of the build host.
2949
2950 @item --verbose
2951 Produce verbose output, writing build logs to the standard error output.
2952
2953 @item --bootstrap
2954 Use the bootstrap Guile to build the latest Guix. This option is only
2955 useful to Guix developers.
2956 @end table
2957
2958 The @dfn{channel} mechanism allows you to instruct @command{guix pull} which
2959 repository and branch to pull from, as well as @emph{additional} repositories
2960 containing package modules that should be deployed. @xref{Channels}, for more
2961 information.
2962
2963 In addition, @command{guix pull} supports all the common build options
2964 (@pxref{Common Build Options}).
2965
2966 @node Channels
2967 @section Channels
2968
2969 @cindex channels
2970 @cindex @file{channels.scm}, configuration file
2971 @cindex configuration file for channels
2972 @cindex @command{guix pull}, configuration file
2973 @cindex configuration of @command{guix pull}
2974 Guix and its package collection are updated by running @command{guix pull}
2975 (@pxref{Invoking guix pull}). By default @command{guix pull} downloads and
2976 deploys Guix itself from the official GNU@tie{}Guix repository. This can be
2977 customized by defining @dfn{channels} in the
2978 @file{~/.config/guix/channels.scm} file. A channel specifies a URL and branch
2979 of a Git repository to be deployed, and @command{guix pull} can be instructed
2980 to pull from one or more channels. In other words, channels can be used to
2981 @emph{customize} and to @emph{extend} Guix, as we will see below.
2982
2983 @subsection Using a Custom Guix Channel
2984
2985 The channel called @code{guix} specifies where Guix itself---its command-line
2986 tools as well as its package collection---should be downloaded. For instance,
2987 suppose you want to update from your own copy of the Guix repository at
2988 @code{example.org}, and specifically the @code{super-hacks} branch, you can
2989 write in @code{~/.config/guix/channels.scm} this specification:
2990
2991 @lisp
2992 ;; Tell 'guix pull' to use my own repo.
2993 (list (channel
2994 (name 'guix)
2995 (url "https://example.org/my-guix.git")
2996 (branch "super-hacks")))
2997 @end lisp
2998
2999 @noindent
3000 From there on, @command{guix pull} will fetch code from the @code{super-hacks}
3001 branch of the repository at @code{example.org}.
3002
3003 @subsection Specifying Additional Channels
3004
3005 @cindex extending the package collection (channels)
3006 @cindex personal packages (channels)
3007 @cindex channels, for personal packages
3008 You can also specify @emph{additional channels} to pull from. Let's say you
3009 have a bunch of custom package variants or personal packages that you think
3010 would make little sense to contribute to the Guix project, but would like to
3011 have these packages transparently available to you at the command line. You
3012 would first write modules containing those package definitions (@pxref{Package
3013 Modules}), maintain them in a Git repository, and then you and anyone else can
3014 use it as an additional channel to get packages from. Neat, no?
3015
3016 @c What follows stems from discussions at
3017 @c <https://debbugs.gnu.org/cgi/bugreport.cgi?bug=22629#134> as well as
3018 @c earlier discussions on guix-devel@gnu.org.
3019 @quotation Warning
3020 Before you, dear user, shout---``woow this is @emph{soooo coool}!''---and
3021 publish your personal channel to the world, we would like to share a few words
3022 of caution:
3023
3024 @itemize
3025 @item
3026 Before publishing a channel, please consider contributing your package
3027 definitions to Guix proper (@pxref{Contributing}). Guix as a project is open
3028 to free software of all sorts, and packages in Guix proper are readily
3029 available to all Guix users and benefit from the project's quality assurance
3030 process.
3031
3032 @item
3033 When you maintain package definitions outside Guix, we, Guix developers,
3034 consider that @emph{the compatibility burden is on you}. Remember that
3035 package modules and package definitions are just Scheme code that uses various
3036 programming interfaces (APIs). We want to remain free to change these APIs to
3037 keep improving Guix, possibly in ways that break your channel. We never
3038 change APIs gratuitously, but we will @emph{not} commit to freezing APIs
3039 either.
3040
3041 @item
3042 Corollary: if you're using an external channel and that channel breaks, please
3043 @emph{report the issue to the channel authors}, not to the Guix project.
3044 @end itemize
3045
3046 You've been warned! Having said this, we believe external channels are a
3047 practical way to exert your freedom to augment Guix' package collection and to
3048 share your improvements, which are basic tenets of
3049 @uref{https://www.gnu.org/philosophy/free-sw.html, free software}. Please
3050 email us at @email{guix-devel@@gnu.org} if you'd like to discuss this.
3051 @end quotation
3052
3053 Once you have a Git repository containing your own package modules, you can
3054 write @code{~/.config/guix/channels.scm} to instruct @command{guix pull} to
3055 pull from your personal channel @emph{in addition} to the default Guix
3056 channel(s):
3057
3058 @vindex %default-channels
3059 @lisp
3060 ;; Add my personal packages to those Guix provides.
3061 (cons (channel
3062 (name 'my-personal-packages)
3063 (url "https://example.org/personal-packages.git"))
3064 %default-channels)
3065 @end lisp
3066
3067 @noindent
3068 Note that the snippet above is (as always!)@: Scheme code; we use @code{cons} to
3069 add a channel the list of channels that the variable @code{%default-channels}
3070 is bound to (@pxref{Pairs, @code{cons} and lists,, guile, GNU Guile Reference
3071 Manual}). With this file in place, @command{guix pull} builds not only Guix
3072 but also the package modules from your own repository. The result in
3073 @file{~/.config/guix/current} is the union of Guix with your own package
3074 modules:
3075
3076 @example
3077 $ guix pull --list-generations
3078 @dots{}
3079 Generation 19 Aug 27 2018 16:20:48
3080 guix d894ab8
3081 repository URL: https://git.savannah.gnu.org/git/guix.git
3082 branch: master
3083 commit: d894ab8e9bfabcefa6c49d9ba2e834dd5a73a300
3084 my-personal-packages dd3df5e
3085 repository URL: https://example.org/personal-packages.git
3086 branch: master
3087 commit: dd3df5e2c8818760a8fc0bd699e55d3b69fef2bb
3088 11 new packages: my-gimp, my-emacs-with-cool-features, @dots{}
3089 4 packages upgraded: emacs-racket-mode@@0.0.2-2.1b78827, @dots{}
3090 @end example
3091
3092 @noindent
3093 The output of @command{guix pull} above shows that Generation@tie{}19 includes
3094 both Guix and packages from the @code{my-personal-packages} channel. Among
3095 the new and upgraded packages that are listed, some like @code{my-gimp} and
3096 @code{my-emacs-with-cool-features} might come from
3097 @code{my-personal-packages}, while others come from the Guix default channel.
3098
3099 @cindex dependencies, channels
3100 @cindex meta-data, channels
3101 @subsection Declaring Channel Dependencies
3102
3103 Channel authors may decide to augment a package collection provided by other
3104 channels. They can declare their channel to be dependent on other channels in
3105 a meta-data file @file{.guix-channel}, which is to be placed in the root of
3106 the channel repository.
3107
3108 The meta-data file should contain a simple S-expression like this:
3109
3110 @lisp
3111 (channel
3112 (version 0)
3113 (dependencies
3114 (channel
3115 (name some-collection)
3116 (url "https://example.org/first-collection.git"))
3117 (channel
3118 (name some-other-collection)
3119 (url "https://example.org/second-collection.git")
3120 (branch "testing"))))
3121 @end lisp
3122
3123 In the above example this channel is declared to depend on two other channels,
3124 which will both be fetched automatically. The modules provided by the channel
3125 will be compiled in an environment where the modules of all these declared
3126 channels are available.
3127
3128 For the sake of reliability and maintainability, you should avoid dependencies
3129 on channels that you don't control, and you should aim to keep the number of
3130 dependencies to a minimum.
3131
3132 @subsection Replicating Guix
3133
3134 @cindex pinning, channels
3135 @cindex replicating Guix
3136 @cindex reproducibility, of Guix
3137 The @command{guix pull --list-generations} output above shows precisely which
3138 commits were used to build this instance of Guix. We can thus replicate it,
3139 say, on another machine, by providing a channel specification in
3140 @file{~/.config/guix/channels.scm} that is ``pinned'' to these commits:
3141
3142 @lisp
3143 ;; Deploy specific commits of my channels of interest.
3144 (list (channel
3145 (name 'guix)
3146 (url "https://git.savannah.gnu.org/git/guix.git")
3147 (commit "d894ab8e9bfabcefa6c49d9ba2e834dd5a73a300"))
3148 (channel
3149 (name 'my-personal-packages)
3150 (url "https://example.org/personal-packages.git")
3151 (branch "dd3df5e2c8818760a8fc0bd699e55d3b69fef2bb")))
3152 @end lisp
3153
3154 The @command{guix describe --format=channels} command can even generate this
3155 list of channels directly (@pxref{Invoking guix describe}).
3156
3157 At this point the two machines run the @emph{exact same Guix}, with access to
3158 the @emph{exact same packages}. The output of @command{guix build gimp} on
3159 one machine will be exactly the same, bit for bit, as the output of the same
3160 command on the other machine. It also means both machines have access to all
3161 the source code of Guix and, transitively, to all the source code of every
3162 package it defines.
3163
3164 This gives you super powers, allowing you to track the provenance of binary
3165 artifacts with very fine grain, and to reproduce software environments at
3166 will---some sort of ``meta reproducibility'' capabilities, if you will.
3167 @xref{Inferiors}, for another way to take advantage of these super powers.
3168
3169 @node Inferiors
3170 @section Inferiors
3171
3172 @c TODO: Remove this once we're more confident about API stability.
3173 @quotation Note
3174 The functionality described here is a ``technology preview'' as of version
3175 @value{VERSION}. As such, the interface is subject to change.
3176 @end quotation
3177
3178 @cindex inferiors
3179 @cindex composition of Guix revisions
3180 Sometimes you might need to mix packages from the revision of Guix you're
3181 currently running with packages available in a different revision of Guix.
3182 Guix @dfn{inferiors} allow you to achieve that by composing different Guix
3183 revisions in arbitrary ways.
3184
3185 @cindex inferior packages
3186 Technically, an ``inferior'' is essentially a separate Guix process connected
3187 to your main Guix process through a REPL (@pxref{Invoking guix repl}). The
3188 @code{(guix inferior)} module allows you to create inferiors and to
3189 communicate with them. It also provides a high-level interface to browse and
3190 manipulate the packages that an inferior provides---@dfn{inferior packages}.
3191
3192 When combined with channels (@pxref{Channels}), inferiors provide a simple way
3193 to interact with a separate revision of Guix. For example, let's assume you
3194 want to install in your profile the current @code{guile} package, along with
3195 the @code{guile-json} as it existed in an older revision of Guix---perhaps
3196 because the newer @code{guile-json} has an incompatible API and you want to
3197 run your code against the old API@. To do that, you could write a manifest for
3198 use by @code{guix package --manifest} (@pxref{Invoking guix package}); in that
3199 manifest, you would create an inferior for that old Guix revision you care
3200 about, and you would look up the @code{guile-json} package in the inferior:
3201
3202 @lisp
3203 (use-modules (guix inferior) (guix channels)
3204 (srfi srfi-1)) ;for 'first'
3205
3206 (define channels
3207 ;; This is the old revision from which we want to
3208 ;; extract guile-json.
3209 (list (channel
3210 (name 'guix)
3211 (url "https://git.savannah.gnu.org/git/guix.git")
3212 (commit
3213 "65956ad3526ba09e1f7a40722c96c6ef7c0936fe"))))
3214
3215 (define inferior
3216 ;; An inferior representing the above revision.
3217 (inferior-for-channels channels))
3218
3219 ;; Now create a manifest with the current "guile" package
3220 ;; and the old "guile-json" package.
3221 (packages->manifest
3222 (list (first (lookup-inferior-packages inferior "guile-json"))
3223 (specification->package "guile")))
3224 @end lisp
3225
3226 On its first run, @command{guix package --manifest} might have to build the
3227 channel you specified before it can create the inferior; subsequent runs will
3228 be much faster because the Guix revision will be cached.
3229
3230 The @code{(guix inferior)} module provides the following procedures to open an
3231 inferior:
3232
3233 @deffn {Scheme Procedure} inferior-for-channels @var{channels} @
3234 [#:cache-directory] [#:ttl]
3235 Return an inferior for @var{channels}, a list of channels. Use the cache at
3236 @var{cache-directory}, where entries can be reclaimed after @var{ttl} seconds.
3237 This procedure opens a new connection to the build daemon.
3238
3239 As a side effect, this procedure may build or substitute binaries for
3240 @var{channels}, which can take time.
3241 @end deffn
3242
3243 @deffn {Scheme Procedure} open-inferior @var{directory} @
3244 [#:command "bin/guix"]
3245 Open the inferior Guix in @var{directory}, running
3246 @code{@var{directory}/@var{command} repl} or equivalent. Return @code{#f} if
3247 the inferior could not be launched.
3248 @end deffn
3249
3250 @cindex inferior packages
3251 The procedures listed below allow you to obtain and manipulate inferior
3252 packages.
3253
3254 @deffn {Scheme Procedure} inferior-packages @var{inferior}
3255 Return the list of packages known to @var{inferior}.
3256 @end deffn
3257
3258 @deffn {Scheme Procedure} lookup-inferior-packages @var{inferior} @var{name} @
3259 [@var{version}]
3260 Return the sorted list of inferior packages matching @var{name} in
3261 @var{inferior}, with highest version numbers first. If @var{version} is true,
3262 return only packages with a version number prefixed by @var{version}.
3263 @end deffn
3264
3265 @deffn {Scheme Procedure} inferior-package? @var{obj}
3266 Return true if @var{obj} is an inferior package.
3267 @end deffn
3268
3269 @deffn {Scheme Procedure} inferior-package-name @var{package}
3270 @deffnx {Scheme Procedure} inferior-package-version @var{package}
3271 @deffnx {Scheme Procedure} inferior-package-synopsis @var{package}
3272 @deffnx {Scheme Procedure} inferior-package-description @var{package}
3273 @deffnx {Scheme Procedure} inferior-package-home-page @var{package}
3274 @deffnx {Scheme Procedure} inferior-package-location @var{package}
3275 @deffnx {Scheme Procedure} inferior-package-inputs @var{package}
3276 @deffnx {Scheme Procedure} inferior-package-native-inputs @var{package}
3277 @deffnx {Scheme Procedure} inferior-package-propagated-inputs @var{package}
3278 @deffnx {Scheme Procedure} inferior-package-transitive-propagated-inputs @var{package}
3279 @deffnx {Scheme Procedure} inferior-package-native-search-paths @var{package}
3280 @deffnx {Scheme Procedure} inferior-package-transitive-native-search-paths @var{package}
3281 @deffnx {Scheme Procedure} inferior-package-search-paths @var{package}
3282 These procedures are the counterpart of package record accessors
3283 (@pxref{package Reference}). Most of them work by querying the inferior
3284 @var{package} comes from, so the inferior must still be live when you call
3285 these procedures.
3286 @end deffn
3287
3288 Inferior packages can be used transparently like any other package or
3289 file-like object in G-expressions (@pxref{G-Expressions}). They are also
3290 transparently handled by the @code{packages->manifest} procedure, which is
3291 commonly use in manifests (@pxref{Invoking guix package, the
3292 @option{--manifest} option of @command{guix package}}). Thus you can insert
3293 an inferior package pretty much anywhere you would insert a regular package:
3294 in manifests, in the @code{packages} field of your @code{operating-system}
3295 declaration, and so on.
3296
3297 @node Invoking guix describe
3298 @section Invoking @command{guix describe}
3299
3300 @cindex reproducibility
3301 @cindex replicating Guix
3302 Often you may want to answer questions like: ``Which revision of Guix am I
3303 using?'' or ``Which channels am I using?'' This is useful information in many
3304 situations: if you want to @emph{replicate} an environment on a different
3305 machine or user account, if you want to report a bug or to determine what
3306 change in the channels you are using caused it, or if you want to record your
3307 system state for reproducibility purposes. The @command{guix describe}
3308 command answers these questions.
3309
3310 When run from a @command{guix pull}ed @command{guix}, @command{guix describe}
3311 displays the channel(s) that it was built from, including their repository URL
3312 and commit IDs (@pxref{Channels}):
3313
3314 @example
3315 $ guix describe
3316 Generation 10 Sep 03 2018 17:32:44 (current)
3317 guix e0fa68c
3318 repository URL: https://git.savannah.gnu.org/git/guix.git
3319 branch: master
3320 commit: e0fa68c7718fffd33d81af415279d6ddb518f727
3321 @end example
3322
3323 If you're familiar with the Git version control system, this is similar in
3324 spirit to @command{git describe}; the output is also similar to that of
3325 @command{guix pull --list-generations}, but limited to the current generation
3326 (@pxref{Invoking guix pull, the @option{--list-generations} option}). Because
3327 the Git commit ID shown above unambiguously refers to a snapshot of Guix, this
3328 information is all it takes to describe the revision of Guix you're using, and
3329 also to replicate it.
3330
3331 To make it easier to replicate Guix, @command{guix describe} can also be asked
3332 to return a list of channels instead of the human-readable description above:
3333
3334 @example
3335 $ guix describe -f channels
3336 (list (channel
3337 (name 'guix)
3338 (url "https://git.savannah.gnu.org/git/guix.git")
3339 (commit
3340 "e0fa68c7718fffd33d81af415279d6ddb518f727")))
3341 @end example
3342
3343 @noindent
3344 You can save this to a file and feed it to @command{guix pull -C} on some
3345 other machine or at a later point in time, which will instantiate @emph{this
3346 exact Guix revision} (@pxref{Invoking guix pull, the @option{-C} option}).
3347 From there on, since you're able to deploy the same revision of Guix, you can
3348 just as well @emph{replicate a complete software environment}. We humbly
3349 think that this is @emph{awesome}, and we hope you'll like it too!
3350
3351 The details of the options supported by @command{guix describe} are as
3352 follows:
3353
3354 @table @code
3355 @item --format=@var{format}
3356 @itemx -f @var{format}
3357 Produce output in the specified @var{format}, one of:
3358
3359 @table @code
3360 @item human
3361 produce human-readable output;
3362 @item channels
3363 produce a list of channel specifications that can be passed to @command{guix
3364 pull -C} or installed as @file{~/.config/guix/channels.scm} (@pxref{Invoking
3365 guix pull});
3366 @item json
3367 @cindex JSON
3368 produce a list of channel specifications in JSON format;
3369 @item recutils
3370 produce a list of channel specifications in Recutils format.
3371 @end table
3372
3373 @item --profile=@var{profile}
3374 @itemx -p @var{profile}
3375 Display information about @var{profile}.
3376 @end table
3377
3378 @node Invoking guix pack
3379 @section Invoking @command{guix pack}
3380
3381 Occasionally you want to pass software to people who are not (yet!)
3382 lucky enough to be using Guix. You'd tell them to run @command{guix
3383 package -i @var{something}}, but that's not possible in this case. This
3384 is where @command{guix pack} comes in.
3385
3386 @quotation Note
3387 If you are looking for ways to exchange binaries among machines that
3388 already run Guix, @pxref{Invoking guix copy}, @ref{Invoking guix
3389 publish}, and @ref{Invoking guix archive}.
3390 @end quotation
3391
3392 @cindex pack
3393 @cindex bundle
3394 @cindex application bundle
3395 @cindex software bundle
3396 The @command{guix pack} command creates a shrink-wrapped @dfn{pack} or
3397 @dfn{software bundle}: it creates a tarball or some other archive
3398 containing the binaries of the software you're interested in, and all
3399 its dependencies. The resulting archive can be used on any machine that
3400 does not have Guix, and people can run the exact same binaries as those
3401 you have with Guix. The pack itself is created in a bit-reproducible
3402 fashion, so anyone can verify that it really contains the build results
3403 that you pretend to be shipping.
3404
3405 For example, to create a bundle containing Guile, Emacs, Geiser, and all
3406 their dependencies, you can run:
3407
3408 @example
3409 $ guix pack guile emacs geiser
3410 @dots{}
3411 /gnu/store/@dots{}-pack.tar.gz
3412 @end example
3413
3414 The result here is a tarball containing a @file{/gnu/store} directory
3415 with all the relevant packages. The resulting tarball contains a
3416 @dfn{profile} with the three packages of interest; the profile is the
3417 same as would be created by @command{guix package -i}. It is this
3418 mechanism that is used to create Guix's own standalone binary tarball
3419 (@pxref{Binary Installation}).
3420
3421 Users of this pack would have to run
3422 @file{/gnu/store/@dots{}-profile/bin/guile} to run Guile, which you may
3423 find inconvenient. To work around it, you can create, say, a
3424 @file{/opt/gnu/bin} symlink to the profile:
3425
3426 @example
3427 guix pack -S /opt/gnu/bin=bin guile emacs geiser
3428 @end example
3429
3430 @noindent
3431 That way, users can happily type @file{/opt/gnu/bin/guile} and enjoy.
3432
3433 @cindex relocatable binaries, with @command{guix pack}
3434 What if the recipient of your pack does not have root privileges on
3435 their machine, and thus cannot unpack it in the root file system? In
3436 that case, you will want to use the @code{--relocatable} option (see
3437 below). This option produces @dfn{relocatable binaries}, meaning they
3438 they can be placed anywhere in the file system hierarchy: in the example
3439 above, users can unpack your tarball in their home directory and
3440 directly run @file{./opt/gnu/bin/guile}.
3441
3442 @cindex Docker, build an image with guix pack
3443 Alternatively, you can produce a pack in the Docker image format using
3444 the following command:
3445
3446 @example
3447 guix pack -f docker guile emacs geiser
3448 @end example
3449
3450 @noindent
3451 The result is a tarball that can be passed to the @command{docker load}
3452 command. See the
3453 @uref{https://docs.docker.com/engine/reference/commandline/load/, Docker
3454 documentation} for more information.
3455
3456 @cindex Singularity, build an image with guix pack
3457 @cindex SquashFS, build an image with guix pack
3458 Yet another option is to produce a SquashFS image with the following
3459 command:
3460
3461 @example
3462 guix pack -f squashfs guile emacs geiser
3463 @end example
3464
3465 @noindent
3466 The result is a SquashFS file system image that can either be mounted or
3467 directly be used as a file system container image with the
3468 @uref{http://singularity.lbl.gov, Singularity container execution
3469 environment}, using commands like @command{singularity shell} or
3470 @command{singularity exec}.
3471
3472 Several command-line options allow you to customize your pack:
3473
3474 @table @code
3475 @item --format=@var{format}
3476 @itemx -f @var{format}
3477 Produce a pack in the given @var{format}.
3478
3479 The available formats are:
3480
3481 @table @code
3482 @item tarball
3483 This is the default format. It produces a tarball containing all the
3484 specified binaries and symlinks.
3485
3486 @item docker
3487 This produces a tarball that follows the
3488 @uref{https://github.com/docker/docker/blob/master/image/spec/v1.2.md,
3489 Docker Image Specification}.
3490
3491 @item squashfs
3492 This produces a SquashFS image containing all the specified binaries and
3493 symlinks, as well as empty mount points for virtual file systems like
3494 procfs.
3495 @end table
3496
3497 @item --relocatable
3498 @itemx -R
3499 Produce @dfn{relocatable binaries}---i.e., binaries that can be placed
3500 anywhere in the file system hierarchy and run from there. For example,
3501 if you create a pack containing Bash with:
3502
3503 @example
3504 guix pack -R -S /mybin=bin bash
3505 @end example
3506
3507 @noindent
3508 ...@: you can copy that pack to a machine that lacks Guix, and from your
3509 home directory as a normal user, run:
3510
3511 @example
3512 tar xf pack.tar.gz
3513 ./mybin/sh
3514 @end example
3515
3516 @noindent
3517 In that shell, if you type @code{ls /gnu/store}, you'll notice that
3518 @file{/gnu/store} shows up and contains all the dependencies of
3519 @code{bash}, even though the machine actually lacks @file{/gnu/store}
3520 altogether! That is probably the simplest way to deploy Guix-built
3521 software on a non-Guix machine.
3522
3523 There's a gotcha though: this technique relies on the @dfn{user
3524 namespace} feature of the kernel Linux, which allows unprivileged users
3525 to mount or change root. Old versions of Linux did not support it, and
3526 some GNU/Linux distributions turn it off; on these systems, programs
3527 from the pack @emph{will fail to run}, unless they are unpacked in the
3528 root file system.
3529
3530 @item --expression=@var{expr}
3531 @itemx -e @var{expr}
3532 Consider the package @var{expr} evaluates to.
3533
3534 This has the same purpose as the same-named option in @command{guix
3535 build} (@pxref{Additional Build Options, @code{--expression} in
3536 @command{guix build}}).
3537
3538 @item --manifest=@var{file}
3539 @itemx -m @var{file}
3540 Use the packages contained in the manifest object returned by the Scheme
3541 code in @var{file}.
3542
3543 This has a similar purpose as the same-named option in @command{guix
3544 package} (@pxref{profile-manifest, @option{--manifest}}) and uses the
3545 same manifest files. It allows you to define a collection of packages
3546 once and use it both for creating profiles and for creating archives
3547 for use on machines that do not have Guix installed. Note that you can
3548 specify @emph{either} a manifest file @emph{or} a list of packages,
3549 but not both.
3550
3551 @item --system=@var{system}
3552 @itemx -s @var{system}
3553 Attempt to build for @var{system}---e.g., @code{i686-linux}---instead of
3554 the system type of the build host.
3555
3556 @item --target=@var{triplet}
3557 @cindex cross-compilation
3558 Cross-build for @var{triplet}, which must be a valid GNU triplet, such
3559 as @code{"mips64el-linux-gnu"} (@pxref{Specifying target triplets, GNU
3560 configuration triplets,, autoconf, Autoconf}).
3561
3562 @item --compression=@var{tool}
3563 @itemx -C @var{tool}
3564 Compress the resulting tarball using @var{tool}---one of @code{gzip},
3565 @code{bzip2}, @code{xz}, @code{lzip}, or @code{none} for no compression.
3566
3567 @item --symlink=@var{spec}
3568 @itemx -S @var{spec}
3569 Add the symlinks specified by @var{spec} to the pack. This option can
3570 appear several times.
3571
3572 @var{spec} has the form @code{@var{source}=@var{target}}, where
3573 @var{source} is the symlink that will be created and @var{target} is the
3574 symlink target.
3575
3576 For instance, @code{-S /opt/gnu/bin=bin} creates a @file{/opt/gnu/bin}
3577 symlink pointing to the @file{bin} sub-directory of the profile.
3578
3579 @item --localstatedir
3580 @itemx --profile-name=@var{name}
3581 Include the ``local state directory'', @file{/var/guix}, in the resulting
3582 pack, and notably the @file{/var/guix/profiles/per-user/root/@var{name}}
3583 profile---by default @var{name} is @code{guix-profile}, which corresponds to
3584 @file{~root/.guix-profile}.
3585
3586 @file{/var/guix} contains the store database (@pxref{The Store}) as well
3587 as garbage-collector roots (@pxref{Invoking guix gc}). Providing it in
3588 the pack means that the store is ``complete'' and manageable by Guix;
3589 not providing it pack means that the store is ``dead'': items cannot be
3590 added to it or removed from it after extraction of the pack.
3591
3592 One use case for this is the Guix self-contained binary tarball
3593 (@pxref{Binary Installation}).
3594
3595 @item --bootstrap
3596 Use the bootstrap binaries to build the pack. This option is only
3597 useful to Guix developers.
3598 @end table
3599
3600 In addition, @command{guix pack} supports all the common build options
3601 (@pxref{Common Build Options}) and all the package transformation
3602 options (@pxref{Package Transformation Options}).
3603
3604
3605 @node Invoking guix archive
3606 @section Invoking @command{guix archive}
3607
3608 @cindex @command{guix archive}
3609 @cindex archive
3610 The @command{guix archive} command allows users to @dfn{export} files
3611 from the store into a single archive, and to later @dfn{import} them on
3612 a machine that runs Guix.
3613 In particular, it allows store files to be transferred from one machine
3614 to the store on another machine.
3615
3616 @quotation Note
3617 If you're looking for a way to produce archives in a format suitable for
3618 tools other than Guix, @pxref{Invoking guix pack}.
3619 @end quotation
3620
3621 @cindex exporting store items
3622 To export store files as an archive to standard output, run:
3623
3624 @example
3625 guix archive --export @var{options} @var{specifications}...
3626 @end example
3627
3628 @var{specifications} may be either store file names or package
3629 specifications, as for @command{guix package} (@pxref{Invoking guix
3630 package}). For instance, the following command creates an archive
3631 containing the @code{gui} output of the @code{git} package and the main
3632 output of @code{emacs}:
3633
3634 @example
3635 guix archive --export git:gui /gnu/store/...-emacs-24.3 > great.nar
3636 @end example
3637
3638 If the specified packages are not built yet, @command{guix archive}
3639 automatically builds them. The build process may be controlled with the
3640 common build options (@pxref{Common Build Options}).
3641
3642 To transfer the @code{emacs} package to a machine connected over SSH,
3643 one would run:
3644
3645 @example
3646 guix archive --export -r emacs | ssh the-machine guix archive --import
3647 @end example
3648
3649 @noindent
3650 Similarly, a complete user profile may be transferred from one machine
3651 to another like this:
3652
3653 @example
3654 guix archive --export -r $(readlink -f ~/.guix-profile) | \
3655 ssh the-machine guix-archive --import
3656 @end example
3657
3658 @noindent
3659 However, note that, in both examples, all of @code{emacs} and the
3660 profile as well as all of their dependencies are transferred (due to
3661 @code{-r}), regardless of what is already available in the store on the
3662 target machine. The @code{--missing} option can help figure out which
3663 items are missing from the target store. The @command{guix copy}
3664 command simplifies and optimizes this whole process, so this is probably
3665 what you should use in this case (@pxref{Invoking guix copy}).
3666
3667 @cindex nar, archive format
3668 @cindex normalized archive (nar)
3669 Archives are stored in the ``normalized archive'' or ``nar'' format, which is
3670 comparable in spirit to `tar', but with differences
3671 that make it more appropriate for our purposes. First, rather than
3672 recording all Unix metadata for each file, the nar format only mentions
3673 the file type (regular, directory, or symbolic link); Unix permissions
3674 and owner/group are dismissed. Second, the order in which directory
3675 entries are stored always follows the order of file names according to
3676 the C locale collation order. This makes archive production fully
3677 deterministic.
3678
3679 When exporting, the daemon digitally signs the contents of the archive,
3680 and that digital signature is appended. When importing, the daemon
3681 verifies the signature and rejects the import in case of an invalid
3682 signature or if the signing key is not authorized.
3683 @c FIXME: Add xref to daemon doc about signatures.
3684
3685 The main options are:
3686
3687 @table @code
3688 @item --export
3689 Export the specified store files or packages (see below.) Write the
3690 resulting archive to the standard output.
3691
3692 Dependencies are @emph{not} included in the output, unless
3693 @code{--recursive} is passed.
3694
3695 @item -r
3696 @itemx --recursive
3697 When combined with @code{--export}, this instructs @command{guix
3698 archive} to include dependencies of the given items in the archive.
3699 Thus, the resulting archive is self-contained: it contains the closure
3700 of the exported store items.
3701
3702 @item --import
3703 Read an archive from the standard input, and import the files listed
3704 therein into the store. Abort if the archive has an invalid digital
3705 signature, or if it is signed by a public key not among the authorized
3706 keys (see @code{--authorize} below.)
3707
3708 @item --missing
3709 Read a list of store file names from the standard input, one per line,
3710 and write on the standard output the subset of these files missing from
3711 the store.
3712
3713 @item --generate-key[=@var{parameters}]
3714 @cindex signing, archives
3715 Generate a new key pair for the daemon. This is a prerequisite before
3716 archives can be exported with @code{--export}. Note that this operation
3717 usually takes time, because it needs to gather enough entropy to
3718 generate the key pair.
3719
3720 The generated key pair is typically stored under @file{/etc/guix}, in
3721 @file{signing-key.pub} (public key) and @file{signing-key.sec} (private
3722 key, which must be kept secret.) When @var{parameters} is omitted,
3723 an ECDSA key using the Ed25519 curve is generated, or, for Libgcrypt
3724 versions before 1.6.0, it is a 4096-bit RSA key.
3725 Alternatively, @var{parameters} can specify
3726 @code{genkey} parameters suitable for Libgcrypt (@pxref{General
3727 public-key related Functions, @code{gcry_pk_genkey},, gcrypt, The
3728 Libgcrypt Reference Manual}).
3729
3730 @item --authorize
3731 @cindex authorizing, archives
3732 Authorize imports signed by the public key passed on standard input.
3733 The public key must be in ``s-expression advanced format''---i.e., the
3734 same format as the @file{signing-key.pub} file.
3735
3736 The list of authorized keys is kept in the human-editable file
3737 @file{/etc/guix/acl}. The file contains
3738 @url{http://people.csail.mit.edu/rivest/Sexp.txt, ``advanced-format
3739 s-expressions''} and is structured as an access-control list in the
3740 @url{http://theworld.com/~cme/spki.txt, Simple Public-Key Infrastructure
3741 (SPKI)}.
3742
3743 @item --extract=@var{directory}
3744 @itemx -x @var{directory}
3745 Read a single-item archive as served by substitute servers
3746 (@pxref{Substitutes}) and extract it to @var{directory}. This is a
3747 low-level operation needed in only very narrow use cases; see below.
3748
3749 For example, the following command extracts the substitute for Emacs
3750 served by @code{@value{SUBSTITUTE-SERVER}} to @file{/tmp/emacs}:
3751
3752 @example
3753 $ wget -O - \
3754 https://@value{SUBSTITUTE-SERVER}/nar/@dots{}-emacs-24.5 \
3755 | bunzip2 | guix archive -x /tmp/emacs
3756 @end example
3757
3758 Single-item archives are different from multiple-item archives produced
3759 by @command{guix archive --export}; they contain a single store item,
3760 and they do @emph{not} embed a signature. Thus this operation does
3761 @emph{no} signature verification and its output should be considered
3762 unsafe.
3763
3764 The primary purpose of this operation is to facilitate inspection of
3765 archive contents coming from possibly untrusted substitute servers.
3766
3767 @end table
3768
3769 @c *********************************************************************
3770 @node Programming Interface
3771 @chapter Programming Interface
3772
3773 GNU Guix provides several Scheme programming interfaces (APIs) to
3774 define, build, and query packages. The first interface allows users to
3775 write high-level package definitions. These definitions refer to
3776 familiar packaging concepts, such as the name and version of a package,
3777 its build system, and its dependencies. These definitions can then be
3778 turned into concrete build actions.
3779
3780 Build actions are performed by the Guix daemon, on behalf of users. In a
3781 standard setup, the daemon has write access to the store---the
3782 @file{/gnu/store} directory---whereas users do not. The recommended
3783 setup also has the daemon perform builds in chroots, under a specific
3784 build users, to minimize interference with the rest of the system.
3785
3786 @cindex derivation
3787 Lower-level APIs are available to interact with the daemon and the
3788 store. To instruct the daemon to perform a build action, users actually
3789 provide it with a @dfn{derivation}. A derivation is a low-level
3790 representation of the build actions to be taken, and the environment in
3791 which they should occur---derivations are to package definitions what
3792 assembly is to C programs. The term ``derivation'' comes from the fact
3793 that build results @emph{derive} from them.
3794
3795 This chapter describes all these APIs in turn, starting from high-level
3796 package definitions.
3797
3798 @menu
3799 * Defining Packages:: Defining new packages.
3800 * Build Systems:: Specifying how packages are built.
3801 * The Store:: Manipulating the package store.
3802 * Derivations:: Low-level interface to package derivations.
3803 * The Store Monad:: Purely functional interface to the store.
3804 * G-Expressions:: Manipulating build expressions.
3805 * Invoking guix repl:: Fiddling with Guix interactively.
3806 @end menu
3807
3808 @node Defining Packages
3809 @section Defining Packages
3810
3811 The high-level interface to package definitions is implemented in the
3812 @code{(guix packages)} and @code{(guix build-system)} modules. As an
3813 example, the package definition, or @dfn{recipe}, for the GNU Hello
3814 package looks like this:
3815
3816 @example
3817 (define-module (gnu packages hello)
3818 #:use-module (guix packages)
3819 #:use-module (guix download)
3820 #:use-module (guix build-system gnu)
3821 #:use-module (guix licenses)
3822 #:use-module (gnu packages gawk))
3823
3824 (define-public hello
3825 (package
3826 (name "hello")
3827 (version "2.10")
3828 (source (origin
3829 (method url-fetch)
3830 (uri (string-append "mirror://gnu/hello/hello-" version
3831 ".tar.gz"))
3832 (sha256
3833 (base32
3834 "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i"))))
3835 (build-system gnu-build-system)
3836 (arguments '(#:configure-flags '("--enable-silent-rules")))
3837 (inputs `(("gawk" ,gawk)))
3838 (synopsis "Hello, GNU world: An example GNU package")
3839 (description "Guess what GNU Hello prints!")
3840 (home-page "http://www.gnu.org/software/hello/")
3841 (license gpl3+)))
3842 @end example
3843
3844 @noindent
3845 Without being a Scheme expert, the reader may have guessed the meaning
3846 of the various fields here. This expression binds the variable
3847 @code{hello} to a @code{<package>} object, which is essentially a record
3848 (@pxref{SRFI-9, Scheme records,, guile, GNU Guile Reference Manual}).
3849 This package object can be inspected using procedures found in the
3850 @code{(guix packages)} module; for instance, @code{(package-name hello)}
3851 returns---surprise!---@code{"hello"}.
3852
3853 With luck, you may be able to import part or all of the definition of
3854 the package you are interested in from another repository, using the
3855 @code{guix import} command (@pxref{Invoking guix import}).
3856
3857 In the example above, @var{hello} is defined in a module of its own,
3858 @code{(gnu packages hello)}. Technically, this is not strictly
3859 necessary, but it is convenient to do so: all the packages defined in
3860 modules under @code{(gnu packages @dots{})} are automatically known to
3861 the command-line tools (@pxref{Package Modules}).
3862
3863 There are a few points worth noting in the above package definition:
3864
3865 @itemize
3866 @item
3867 The @code{source} field of the package is an @code{<origin>} object
3868 (@pxref{origin Reference}, for the complete reference).
3869 Here, the @code{url-fetch} method from @code{(guix download)} is used,
3870 meaning that the source is a file to be downloaded over FTP or HTTP.
3871
3872 The @code{mirror://gnu} prefix instructs @code{url-fetch} to use one of
3873 the GNU mirrors defined in @code{(guix download)}.
3874
3875 The @code{sha256} field specifies the expected SHA256 hash of the file
3876 being downloaded. It is mandatory, and allows Guix to check the
3877 integrity of the file. The @code{(base32 @dots{})} form introduces the
3878 base32 representation of the hash. You can obtain this information with
3879 @code{guix download} (@pxref{Invoking guix download}) and @code{guix
3880 hash} (@pxref{Invoking guix hash}).
3881
3882 @cindex patches
3883 When needed, the @code{origin} form can also have a @code{patches} field
3884 listing patches to be applied, and a @code{snippet} field giving a
3885 Scheme expression to modify the source code.
3886
3887 @item
3888 @cindex GNU Build System
3889 The @code{build-system} field specifies the procedure to build the
3890 package (@pxref{Build Systems}). Here, @var{gnu-build-system}
3891 represents the familiar GNU Build System, where packages may be
3892 configured, built, and installed with the usual @code{./configure &&
3893 make && make check && make install} command sequence.
3894
3895 @item
3896 The @code{arguments} field specifies options for the build system
3897 (@pxref{Build Systems}). Here it is interpreted by
3898 @var{gnu-build-system} as a request run @file{configure} with the
3899 @code{--enable-silent-rules} flag.
3900
3901 @cindex quote
3902 @cindex quoting
3903 @findex '
3904 @findex quote
3905 What about these quote (@code{'}) characters? They are Scheme syntax to
3906 introduce a literal list; @code{'} is synonymous with @code{quote}.
3907 @xref{Expression Syntax, quoting,, guile, GNU Guile Reference Manual},
3908 for details. Here the value of the @code{arguments} field is a list of
3909 arguments passed to the build system down the road, as with @code{apply}
3910 (@pxref{Fly Evaluation, @code{apply},, guile, GNU Guile Reference
3911 Manual}).
3912
3913 The hash-colon (@code{#:}) sequence defines a Scheme @dfn{keyword}
3914 (@pxref{Keywords,,, guile, GNU Guile Reference Manual}), and
3915 @code{#:configure-flags} is a keyword used to pass a keyword argument
3916 to the build system (@pxref{Coding With Keywords,,, guile, GNU Guile
3917 Reference Manual}).
3918
3919 @item
3920 The @code{inputs} field specifies inputs to the build process---i.e.,
3921 build-time or run-time dependencies of the package. Here, we define an
3922 input called @code{"gawk"} whose value is that of the @var{gawk}
3923 variable; @var{gawk} is itself bound to a @code{<package>} object.
3924
3925 @cindex backquote (quasiquote)
3926 @findex `
3927 @findex quasiquote
3928 @cindex comma (unquote)
3929 @findex ,
3930 @findex unquote
3931 @findex ,@@
3932 @findex unquote-splicing
3933 Again, @code{`} (a backquote, synonymous with @code{quasiquote}) allows
3934 us to introduce a literal list in the @code{inputs} field, while
3935 @code{,} (a comma, synonymous with @code{unquote}) allows us to insert a
3936 value in that list (@pxref{Expression Syntax, unquote,, guile, GNU Guile
3937 Reference Manual}).
3938
3939 Note that GCC, Coreutils, Bash, and other essential tools do not need to
3940 be specified as inputs here. Instead, @var{gnu-build-system} takes care
3941 of ensuring that they are present (@pxref{Build Systems}).
3942
3943 However, any other dependencies need to be specified in the
3944 @code{inputs} field. Any dependency not specified here will simply be
3945 unavailable to the build process, possibly leading to a build failure.
3946 @end itemize
3947
3948 @xref{package Reference}, for a full description of possible fields.
3949
3950 Once a package definition is in place, the
3951 package may actually be built using the @code{guix build} command-line
3952 tool (@pxref{Invoking guix build}), troubleshooting any build failures
3953 you encounter (@pxref{Debugging Build Failures}). You can easily jump back to the
3954 package definition using the @command{guix edit} command
3955 (@pxref{Invoking guix edit}).
3956 @xref{Packaging Guidelines}, for
3957 more information on how to test package definitions, and
3958 @ref{Invoking guix lint}, for information on how to check a definition
3959 for style conformance.
3960 @vindex GUIX_PACKAGE_PATH
3961 Lastly, @pxref{Channels}, for information
3962 on how to extend the distribution by adding your own package definitions
3963 in a ``channel''.
3964
3965 Finally, updating the package definition to a new upstream version
3966 can be partly automated by the @command{guix refresh} command
3967 (@pxref{Invoking guix refresh}).
3968
3969 Behind the scenes, a derivation corresponding to the @code{<package>}
3970 object is first computed by the @code{package-derivation} procedure.
3971 That derivation is stored in a @code{.drv} file under @file{/gnu/store}.
3972 The build actions it prescribes may then be realized by using the
3973 @code{build-derivations} procedure (@pxref{The Store}).
3974
3975 @deffn {Scheme Procedure} package-derivation @var{store} @var{package} [@var{system}]
3976 Return the @code{<derivation>} object of @var{package} for @var{system}
3977 (@pxref{Derivations}).
3978
3979 @var{package} must be a valid @code{<package>} object, and @var{system}
3980 must be a string denoting the target system type---e.g.,
3981 @code{"x86_64-linux"} for an x86_64 Linux-based GNU system. @var{store}
3982 must be a connection to the daemon, which operates on the store
3983 (@pxref{The Store}).
3984 @end deffn
3985
3986 @noindent
3987 @cindex cross-compilation
3988 Similarly, it is possible to compute a derivation that cross-builds a
3989 package for some other system:
3990
3991 @deffn {Scheme Procedure} package-cross-derivation @var{store} @
3992 @var{package} @var{target} [@var{system}]
3993 Return the @code{<derivation>} object of @var{package} cross-built from
3994 @var{system} to @var{target}.
3995
3996 @var{target} must be a valid GNU triplet denoting the target hardware
3997 and operating system, such as @code{"mips64el-linux-gnu"}
3998 (@pxref{Configuration Names, GNU configuration triplets,, configure, GNU
3999 Configure and Build System}).
4000 @end deffn
4001
4002 @cindex package transformations
4003 @cindex input rewriting
4004 @cindex dependency tree rewriting
4005 Packages can be manipulated in arbitrary ways. An example of a useful
4006 transformation is @dfn{input rewriting}, whereby the dependency tree of
4007 a package is rewritten by replacing specific inputs by others:
4008
4009 @deffn {Scheme Procedure} package-input-rewriting @var{replacements} @
4010 [@var{rewrite-name}]
4011 Return a procedure that, when passed a package, replaces its direct and
4012 indirect dependencies (but not its implicit inputs) according to
4013 @var{replacements}. @var{replacements} is a list of package pairs; the
4014 first element of each pair is the package to replace, and the second one
4015 is the replacement.
4016
4017 Optionally, @var{rewrite-name} is a one-argument procedure that takes
4018 the name of a package and returns its new name after rewrite.
4019 @end deffn
4020
4021 @noindent
4022 Consider this example:
4023
4024 @example
4025 (define libressl-instead-of-openssl
4026 ;; This is a procedure to replace OPENSSL by LIBRESSL,
4027 ;; recursively.
4028 (package-input-rewriting `((,openssl . ,libressl))))
4029
4030 (define git-with-libressl
4031 (libressl-instead-of-openssl git))
4032 @end example
4033
4034 @noindent
4035 Here we first define a rewriting procedure that replaces @var{openssl}
4036 with @var{libressl}. Then we use it to define a @dfn{variant} of the
4037 @var{git} package that uses @var{libressl} instead of @var{openssl}.
4038 This is exactly what the @option{--with-input} command-line option does
4039 (@pxref{Package Transformation Options, @option{--with-input}}).
4040
4041 A more generic procedure to rewrite a package dependency graph is
4042 @code{package-mapping}: it supports arbitrary changes to nodes in the
4043 graph.
4044
4045 @deffn {Scheme Procedure} package-mapping @var{proc} [@var{cut?}]
4046 Return a procedure that, given a package, applies @var{proc} to all the packages
4047 depended on and returns the resulting package. The procedure stops recursion
4048 when @var{cut?} returns true for a given package.
4049 @end deffn
4050
4051 @menu
4052 * package Reference:: The package data type.
4053 * origin Reference:: The origin data type.
4054 @end menu
4055
4056
4057 @node package Reference
4058 @subsection @code{package} Reference
4059
4060 This section summarizes all the options available in @code{package}
4061 declarations (@pxref{Defining Packages}).
4062
4063 @deftp {Data Type} package
4064 This is the data type representing a package recipe.
4065
4066 @table @asis
4067 @item @code{name}
4068 The name of the package, as a string.
4069
4070 @item @code{version}
4071 The version of the package, as a string.
4072
4073 @item @code{source}
4074 An object telling how the source code for the package should be
4075 acquired. Most of the time, this is an @code{origin} object, which
4076 denotes a file fetched from the Internet (@pxref{origin Reference}). It
4077 can also be any other ``file-like'' object such as a @code{local-file},
4078 which denotes a file from the local file system (@pxref{G-Expressions,
4079 @code{local-file}}).
4080
4081 @item @code{build-system}
4082 The build system that should be used to build the package (@pxref{Build
4083 Systems}).
4084
4085 @item @code{arguments} (default: @code{'()})
4086 The arguments that should be passed to the build system. This is a
4087 list, typically containing sequential keyword-value pairs.
4088
4089 @item @code{inputs} (default: @code{'()})
4090 @itemx @code{native-inputs} (default: @code{'()})
4091 @itemx @code{propagated-inputs} (default: @code{'()})
4092 @cindex inputs, of packages
4093 These fields list dependencies of the package. Each one is a list of
4094 tuples, where each tuple has a label for the input (a string) as its
4095 first element, a package, origin, or derivation as its second element,
4096 and optionally the name of the output thereof that should be used, which
4097 defaults to @code{"out"} (@pxref{Packages with Multiple Outputs}, for
4098 more on package outputs). For example, the list below specifies three
4099 inputs:
4100
4101 @example
4102 `(("libffi" ,libffi)
4103 ("libunistring" ,libunistring)
4104 ("glib:bin" ,glib "bin")) ;the "bin" output of Glib
4105 @end example
4106
4107 @cindex cross compilation, package dependencies
4108 The distinction between @code{native-inputs} and @code{inputs} is
4109 necessary when considering cross-compilation. When cross-compiling,
4110 dependencies listed in @code{inputs} are built for the @emph{target}
4111 architecture; conversely, dependencies listed in @code{native-inputs}
4112 are built for the architecture of the @emph{build} machine.
4113
4114 @code{native-inputs} is typically used to list tools needed at
4115 build time, but not at run time, such as Autoconf, Automake, pkg-config,
4116 Gettext, or Bison. @command{guix lint} can report likely mistakes in
4117 this area (@pxref{Invoking guix lint}).
4118
4119 @anchor{package-propagated-inputs}
4120 Lastly, @code{propagated-inputs} is similar to @code{inputs}, but the
4121 specified packages will be automatically installed alongside the package
4122 they belong to (@pxref{package-cmd-propagated-inputs, @command{guix
4123 package}}, for information on how @command{guix package} deals with
4124 propagated inputs.)
4125
4126 For example this is necessary when a C/C++ library needs headers of
4127 another library to compile, or when a pkg-config file refers to another
4128 one @i{via} its @code{Requires} field.
4129
4130 Another example where @code{propagated-inputs} is useful is for languages
4131 that lack a facility to record the run-time search path akin to the
4132 @code{RUNPATH} of ELF files; this includes Guile, Python, Perl, and
4133 more. To ensure that libraries written in those languages can find
4134 library code they depend on at run time, run-time dependencies must be
4135 listed in @code{propagated-inputs} rather than @code{inputs}.
4136
4137 @item @code{self-native-input?} (default: @code{#f})
4138 This is a Boolean field telling whether the package should use itself as
4139 a native input when cross-compiling.
4140
4141 @item @code{outputs} (default: @code{'("out")})
4142 The list of output names of the package. @xref{Packages with Multiple
4143 Outputs}, for typical uses of additional outputs.
4144
4145 @item @code{native-search-paths} (default: @code{'()})
4146 @itemx @code{search-paths} (default: @code{'()})
4147 A list of @code{search-path-specification} objects describing
4148 search-path environment variables honored by the package.
4149
4150 @item @code{replacement} (default: @code{#f})
4151 This must be either @code{#f} or a package object that will be used as a
4152 @dfn{replacement} for this package. @xref{Security Updates, grafts},
4153 for details.
4154
4155 @item @code{synopsis}
4156 A one-line description of the package.
4157
4158 @item @code{description}
4159 A more elaborate description of the package.
4160
4161 @item @code{license}
4162 @cindex license, of packages
4163 The license of the package; a value from @code{(guix licenses)},
4164 or a list of such values.
4165
4166 @item @code{home-page}
4167 The URL to the home-page of the package, as a string.
4168
4169 @item @code{supported-systems} (default: @var{%supported-systems})
4170 The list of systems supported by the package, as strings of the form
4171 @code{architecture-kernel}, for example @code{"x86_64-linux"}.
4172
4173 @item @code{maintainers} (default: @code{'()})
4174 The list of maintainers of the package, as @code{maintainer} objects.
4175
4176 @item @code{location} (default: source location of the @code{package} form)
4177 The source location of the package. It is useful to override this when
4178 inheriting from another package, in which case this field is not
4179 automatically corrected.
4180 @end table
4181 @end deftp
4182
4183
4184 @node origin Reference
4185 @subsection @code{origin} Reference
4186
4187 This section summarizes all the options available in @code{origin}
4188 declarations (@pxref{Defining Packages}).
4189
4190 @deftp {Data Type} origin
4191 This is the data type representing a source code origin.
4192
4193 @table @asis
4194 @item @code{uri}
4195 An object containing the URI of the source. The object type depends on
4196 the @code{method} (see below). For example, when using the
4197 @var{url-fetch} method of @code{(guix download)}, the valid @code{uri}
4198 values are: a URL represented as a string, or a list thereof.
4199
4200 @item @code{method}
4201 A procedure that handles the URI.
4202
4203 Examples include:
4204
4205 @table @asis
4206 @item @var{url-fetch} from @code{(guix download)}
4207 download a file from the HTTP, HTTPS, or FTP URL specified in the
4208 @code{uri} field;
4209
4210 @vindex git-fetch
4211 @item @var{git-fetch} from @code{(guix git-download)}
4212 clone the Git version control repository, and check out the revision
4213 specified in the @code{uri} field as a @code{git-reference} object; a
4214 @code{git-reference} looks like this:
4215
4216 @example
4217 (git-reference
4218 (url "git://git.debian.org/git/pkg-shadow/shadow")
4219 (commit "v4.1.5.1"))
4220 @end example
4221 @end table
4222
4223 @item @code{sha256}
4224 A bytevector containing the SHA-256 hash of the source. Typically the
4225 @code{base32} form is used here to generate the bytevector from a
4226 base-32 string.
4227
4228 You can obtain this information using @code{guix download}
4229 (@pxref{Invoking guix download}) or @code{guix hash} (@pxref{Invoking
4230 guix hash}).
4231
4232 @item @code{file-name} (default: @code{#f})
4233 The file name under which the source code should be saved. When this is
4234 @code{#f}, a sensible default value will be used in most cases. In case
4235 the source is fetched from a URL, the file name from the URL will be
4236 used. For version control checkouts, it is recommended to provide the
4237 file name explicitly because the default is not very descriptive.
4238
4239 @item @code{patches} (default: @code{'()})
4240 A list of file names, origins, or file-like objects (@pxref{G-Expressions,
4241 file-like objects}) pointing to patches to be applied to the source.
4242
4243 This list of patches must be unconditional. In particular, it cannot
4244 depend on the value of @code{%current-system} or
4245 @code{%current-target-system}.
4246
4247 @item @code{snippet} (default: @code{#f})
4248 A G-expression (@pxref{G-Expressions}) or S-expression that will be run
4249 in the source directory. This is a convenient way to modify the source,
4250 sometimes more convenient than a patch.
4251
4252 @item @code{patch-flags} (default: @code{'("-p1")})
4253 A list of command-line flags that should be passed to the @code{patch}
4254 command.
4255
4256 @item @code{patch-inputs} (default: @code{#f})
4257 Input packages or derivations to the patching process. When this is
4258 @code{#f}, the usual set of inputs necessary for patching are provided,
4259 such as GNU@tie{}Patch.
4260
4261 @item @code{modules} (default: @code{'()})
4262 A list of Guile modules that should be loaded during the patching
4263 process and while running the code in the @code{snippet} field.
4264
4265 @item @code{patch-guile} (default: @code{#f})
4266 The Guile package that should be used in the patching process. When
4267 this is @code{#f}, a sensible default is used.
4268 @end table
4269 @end deftp
4270
4271
4272 @node Build Systems
4273 @section Build Systems
4274
4275 @cindex build system
4276 Each package definition specifies a @dfn{build system} and arguments for
4277 that build system (@pxref{Defining Packages}). This @code{build-system}
4278 field represents the build procedure of the package, as well as implicit
4279 dependencies of that build procedure.
4280
4281 Build systems are @code{<build-system>} objects. The interface to
4282 create and manipulate them is provided by the @code{(guix build-system)}
4283 module, and actual build systems are exported by specific modules.
4284
4285 @cindex bag (low-level package representation)
4286 Under the hood, build systems first compile package objects to
4287 @dfn{bags}. A @dfn{bag} is like a package, but with less
4288 ornamentation---in other words, a bag is a lower-level representation of
4289 a package, which includes all the inputs of that package, including some
4290 that were implicitly added by the build system. This intermediate
4291 representation is then compiled to a derivation (@pxref{Derivations}).
4292
4293 Build systems accept an optional list of @dfn{arguments}. In package
4294 definitions, these are passed @i{via} the @code{arguments} field
4295 (@pxref{Defining Packages}). They are typically keyword arguments
4296 (@pxref{Optional Arguments, keyword arguments in Guile,, guile, GNU
4297 Guile Reference Manual}). The value of these arguments is usually
4298 evaluated in the @dfn{build stratum}---i.e., by a Guile process launched
4299 by the daemon (@pxref{Derivations}).
4300
4301 The main build system is @var{gnu-build-system}, which implements the
4302 standard build procedure for GNU and many other packages. It
4303 is provided by the @code{(guix build-system gnu)} module.
4304
4305 @defvr {Scheme Variable} gnu-build-system
4306 @var{gnu-build-system} represents the GNU Build System, and variants
4307 thereof (@pxref{Configuration, configuration and makefile conventions,,
4308 standards, GNU Coding Standards}).
4309
4310 @cindex build phases
4311 In a nutshell, packages using it are configured, built, and installed with
4312 the usual @code{./configure && make && make check && make install}
4313 command sequence. In practice, a few additional steps are often needed.
4314 All these steps are split up in separate @dfn{phases},
4315 notably@footnote{Please see the @code{(guix build gnu-build-system)}
4316 modules for more details about the build phases.}:
4317
4318 @table @code
4319 @item unpack
4320 Unpack the source tarball, and change the current directory to the
4321 extracted source tree. If the source is actually a directory, copy it
4322 to the build tree, and enter that directory.
4323
4324 @item patch-source-shebangs
4325 Patch shebangs encountered in source files so they refer to the right
4326 store file names. For instance, this changes @code{#!/bin/sh} to
4327 @code{#!/gnu/store/@dots{}-bash-4.3/bin/sh}.
4328
4329 @item configure
4330 Run the @file{configure} script with a number of default options, such
4331 as @code{--prefix=/gnu/store/@dots{}}, as well as the options specified
4332 by the @code{#:configure-flags} argument.
4333
4334 @item build
4335 Run @code{make} with the list of flags specified with
4336 @code{#:make-flags}. If the @code{#:parallel-build?} argument is true
4337 (the default), build with @code{make -j}.
4338
4339 @item check
4340 Run @code{make check}, or some other target specified with
4341 @code{#:test-target}, unless @code{#:tests? #f} is passed. If the
4342 @code{#:parallel-tests?} argument is true (the default), run @code{make
4343 check -j}.
4344
4345 @item install
4346 Run @code{make install} with the flags listed in @code{#:make-flags}.
4347
4348 @item patch-shebangs
4349 Patch shebangs on the installed executable files.
4350
4351 @item strip
4352 Strip debugging symbols from ELF files (unless @code{#:strip-binaries?}
4353 is false), copying them to the @code{debug} output when available
4354 (@pxref{Installing Debugging Files}).
4355 @end table
4356
4357 @vindex %standard-phases
4358 The build-side module @code{(guix build gnu-build-system)} defines
4359 @var{%standard-phases} as the default list of build phases.
4360 @var{%standard-phases} is a list of symbol/procedure pairs, where the
4361 procedure implements the actual phase.
4362
4363 The list of phases used for a particular package can be changed with the
4364 @code{#:phases} parameter. For instance, passing:
4365
4366 @example
4367 #:phases (modify-phases %standard-phases (delete 'configure))
4368 @end example
4369
4370 means that all the phases described above will be used, except the
4371 @code{configure} phase.
4372
4373 In addition, this build system ensures that the ``standard'' environment
4374 for GNU packages is available. This includes tools such as GCC, libc,
4375 Coreutils, Bash, Make, Diffutils, grep, and sed (see the @code{(guix
4376 build-system gnu)} module for a complete list). We call these the
4377 @dfn{implicit inputs} of a package, because package definitions do not
4378 have to mention them.
4379 @end defvr
4380
4381 Other @code{<build-system>} objects are defined to support other
4382 conventions and tools used by free software packages. They inherit most
4383 of @var{gnu-build-system}, and differ mainly in the set of inputs
4384 implicitly added to the build process, and in the list of phases
4385 executed. Some of these build systems are listed below.
4386
4387 @defvr {Scheme Variable} ant-build-system
4388 This variable is exported by @code{(guix build-system ant)}. It
4389 implements the build procedure for Java packages that can be built with
4390 @url{http://ant.apache.org/, Ant build tool}.
4391
4392 It adds both @code{ant} and the @dfn{Java Development Kit} (JDK) as
4393 provided by the @code{icedtea} package to the set of inputs. Different
4394 packages can be specified with the @code{#:ant} and @code{#:jdk}
4395 parameters, respectively.
4396
4397 When the original package does not provide a suitable Ant build file,
4398 the parameter @code{#:jar-name} can be used to generate a minimal Ant
4399 build file @file{build.xml} with tasks to build the specified jar
4400 archive. In this case the parameter @code{#:source-dir} can be used to
4401 specify the source sub-directory, defaulting to ``src''.
4402
4403 The @code{#:main-class} parameter can be used with the minimal ant
4404 buildfile to specify the main class of the resulting jar. This makes the
4405 jar file executable. The @code{#:test-include} parameter can be used to
4406 specify the list of junit tests to run. It defaults to
4407 @code{(list "**/*Test.java")}. The @code{#:test-exclude} can be used to
4408 disable some tests. It defaults to @code{(list "**/Abstract*.java")},
4409 because abstract classes cannot be run as tests.
4410
4411 The parameter @code{#:build-target} can be used to specify the Ant task
4412 that should be run during the @code{build} phase. By default the
4413 ``jar'' task will be run.
4414
4415 @end defvr
4416
4417 @defvr {Scheme Variable} android-ndk-build-system
4418 @cindex Android distribution
4419 @cindex Android NDK build system
4420 This variable is exported by @code{(guix build-system android-ndk)}. It
4421 implements a build procedure for Android NDK (native development kit)
4422 packages using a Guix-specific build process.
4423
4424 The build system assumes that packages install their public interface
4425 (header) files to the subdirectory "include" of the "out" output and
4426 their libraries to the subdirectory "lib" of the "out" output.
4427
4428 It's also assumed that the union of all the dependencies of a package
4429 has no conflicting files.
4430
4431 For the time being, cross-compilation is not supported - so right now
4432 the libraries and header files are assumed to be host tools.
4433
4434 @end defvr
4435
4436 @defvr {Scheme Variable} asdf-build-system/source
4437 @defvrx {Scheme Variable} asdf-build-system/sbcl
4438 @defvrx {Scheme Variable} asdf-build-system/ecl
4439
4440 These variables, exported by @code{(guix build-system asdf)}, implement
4441 build procedures for Common Lisp packages using
4442 @url{https://common-lisp.net/project/asdf/, ``ASDF''}. ASDF is a system
4443 definition facility for Common Lisp programs and libraries.
4444
4445 The @code{asdf-build-system/source} system installs the packages in
4446 source form, and can be loaded using any common lisp implementation, via
4447 ASDF. The others, such as @code{asdf-build-system/sbcl}, install binary
4448 systems in the format which a particular implementation understands.
4449 These build systems can also be used to produce executable programs, or
4450 lisp images which contain a set of packages pre-loaded.
4451
4452 The build system uses naming conventions. For binary packages, the
4453 package name should be prefixed with the lisp implementation, such as
4454 @code{sbcl-} for @code{asdf-build-system/sbcl}.
4455
4456 Additionally, the corresponding source package should be labeled using
4457 the same convention as python packages (see @ref{Python Modules}), using
4458 the @code{cl-} prefix.
4459
4460 For binary packages, each system should be defined as a Guix package.
4461 If one package @code{origin} contains several systems, package variants
4462 can be created in order to build all the systems. Source packages,
4463 which use @code{asdf-build-system/source}, may contain several systems.
4464
4465 In order to create executable programs and images, the build-side
4466 procedures @code{build-program} and @code{build-image} can be used.
4467 They should be called in a build phase after the @code{create-symlinks}
4468 phase, so that the system which was just built can be used within the
4469 resulting image. @code{build-program} requires a list of Common Lisp
4470 expressions to be passed as the @code{#:entry-program} argument.
4471
4472 If the system is not defined within its own @code{.asd} file of the same
4473 name, then the @code{#:asd-file} parameter should be used to specify
4474 which file the system is defined in. Furthermore, if the package
4475 defines a system for its tests in a separate file, it will be loaded
4476 before the tests are run if it is specified by the
4477 @code{#:test-asd-file} parameter. If it is not set, the files
4478 @code{<system>-tests.asd}, @code{<system>-test.asd}, @code{tests.asd},
4479 and @code{test.asd} will be tried if they exist.
4480
4481 If for some reason the package must be named in a different way than the
4482 naming conventions suggest, the @code{#:asd-system-name} parameter can
4483 be used to specify the name of the system.
4484
4485 @end defvr
4486
4487 @defvr {Scheme Variable} cargo-build-system
4488 @cindex Rust programming language
4489 @cindex Cargo (Rust build system)
4490 This variable is exported by @code{(guix build-system cargo)}. It
4491 supports builds of packages using Cargo, the build tool of the
4492 @uref{https://www.rust-lang.org, Rust programming language}.
4493
4494 In its @code{configure} phase, this build system replaces dependencies
4495 specified in the @file{Carto.toml} file with inputs to the Guix package.
4496 The @code{install} phase installs the binaries, and it also installs the
4497 source code and @file{Cargo.toml} file.
4498 @end defvr
4499
4500 @cindex Clojure (programming language)
4501 @cindex simple Clojure build system
4502 @defvr {Scheme Variable} clojure-build-system
4503 This variable is exported by @code{(guix build-system clojure)}. It implements
4504 a simple build procedure for @uref{https://clojure.org/, Clojure} packages
4505 using plain old @code{compile} in Clojure. Cross-compilation is not supported
4506 yet.
4507
4508 It adds @code{clojure}, @code{icedtea} and @code{zip} to the set of inputs.
4509 Different packages can be specified with the @code{#:clojure}, @code{#:jdk} and
4510 @code{#:zip} parameters, respectively.
4511
4512 A list of source directories, test directories and jar names can be specified
4513 with the @code{#:source-dirs}, @code{#:test-dirs} and @code{#:jar-names}
4514 parameters, respectively. Compile directory and main class can be specified
4515 with the @code{#:compile-dir} and @code{#:main-class} parameters, respectively.
4516 Other parameters are documented below.
4517
4518 This build system is an extension of @var{ant-build-system}, but with the
4519 following phases changed:
4520
4521 @table @code
4522
4523 @item build
4524 This phase calls @code{compile} in Clojure to compile source files and runs
4525 @command{jar} to create jars from both source files and compiled files
4526 according to the include list and exclude list specified in
4527 @code{#:aot-include} and @code{#:aot-exclude}, respectively. The exclude list
4528 has priority over the include list. These lists consist of symbols
4529 representing Clojure libraries or the special keyword @code{#:all} representing
4530 all Clojure libraries found under the source directories. The parameter
4531 @code{#:omit-source?} decides if source should be included into the jars.
4532
4533 @item check
4534 This phase runs tests according to the include list and exclude list specified
4535 in @code{#:test-include} and @code{#:test-exclude}, respectively. Their
4536 meanings are analogous to that of @code{#:aot-include} and
4537 @code{#:aot-exclude}, except that the special keyword @code{#:all} now
4538 stands for all Clojure libraries found under the test directories. The
4539 parameter @code{#:tests?} decides if tests should be run.
4540
4541 @item install
4542 This phase installs all jars built previously.
4543 @end table
4544
4545 Apart from the above, this build system also contains an additional phase:
4546
4547 @table @code
4548
4549 @item install-doc
4550 This phase installs all top-level files with base name matching
4551 @var{%doc-regex}. A different regex can be specified with the
4552 @code{#:doc-regex} parameter. All files (recursively) inside the documentation
4553 directories specified in @code{#:doc-dirs} are installed as well.
4554 @end table
4555 @end defvr
4556
4557 @defvr {Scheme Variable} cmake-build-system
4558 This variable is exported by @code{(guix build-system cmake)}. It
4559 implements the build procedure for packages using the
4560 @url{http://www.cmake.org, CMake build tool}.
4561
4562 It automatically adds the @code{cmake} package to the set of inputs.
4563 Which package is used can be specified with the @code{#:cmake}
4564 parameter.
4565
4566 The @code{#:configure-flags} parameter is taken as a list of flags
4567 passed to the @command{cmake} command. The @code{#:build-type}
4568 parameter specifies in abstract terms the flags passed to the compiler;
4569 it defaults to @code{"RelWithDebInfo"} (short for ``release mode with
4570 debugging information''), which roughly means that code is compiled with
4571 @code{-O2 -g}, as is the case for Autoconf-based packages by default.
4572 @end defvr
4573
4574 @defvr {Scheme Variable} dune-build-system
4575 This variable is exported by @code{(guix build-system dune)}. It
4576 supports builds of packages using @uref{https://dune.build/, Dune}, a build
4577 tool for the OCaml programming language. It is implemented as an extension
4578 of the @code{ocaml-build-system} which is described below. As such, the
4579 @code{#:ocaml} and @code{#:findlib} parameters can be passed to this build
4580 system.
4581
4582 It automatically adds the @code{dune} package to the set of inputs.
4583 Which package is used can be specified with the @code{#:dune}
4584 parameter.
4585
4586 There is no @code{configure} phase because dune packages typically don't
4587 need to be configured. The @code{#:build-flags} parameter is taken as a
4588 list of flags passed to the @code{dune} command during the build.
4589
4590 The @code{#:jbuild?} parameter can be passed to use the @code{jbuild}
4591 command instead of the more recent @code{dune} command while building
4592 a package. Its default value is @code{#f}.
4593 @end defvr
4594
4595 @defvr {Scheme Variable} go-build-system
4596 This variable is exported by @code{(guix build-system go)}. It
4597 implements a build procedure for Go packages using the standard
4598 @url{https://golang.org/cmd/go/#hdr-Compile_packages_and_dependencies,
4599 Go build mechanisms}.
4600
4601 The user is expected to provide a value for the key @code{#:import-path}
4602 and, in some cases, @code{#:unpack-path}. The
4603 @url{https://golang.org/doc/code.html#ImportPaths, import path}
4604 corresponds to the file system path expected by the package's build
4605 scripts and any referring packages, and provides a unique way to
4606 refer to a Go package. It is typically based on a combination of the
4607 package source code's remote URI and file system hierarchy structure. In
4608 some cases, you will need to unpack the package's source code to a
4609 different directory structure than the one indicated by the import path,
4610 and @code{#:unpack-path} should be used in such cases.
4611
4612 Packages that provide Go libraries should be installed along with their
4613 source code. The key @code{#:install-source?}, which defaults to
4614 @code{#t}, controls whether or not the source code is installed. It can
4615 be set to @code{#f} for packages that only provide executable files.
4616 @end defvr
4617
4618 @defvr {Scheme Variable} glib-or-gtk-build-system
4619 This variable is exported by @code{(guix build-system glib-or-gtk)}. It
4620 is intended for use with packages making use of GLib or GTK+.
4621
4622 This build system adds the following two phases to the ones defined by
4623 @var{gnu-build-system}:
4624
4625 @table @code
4626 @item glib-or-gtk-wrap
4627 The phase @code{glib-or-gtk-wrap} ensures that programs in
4628 @file{bin/} are able to find GLib ``schemas'' and
4629 @uref{https://developer.gnome.org/gtk3/stable/gtk-running.html, GTK+
4630 modules}. This is achieved by wrapping the programs in launch scripts
4631 that appropriately set the @code{XDG_DATA_DIRS} and @code{GTK_PATH}
4632 environment variables.
4633
4634 It is possible to exclude specific package outputs from that wrapping
4635 process by listing their names in the
4636 @code{#:glib-or-gtk-wrap-excluded-outputs} parameter. This is useful
4637 when an output is known not to contain any GLib or GTK+ binaries, and
4638 where wrapping would gratuitously add a dependency of that output on
4639 GLib and GTK+.
4640
4641 @item glib-or-gtk-compile-schemas
4642 The phase @code{glib-or-gtk-compile-schemas} makes sure that all
4643 @uref{https://developer.gnome.org/gio/stable/glib-compile-schemas.html,
4644 GSettings schemas} of GLib are compiled. Compilation is performed by the
4645 @command{glib-compile-schemas} program. It is provided by the package
4646 @code{glib:bin} which is automatically imported by the build system.
4647 The @code{glib} package providing @command{glib-compile-schemas} can be
4648 specified with the @code{#:glib} parameter.
4649 @end table
4650
4651 Both phases are executed after the @code{install} phase.
4652 @end defvr
4653
4654 @defvr {Scheme Variable} guile-build-system
4655 This build system is for Guile packages that consist exclusively of Scheme
4656 code and that are so lean that they don't even have a makefile, let alone a
4657 @file{configure} script. It compiles Scheme code using @command{guild
4658 compile} (@pxref{Compilation,,, guile, GNU Guile Reference Manual}) and
4659 installs the @file{.scm} and @file{.go} files in the right place. It also
4660 installs documentation.
4661
4662 This build system supports cross-compilation by using the @code{--target}
4663 option of @command{guild compile}.
4664
4665 Packages built with @code{guile-build-system} must provide a Guile package in
4666 their @code{native-inputs} field.
4667 @end defvr
4668
4669 @defvr {Scheme Variable} minify-build-system
4670 This variable is exported by @code{(guix build-system minify)}. It
4671 implements a minification procedure for simple JavaScript packages.
4672
4673 It adds @code{uglify-js} to the set of inputs and uses it to compress
4674 all JavaScript files in the @file{src} directory. A different minifier
4675 package can be specified with the @code{#:uglify-js} parameter, but it
4676 is expected that the package writes the minified code to the standard
4677 output.
4678
4679 When the input JavaScript files are not all located in the @file{src}
4680 directory, the parameter @code{#:javascript-files} can be used to
4681 specify a list of file names to feed to the minifier.
4682 @end defvr
4683
4684 @defvr {Scheme Variable} ocaml-build-system
4685 This variable is exported by @code{(guix build-system ocaml)}. It implements
4686 a build procedure for @uref{https://ocaml.org, OCaml} packages, which consists
4687 of choosing the correct set of commands to run for each package. OCaml
4688 packages can expect many different commands to be run. This build system will
4689 try some of them.
4690
4691 When the package has a @file{setup.ml} file present at the top-level, it will
4692 run @code{ocaml setup.ml -configure}, @code{ocaml setup.ml -build} and
4693 @code{ocaml setup.ml -install}. The build system will assume that this file
4694 was generated by @uref{http://oasis.forge.ocamlcore.org/, OASIS} and will take
4695 care of setting the prefix and enabling tests if they are not disabled. You
4696 can pass configure and build flags with the @code{#:configure-flags} and
4697 @code{#:build-flags}. The @code{#:test-flags} key can be passed to change the
4698 set of flags used to enable tests. The @code{#:use-make?} key can be used to
4699 bypass this system in the build and install phases.
4700
4701 When the package has a @file{configure} file, it is assumed that it is a
4702 hand-made configure script that requires a different argument format than
4703 in the @code{gnu-build-system}. You can add more flags with the
4704 @code{#:configure-flags} key.
4705
4706 When the package has a @file{Makefile} file (or @code{#:use-make?} is
4707 @code{#t}), it will be used and more flags can be passed to the build and
4708 install phases with the @code{#:make-flags} key.
4709
4710 Finally, some packages do not have these files and use a somewhat standard
4711 location for its build system. In that case, the build system will run
4712 @code{ocaml pkg/pkg.ml} or @code{ocaml pkg/build.ml} and take care of
4713 providing the path to the required findlib module. Additional flags can
4714 be passed via the @code{#:build-flags} key. Install is taken care of by
4715 @command{opam-installer}. In this case, the @code{opam} package must
4716 be added to the @code{native-inputs} field of the package definition.
4717
4718 Note that most OCaml packages assume they will be installed in the same
4719 directory as OCaml, which is not what we want in guix. In particular, they
4720 will install @file{.so} files in their module's directory, which is usually
4721 fine because it is in the OCaml compiler directory. In guix though, these
4722 libraries cannot be found and we use @code{CAML_LD_LIBRARY_PATH}. This
4723 variable points to @file{lib/ocaml/site-lib/stubslibs} and this is where
4724 @file{.so} libraries should be installed.
4725 @end defvr
4726
4727 @defvr {Scheme Variable} python-build-system
4728 This variable is exported by @code{(guix build-system python)}. It
4729 implements the more or less standard build procedure used by Python
4730 packages, which consists in running @code{python setup.py build} and
4731 then @code{python setup.py install --prefix=/gnu/store/@dots{}}.
4732
4733 For packages that install stand-alone Python programs under @code{bin/},
4734 it takes care of wrapping these programs so that their @code{PYTHONPATH}
4735 environment variable points to all the Python libraries they depend on.
4736
4737 Which Python package is used to perform the build can be specified with
4738 the @code{#:python} parameter. This is a useful way to force a package
4739 to be built for a specific version of the Python interpreter, which
4740 might be necessary if the package is only compatible with a single
4741 interpreter version.
4742
4743 By default guix calls @code{setup.py} under control of
4744 @code{setuptools}, much like @command{pip} does. Some packages are not
4745 compatible with setuptools (and pip), thus you can disable this by
4746 setting the @code{#:use-setuptools} parameter to @code{#f}.
4747 @end defvr
4748
4749 @defvr {Scheme Variable} perl-build-system
4750 This variable is exported by @code{(guix build-system perl)}. It
4751 implements the standard build procedure for Perl packages, which either
4752 consists in running @code{perl Build.PL --prefix=/gnu/store/@dots{}},
4753 followed by @code{Build} and @code{Build install}; or in running
4754 @code{perl Makefile.PL PREFIX=/gnu/store/@dots{}}, followed by
4755 @code{make} and @code{make install}, depending on which of
4756 @code{Build.PL} or @code{Makefile.PL} is present in the package
4757 distribution. Preference is given to the former if both @code{Build.PL}
4758 and @code{Makefile.PL} exist in the package distribution. This
4759 preference can be reversed by specifying @code{#t} for the
4760 @code{#:make-maker?} parameter.
4761
4762 The initial @code{perl Makefile.PL} or @code{perl Build.PL} invocation
4763 passes flags specified by the @code{#:make-maker-flags} or
4764 @code{#:module-build-flags} parameter, respectively.
4765
4766 Which Perl package is used can be specified with @code{#:perl}.
4767 @end defvr
4768
4769 @defvr {Scheme Variable} r-build-system
4770 This variable is exported by @code{(guix build-system r)}. It
4771 implements the build procedure used by @uref{http://r-project.org, R}
4772 packages, which essentially is little more than running @code{R CMD
4773 INSTALL --library=/gnu/store/@dots{}} in an environment where
4774 @code{R_LIBS_SITE} contains the paths to all R package inputs. Tests
4775 are run after installation using the R function
4776 @code{tools::testInstalledPackage}.
4777 @end defvr
4778
4779 @defvr {Scheme Variable} texlive-build-system
4780 This variable is exported by @code{(guix build-system texlive)}. It is
4781 used to build TeX packages in batch mode with a specified engine. The
4782 build system sets the @code{TEXINPUTS} variable to find all TeX source
4783 files in the inputs.
4784
4785 By default it runs @code{luatex} on all files ending on @code{ins}. A
4786 different engine and format can be specified with the
4787 @code{#:tex-format} argument. Different build targets can be specified
4788 with the @code{#:build-targets} argument, which expects a list of file
4789 names. The build system adds only @code{texlive-bin} and
4790 @code{texlive-latex-base} (both from @code{(gnu packages tex}) to the
4791 inputs. Both can be overridden with the arguments @code{#:texlive-bin}
4792 and @code{#:texlive-latex-base}, respectively.
4793
4794 The @code{#:tex-directory} parameter tells the build system where to
4795 install the built files under the texmf tree.
4796 @end defvr
4797
4798 @defvr {Scheme Variable} ruby-build-system
4799 This variable is exported by @code{(guix build-system ruby)}. It
4800 implements the RubyGems build procedure used by Ruby packages, which
4801 involves running @code{gem build} followed by @code{gem install}.
4802
4803 The @code{source} field of a package that uses this build system
4804 typically references a gem archive, since this is the format that Ruby
4805 developers use when releasing their software. The build system unpacks
4806 the gem archive, potentially patches the source, runs the test suite,
4807 repackages the gem, and installs it. Additionally, directories and
4808 tarballs may be referenced to allow building unreleased gems from Git or
4809 a traditional source release tarball.
4810
4811 Which Ruby package is used can be specified with the @code{#:ruby}
4812 parameter. A list of additional flags to be passed to the @command{gem}
4813 command can be specified with the @code{#:gem-flags} parameter.
4814 @end defvr
4815
4816 @defvr {Scheme Variable} waf-build-system
4817 This variable is exported by @code{(guix build-system waf)}. It
4818 implements a build procedure around the @code{waf} script. The common
4819 phases---@code{configure}, @code{build}, and @code{install}---are
4820 implemented by passing their names as arguments to the @code{waf}
4821 script.
4822
4823 The @code{waf} script is executed by the Python interpreter. Which
4824 Python package is used to run the script can be specified with the
4825 @code{#:python} parameter.
4826 @end defvr
4827
4828 @defvr {Scheme Variable} scons-build-system
4829 This variable is exported by @code{(guix build-system scons)}. It
4830 implements the build procedure used by the SCons software construction
4831 tool. This build system runs @code{scons} to build the package,
4832 @code{scons test} to run tests, and then @code{scons install} to install
4833 the package.
4834
4835 Additional flags to be passed to @code{scons} can be specified with the
4836 @code{#:scons-flags} parameter. The version of Python used to run SCons
4837 can be specified by selecting the appropriate SCons package with the
4838 @code{#:scons} parameter.
4839 @end defvr
4840
4841 @defvr {Scheme Variable} haskell-build-system
4842 This variable is exported by @code{(guix build-system haskell)}. It
4843 implements the Cabal build procedure used by Haskell packages, which
4844 involves running @code{runhaskell Setup.hs configure
4845 --prefix=/gnu/store/@dots{}} and @code{runhaskell Setup.hs build}.
4846 Instead of installing the package by running @code{runhaskell Setup.hs
4847 install}, to avoid trying to register libraries in the read-only
4848 compiler store directory, the build system uses @code{runhaskell
4849 Setup.hs copy}, followed by @code{runhaskell Setup.hs register}. In
4850 addition, the build system generates the package documentation by
4851 running @code{runhaskell Setup.hs haddock}, unless @code{#:haddock? #f}
4852 is passed. Optional Haddock parameters can be passed with the help of
4853 the @code{#:haddock-flags} parameter. If the file @code{Setup.hs} is
4854 not found, the build system looks for @code{Setup.lhs} instead.
4855
4856 Which Haskell compiler is used can be specified with the @code{#:haskell}
4857 parameter which defaults to @code{ghc}.
4858 @end defvr
4859
4860 @defvr {Scheme Variable} dub-build-system
4861 This variable is exported by @code{(guix build-system dub)}. It
4862 implements the Dub build procedure used by D packages, which
4863 involves running @code{dub build} and @code{dub run}.
4864 Installation is done by copying the files manually.
4865
4866 Which D compiler is used can be specified with the @code{#:ldc}
4867 parameter which defaults to @code{ldc}.
4868 @end defvr
4869
4870 @defvr {Scheme Variable} emacs-build-system
4871 This variable is exported by @code{(guix build-system emacs)}. It
4872 implements an installation procedure similar to the packaging system
4873 of Emacs itself (@pxref{Packages,,, emacs, The GNU Emacs Manual}).
4874
4875 It first creates the @code{@var{package}-autoloads.el} file, then it
4876 byte compiles all Emacs Lisp files. Differently from the Emacs
4877 packaging system, the Info documentation files are moved to the standard
4878 documentation directory and the @file{dir} file is deleted. Each
4879 package is installed in its own directory under
4880 @file{share/emacs/site-lisp/guix.d}.
4881 @end defvr
4882
4883 @defvr {Scheme Variable} font-build-system
4884 This variable is exported by @code{(guix build-system font)}. It
4885 implements an installation procedure for font packages where upstream
4886 provides pre-compiled TrueType, OpenType, etc.@: font files that merely
4887 need to be copied into place. It copies font files to standard
4888 locations in the output directory.
4889 @end defvr
4890
4891 @defvr {Scheme Variable} meson-build-system
4892 This variable is exported by @code{(guix build-system meson)}. It
4893 implements the build procedure for packages that use
4894 @url{http://mesonbuild.com, Meson} as their build system.
4895
4896 It adds both Meson and @uref{https://ninja-build.org/, Ninja} to the set
4897 of inputs, and they can be changed with the parameters @code{#:meson}
4898 and @code{#:ninja} if needed. The default Meson is
4899 @code{meson-for-build}, which is special because it doesn't clear the
4900 @code{RUNPATH} of binaries and libraries when they are installed.
4901
4902 This build system is an extension of @var{gnu-build-system}, but with the
4903 following phases changed to some specific for Meson:
4904
4905 @table @code
4906
4907 @item configure
4908 The phase runs @code{meson} with the flags specified in
4909 @code{#:configure-flags}. The flag @code{--build-type} is always set to
4910 @code{plain} unless something else is specified in @code{#:build-type}.
4911
4912 @item build
4913 The phase runs @code{ninja} to build the package in parallel by default, but
4914 this can be changed with @code{#:parallel-build?}.
4915
4916 @item check
4917 The phase runs @code{ninja} with the target specified in @code{#:test-target},
4918 which is @code{"test"} by default.
4919
4920 @item install
4921 The phase runs @code{ninja install} and can not be changed.
4922 @end table
4923
4924 Apart from that, the build system also adds the following phases:
4925
4926 @table @code
4927
4928 @item fix-runpath
4929 This phase ensures that all binaries can find the libraries they need.
4930 It searches for required libraries in subdirectories of the package being
4931 built, and adds those to @code{RUNPATH} where needed. It also removes
4932 references to libraries left over from the build phase by
4933 @code{meson-for-build}, such as test dependencies, that aren't actually
4934 required for the program to run.
4935
4936 @item glib-or-gtk-wrap
4937 This phase is the phase provided by @code{glib-or-gtk-build-system}, and it
4938 is not enabled by default. It can be enabled with @code{#:glib-or-gtk?}.
4939
4940 @item glib-or-gtk-compile-schemas
4941 This phase is the phase provided by @code{glib-or-gtk-build-system}, and it
4942 is not enabled by default. It can be enabled with @code{#:glib-or-gtk?}.
4943 @end table
4944 @end defvr
4945
4946 Lastly, for packages that do not need anything as sophisticated, a
4947 ``trivial'' build system is provided. It is trivial in the sense that
4948 it provides basically no support: it does not pull any implicit inputs,
4949 and does not have a notion of build phases.
4950
4951 @defvr {Scheme Variable} trivial-build-system
4952 This variable is exported by @code{(guix build-system trivial)}.
4953
4954 This build system requires a @code{#:builder} argument. This argument
4955 must be a Scheme expression that builds the package output(s)---as
4956 with @code{build-expression->derivation} (@pxref{Derivations,
4957 @code{build-expression->derivation}}).
4958 @end defvr
4959
4960 @node The Store
4961 @section The Store
4962
4963 @cindex store
4964 @cindex store items
4965 @cindex store paths
4966
4967 Conceptually, the @dfn{store} is the place where derivations that have
4968 been built successfully are stored---by default, @file{/gnu/store}.
4969 Sub-directories in the store are referred to as @dfn{store items} or
4970 sometimes @dfn{store paths}. The store has an associated database that
4971 contains information such as the store paths referred to by each store
4972 path, and the list of @emph{valid} store items---results of successful
4973 builds. This database resides in @file{@var{localstatedir}/guix/db},
4974 where @var{localstatedir} is the state directory specified @i{via}
4975 @option{--localstatedir} at configure time, usually @file{/var}.
4976
4977 The store is @emph{always} accessed by the daemon on behalf of its clients
4978 (@pxref{Invoking guix-daemon}). To manipulate the store, clients
4979 connect to the daemon over a Unix-domain socket, send requests to it,
4980 and read the result---these are remote procedure calls, or RPCs.
4981
4982 @quotation Note
4983 Users must @emph{never} modify files under @file{/gnu/store} directly.
4984 This would lead to inconsistencies and break the immutability
4985 assumptions of Guix's functional model (@pxref{Introduction}).
4986
4987 @xref{Invoking guix gc, @command{guix gc --verify}}, for information on
4988 how to check the integrity of the store and attempt recovery from
4989 accidental modifications.
4990 @end quotation
4991
4992 The @code{(guix store)} module provides procedures to connect to the
4993 daemon, and to perform RPCs. These are described below. By default,
4994 @code{open-connection}, and thus all the @command{guix} commands,
4995 connect to the local daemon or to the URI specified by the
4996 @code{GUIX_DAEMON_SOCKET} environment variable.
4997
4998 @defvr {Environment Variable} GUIX_DAEMON_SOCKET
4999 When set, the value of this variable should be a file name or a URI
5000 designating the daemon endpoint. When it is a file name, it denotes a
5001 Unix-domain socket to connect to. In addition to file names, the
5002 supported URI schemes are:
5003
5004 @table @code
5005 @item file
5006 @itemx unix
5007 These are for Unix-domain sockets.
5008 @code{file:///var/guix/daemon-socket/socket} is equivalent to
5009 @file{/var/guix/daemon-socket/socket}.
5010
5011 @item guix
5012 @cindex daemon, remote access
5013 @cindex remote access to the daemon
5014 @cindex daemon, cluster setup
5015 @cindex clusters, daemon setup
5016 These URIs denote connections over TCP/IP, without encryption nor
5017 authentication of the remote host. The URI must specify the host name
5018 and optionally a port number (by default port 44146 is used):
5019
5020 @example
5021 guix://master.guix.example.org:1234
5022 @end example
5023
5024 This setup is suitable on local networks, such as clusters, where only
5025 trusted nodes may connect to the build daemon at
5026 @code{master.guix.example.org}.
5027
5028 The @code{--listen} option of @command{guix-daemon} can be used to
5029 instruct it to listen for TCP connections (@pxref{Invoking guix-daemon,
5030 @code{--listen}}).
5031
5032 @item ssh
5033 @cindex SSH access to build daemons
5034 These URIs allow you to connect to a remote daemon over
5035 SSH@footnote{This feature requires Guile-SSH (@pxref{Requirements}).}.
5036 A typical URL might look like this:
5037
5038 @example
5039 ssh://charlie@@guix.example.org:22
5040 @end example
5041
5042 As for @command{guix copy}, the usual OpenSSH client configuration files
5043 are honored (@pxref{Invoking guix copy}).
5044 @end table
5045
5046 Additional URI schemes may be supported in the future.
5047
5048 @c XXX: Remove this note when the protocol incurs fewer round trips
5049 @c and when (guix derivations) no longer relies on file system access.
5050 @quotation Note
5051 The ability to connect to remote build daemons is considered
5052 experimental as of @value{VERSION}. Please get in touch with us to
5053 share any problems or suggestions you may have (@pxref{Contributing}).
5054 @end quotation
5055 @end defvr
5056
5057 @deffn {Scheme Procedure} open-connection [@var{uri}] [#:reserve-space? #t]
5058 Connect to the daemon over the Unix-domain socket at @var{uri} (a string). When
5059 @var{reserve-space?} is true, instruct it to reserve a little bit of
5060 extra space on the file system so that the garbage collector can still
5061 operate should the disk become full. Return a server object.
5062
5063 @var{file} defaults to @var{%default-socket-path}, which is the normal
5064 location given the options that were passed to @command{configure}.
5065 @end deffn
5066
5067 @deffn {Scheme Procedure} close-connection @var{server}
5068 Close the connection to @var{server}.
5069 @end deffn
5070
5071 @defvr {Scheme Variable} current-build-output-port
5072 This variable is bound to a SRFI-39 parameter, which refers to the port
5073 where build and error logs sent by the daemon should be written.
5074 @end defvr
5075
5076 Procedures that make RPCs all take a server object as their first
5077 argument.
5078
5079 @deffn {Scheme Procedure} valid-path? @var{server} @var{path}
5080 @cindex invalid store items
5081 Return @code{#t} when @var{path} designates a valid store item and
5082 @code{#f} otherwise (an invalid item may exist on disk but still be
5083 invalid, for instance because it is the result of an aborted or failed
5084 build.)
5085
5086 A @code{&store-protocol-error} condition is raised if @var{path} is not
5087 prefixed by the store directory (@file{/gnu/store}).
5088 @end deffn
5089
5090 @deffn {Scheme Procedure} add-text-to-store @var{server} @var{name} @var{text} [@var{references}]
5091 Add @var{text} under file @var{name} in the store, and return its store
5092 path. @var{references} is the list of store paths referred to by the
5093 resulting store path.
5094 @end deffn
5095
5096 @deffn {Scheme Procedure} build-derivations @var{server} @var{derivations}
5097 Build @var{derivations} (a list of @code{<derivation>} objects or
5098 derivation paths), and return when the worker is done building them.
5099 Return @code{#t} on success.
5100 @end deffn
5101
5102 Note that the @code{(guix monads)} module provides a monad as well as
5103 monadic versions of the above procedures, with the goal of making it
5104 more convenient to work with code that accesses the store (@pxref{The
5105 Store Monad}).
5106
5107 @c FIXME
5108 @i{This section is currently incomplete.}
5109
5110 @node Derivations
5111 @section Derivations
5112
5113 @cindex derivations
5114 Low-level build actions and the environment in which they are performed
5115 are represented by @dfn{derivations}. A derivation contains the
5116 following pieces of information:
5117
5118 @itemize
5119 @item
5120 The outputs of the derivation---derivations produce at least one file or
5121 directory in the store, but may produce more.
5122
5123 @item
5124 The inputs of the derivations, which may be other derivations or plain
5125 files in the store (patches, build scripts, etc.)
5126
5127 @item
5128 The system type targeted by the derivation---e.g., @code{x86_64-linux}.
5129
5130 @item
5131 The file name of a build script in the store, along with the arguments
5132 to be passed.
5133
5134 @item
5135 A list of environment variables to be defined.
5136
5137 @end itemize
5138
5139 @cindex derivation path
5140 Derivations allow clients of the daemon to communicate build actions to
5141 the store. They exist in two forms: as an in-memory representation,
5142 both on the client- and daemon-side, and as files in the store whose
5143 name end in @code{.drv}---these files are referred to as @dfn{derivation
5144 paths}. Derivations paths can be passed to the @code{build-derivations}
5145 procedure to perform the build actions they prescribe (@pxref{The
5146 Store}).
5147
5148 @cindex fixed-output derivations
5149 Operations such as file downloads and version-control checkouts for
5150 which the expected content hash is known in advance are modeled as
5151 @dfn{fixed-output derivations}. Unlike regular derivations, the outputs
5152 of a fixed-output derivation are independent of its inputs---e.g., a
5153 source code download produces the same result regardless of the download
5154 method and tools being used.
5155
5156 The @code{(guix derivations)} module provides a representation of
5157 derivations as Scheme objects, along with procedures to create and
5158 otherwise manipulate derivations. The lowest-level primitive to create
5159 a derivation is the @code{derivation} procedure:
5160
5161 @deffn {Scheme Procedure} derivation @var{store} @var{name} @var{builder} @
5162 @var{args} [#:outputs '("out")] [#:hash #f] [#:hash-algo #f] @
5163 [#:recursive? #f] [#:inputs '()] [#:env-vars '()] @
5164 [#:system (%current-system)] [#:references-graphs #f] @
5165 [#:allowed-references #f] [#:disallowed-references #f] @
5166 [#:leaked-env-vars #f] [#:local-build? #f] @
5167 [#:substitutable? #t] [#:properties '()]
5168 Build a derivation with the given arguments, and return the resulting
5169 @code{<derivation>} object.
5170
5171 When @var{hash} and @var{hash-algo} are given, a
5172 @dfn{fixed-output derivation} is created---i.e., one whose result is
5173 known in advance, such as a file download. If, in addition,
5174 @var{recursive?} is true, then that fixed output may be an executable
5175 file or a directory and @var{hash} must be the hash of an archive
5176 containing this output.
5177
5178 When @var{references-graphs} is true, it must be a list of file
5179 name/store path pairs. In that case, the reference graph of each store
5180 path is exported in the build environment in the corresponding file, in
5181 a simple text format.
5182
5183 When @var{allowed-references} is true, it must be a list of store items
5184 or outputs that the derivation's output may refer to. Likewise,
5185 @var{disallowed-references}, if true, must be a list of things the
5186 outputs may @emph{not} refer to.
5187
5188 When @var{leaked-env-vars} is true, it must be a list of strings
5189 denoting environment variables that are allowed to ``leak'' from the
5190 daemon's environment to the build environment. This is only applicable
5191 to fixed-output derivations---i.e., when @var{hash} is true. The main
5192 use is to allow variables such as @code{http_proxy} to be passed to
5193 derivations that download files.
5194
5195 When @var{local-build?} is true, declare that the derivation is not a
5196 good candidate for offloading and should rather be built locally
5197 (@pxref{Daemon Offload Setup}). This is the case for small derivations
5198 where the costs of data transfers would outweigh the benefits.
5199
5200 When @var{substitutable?} is false, declare that substitutes of the
5201 derivation's output should not be used (@pxref{Substitutes}). This is
5202 useful, for instance, when building packages that capture details of the
5203 host CPU instruction set.
5204
5205 @var{properties} must be an association list describing ``properties'' of the
5206 derivation. It is kept as-is, uninterpreted, in the derivation.
5207 @end deffn
5208
5209 @noindent
5210 Here's an example with a shell script as its builder, assuming
5211 @var{store} is an open connection to the daemon, and @var{bash} points
5212 to a Bash executable in the store:
5213
5214 @lisp
5215 (use-modules (guix utils)
5216 (guix store)
5217 (guix derivations))
5218
5219 (let ((builder ; add the Bash script to the store
5220 (add-text-to-store store "my-builder.sh"
5221 "echo hello world > $out\n" '())))
5222 (derivation store "foo"
5223 bash `("-e" ,builder)
5224 #:inputs `((,bash) (,builder))
5225 #:env-vars '(("HOME" . "/homeless"))))
5226 @result{} #<derivation /gnu/store/@dots{}-foo.drv => /gnu/store/@dots{}-foo>
5227 @end lisp
5228
5229 As can be guessed, this primitive is cumbersome to use directly. A
5230 better approach is to write build scripts in Scheme, of course! The
5231 best course of action for that is to write the build code as a
5232 ``G-expression'', and to pass it to @code{gexp->derivation}. For more
5233 information, @pxref{G-Expressions}.
5234
5235 Once upon a time, @code{gexp->derivation} did not exist and constructing
5236 derivations with build code written in Scheme was achieved with
5237 @code{build-expression->derivation}, documented below. This procedure
5238 is now deprecated in favor of the much nicer @code{gexp->derivation}.
5239
5240 @deffn {Scheme Procedure} build-expression->derivation @var{store} @
5241 @var{name} @var{exp} @
5242 [#:system (%current-system)] [#:inputs '()] @
5243 [#:outputs '("out")] [#:hash #f] [#:hash-algo #f] @
5244 [#:recursive? #f] [#:env-vars '()] [#:modules '()] @
5245 [#:references-graphs #f] [#:allowed-references #f] @
5246 [#:disallowed-references #f] @
5247 [#:local-build? #f] [#:substitutable? #t] [#:guile-for-build #f]
5248 Return a derivation that executes Scheme expression @var{exp} as a
5249 builder for derivation @var{name}. @var{inputs} must be a list of
5250 @code{(name drv-path sub-drv)} tuples; when @var{sub-drv} is omitted,
5251 @code{"out"} is assumed. @var{modules} is a list of names of Guile
5252 modules from the current search path to be copied in the store,
5253 compiled, and made available in the load path during the execution of
5254 @var{exp}---e.g., @code{((guix build utils) (guix build
5255 gnu-build-system))}.
5256
5257 @var{exp} is evaluated in an environment where @code{%outputs} is bound
5258 to a list of output/path pairs, and where @code{%build-inputs} is bound
5259 to a list of string/output-path pairs made from @var{inputs}.
5260 Optionally, @var{env-vars} is a list of string pairs specifying the name
5261 and value of environment variables visible to the builder. The builder
5262 terminates by passing the result of @var{exp} to @code{exit}; thus, when
5263 @var{exp} returns @code{#f}, the build is considered to have failed.
5264
5265 @var{exp} is built using @var{guile-for-build} (a derivation). When
5266 @var{guile-for-build} is omitted or is @code{#f}, the value of the
5267 @code{%guile-for-build} fluid is used instead.
5268
5269 See the @code{derivation} procedure for the meaning of
5270 @var{references-graphs}, @var{allowed-references},
5271 @var{disallowed-references}, @var{local-build?}, and
5272 @var{substitutable?}.
5273 @end deffn
5274
5275 @noindent
5276 Here's an example of a single-output derivation that creates a directory
5277 containing one file:
5278
5279 @lisp
5280 (let ((builder '(let ((out (assoc-ref %outputs "out")))
5281 (mkdir out) ; create /gnu/store/@dots{}-goo
5282 (call-with-output-file (string-append out "/test")
5283 (lambda (p)
5284 (display '(hello guix) p))))))
5285 (build-expression->derivation store "goo" builder))
5286
5287 @result{} #<derivation /gnu/store/@dots{}-goo.drv => @dots{}>
5288 @end lisp
5289
5290
5291 @node The Store Monad
5292 @section The Store Monad
5293
5294 @cindex monad
5295
5296 The procedures that operate on the store described in the previous
5297 sections all take an open connection to the build daemon as their first
5298 argument. Although the underlying model is functional, they either have
5299 side effects or depend on the current state of the store.
5300
5301 The former is inconvenient: the connection to the build daemon has to be
5302 carried around in all those functions, making it impossible to compose
5303 functions that do not take that parameter with functions that do. The
5304 latter can be problematic: since store operations have side effects
5305 and/or depend on external state, they have to be properly sequenced.
5306
5307 @cindex monadic values
5308 @cindex monadic functions
5309 This is where the @code{(guix monads)} module comes in. This module
5310 provides a framework for working with @dfn{monads}, and a particularly
5311 useful monad for our uses, the @dfn{store monad}. Monads are a
5312 construct that allows two things: associating ``context'' with values
5313 (in our case, the context is the store), and building sequences of
5314 computations (here computations include accesses to the store). Values
5315 in a monad---values that carry this additional context---are called
5316 @dfn{monadic values}; procedures that return such values are called
5317 @dfn{monadic procedures}.
5318
5319 Consider this ``normal'' procedure:
5320
5321 @example
5322 (define (sh-symlink store)
5323 ;; Return a derivation that symlinks the 'bash' executable.
5324 (let* ((drv (package-derivation store bash))
5325 (out (derivation->output-path drv))
5326 (sh (string-append out "/bin/bash")))
5327 (build-expression->derivation store "sh"
5328 `(symlink ,sh %output))))
5329 @end example
5330
5331 Using @code{(guix monads)} and @code{(guix gexp)}, it may be rewritten
5332 as a monadic function:
5333
5334 @example
5335 (define (sh-symlink)
5336 ;; Same, but return a monadic value.
5337 (mlet %store-monad ((drv (package->derivation bash)))
5338 (gexp->derivation "sh"
5339 #~(symlink (string-append #$drv "/bin/bash")
5340 #$output))))
5341 @end example
5342
5343 There are several things to note in the second version: the @code{store}
5344 parameter is now implicit and is ``threaded'' in the calls to the
5345 @code{package->derivation} and @code{gexp->derivation} monadic
5346 procedures, and the monadic value returned by @code{package->derivation}
5347 is @dfn{bound} using @code{mlet} instead of plain @code{let}.
5348
5349 As it turns out, the call to @code{package->derivation} can even be
5350 omitted since it will take place implicitly, as we will see later
5351 (@pxref{G-Expressions}):
5352
5353 @example
5354 (define (sh-symlink)
5355 (gexp->derivation "sh"
5356 #~(symlink (string-append #$bash "/bin/bash")
5357 #$output)))
5358 @end example
5359
5360 @c See
5361 @c <https://syntaxexclamation.wordpress.com/2014/06/26/escaping-continuations/>
5362 @c for the funny quote.
5363 Calling the monadic @code{sh-symlink} has no effect. As someone once
5364 said, ``you exit a monad like you exit a building on fire: by running''.
5365 So, to exit the monad and get the desired effect, one must use
5366 @code{run-with-store}:
5367
5368 @example
5369 (run-with-store (open-connection) (sh-symlink))
5370 @result{} /gnu/store/...-sh-symlink
5371 @end example
5372
5373 Note that the @code{(guix monad-repl)} module extends the Guile REPL with
5374 new ``meta-commands'' to make it easier to deal with monadic procedures:
5375 @code{run-in-store}, and @code{enter-store-monad}. The former is used
5376 to ``run'' a single monadic value through the store:
5377
5378 @example
5379 scheme@@(guile-user)> ,run-in-store (package->derivation hello)
5380 $1 = #<derivation /gnu/store/@dots{}-hello-2.9.drv => @dots{}>
5381 @end example
5382
5383 The latter enters a recursive REPL, where all the return values are
5384 automatically run through the store:
5385
5386 @example
5387 scheme@@(guile-user)> ,enter-store-monad
5388 store-monad@@(guile-user) [1]> (package->derivation hello)
5389 $2 = #<derivation /gnu/store/@dots{}-hello-2.9.drv => @dots{}>
5390 store-monad@@(guile-user) [1]> (text-file "foo" "Hello!")
5391 $3 = "/gnu/store/@dots{}-foo"
5392 store-monad@@(guile-user) [1]> ,q
5393 scheme@@(guile-user)>
5394 @end example
5395
5396 @noindent
5397 Note that non-monadic values cannot be returned in the
5398 @code{store-monad} REPL.
5399
5400 The main syntactic forms to deal with monads in general are provided by
5401 the @code{(guix monads)} module and are described below.
5402
5403 @deffn {Scheme Syntax} with-monad @var{monad} @var{body} ...
5404 Evaluate any @code{>>=} or @code{return} forms in @var{body} as being
5405 in @var{monad}.
5406 @end deffn
5407
5408 @deffn {Scheme Syntax} return @var{val}
5409 Return a monadic value that encapsulates @var{val}.
5410 @end deffn
5411
5412 @deffn {Scheme Syntax} >>= @var{mval} @var{mproc} ...
5413 @dfn{Bind} monadic value @var{mval}, passing its ``contents'' to monadic
5414 procedures @var{mproc}@dots{}@footnote{This operation is commonly
5415 referred to as ``bind'', but that name denotes an unrelated procedure in
5416 Guile. Thus we use this somewhat cryptic symbol inherited from the
5417 Haskell language.}. There can be one @var{mproc} or several of them, as
5418 in this example:
5419
5420 @example
5421 (run-with-state
5422 (with-monad %state-monad
5423 (>>= (return 1)
5424 (lambda (x) (return (+ 1 x)))
5425 (lambda (x) (return (* 2 x)))))
5426 'some-state)
5427
5428 @result{} 4
5429 @result{} some-state
5430 @end example
5431 @end deffn
5432
5433 @deffn {Scheme Syntax} mlet @var{monad} ((@var{var} @var{mval}) ...) @
5434 @var{body} ...
5435 @deffnx {Scheme Syntax} mlet* @var{monad} ((@var{var} @var{mval}) ...) @
5436 @var{body} ...
5437 Bind the variables @var{var} to the monadic values @var{mval} in
5438 @var{body}, which is a sequence of expressions. As with the bind
5439 operator, this can be thought of as ``unpacking'' the raw, non-monadic
5440 value ``contained'' in @var{mval} and making @var{var} refer to that
5441 raw, non-monadic value within the scope of the @var{body}. The form
5442 (@var{var} -> @var{val}) binds @var{var} to the ``normal'' value
5443 @var{val}, as per @code{let}. The binding operations occur in sequence
5444 from left to right. The last expression of @var{body} must be a monadic
5445 expression, and its result will become the result of the @code{mlet} or
5446 @code{mlet*} when run in the @var{monad}.
5447
5448 @code{mlet*} is to @code{mlet} what @code{let*} is to @code{let}
5449 (@pxref{Local Bindings,,, guile, GNU Guile Reference Manual}).
5450 @end deffn
5451
5452 @deffn {Scheme System} mbegin @var{monad} @var{mexp} ...
5453 Bind @var{mexp} and the following monadic expressions in sequence,
5454 returning the result of the last expression. Every expression in the
5455 sequence must be a monadic expression.
5456
5457 This is akin to @code{mlet}, except that the return values of the
5458 monadic expressions are ignored. In that sense, it is analogous to
5459 @code{begin}, but applied to monadic expressions.
5460 @end deffn
5461
5462 @deffn {Scheme System} mwhen @var{condition} @var{mexp0} @var{mexp*} ...
5463 When @var{condition} is true, evaluate the sequence of monadic
5464 expressions @var{mexp0}..@var{mexp*} as in an @code{mbegin}. When
5465 @var{condition} is false, return @code{*unspecified*} in the current
5466 monad. Every expression in the sequence must be a monadic expression.
5467 @end deffn
5468
5469 @deffn {Scheme System} munless @var{condition} @var{mexp0} @var{mexp*} ...
5470 When @var{condition} is false, evaluate the sequence of monadic
5471 expressions @var{mexp0}..@var{mexp*} as in an @code{mbegin}. When
5472 @var{condition} is true, return @code{*unspecified*} in the current
5473 monad. Every expression in the sequence must be a monadic expression.
5474 @end deffn
5475
5476 @cindex state monad
5477 The @code{(guix monads)} module provides the @dfn{state monad}, which
5478 allows an additional value---the state---to be @emph{threaded} through
5479 monadic procedure calls.
5480
5481 @defvr {Scheme Variable} %state-monad
5482 The state monad. Procedures in the state monad can access and change
5483 the state that is threaded.
5484
5485 Consider the example below. The @code{square} procedure returns a value
5486 in the state monad. It returns the square of its argument, but also
5487 increments the current state value:
5488
5489 @example
5490 (define (square x)
5491 (mlet %state-monad ((count (current-state)))
5492 (mbegin %state-monad
5493 (set-current-state (+ 1 count))
5494 (return (* x x)))))
5495
5496 (run-with-state (sequence %state-monad (map square (iota 3))) 0)
5497 @result{} (0 1 4)
5498 @result{} 3
5499 @end example
5500
5501 When ``run'' through @var{%state-monad}, we obtain that additional state
5502 value, which is the number of @code{square} calls.
5503 @end defvr
5504
5505 @deffn {Monadic Procedure} current-state
5506 Return the current state as a monadic value.
5507 @end deffn
5508
5509 @deffn {Monadic Procedure} set-current-state @var{value}
5510 Set the current state to @var{value} and return the previous state as a
5511 monadic value.
5512 @end deffn
5513
5514 @deffn {Monadic Procedure} state-push @var{value}
5515 Push @var{value} to the current state, which is assumed to be a list,
5516 and return the previous state as a monadic value.
5517 @end deffn
5518
5519 @deffn {Monadic Procedure} state-pop
5520 Pop a value from the current state and return it as a monadic value.
5521 The state is assumed to be a list.
5522 @end deffn
5523
5524 @deffn {Scheme Procedure} run-with-state @var{mval} [@var{state}]
5525 Run monadic value @var{mval} starting with @var{state} as the initial
5526 state. Return two values: the resulting value, and the resulting state.
5527 @end deffn
5528
5529 The main interface to the store monad, provided by the @code{(guix
5530 store)} module, is as follows.
5531
5532 @defvr {Scheme Variable} %store-monad
5533 The store monad---an alias for @var{%state-monad}.
5534
5535 Values in the store monad encapsulate accesses to the store. When its
5536 effect is needed, a value of the store monad must be ``evaluated'' by
5537 passing it to the @code{run-with-store} procedure (see below.)
5538 @end defvr
5539
5540 @deffn {Scheme Procedure} run-with-store @var{store} @var{mval} [#:guile-for-build] [#:system (%current-system)]
5541 Run @var{mval}, a monadic value in the store monad, in @var{store}, an
5542 open store connection.
5543 @end deffn
5544
5545 @deffn {Monadic Procedure} text-file @var{name} @var{text} [@var{references}]
5546 Return as a monadic value the absolute file name in the store of the file
5547 containing @var{text}, a string. @var{references} is a list of store items that the
5548 resulting text file refers to; it defaults to the empty list.
5549 @end deffn
5550
5551 @deffn {Monadic Procedure} binary-file @var{name} @var{data} [@var{references}]
5552 Return as a monadic value the absolute file name in the store of the file
5553 containing @var{data}, a bytevector. @var{references} is a list of store
5554 items that the resulting binary file refers to; it defaults to the empty list.
5555 @end deffn
5556
5557 @deffn {Monadic Procedure} interned-file @var{file} [@var{name}] @
5558 [#:recursive? #t] [#:select? (const #t)]
5559 Return the name of @var{file} once interned in the store. Use
5560 @var{name} as its store name, or the basename of @var{file} if
5561 @var{name} is omitted.
5562
5563 When @var{recursive?} is true, the contents of @var{file} are added
5564 recursively; if @var{file} designates a flat file and @var{recursive?}
5565 is true, its contents are added, and its permission bits are kept.
5566
5567 When @var{recursive?} is true, call @code{(@var{select?} @var{file}
5568 @var{stat})} for each directory entry, where @var{file} is the entry's
5569 absolute file name and @var{stat} is the result of @code{lstat}; exclude
5570 entries for which @var{select?} does not return true.
5571
5572 The example below adds a file to the store, under two different names:
5573
5574 @example
5575 (run-with-store (open-connection)
5576 (mlet %store-monad ((a (interned-file "README"))
5577 (b (interned-file "README" "LEGU-MIN")))
5578 (return (list a b))))
5579
5580 @result{} ("/gnu/store/rwm@dots{}-README" "/gnu/store/44i@dots{}-LEGU-MIN")
5581 @end example
5582
5583 @end deffn
5584
5585 The @code{(guix packages)} module exports the following package-related
5586 monadic procedures:
5587
5588 @deffn {Monadic Procedure} package-file @var{package} [@var{file}] @
5589 [#:system (%current-system)] [#:target #f] @
5590 [#:output "out"]
5591 Return as a monadic
5592 value in the absolute file name of @var{file} within the @var{output}
5593 directory of @var{package}. When @var{file} is omitted, return the name
5594 of the @var{output} directory of @var{package}. When @var{target} is
5595 true, use it as a cross-compilation target triplet.
5596 @end deffn
5597
5598 @deffn {Monadic Procedure} package->derivation @var{package} [@var{system}]
5599 @deffnx {Monadic Procedure} package->cross-derivation @var{package} @
5600 @var{target} [@var{system}]
5601 Monadic version of @code{package-derivation} and
5602 @code{package-cross-derivation} (@pxref{Defining Packages}).
5603 @end deffn
5604
5605
5606 @node G-Expressions
5607 @section G-Expressions
5608
5609 @cindex G-expression
5610 @cindex build code quoting
5611 So we have ``derivations'', which represent a sequence of build actions
5612 to be performed to produce an item in the store (@pxref{Derivations}).
5613 These build actions are performed when asking the daemon to actually
5614 build the derivations; they are run by the daemon in a container
5615 (@pxref{Invoking guix-daemon}).
5616
5617 @cindex strata of code
5618 It should come as no surprise that we like to write these build actions
5619 in Scheme. When we do that, we end up with two @dfn{strata} of Scheme
5620 code@footnote{The term @dfn{stratum} in this context was coined by
5621 Manuel Serrano et al.@: in the context of their work on Hop. Oleg
5622 Kiselyov, who has written insightful
5623 @url{http://okmij.org/ftp/meta-programming/#meta-scheme, essays and code
5624 on this topic}, refers to this kind of code generation as
5625 @dfn{staging}.}: the ``host code''---code that defines packages, talks
5626 to the daemon, etc.---and the ``build code''---code that actually
5627 performs build actions, such as making directories, invoking
5628 @command{make}, etc.
5629
5630 To describe a derivation and its build actions, one typically needs to
5631 embed build code inside host code. It boils down to manipulating build
5632 code as data, and the homoiconicity of Scheme---code has a direct
5633 representation as data---comes in handy for that. But we need more than
5634 the normal @code{quasiquote} mechanism in Scheme to construct build
5635 expressions.
5636
5637 The @code{(guix gexp)} module implements @dfn{G-expressions}, a form of
5638 S-expressions adapted to build expressions. G-expressions, or
5639 @dfn{gexps}, consist essentially of three syntactic forms: @code{gexp},
5640 @code{ungexp}, and @code{ungexp-splicing} (or simply: @code{#~},
5641 @code{#$}, and @code{#$@@}), which are comparable to
5642 @code{quasiquote}, @code{unquote}, and @code{unquote-splicing},
5643 respectively (@pxref{Expression Syntax, @code{quasiquote},, guile,
5644 GNU Guile Reference Manual}). However, there are major differences:
5645
5646 @itemize
5647 @item
5648 Gexps are meant to be written to a file and run or manipulated by other
5649 processes.
5650
5651 @item
5652 When a high-level object such as a package or derivation is unquoted
5653 inside a gexp, the result is as if its output file name had been
5654 introduced.
5655
5656 @item
5657 Gexps carry information about the packages or derivations they refer to,
5658 and these dependencies are automatically added as inputs to the build
5659 processes that use them.
5660 @end itemize
5661
5662 @cindex lowering, of high-level objects in gexps
5663 This mechanism is not limited to package and derivation
5664 objects: @dfn{compilers} able to ``lower'' other high-level objects to
5665 derivations or files in the store can be defined,
5666 such that these objects can also be inserted
5667 into gexps. For example, a useful type of high-level objects that can be
5668 inserted in a gexp is ``file-like objects'', which make it easy to
5669 add files to the store and to refer to them in
5670 derivations and such (see @code{local-file} and @code{plain-file}
5671 below.)
5672
5673 To illustrate the idea, here is an example of a gexp:
5674
5675 @example
5676 (define build-exp
5677 #~(begin
5678 (mkdir #$output)
5679 (chdir #$output)
5680 (symlink (string-append #$coreutils "/bin/ls")
5681 "list-files")))
5682 @end example
5683
5684 This gexp can be passed to @code{gexp->derivation}; we obtain a
5685 derivation that builds a directory containing exactly one symlink to
5686 @file{/gnu/store/@dots{}-coreutils-8.22/bin/ls}:
5687
5688 @example
5689 (gexp->derivation "the-thing" build-exp)
5690 @end example
5691
5692 As one would expect, the @code{"/gnu/store/@dots{}-coreutils-8.22"} string is
5693 substituted to the reference to the @var{coreutils} package in the
5694 actual build code, and @var{coreutils} is automatically made an input to
5695 the derivation. Likewise, @code{#$output} (equivalent to @code{(ungexp
5696 output)}) is replaced by a string containing the directory name of the
5697 output of the derivation.
5698
5699 @cindex cross compilation
5700 In a cross-compilation context, it is useful to distinguish between
5701 references to the @emph{native} build of a package---that can run on the
5702 host---versus references to cross builds of a package. To that end, the
5703 @code{#+} plays the same role as @code{#$}, but is a reference to a
5704 native package build:
5705
5706 @example
5707 (gexp->derivation "vi"
5708 #~(begin
5709 (mkdir #$output)
5710 (system* (string-append #+coreutils "/bin/ln")
5711 "-s"
5712 (string-append #$emacs "/bin/emacs")
5713 (string-append #$output "/bin/vi")))
5714 #:target "mips64el-linux-gnu")
5715 @end example
5716
5717 @noindent
5718 In the example above, the native build of @var{coreutils} is used, so
5719 that @command{ln} can actually run on the host; but then the
5720 cross-compiled build of @var{emacs} is referenced.
5721
5722 @cindex imported modules, for gexps
5723 @findex with-imported-modules
5724 Another gexp feature is @dfn{imported modules}: sometimes you want to be
5725 able to use certain Guile modules from the ``host environment'' in the
5726 gexp, so those modules should be imported in the ``build environment''.
5727 The @code{with-imported-modules} form allows you to express that:
5728
5729 @example
5730 (let ((build (with-imported-modules '((guix build utils))
5731 #~(begin
5732 (use-modules (guix build utils))
5733 (mkdir-p (string-append #$output "/bin"))))))
5734 (gexp->derivation "empty-dir"
5735 #~(begin
5736 #$build
5737 (display "success!\n")
5738 #t)))
5739 @end example
5740
5741 @noindent
5742 In this example, the @code{(guix build utils)} module is automatically
5743 pulled into the isolated build environment of our gexp, such that
5744 @code{(use-modules (guix build utils))} works as expected.
5745
5746 @cindex module closure
5747 @findex source-module-closure
5748 Usually you want the @emph{closure} of the module to be imported---i.e.,
5749 the module itself and all the modules it depends on---rather than just
5750 the module; failing to do that, attempts to use the module will fail
5751 because of missing dependent modules. The @code{source-module-closure}
5752 procedure computes the closure of a module by looking at its source file
5753 headers, which comes in handy in this case:
5754
5755 @example
5756 (use-modules (guix modules)) ;for 'source-module-closure'
5757
5758 (with-imported-modules (source-module-closure
5759 '((guix build utils)
5760 (gnu build vm)))
5761 (gexp->derivation "something-with-vms"
5762 #~(begin
5763 (use-modules (guix build utils)
5764 (gnu build vm))
5765 @dots{})))
5766 @end example
5767
5768 @cindex extensions, for gexps
5769 @findex with-extensions
5770 In the same vein, sometimes you want to import not just pure-Scheme
5771 modules, but also ``extensions'' such as Guile bindings to C libraries
5772 or other ``full-blown'' packages. Say you need the @code{guile-json}
5773 package available on the build side, here's how you would do it:
5774
5775 @example
5776 (use-modules (gnu packages guile)) ;for 'guile-json'
5777
5778 (with-extensions (list guile-json)
5779 (gexp->derivation "something-with-json"
5780 #~(begin
5781 (use-modules (json))
5782 @dots{})))
5783 @end example
5784
5785 The syntactic form to construct gexps is summarized below.
5786
5787 @deffn {Scheme Syntax} #~@var{exp}
5788 @deffnx {Scheme Syntax} (gexp @var{exp})
5789 Return a G-expression containing @var{exp}. @var{exp} may contain one
5790 or more of the following forms:
5791
5792 @table @code
5793 @item #$@var{obj}
5794 @itemx (ungexp @var{obj})
5795 Introduce a reference to @var{obj}. @var{obj} may have one of the
5796 supported types, for example a package or a
5797 derivation, in which case the @code{ungexp} form is replaced by its
5798 output file name---e.g., @code{"/gnu/store/@dots{}-coreutils-8.22}.
5799
5800 If @var{obj} is a list, it is traversed and references to supported
5801 objects are substituted similarly.
5802
5803 If @var{obj} is another gexp, its contents are inserted and its
5804 dependencies are added to those of the containing gexp.
5805
5806 If @var{obj} is another kind of object, it is inserted as is.
5807
5808 @item #$@var{obj}:@var{output}
5809 @itemx (ungexp @var{obj} @var{output})
5810 This is like the form above, but referring explicitly to the
5811 @var{output} of @var{obj}---this is useful when @var{obj} produces
5812 multiple outputs (@pxref{Packages with Multiple Outputs}).
5813
5814 @item #+@var{obj}
5815 @itemx #+@var{obj}:output
5816 @itemx (ungexp-native @var{obj})
5817 @itemx (ungexp-native @var{obj} @var{output})
5818 Same as @code{ungexp}, but produces a reference to the @emph{native}
5819 build of @var{obj} when used in a cross compilation context.
5820
5821 @item #$output[:@var{output}]
5822 @itemx (ungexp output [@var{output}])
5823 Insert a reference to derivation output @var{output}, or to the main
5824 output when @var{output} is omitted.
5825
5826 This only makes sense for gexps passed to @code{gexp->derivation}.
5827
5828 @item #$@@@var{lst}
5829 @itemx (ungexp-splicing @var{lst})
5830 Like the above, but splices the contents of @var{lst} inside the
5831 containing list.
5832
5833 @item #+@@@var{lst}
5834 @itemx (ungexp-native-splicing @var{lst})
5835 Like the above, but refers to native builds of the objects listed in
5836 @var{lst}.
5837
5838 @end table
5839
5840 G-expressions created by @code{gexp} or @code{#~} are run-time objects
5841 of the @code{gexp?} type (see below.)
5842 @end deffn
5843
5844 @deffn {Scheme Syntax} with-imported-modules @var{modules} @var{body}@dots{}
5845 Mark the gexps defined in @var{body}@dots{} as requiring @var{modules}
5846 in their execution environment.
5847
5848 Each item in @var{modules} can be the name of a module, such as
5849 @code{(guix build utils)}, or it can be a module name, followed by an
5850 arrow, followed by a file-like object:
5851
5852 @example
5853 `((guix build utils)
5854 (guix gcrypt)
5855 ((guix config) => ,(scheme-file "config.scm"
5856 #~(define-module @dots{}))))
5857 @end example
5858
5859 @noindent
5860 In the example above, the first two modules are taken from the search
5861 path, and the last one is created from the given file-like object.
5862
5863 This form has @emph{lexical} scope: it has an effect on the gexps
5864 directly defined in @var{body}@dots{}, but not on those defined, say, in
5865 procedures called from @var{body}@dots{}.
5866 @end deffn
5867
5868 @deffn {Scheme Syntax} with-extensions @var{extensions} @var{body}@dots{}
5869 Mark the gexps defined in @var{body}@dots{} as requiring
5870 @var{extensions} in their build and execution environment.
5871 @var{extensions} is typically a list of package objects such as those
5872 defined in the @code{(gnu packages guile)} module.
5873
5874 Concretely, the packages listed in @var{extensions} are added to the
5875 load path while compiling imported modules in @var{body}@dots{}; they
5876 are also added to the load path of the gexp returned by
5877 @var{body}@dots{}.
5878 @end deffn
5879
5880 @deffn {Scheme Procedure} gexp? @var{obj}
5881 Return @code{#t} if @var{obj} is a G-expression.
5882 @end deffn
5883
5884 G-expressions are meant to be written to disk, either as code building
5885 some derivation, or as plain files in the store. The monadic procedures
5886 below allow you to do that (@pxref{The Store Monad}, for more
5887 information about monads.)
5888
5889 @deffn {Monadic Procedure} gexp->derivation @var{name} @var{exp} @
5890 [#:system (%current-system)] [#:target #f] [#:graft? #t] @
5891 [#:hash #f] [#:hash-algo #f] @
5892 [#:recursive? #f] [#:env-vars '()] [#:modules '()] @
5893 [#:module-path @var{%load-path}] @
5894 [#:effective-version "2.2"] @
5895 [#:references-graphs #f] [#:allowed-references #f] @
5896 [#:disallowed-references #f] @
5897 [#:leaked-env-vars #f] @
5898 [#:script-name (string-append @var{name} "-builder")] @
5899 [#:deprecation-warnings #f] @
5900 [#:local-build? #f] [#:substitutable? #t] @
5901 [#:properties '()] [#:guile-for-build #f]
5902 Return a derivation @var{name} that runs @var{exp} (a gexp) with
5903 @var{guile-for-build} (a derivation) on @var{system}; @var{exp} is
5904 stored in a file called @var{script-name}. When @var{target} is true,
5905 it is used as the cross-compilation target triplet for packages referred
5906 to by @var{exp}.
5907
5908 @var{modules} is deprecated in favor of @code{with-imported-modules}.
5909 Its meaning is to
5910 make @var{modules} available in the evaluation context of @var{exp};
5911 @var{modules} is a list of names of Guile modules searched in
5912 @var{module-path} to be copied in the store, compiled, and made available in
5913 the load path during the execution of @var{exp}---e.g., @code{((guix
5914 build utils) (guix build gnu-build-system))}.
5915
5916 @var{effective-version} determines the string to use when adding extensions of
5917 @var{exp} (see @code{with-extensions}) to the search path---e.g., @code{"2.2"}.
5918
5919 @var{graft?} determines whether packages referred to by @var{exp} should be grafted when
5920 applicable.
5921
5922 When @var{references-graphs} is true, it must be a list of tuples of one of the
5923 following forms:
5924
5925 @example
5926 (@var{file-name} @var{package})
5927 (@var{file-name} @var{package} @var{output})
5928 (@var{file-name} @var{derivation})
5929 (@var{file-name} @var{derivation} @var{output})
5930 (@var{file-name} @var{store-item})
5931 @end example
5932
5933 The right-hand-side of each element of @var{references-graphs} is automatically made
5934 an input of the build process of @var{exp}. In the build environment, each
5935 @var{file-name} contains the reference graph of the corresponding item, in a simple
5936 text format.
5937
5938 @var{allowed-references} must be either @code{#f} or a list of output names and packages.
5939 In the latter case, the list denotes store items that the result is allowed to
5940 refer to. Any reference to another store item will lead to a build error.
5941 Similarly for @var{disallowed-references}, which can list items that must not be
5942 referenced by the outputs.
5943
5944 @var{deprecation-warnings} determines whether to show deprecation warnings while
5945 compiling modules. It can be @code{#f}, @code{#t}, or @code{'detailed}.
5946
5947 The other arguments are as for @code{derivation} (@pxref{Derivations}).
5948 @end deffn
5949
5950 @cindex file-like objects
5951 The @code{local-file}, @code{plain-file}, @code{computed-file},
5952 @code{program-file}, and @code{scheme-file} procedures below return
5953 @dfn{file-like objects}. That is, when unquoted in a G-expression,
5954 these objects lead to a file in the store. Consider this G-expression:
5955
5956 @example
5957 #~(system* #$(file-append glibc "/sbin/nscd") "-f"
5958 #$(local-file "/tmp/my-nscd.conf"))
5959 @end example
5960
5961 The effect here is to ``intern'' @file{/tmp/my-nscd.conf} by copying it
5962 to the store. Once expanded, for instance @i{via}
5963 @code{gexp->derivation}, the G-expression refers to that copy under
5964 @file{/gnu/store}; thus, modifying or removing the file in @file{/tmp}
5965 does not have any effect on what the G-expression does.
5966 @code{plain-file} can be used similarly; it differs in that the file
5967 content is directly passed as a string.
5968
5969 @deffn {Scheme Procedure} local-file @var{file} [@var{name}] @
5970 [#:recursive? #f] [#:select? (const #t)]
5971 Return an object representing local file @var{file} to add to the store; this
5972 object can be used in a gexp. If @var{file} is a relative file name, it is looked
5973 up relative to the source file where this form appears. @var{file} will be added to
5974 the store under @var{name}--by default the base name of @var{file}.
5975
5976 When @var{recursive?} is true, the contents of @var{file} are added recursively; if @var{file}
5977 designates a flat file and @var{recursive?} is true, its contents are added, and its
5978 permission bits are kept.
5979
5980 When @var{recursive?} is true, call @code{(@var{select?} @var{file}
5981 @var{stat})} for each directory entry, where @var{file} is the entry's
5982 absolute file name and @var{stat} is the result of @code{lstat}; exclude
5983 entries for which @var{select?} does not return true.
5984
5985 This is the declarative counterpart of the @code{interned-file} monadic
5986 procedure (@pxref{The Store Monad, @code{interned-file}}).
5987 @end deffn
5988
5989 @deffn {Scheme Procedure} plain-file @var{name} @var{content}
5990 Return an object representing a text file called @var{name} with the given
5991 @var{content} (a string or a bytevector) to be added to the store.
5992
5993 This is the declarative counterpart of @code{text-file}.
5994 @end deffn
5995
5996 @deffn {Scheme Procedure} computed-file @var{name} @var{gexp} @
5997 [#:options '(#:local-build? #t)]
5998 Return an object representing the store item @var{name}, a file or
5999 directory computed by @var{gexp}. @var{options}
6000 is a list of additional arguments to pass to @code{gexp->derivation}.
6001
6002 This is the declarative counterpart of @code{gexp->derivation}.
6003 @end deffn
6004
6005 @deffn {Monadic Procedure} gexp->script @var{name} @var{exp} @
6006 [#:guile (default-guile)] [#:module-path %load-path]
6007 Return an executable script @var{name} that runs @var{exp} using
6008 @var{guile}, with @var{exp}'s imported modules in its search path.
6009 Look up @var{exp}'s modules in @var{module-path}.
6010
6011 The example below builds a script that simply invokes the @command{ls}
6012 command:
6013
6014 @example
6015 (use-modules (guix gexp) (gnu packages base))
6016
6017 (gexp->script "list-files"
6018 #~(execl #$(file-append coreutils "/bin/ls")
6019 "ls"))
6020 @end example
6021
6022 When ``running'' it through the store (@pxref{The Store Monad,
6023 @code{run-with-store}}), we obtain a derivation that produces an
6024 executable file @file{/gnu/store/@dots{}-list-files} along these lines:
6025
6026 @example
6027 #!/gnu/store/@dots{}-guile-2.0.11/bin/guile -ds
6028 !#
6029 (execl "/gnu/store/@dots{}-coreutils-8.22"/bin/ls" "ls")
6030 @end example
6031 @end deffn
6032
6033 @deffn {Scheme Procedure} program-file @var{name} @var{exp} @
6034 [#:guile #f] [#:module-path %load-path]
6035 Return an object representing the executable store item @var{name} that
6036 runs @var{gexp}. @var{guile} is the Guile package used to execute that
6037 script. Imported modules of @var{gexp} are looked up in @var{module-path}.
6038
6039 This is the declarative counterpart of @code{gexp->script}.
6040 @end deffn
6041
6042 @deffn {Monadic Procedure} gexp->file @var{name} @var{exp} @
6043 [#:set-load-path? #t] [#:module-path %load-path] @
6044 [#:splice? #f] @
6045 [#:guile (default-guile)]
6046 Return a derivation that builds a file @var{name} containing @var{exp}.
6047 When @var{splice?} is true, @var{exp} is considered to be a list of
6048 expressions that will be spliced in the resulting file.
6049
6050 When @var{set-load-path?} is true, emit code in the resulting file to
6051 set @code{%load-path} and @code{%load-compiled-path} to honor
6052 @var{exp}'s imported modules. Look up @var{exp}'s modules in
6053 @var{module-path}.
6054
6055 The resulting file holds references to all the dependencies of @var{exp}
6056 or a subset thereof.
6057 @end deffn
6058
6059 @deffn {Scheme Procedure} scheme-file @var{name} @var{exp} [#:splice? #f]
6060 Return an object representing the Scheme file @var{name} that contains
6061 @var{exp}.
6062
6063 This is the declarative counterpart of @code{gexp->file}.
6064 @end deffn
6065
6066 @deffn {Monadic Procedure} text-file* @var{name} @var{text} @dots{}
6067 Return as a monadic value a derivation that builds a text file
6068 containing all of @var{text}. @var{text} may list, in addition to
6069 strings, objects of any type that can be used in a gexp: packages,
6070 derivations, local file objects, etc. The resulting store file holds
6071 references to all these.
6072
6073 This variant should be preferred over @code{text-file} anytime the file
6074 to create will reference items from the store. This is typically the
6075 case when building a configuration file that embeds store file names,
6076 like this:
6077
6078 @example
6079 (define (profile.sh)
6080 ;; Return the name of a shell script in the store that
6081 ;; initializes the 'PATH' environment variable.
6082 (text-file* "profile.sh"
6083 "export PATH=" coreutils "/bin:"
6084 grep "/bin:" sed "/bin\n"))
6085 @end example
6086
6087 In this example, the resulting @file{/gnu/store/@dots{}-profile.sh} file
6088 will reference @var{coreutils}, @var{grep}, and @var{sed}, thereby
6089 preventing them from being garbage-collected during its lifetime.
6090 @end deffn
6091
6092 @deffn {Scheme Procedure} mixed-text-file @var{name} @var{text} @dots{}
6093 Return an object representing store file @var{name} containing
6094 @var{text}. @var{text} is a sequence of strings and file-like objects,
6095 as in:
6096
6097 @example
6098 (mixed-text-file "profile"
6099 "export PATH=" coreutils "/bin:" grep "/bin")
6100 @end example
6101
6102 This is the declarative counterpart of @code{text-file*}.
6103 @end deffn
6104
6105 @deffn {Scheme Procedure} file-union @var{name} @var{files}
6106 Return a @code{<computed-file>} that builds a directory containing all of @var{files}.
6107 Each item in @var{files} must be a two-element list where the first element is the
6108 file name to use in the new directory, and the second element is a gexp
6109 denoting the target file. Here's an example:
6110
6111 @example
6112 (file-union "etc"
6113 `(("hosts" ,(plain-file "hosts"
6114 "127.0.0.1 localhost"))
6115 ("bashrc" ,(plain-file "bashrc"
6116 "alias ls='ls --color=auto'"))))
6117 @end example
6118
6119 This yields an @code{etc} directory containing these two files.
6120 @end deffn
6121
6122 @deffn {Scheme Procedure} directory-union @var{name} @var{things}
6123 Return a directory that is the union of @var{things}, where @var{things} is a list of
6124 file-like objects denoting directories. For example:
6125
6126 @example
6127 (directory-union "guile+emacs" (list guile emacs))
6128 @end example
6129
6130 yields a directory that is the union of the @code{guile} and @code{emacs} packages.
6131 @end deffn
6132
6133 @deffn {Scheme Procedure} file-append @var{obj} @var{suffix} @dots{}
6134 Return a file-like object that expands to the concatenation of @var{obj}
6135 and @var{suffix}, where @var{obj} is a lowerable object and each
6136 @var{suffix} is a string.
6137
6138 As an example, consider this gexp:
6139
6140 @example
6141 (gexp->script "run-uname"
6142 #~(system* #$(file-append coreutils
6143 "/bin/uname")))
6144 @end example
6145
6146 The same effect could be achieved with:
6147
6148 @example
6149 (gexp->script "run-uname"
6150 #~(system* (string-append #$coreutils
6151 "/bin/uname")))
6152 @end example
6153
6154 There is one difference though: in the @code{file-append} case, the
6155 resulting script contains the absolute file name as a string, whereas in
6156 the second case, the resulting script contains a @code{(string-append
6157 @dots{})} expression to construct the file name @emph{at run time}.
6158 @end deffn
6159
6160
6161 Of course, in addition to gexps embedded in ``host'' code, there are
6162 also modules containing build tools. To make it clear that they are
6163 meant to be used in the build stratum, these modules are kept in the
6164 @code{(guix build @dots{})} name space.
6165
6166 @cindex lowering, of high-level objects in gexps
6167 Internally, high-level objects are @dfn{lowered}, using their compiler,
6168 to either derivations or store items. For instance, lowering a package
6169 yields a derivation, and lowering a @code{plain-file} yields a store
6170 item. This is achieved using the @code{lower-object} monadic procedure.
6171
6172 @deffn {Monadic Procedure} lower-object @var{obj} [@var{system}] @
6173 [#:target #f]
6174 Return as a value in @var{%store-monad} the derivation or store item
6175 corresponding to @var{obj} for @var{system}, cross-compiling for
6176 @var{target} if @var{target} is true. @var{obj} must be an object that
6177 has an associated gexp compiler, such as a @code{<package>}.
6178 @end deffn
6179
6180 @node Invoking guix repl
6181 @section Invoking @command{guix repl}
6182
6183 @cindex REPL, read-eval-print loop
6184 The @command{guix repl} command spawns a Guile @dfn{read-eval-print loop}
6185 (REPL) for interactive programming (@pxref{Using Guile Interactively,,, guile,
6186 GNU Guile Reference Manual}). Compared to just launching the @command{guile}
6187 command, @command{guix repl} guarantees that all the Guix modules and all its
6188 dependencies are available in the search path. You can use it this way:
6189
6190 @example
6191 $ guix repl
6192 scheme@@(guile-user)> ,use (gnu packages base)
6193 scheme@@(guile-user)> coreutils
6194 $1 = #<package coreutils@@8.29 gnu/packages/base.scm:327 3e28300>
6195 @end example
6196
6197 @cindex inferiors
6198 In addition, @command{guix repl} implements a simple machine-readable REPL
6199 protocol for use by @code{(guix inferior)}, a facility to interact with
6200 @dfn{inferiors}, separate processes running a potentially different revision
6201 of Guix.
6202
6203 The available options are as follows:
6204
6205 @table @code
6206 @item --type=@var{type}
6207 @itemx -t @var{type}
6208 Start a REPL of the given @var{TYPE}, which can be one of the following:
6209
6210 @table @code
6211 @item guile
6212 This is default, and it spawns a standard full-featured Guile REPL.
6213 @item machine
6214 Spawn a REPL that uses the machine-readable protocol. This is the protocol
6215 that the @code{(guix inferior)} module speaks.
6216 @end table
6217
6218 @item --listen=@var{endpoint}
6219 By default, @command{guix repl} reads from standard input and writes to
6220 standard output. When this option is passed, it will instead listen for
6221 connections on @var{endpoint}. Here are examples of valid options:
6222
6223 @table @code
6224 @item --listen=tcp:37146
6225 Accept connections on localhost on port 37146.
6226
6227 @item --listen=unix:/tmp/socket
6228 Accept connections on the Unix-domain socket @file{/tmp/socket}.
6229 @end table
6230 @end table
6231
6232 @c *********************************************************************
6233 @node Utilities
6234 @chapter Utilities
6235
6236 This section describes Guix command-line utilities. Some of them are
6237 primarily targeted at developers and users who write new package
6238 definitions, while others are more generally useful. They complement
6239 the Scheme programming interface of Guix in a convenient way.
6240
6241 @menu
6242 * Invoking guix build:: Building packages from the command line.
6243 * Invoking guix edit:: Editing package definitions.
6244 * Invoking guix download:: Downloading a file and printing its hash.
6245 * Invoking guix hash:: Computing the cryptographic hash of a file.
6246 * Invoking guix import:: Importing package definitions.
6247 * Invoking guix refresh:: Updating package definitions.
6248 * Invoking guix lint:: Finding errors in package definitions.
6249 * Invoking guix size:: Profiling disk usage.
6250 * Invoking guix graph:: Visualizing the graph of packages.
6251 * Invoking guix environment:: Setting up development environments.
6252 * Invoking guix publish:: Sharing substitutes.
6253 * Invoking guix challenge:: Challenging substitute servers.
6254 * Invoking guix copy:: Copying to and from a remote store.
6255 * Invoking guix container:: Process isolation.
6256 * Invoking guix weather:: Assessing substitute availability.
6257 * Invoking guix processes:: Listing client processes.
6258 @end menu
6259
6260 @node Invoking guix build
6261 @section Invoking @command{guix build}
6262
6263 @cindex package building
6264 @cindex @command{guix build}
6265 The @command{guix build} command builds packages or derivations and
6266 their dependencies, and prints the resulting store paths. Note that it
6267 does not modify the user's profile---this is the job of the
6268 @command{guix package} command (@pxref{Invoking guix package}). Thus,
6269 it is mainly useful for distribution developers.
6270
6271 The general syntax is:
6272
6273 @example
6274 guix build @var{options} @var{package-or-derivation}@dots{}
6275 @end example
6276
6277 As an example, the following command builds the latest versions of Emacs
6278 and of Guile, displays their build logs, and finally displays the
6279 resulting directories:
6280
6281 @example
6282 guix build emacs guile
6283 @end example
6284
6285 Similarly, the following command builds all the available packages:
6286
6287 @example
6288 guix build --quiet --keep-going \
6289 `guix package -A | cut -f1,2 --output-delimiter=@@`
6290 @end example
6291
6292 @var{package-or-derivation} may be either the name of a package found in
6293 the software distribution such as @code{coreutils} or
6294 @code{coreutils@@8.20}, or a derivation such as
6295 @file{/gnu/store/@dots{}-coreutils-8.19.drv}. In the former case, a
6296 package with the corresponding name (and optionally version) is searched
6297 for among the GNU distribution modules (@pxref{Package Modules}).
6298
6299 Alternatively, the @code{--expression} option may be used to specify a
6300 Scheme expression that evaluates to a package; this is useful when
6301 disambiguating among several same-named packages or package variants is
6302 needed.
6303
6304 There may be zero or more @var{options}. The available options are
6305 described in the subsections below.
6306
6307 @menu
6308 * Common Build Options:: Build options for most commands.
6309 * Package Transformation Options:: Creating variants of packages.
6310 * Additional Build Options:: Options specific to 'guix build'.
6311 * Debugging Build Failures:: Real life packaging experience.
6312 @end menu
6313
6314 @node Common Build Options
6315 @subsection Common Build Options
6316
6317 A number of options that control the build process are common to
6318 @command{guix build} and other commands that can spawn builds, such as
6319 @command{guix package} or @command{guix archive}. These are the
6320 following:
6321
6322 @table @code
6323
6324 @item --load-path=@var{directory}
6325 @itemx -L @var{directory}
6326 Add @var{directory} to the front of the package module search path
6327 (@pxref{Package Modules}).
6328
6329 This allows users to define their own packages and make them visible to
6330 the command-line tools.
6331
6332 @item --keep-failed
6333 @itemx -K
6334 Keep the build tree of failed builds. Thus, if a build fails, its build
6335 tree is kept under @file{/tmp}, in a directory whose name is shown at
6336 the end of the build log. This is useful when debugging build issues.
6337 @xref{Debugging Build Failures}, for tips and tricks on how to debug
6338 build issues.
6339
6340 This option has no effect when connecting to a remote daemon with a
6341 @code{guix://} URI (@pxref{The Store, the @code{GUIX_DAEMON_SOCKET}
6342 variable}).
6343
6344 @item --keep-going
6345 @itemx -k
6346 Keep going when some of the derivations fail to build; return only once
6347 all the builds have either completed or failed.
6348
6349 The default behavior is to stop as soon as one of the specified
6350 derivations has failed.
6351
6352 @item --dry-run
6353 @itemx -n
6354 Do not build the derivations.
6355
6356 @anchor{fallback-option}
6357 @item --fallback
6358 When substituting a pre-built binary fails, fall back to building
6359 packages locally (@pxref{Substitution Failure}).
6360
6361 @item --substitute-urls=@var{urls}
6362 @anchor{client-substitute-urls}
6363 Consider @var{urls} the whitespace-separated list of substitute source
6364 URLs, overriding the default list of URLs of @command{guix-daemon}
6365 (@pxref{daemon-substitute-urls,, @command{guix-daemon} URLs}).
6366
6367 This means that substitutes may be downloaded from @var{urls}, provided
6368 they are signed by a key authorized by the system administrator
6369 (@pxref{Substitutes}).
6370
6371 When @var{urls} is the empty string, substitutes are effectively
6372 disabled.
6373
6374 @item --no-substitutes
6375 Do not use substitutes for build products. That is, always build things
6376 locally instead of allowing downloads of pre-built binaries
6377 (@pxref{Substitutes}).
6378
6379 @item --no-grafts
6380 Do not ``graft'' packages. In practice, this means that package updates
6381 available as grafts are not applied. @xref{Security Updates}, for more
6382 information on grafts.
6383
6384 @item --rounds=@var{n}
6385 Build each derivation @var{n} times in a row, and raise an error if
6386 consecutive build results are not bit-for-bit identical.
6387
6388 This is a useful way to detect non-deterministic builds processes.
6389 Non-deterministic build processes are a problem because they make it
6390 practically impossible for users to @emph{verify} whether third-party
6391 binaries are genuine. @xref{Invoking guix challenge}, for more.
6392
6393 Note that, currently, the differing build results are not kept around,
6394 so you will have to manually investigate in case of an error---e.g., by
6395 stashing one of the build results with @code{guix archive --export}
6396 (@pxref{Invoking guix archive}), then rebuilding, and finally comparing
6397 the two results.
6398
6399 @item --no-build-hook
6400 Do not attempt to offload builds @i{via} the ``build hook'' of the daemon
6401 (@pxref{Daemon Offload Setup}). That is, always build things locally
6402 instead of offloading builds to remote machines.
6403
6404 @item --max-silent-time=@var{seconds}
6405 When the build or substitution process remains silent for more than
6406 @var{seconds}, terminate it and report a build failure.
6407
6408 By default, the daemon's setting is honored (@pxref{Invoking
6409 guix-daemon, @code{--max-silent-time}}).
6410
6411 @item --timeout=@var{seconds}
6412 Likewise, when the build or substitution process lasts for more than
6413 @var{seconds}, terminate it and report a build failure.
6414
6415 By default, the daemon's setting is honored (@pxref{Invoking
6416 guix-daemon, @code{--timeout}}).
6417
6418 @c Note: This option is actually not part of %standard-build-options but
6419 @c most programs honor it.
6420 @cindex verbosity, of the command-line tools
6421 @cindex build logs, verbosity
6422 @item -v @var{level}
6423 @itemx --verbosity=@var{level}
6424 Use the given verbosity @var{level}, an integer. Choosing 0 means that no
6425 output is produced, 1 is for quiet output, and 2 shows all the build log
6426 output on standard error.
6427
6428 @item --cores=@var{n}
6429 @itemx -c @var{n}
6430 Allow the use of up to @var{n} CPU cores for the build. The special
6431 value @code{0} means to use as many CPU cores as available.
6432
6433 @item --max-jobs=@var{n}
6434 @itemx -M @var{n}
6435 Allow at most @var{n} build jobs in parallel. @xref{Invoking
6436 guix-daemon, @code{--max-jobs}}, for details about this option and the
6437 equivalent @command{guix-daemon} option.
6438
6439 @item --debug=@var{level}
6440 Produce debugging output coming from the build daemon. @var{level} must be an
6441 integer between 0 and 5; higher means more verbose output. Setting a level of
6442 4 or more may be helpful when debugging setup issues with the build daemon.
6443
6444 @end table
6445
6446 Behind the scenes, @command{guix build} is essentially an interface to
6447 the @code{package-derivation} procedure of the @code{(guix packages)}
6448 module, and to the @code{build-derivations} procedure of the @code{(guix
6449 derivations)} module.
6450
6451 In addition to options explicitly passed on the command line,
6452 @command{guix build} and other @command{guix} commands that support
6453 building honor the @code{GUIX_BUILD_OPTIONS} environment variable.
6454
6455 @defvr {Environment Variable} GUIX_BUILD_OPTIONS
6456 Users can define this variable to a list of command line options that
6457 will automatically be used by @command{guix build} and other
6458 @command{guix} commands that can perform builds, as in the example
6459 below:
6460
6461 @example
6462 $ export GUIX_BUILD_OPTIONS="--no-substitutes -c 2 -L /foo/bar"
6463 @end example
6464
6465 These options are parsed independently, and the result is appended to
6466 the parsed command-line options.
6467 @end defvr
6468
6469
6470 @node Package Transformation Options
6471 @subsection Package Transformation Options
6472
6473 @cindex package variants
6474 Another set of command-line options supported by @command{guix build}
6475 and also @command{guix package} are @dfn{package transformation
6476 options}. These are options that make it possible to define @dfn{package
6477 variants}---for instance, packages built from different source code.
6478 This is a convenient way to create customized packages on the fly
6479 without having to type in the definitions of package variants
6480 (@pxref{Defining Packages}).
6481
6482 @table @code
6483
6484 @item --with-source=@var{source}
6485 @itemx --with-source=@var{package}=@var{source}
6486 @itemx --with-source=@var{package}@@@var{version}=@var{source}
6487 Use @var{source} as the source of @var{package}, and @var{version} as
6488 its version number.
6489 @var{source} must be a file name or a URL, as for @command{guix
6490 download} (@pxref{Invoking guix download}).
6491
6492 When @var{package} is omitted,
6493 it is taken to be the package name specified on the
6494 command line that matches the base of @var{source}---e.g.,
6495 if @var{source} is @code{/src/guile-2.0.10.tar.gz}, the corresponding
6496 package is @code{guile}.
6497
6498 Likewise, when @var{version} is omitted, the version string is inferred from
6499 @var{source}; in the previous example, it is @code{2.0.10}.
6500
6501 This option allows users to try out versions of packages other than the
6502 one provided by the distribution. The example below downloads
6503 @file{ed-1.7.tar.gz} from a GNU mirror and uses that as the source for
6504 the @code{ed} package:
6505
6506 @example
6507 guix build ed --with-source=mirror://gnu/ed/ed-1.7.tar.gz
6508 @end example
6509
6510 As a developer, @code{--with-source} makes it easy to test release
6511 candidates:
6512
6513 @example
6514 guix build guile --with-source=../guile-2.0.9.219-e1bb7.tar.xz
6515 @end example
6516
6517 @dots{} or to build from a checkout in a pristine environment:
6518
6519 @example
6520 $ git clone git://git.sv.gnu.org/guix.git
6521 $ guix build guix --with-source=guix@@1.0=./guix
6522 @end example
6523
6524 @item --with-input=@var{package}=@var{replacement}
6525 Replace dependency on @var{package} by a dependency on
6526 @var{replacement}. @var{package} must be a package name, and
6527 @var{replacement} must be a package specification such as @code{guile}
6528 or @code{guile@@1.8}.
6529
6530 For instance, the following command builds Guix, but replaces its
6531 dependency on the current stable version of Guile with a dependency on
6532 the legacy version of Guile, @code{guile@@2.0}:
6533
6534 @example
6535 guix build --with-input=guile=guile@@2.0 guix
6536 @end example
6537
6538 This is a recursive, deep replacement. So in this example, both
6539 @code{guix} and its dependency @code{guile-json} (which also depends on
6540 @code{guile}) get rebuilt against @code{guile@@2.0}.
6541
6542 This is implemented using the @code{package-input-rewriting} Scheme
6543 procedure (@pxref{Defining Packages, @code{package-input-rewriting}}).
6544
6545 @item --with-graft=@var{package}=@var{replacement}
6546 This is similar to @code{--with-input} but with an important difference:
6547 instead of rebuilding the whole dependency chain, @var{replacement} is
6548 built and then @dfn{grafted} onto the binaries that were initially
6549 referring to @var{package}. @xref{Security Updates}, for more
6550 information on grafts.
6551
6552 For example, the command below grafts version 3.5.4 of GnuTLS onto Wget
6553 and all its dependencies, replacing references to the version of GnuTLS
6554 they currently refer to:
6555
6556 @example
6557 guix build --with-graft=gnutls=gnutls@@3.5.4 wget
6558 @end example
6559
6560 This has the advantage of being much faster than rebuilding everything.
6561 But there is a caveat: it works if and only if @var{package} and
6562 @var{replacement} are strictly compatible---for example, if they provide
6563 a library, the application binary interface (ABI) of those libraries
6564 must be compatible. If @var{replacement} is somehow incompatible with
6565 @var{package}, then the resulting package may be unusable. Use with
6566 care!
6567
6568 @item --with-branch=@var{package}=@var{branch}
6569 @cindex Git, using the latest commit
6570 @cindex latest commit, building
6571 Build @var{package} from the latest commit of @var{branch}. The @code{source}
6572 field of @var{package} must be an origin with the @code{git-fetch} method
6573 (@pxref{origin Reference}) or a @code{git-checkout} object; the repository URL
6574 is taken from that @code{source}.
6575
6576 For instance, the following command builds @code{guile-sqlite3} from the
6577 latest commit of its @code{master} branch, and then builds @code{guix} (which
6578 depends on it) and @code{cuirass} (which depends on @code{guix}) against this
6579 specific @code{guile-sqlite3} build:
6580
6581 @example
6582 guix build --with-branch=guile-sqlite3=master cuirass
6583 @end example
6584
6585 @cindex continuous integration
6586 Obviously, since it uses the latest commit of the given branch, the result of
6587 such a command varies over time. Nevertheless it is a convenient way to
6588 rebuild entire software stacks against the latest commit of one or more
6589 packages. This is particularly useful in the context of continuous
6590 integration (CI).
6591
6592 Checkouts are kept in a cache under @file{~/.cache/guix/checkouts} to speed up
6593 consecutive accesses to the same repository. You may want to clean it up once
6594 in a while to save disk space.
6595
6596 @item --with-commit=@var{package}=@var{commit}
6597 This is similar to @code{--with-branch}, except that it builds from
6598 @var{commit} rather than the tip of a branch. @var{commit} must be a valid
6599 Git commit SHA1 identifier.
6600 @end table
6601
6602 @node Additional Build Options
6603 @subsection Additional Build Options
6604
6605 The command-line options presented below are specific to @command{guix
6606 build}.
6607
6608 @table @code
6609
6610 @item --quiet
6611 @itemx -q
6612 Build quietly, without displaying the build log; this is equivalent to
6613 @code{--verbosity=0}. Upon completion, the build log is kept in @file{/var}
6614 (or similar) and can always be retrieved using the @option{--log-file} option.
6615
6616 @item --file=@var{file}
6617 @itemx -f @var{file}
6618 Build the package, derivation, or other file-like object that the code within
6619 @var{file} evaluates to (@pxref{G-Expressions, file-like objects}).
6620
6621 As an example, @var{file} might contain a package definition like this
6622 (@pxref{Defining Packages}):
6623
6624 @example
6625 @verbatiminclude package-hello.scm
6626 @end example
6627
6628 @item --expression=@var{expr}
6629 @itemx -e @var{expr}
6630 Build the package or derivation @var{expr} evaluates to.
6631
6632 For example, @var{expr} may be @code{(@@ (gnu packages guile)
6633 guile-1.8)}, which unambiguously designates this specific variant of
6634 version 1.8 of Guile.
6635
6636 Alternatively, @var{expr} may be a G-expression, in which case it is used
6637 as a build program passed to @code{gexp->derivation}
6638 (@pxref{G-Expressions}).
6639
6640 Lastly, @var{expr} may refer to a zero-argument monadic procedure
6641 (@pxref{The Store Monad}). The procedure must return a derivation as a
6642 monadic value, which is then passed through @code{run-with-store}.
6643
6644 @item --source
6645 @itemx -S
6646 Build the source derivations of the packages, rather than the packages
6647 themselves.
6648
6649 For instance, @code{guix build -S gcc} returns something like
6650 @file{/gnu/store/@dots{}-gcc-4.7.2.tar.bz2}, which is the GCC
6651 source tarball.
6652
6653 The returned source tarball is the result of applying any patches and
6654 code snippets specified in the package @code{origin} (@pxref{Defining
6655 Packages}).
6656
6657 @item --sources
6658 Fetch and return the source of @var{package-or-derivation} and all their
6659 dependencies, recursively. This is a handy way to obtain a local copy
6660 of all the source code needed to build @var{packages}, allowing you to
6661 eventually build them even without network access. It is an extension
6662 of the @code{--source} option and can accept one of the following
6663 optional argument values:
6664
6665 @table @code
6666 @item package
6667 This value causes the @code{--sources} option to behave in the same way
6668 as the @code{--source} option.
6669
6670 @item all
6671 Build the source derivations of all packages, including any source that
6672 might be listed as @code{inputs}. This is the default value.
6673
6674 @example
6675 $ guix build --sources tzdata
6676 The following derivations will be built:
6677 /gnu/store/@dots{}-tzdata2015b.tar.gz.drv
6678 /gnu/store/@dots{}-tzcode2015b.tar.gz.drv
6679 @end example
6680
6681 @item transitive
6682 Build the source derivations of all packages, as well of all transitive
6683 inputs to the packages. This can be used e.g.@: to
6684 prefetch package source for later offline building.
6685
6686 @example
6687 $ guix build --sources=transitive tzdata
6688 The following derivations will be built:
6689 /gnu/store/@dots{}-tzcode2015b.tar.gz.drv
6690 /gnu/store/@dots{}-findutils-4.4.2.tar.xz.drv
6691 /gnu/store/@dots{}-grep-2.21.tar.xz.drv
6692 /gnu/store/@dots{}-coreutils-8.23.tar.xz.drv
6693 /gnu/store/@dots{}-make-4.1.tar.xz.drv
6694 /gnu/store/@dots{}-bash-4.3.tar.xz.drv
6695 @dots{}
6696 @end example
6697
6698 @end table
6699
6700 @item --system=@var{system}
6701 @itemx -s @var{system}
6702 Attempt to build for @var{system}---e.g., @code{i686-linux}---instead of
6703 the system type of the build host.
6704
6705 @quotation Note
6706 The @code{--system} flag is for @emph{native} compilation and must not
6707 be confused with cross-compilation. See @code{--target} below for
6708 information on cross-compilation.
6709 @end quotation
6710
6711 An example use of this is on Linux-based systems, which can emulate
6712 different personalities. For instance, passing
6713 @code{--system=i686-linux} on an @code{x86_64-linux} system or
6714 @code{--system=armhf-linux} on an @code{aarch64-linux} system allows you
6715 to build packages in a complete 32-bit environment.
6716
6717 @quotation Note
6718 Building for an @code{armhf-linux} system is unconditionally enabled on
6719 @code{aarch64-linux} machines, although certain aarch64 chipsets do not
6720 allow for this functionality, notably the ThunderX.
6721 @end quotation
6722
6723 Similarly, when transparent emulation with QEMU and @code{binfmt_misc}
6724 is enabled (@pxref{Virtualization Services,
6725 @code{qemu-binfmt-service-type}}), you can build for any system for
6726 which a QEMU @code{binfmt_misc} handler is installed.
6727
6728 Builds for a system other than that of the machine you are using can
6729 also be offloaded to a remote machine of the right architecture.
6730 @xref{Daemon Offload Setup}, for more information on offloading.
6731
6732 @item --target=@var{triplet}
6733 @cindex cross-compilation
6734 Cross-build for @var{triplet}, which must be a valid GNU triplet, such
6735 as @code{"mips64el-linux-gnu"} (@pxref{Specifying target triplets, GNU
6736 configuration triplets,, autoconf, Autoconf}).
6737
6738 @anchor{build-check}
6739 @item --check
6740 @cindex determinism, checking
6741 @cindex reproducibility, checking
6742 Rebuild @var{package-or-derivation}, which are already available in the
6743 store, and raise an error if the build results are not bit-for-bit
6744 identical.
6745
6746 This mechanism allows you to check whether previously installed
6747 substitutes are genuine (@pxref{Substitutes}), or whether the build result
6748 of a package is deterministic. @xref{Invoking guix challenge}, for more
6749 background information and tools.
6750
6751 When used in conjunction with @option{--keep-failed}, the differing
6752 output is kept in the store, under @file{/gnu/store/@dots{}-check}.
6753 This makes it easy to look for differences between the two results.
6754
6755 @item --repair
6756 @cindex repairing store items
6757 @cindex corruption, recovering from
6758 Attempt to repair the specified store items, if they are corrupt, by
6759 re-downloading or rebuilding them.
6760
6761 This operation is not atomic and thus restricted to @code{root}.
6762
6763 @item --derivations
6764 @itemx -d
6765 Return the derivation paths, not the output paths, of the given
6766 packages.
6767
6768 @item --root=@var{file}
6769 @itemx -r @var{file}
6770 @cindex GC roots, adding
6771 @cindex garbage collector roots, adding
6772 Make @var{file} a symlink to the result, and register it as a garbage
6773 collector root.
6774
6775 Consequently, the results of this @command{guix build} invocation are
6776 protected from garbage collection until @var{file} is removed. When
6777 that option is omitted, build results are eligible for garbage
6778 collection as soon as the build completes. @xref{Invoking guix gc}, for
6779 more on GC roots.
6780
6781 @item --log-file
6782 @cindex build logs, access
6783 Return the build log file names or URLs for the given
6784 @var{package-or-derivation}, or raise an error if build logs are
6785 missing.
6786
6787 This works regardless of how packages or derivations are specified. For
6788 instance, the following invocations are equivalent:
6789
6790 @example
6791 guix build --log-file `guix build -d guile`
6792 guix build --log-file `guix build guile`
6793 guix build --log-file guile
6794 guix build --log-file -e '(@@ (gnu packages guile) guile-2.0)'
6795 @end example
6796
6797 If a log is unavailable locally, and unless @code{--no-substitutes} is
6798 passed, the command looks for a corresponding log on one of the
6799 substitute servers (as specified with @code{--substitute-urls}.)
6800
6801 So for instance, imagine you want to see the build log of GDB on MIPS,
6802 but you are actually on an @code{x86_64} machine:
6803
6804 @example
6805 $ guix build --log-file gdb -s mips64el-linux
6806 https://@value{SUBSTITUTE-SERVER}/log/@dots{}-gdb-7.10
6807 @end example
6808
6809 You can freely access a huge library of build logs!
6810 @end table
6811
6812 @node Debugging Build Failures
6813 @subsection Debugging Build Failures
6814
6815 @cindex build failures, debugging
6816 When defining a new package (@pxref{Defining Packages}), you will
6817 probably find yourself spending some time debugging and tweaking the
6818 build until it succeeds. To do that, you need to operate the build
6819 commands yourself in an environment as close as possible to the one the
6820 build daemon uses.
6821
6822 To that end, the first thing to do is to use the @option{--keep-failed}
6823 or @option{-K} option of @command{guix build}, which will keep the
6824 failed build tree in @file{/tmp} or whatever directory you specified as
6825 @code{TMPDIR} (@pxref{Invoking guix build, @code{--keep-failed}}).
6826
6827 From there on, you can @command{cd} to the failed build tree and source
6828 the @file{environment-variables} file, which contains all the
6829 environment variable definitions that were in place when the build
6830 failed. So let's say you're debugging a build failure in package
6831 @code{foo}; a typical session would look like this:
6832
6833 @example
6834 $ guix build foo -K
6835 @dots{} @i{build fails}
6836 $ cd /tmp/guix-build-foo.drv-0
6837 $ source ./environment-variables
6838 $ cd foo-1.2
6839 @end example
6840
6841 Now, you can invoke commands as if you were the daemon (almost) and
6842 troubleshoot your build process.
6843
6844 Sometimes it happens that, for example, a package's tests pass when you
6845 run them manually but they fail when the daemon runs them. This can
6846 happen because the daemon runs builds in containers where, unlike in our
6847 environment above, network access is missing, @file{/bin/sh} does not
6848 exist, etc. (@pxref{Build Environment Setup}).
6849
6850 In such cases, you may need to run inspect the build process from within
6851 a container similar to the one the build daemon creates:
6852
6853 @example
6854 $ guix build -K foo
6855 @dots{}
6856 $ cd /tmp/guix-build-foo.drv-0
6857 $ guix environment --no-grafts -C foo --ad-hoc strace gdb
6858 [env]# source ./environment-variables
6859 [env]# cd foo-1.2
6860 @end example
6861
6862 Here, @command{guix environment -C} creates a container and spawns a new
6863 shell in it (@pxref{Invoking guix environment}). The @command{--ad-hoc
6864 strace gdb} part adds the @command{strace} and @command{gdb} commands to
6865 the container, which would may find handy while debugging. The
6866 @option{--no-grafts} option makes sure we get the exact same
6867 environment, with ungrafted packages (@pxref{Security Updates}, for more
6868 info on grafts).
6869
6870 To get closer to a container like that used by the build daemon, we can
6871 remove @file{/bin/sh}:
6872
6873 @example
6874 [env]# rm /bin/sh
6875 @end example
6876
6877 (Don't worry, this is harmless: this is all happening in the throw-away
6878 container created by @command{guix environment}.)
6879
6880 The @command{strace} command is probably not in the search path, but we
6881 can run:
6882
6883 @example
6884 [env]# $GUIX_ENVIRONMENT/bin/strace -f -o log make check
6885 @end example
6886
6887 In this way, not only you will have reproduced the environment variables
6888 the daemon uses, you will also be running the build process in a container
6889 similar to the one the daemon uses.
6890
6891
6892 @node Invoking guix edit
6893 @section Invoking @command{guix edit}
6894
6895 @cindex @command{guix edit}
6896 @cindex package definition, editing
6897 So many packages, so many source files! The @command{guix edit} command
6898 facilitates the life of users and packagers by pointing their editor at
6899 the source file containing the definition of the specified packages.
6900 For instance:
6901
6902 @example
6903 guix edit gcc@@4.9 vim
6904 @end example
6905
6906 @noindent
6907 launches the program specified in the @code{VISUAL} or in the
6908 @code{EDITOR} environment variable to view the recipe of GCC@tie{}4.9.3
6909 and that of Vim.
6910
6911 If you are using a Guix Git checkout (@pxref{Building from Git}), or
6912 have created your own packages on @code{GUIX_PACKAGE_PATH}
6913 (@pxref{Package Modules}), you will be able to edit the package
6914 recipes. In other cases, you will be able to examine the read-only recipes
6915 for packages currently in the store.
6916
6917
6918 @node Invoking guix download
6919 @section Invoking @command{guix download}
6920
6921 @cindex @command{guix download}
6922 @cindex downloading package sources
6923 When writing a package definition, developers typically need to download
6924 a source tarball, compute its SHA256 hash, and write that
6925 hash in the package definition (@pxref{Defining Packages}). The
6926 @command{guix download} tool helps with this task: it downloads a file
6927 from the given URI, adds it to the store, and prints both its file name
6928 in the store and its SHA256 hash.
6929
6930 The fact that the downloaded file is added to the store saves bandwidth:
6931 when the developer eventually tries to build the newly defined package
6932 with @command{guix build}, the source tarball will not have to be
6933 downloaded again because it is already in the store. It is also a
6934 convenient way to temporarily stash files, which may be deleted
6935 eventually (@pxref{Invoking guix gc}).
6936
6937 The @command{guix download} command supports the same URIs as used in
6938 package definitions. In particular, it supports @code{mirror://} URIs.
6939 @code{https} URIs (HTTP over TLS) are supported @emph{provided} the
6940 Guile bindings for GnuTLS are available in the user's environment; when
6941 they are not available, an error is raised. @xref{Guile Preparations,
6942 how to install the GnuTLS bindings for Guile,, gnutls-guile,
6943 GnuTLS-Guile}, for more information.
6944
6945 @command{guix download} verifies HTTPS server certificates by loading
6946 the certificates of X.509 authorities from the directory pointed to by
6947 the @code{SSL_CERT_DIR} environment variable (@pxref{X.509
6948 Certificates}), unless @option{--no-check-certificate} is used.
6949
6950 The following options are available:
6951
6952 @table @code
6953 @item --format=@var{fmt}
6954 @itemx -f @var{fmt}
6955 Write the hash in the format specified by @var{fmt}. For more
6956 information on the valid values for @var{fmt}, @pxref{Invoking guix hash}.
6957
6958 @item --no-check-certificate
6959 Do not validate the X.509 certificates of HTTPS servers.
6960
6961 When using this option, you have @emph{absolutely no guarantee} that you
6962 are communicating with the authentic server responsible for the given
6963 URL, which makes you vulnerable to ``man-in-the-middle'' attacks.
6964
6965 @item --output=@var{file}
6966 @itemx -o @var{file}
6967 Save the downloaded file to @var{file} instead of adding it to the
6968 store.
6969 @end table
6970
6971 @node Invoking guix hash
6972 @section Invoking @command{guix hash}
6973
6974 @cindex @command{guix hash}
6975 The @command{guix hash} command computes the SHA256 hash of a file.
6976 It is primarily a convenience tool for anyone contributing to the
6977 distribution: it computes the cryptographic hash of a file, which can be
6978 used in the definition of a package (@pxref{Defining Packages}).
6979
6980 The general syntax is:
6981
6982 @example
6983 guix hash @var{option} @var{file}
6984 @end example
6985
6986 When @var{file} is @code{-} (a hyphen), @command{guix hash} computes the
6987 hash of data read from standard input. @command{guix hash} has the
6988 following options:
6989
6990 @table @code
6991
6992 @item --format=@var{fmt}
6993 @itemx -f @var{fmt}
6994 Write the hash in the format specified by @var{fmt}.
6995
6996 Supported formats: @code{nix-base32}, @code{base32}, @code{base16}
6997 (@code{hex} and @code{hexadecimal} can be used as well).
6998
6999 If the @option{--format} option is not specified, @command{guix hash}
7000 will output the hash in @code{nix-base32}. This representation is used
7001 in the definitions of packages.
7002
7003 @item --recursive
7004 @itemx -r
7005 Compute the hash on @var{file} recursively.
7006
7007 In this case, the hash is computed on an archive containing @var{file},
7008 including its children if it is a directory. Some of the metadata of
7009 @var{file} is part of the archive; for instance, when @var{file} is a
7010 regular file, the hash is different depending on whether @var{file} is
7011 executable or not. Metadata such as time stamps has no impact on the
7012 hash (@pxref{Invoking guix archive}).
7013 @c FIXME: Replace xref above with xref to an ``Archive'' section when
7014 @c it exists.
7015
7016 @item --exclude-vcs
7017 @itemx -x
7018 When combined with @option{--recursive}, exclude version control system
7019 directories (@file{.bzr}, @file{.git}, @file{.hg}, etc.)
7020
7021 @vindex git-fetch
7022 As an example, here is how you would compute the hash of a Git checkout,
7023 which is useful when using the @code{git-fetch} method (@pxref{origin
7024 Reference}):
7025
7026 @example
7027 $ git clone http://example.org/foo.git
7028 $ cd foo
7029 $ guix hash -rx .
7030 @end example
7031 @end table
7032
7033 @node Invoking guix import
7034 @section Invoking @command{guix import}
7035
7036 @cindex importing packages
7037 @cindex package import
7038 @cindex package conversion
7039 @cindex Invoking @command{guix import}
7040 The @command{guix import} command is useful for people who would like to
7041 add a package to the distribution with as little work as
7042 possible---a legitimate demand. The command knows of a few
7043 repositories from which it can ``import'' package metadata. The result
7044 is a package definition, or a template thereof, in the format we know
7045 (@pxref{Defining Packages}).
7046
7047 The general syntax is:
7048
7049 @example
7050 guix import @var{importer} @var{options}@dots{}
7051 @end example
7052
7053 @var{importer} specifies the source from which to import package
7054 metadata, and @var{options} specifies a package identifier and other
7055 options specific to @var{importer}. Currently, the available
7056 ``importers'' are:
7057
7058 @table @code
7059 @item gnu
7060 Import metadata for the given GNU package. This provides a template
7061 for the latest version of that GNU package, including the hash of its
7062 source tarball, and its canonical synopsis and description.
7063
7064 Additional information such as the package dependencies and its
7065 license needs to be figured out manually.
7066
7067 For example, the following command returns a package definition for
7068 GNU@tie{}Hello:
7069
7070 @example
7071 guix import gnu hello
7072 @end example
7073
7074 Specific command-line options are:
7075
7076 @table @code
7077 @item --key-download=@var{policy}
7078 As for @code{guix refresh}, specify the policy to handle missing OpenPGP
7079 keys when verifying the package signature. @xref{Invoking guix
7080 refresh, @code{--key-download}}.
7081 @end table
7082
7083 @item pypi
7084 @cindex pypi
7085 Import metadata from the @uref{https://pypi.python.org/, Python Package
7086 Index}. Information is taken from the JSON-formatted description
7087 available at @code{pypi.python.org} and usually includes all the relevant
7088 information, including package dependencies. For maximum efficiency, it
7089 is recommended to install the @command{unzip} utility, so that the
7090 importer can unzip Python wheels and gather data from them.
7091
7092 The command below imports metadata for the @code{itsdangerous} Python
7093 package:
7094
7095 @example
7096 guix import pypi itsdangerous
7097 @end example
7098
7099 @table @code
7100 @item --recursive
7101 @itemx -r
7102 Traverse the dependency graph of the given upstream package recursively
7103 and generate package expressions for all those packages that are not yet
7104 in Guix.
7105 @end table
7106
7107 @item gem
7108 @cindex gem
7109 Import metadata from @uref{https://rubygems.org/, RubyGems}. Information
7110 is taken from the JSON-formatted description available at
7111 @code{rubygems.org} and includes most relevant information, including
7112 runtime dependencies. There are some caveats, however. The metadata
7113 doesn't distinguish between synopses and descriptions, so the same string
7114 is used for both fields. Additionally, the details of non-Ruby
7115 dependencies required to build native extensions is unavailable and left
7116 as an exercise to the packager.
7117
7118 The command below imports metadata for the @code{rails} Ruby package:
7119
7120 @example
7121 guix import gem rails
7122 @end example
7123
7124 @table @code
7125 @item --recursive
7126 @itemx -r
7127 Traverse the dependency graph of the given upstream package recursively
7128 and generate package expressions for all those packages that are not yet
7129 in Guix.
7130 @end table
7131
7132 @item cpan
7133 @cindex CPAN
7134 Import metadata from @uref{https://www.metacpan.org/, MetaCPAN}.
7135 Information is taken from the JSON-formatted metadata provided through
7136 @uref{https://fastapi.metacpan.org/, MetaCPAN's API} and includes most
7137 relevant information, such as module dependencies. License information
7138 should be checked closely. If Perl is available in the store, then the
7139 @code{corelist} utility will be used to filter core modules out of the
7140 list of dependencies.
7141
7142 The command command below imports metadata for the @code{Acme::Boolean}
7143 Perl module:
7144
7145 @example
7146 guix import cpan Acme::Boolean
7147 @end example
7148
7149 @item cran
7150 @cindex CRAN
7151 @cindex Bioconductor
7152 Import metadata from @uref{https://cran.r-project.org/, CRAN}, the
7153 central repository for the @uref{http://r-project.org, GNU@tie{}R
7154 statistical and graphical environment}.
7155
7156 Information is extracted from the @code{DESCRIPTION} file of the package.
7157
7158 The command command below imports metadata for the @code{Cairo}
7159 R package:
7160
7161 @example
7162 guix import cran Cairo
7163 @end example
7164
7165 When @code{--recursive} is added, the importer will traverse the
7166 dependency graph of the given upstream package recursively and generate
7167 package expressions for all those packages that are not yet in Guix.
7168
7169 When @code{--archive=bioconductor} is added, metadata is imported from
7170 @uref{https://www.bioconductor.org/, Bioconductor}, a repository of R
7171 packages for for the analysis and comprehension of high-throughput
7172 genomic data in bioinformatics.
7173
7174 Information is extracted from the @code{DESCRIPTION} file of a package
7175 published on the web interface of the Bioconductor SVN repository.
7176
7177 The command below imports metadata for the @code{GenomicRanges}
7178 R package:
7179
7180 @example
7181 guix import cran --archive=bioconductor GenomicRanges
7182 @end example
7183
7184 @item texlive
7185 @cindex TeX Live
7186 @cindex CTAN
7187 Import metadata from @uref{http://www.ctan.org/, CTAN}, the
7188 comprehensive TeX archive network for TeX packages that are part of the
7189 @uref{https://www.tug.org/texlive/, TeX Live distribution}.
7190
7191 Information about the package is obtained through the XML API provided
7192 by CTAN, while the source code is downloaded from the SVN repository of
7193 the Tex Live project. This is done because the CTAN does not keep
7194 versioned archives.
7195
7196 The command command below imports metadata for the @code{fontspec}
7197 TeX package:
7198
7199 @example
7200 guix import texlive fontspec
7201 @end example
7202
7203 When @code{--archive=DIRECTORY} is added, the source code is downloaded
7204 not from the @file{latex} sub-directory of the @file{texmf-dist/source}
7205 tree in the TeX Live SVN repository, but from the specified sibling
7206 directory under the same root.
7207
7208 The command below imports metadata for the @code{ifxetex} package from
7209 CTAN while fetching the sources from the directory
7210 @file{texmf/source/generic}:
7211
7212 @example
7213 guix import texlive --archive=generic ifxetex
7214 @end example
7215
7216 @item json
7217 @cindex JSON, import
7218 Import package metadata from a local JSON file. Consider the following
7219 example package definition in JSON format:
7220
7221 @example
7222 @{
7223 "name": "hello",
7224 "version": "2.10",
7225 "source": "mirror://gnu/hello/hello-2.10.tar.gz",
7226 "build-system": "gnu",
7227 "home-page": "https://www.gnu.org/software/hello/",
7228 "synopsis": "Hello, GNU world: An example GNU package",
7229 "description": "GNU Hello prints a greeting.",
7230 "license": "GPL-3.0+",
7231 "native-inputs": ["gcc@@6"]
7232 @}
7233 @end example
7234
7235 The field names are the same as for the @code{<package>} record
7236 (@xref{Defining Packages}). References to other packages are provided
7237 as JSON lists of quoted package specification strings such as
7238 @code{guile} or @code{guile@@2.0}.
7239
7240 The importer also supports a more explicit source definition using the
7241 common fields for @code{<origin>} records:
7242
7243 @example
7244 @{
7245 @dots{}
7246 "source": @{
7247 "method": "url-fetch",
7248 "uri": "mirror://gnu/hello/hello-2.10.tar.gz",
7249 "sha256": @{
7250 "base32": "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i"
7251 @}
7252 @}
7253 @dots{}
7254 @}
7255 @end example
7256
7257 The command below reads metadata from the JSON file @code{hello.json}
7258 and outputs a package expression:
7259
7260 @example
7261 guix import json hello.json
7262 @end example
7263
7264 @item nix
7265 Import metadata from a local copy of the source of the
7266 @uref{http://nixos.org/nixpkgs/, Nixpkgs distribution}@footnote{This
7267 relies on the @command{nix-instantiate} command of
7268 @uref{http://nixos.org/nix/, Nix}.}. Package definitions in Nixpkgs are
7269 typically written in a mixture of Nix-language and Bash code. This
7270 command only imports the high-level package structure that is written in
7271 the Nix language. It normally includes all the basic fields of a
7272 package definition.
7273
7274 When importing a GNU package, the synopsis and descriptions are replaced
7275 by their canonical upstream variant.
7276
7277 Usually, you will first need to do:
7278
7279 @example
7280 export NIX_REMOTE=daemon
7281 @end example
7282
7283 @noindent
7284 so that @command{nix-instantiate} does not try to open the Nix database.
7285
7286 As an example, the command below imports the package definition of
7287 LibreOffice (more precisely, it imports the definition of the package
7288 bound to the @code{libreoffice} top-level attribute):
7289
7290 @example
7291 guix import nix ~/path/to/nixpkgs libreoffice
7292 @end example
7293
7294 @item hackage
7295 @cindex hackage
7296 Import metadata from the Haskell community's central package archive
7297 @uref{https://hackage.haskell.org/, Hackage}. Information is taken from
7298 Cabal files and includes all the relevant information, including package
7299 dependencies.
7300
7301 Specific command-line options are:
7302
7303 @table @code
7304 @item --stdin
7305 @itemx -s
7306 Read a Cabal file from standard input.
7307 @item --no-test-dependencies
7308 @itemx -t
7309 Do not include dependencies required only by the test suites.
7310 @item --cabal-environment=@var{alist}
7311 @itemx -e @var{alist}
7312 @var{alist} is a Scheme alist defining the environment in which the
7313 Cabal conditionals are evaluated. The accepted keys are: @code{os},
7314 @code{arch}, @code{impl} and a string representing the name of a flag.
7315 The value associated with a flag has to be either the symbol
7316 @code{true} or @code{false}. The value associated with other keys
7317 has to conform to the Cabal file format definition. The default value
7318 associated with the keys @code{os}, @code{arch} and @code{impl} is
7319 @samp{linux}, @samp{x86_64} and @samp{ghc}, respectively.
7320 @item --recursive
7321 @itemx -r
7322 Traverse the dependency graph of the given upstream package recursively
7323 and generate package expressions for all those packages that are not yet
7324 in Guix.
7325 @end table
7326
7327 The command below imports metadata for the latest version of the
7328 @code{HTTP} Haskell package without including test dependencies and
7329 specifying the value of the flag @samp{network-uri} as @code{false}:
7330
7331 @example
7332 guix import hackage -t -e "'((\"network-uri\" . false))" HTTP
7333 @end example
7334
7335 A specific package version may optionally be specified by following the
7336 package name by an at-sign and a version number as in the following example:
7337
7338 @example
7339 guix import hackage mtl@@2.1.3.1
7340 @end example
7341
7342 @item stackage
7343 @cindex stackage
7344 The @code{stackage} importer is a wrapper around the @code{hackage} one.
7345 It takes a package name, looks up the package version included in a
7346 long-term support (LTS) @uref{https://www.stackage.org, Stackage}
7347 release and uses the @code{hackage} importer to retrieve its metadata.
7348 Note that it is up to you to select an LTS release compatible with the
7349 GHC compiler used by Guix.
7350
7351 Specific command-line options are:
7352
7353 @table @code
7354 @item --no-test-dependencies
7355 @itemx -t
7356 Do not include dependencies required only by the test suites.
7357 @item --lts-version=@var{version}
7358 @itemx -l @var{version}
7359 @var{version} is the desired LTS release version. If omitted the latest
7360 release is used.
7361 @item --recursive
7362 @itemx -r
7363 Traverse the dependency graph of the given upstream package recursively
7364 and generate package expressions for all those packages that are not yet
7365 in Guix.
7366 @end table
7367
7368 The command below imports metadata for the @code{HTTP} Haskell package
7369 included in the LTS Stackage release version 7.18:
7370
7371 @example
7372 guix import stackage --lts-version=7.18 HTTP
7373 @end example
7374
7375 @item elpa
7376 @cindex elpa
7377 Import metadata from an Emacs Lisp Package Archive (ELPA) package
7378 repository (@pxref{Packages,,, emacs, The GNU Emacs Manual}).
7379
7380 Specific command-line options are:
7381
7382 @table @code
7383 @item --archive=@var{repo}
7384 @itemx -a @var{repo}
7385 @var{repo} identifies the archive repository from which to retrieve the
7386 information. Currently the supported repositories and their identifiers
7387 are:
7388 @itemize -
7389 @item
7390 @uref{http://elpa.gnu.org/packages, GNU}, selected by the @code{gnu}
7391 identifier. This is the default.
7392
7393 Packages from @code{elpa.gnu.org} are signed with one of the keys
7394 contained in the GnuPG keyring at
7395 @file{share/emacs/25.1/etc/package-keyring.gpg} (or similar) in the
7396 @code{emacs} package (@pxref{Package Installation, ELPA package
7397 signatures,, emacs, The GNU Emacs Manual}).
7398
7399 @item
7400 @uref{http://stable.melpa.org/packages, MELPA-Stable}, selected by the
7401 @code{melpa-stable} identifier.
7402
7403 @item
7404 @uref{http://melpa.org/packages, MELPA}, selected by the @code{melpa}
7405 identifier.
7406 @end itemize
7407
7408 @item --recursive
7409 @itemx -r
7410 Traverse the dependency graph of the given upstream package recursively
7411 and generate package expressions for all those packages that are not yet
7412 in Guix.
7413 @end table
7414
7415 @item crate
7416 @cindex crate
7417 Import metadata from the crates.io Rust package repository
7418 @uref{https://crates.io, crates.io}.
7419
7420 @item opam
7421 @cindex OPAM
7422 @cindex OCaml
7423 Import metadata from the @uref{https://opam.ocaml.org/, OPAM} package
7424 repository used by the OCaml community.
7425 @end table
7426
7427 The structure of the @command{guix import} code is modular. It would be
7428 useful to have more importers for other package formats, and your help
7429 is welcome here (@pxref{Contributing}).
7430
7431 @node Invoking guix refresh
7432 @section Invoking @command{guix refresh}
7433
7434 @cindex @command {guix refresh}
7435 The primary audience of the @command{guix refresh} command is developers
7436 of the GNU software distribution. By default, it reports any packages
7437 provided by the distribution that are outdated compared to the latest
7438 upstream version, like this:
7439
7440 @example
7441 $ guix refresh
7442 gnu/packages/gettext.scm:29:13: gettext would be upgraded from 0.18.1.1 to 0.18.2.1
7443 gnu/packages/glib.scm:77:12: glib would be upgraded from 2.34.3 to 2.37.0
7444 @end example
7445
7446 Alternately, one can specify packages to consider, in which case a
7447 warning is emitted for packages that lack an updater:
7448
7449 @example
7450 $ guix refresh coreutils guile guile-ssh
7451 gnu/packages/ssh.scm:205:2: warning: no updater for guile-ssh
7452 gnu/packages/guile.scm:136:12: guile would be upgraded from 2.0.12 to 2.0.13
7453 @end example
7454
7455 @command{guix refresh} browses the upstream repository of each package and determines
7456 the highest version number of the releases therein. The command
7457 knows how to update specific types of packages: GNU packages, ELPA
7458 packages, etc.---see the documentation for @option{--type} below. There
7459 are many packages, though, for which it lacks a method to determine
7460 whether a new upstream release is available. However, the mechanism is
7461 extensible, so feel free to get in touch with us to add a new method!
7462
7463 @table @code
7464
7465 @item --recursive
7466 Consider the packages specified, and all the packages upon which they depend.
7467
7468 @example
7469 $ guix refresh --recursive coreutils
7470 gnu/packages/acl.scm:35:2: warning: no updater for acl
7471 gnu/packages/m4.scm:30:12: info: 1.4.18 is already the latest version of m4
7472 gnu/packages/xml.scm:68:2: warning: no updater for expat
7473 gnu/packages/multiprecision.scm:40:12: info: 6.1.2 is already the latest version of gmp
7474 @dots{}
7475 @end example
7476
7477 @end table
7478
7479 Sometimes the upstream name differs from the package name used in Guix,
7480 and @command{guix refresh} needs a little help. Most updaters honor the
7481 @code{upstream-name} property in package definitions, which can be used
7482 to that effect:
7483
7484 @example
7485 (define-public network-manager
7486 (package
7487 (name "network-manager")
7488 ;; @dots{}
7489 (properties '((upstream-name . "NetworkManager")))))
7490 @end example
7491
7492 When passed @code{--update}, it modifies distribution source files to
7493 update the version numbers and source tarball hashes of those package
7494 recipes (@pxref{Defining Packages}). This is achieved by downloading
7495 each package's latest source tarball and its associated OpenPGP
7496 signature, authenticating the downloaded tarball against its signature
7497 using @command{gpg}, and finally computing its hash. When the public
7498 key used to sign the tarball is missing from the user's keyring, an
7499 attempt is made to automatically retrieve it from a public key server;
7500 when this is successful, the key is added to the user's keyring; otherwise,
7501 @command{guix refresh} reports an error.
7502
7503 The following options are supported:
7504
7505 @table @code
7506
7507 @item --expression=@var{expr}
7508 @itemx -e @var{expr}
7509 Consider the package @var{expr} evaluates to.
7510
7511 This is useful to precisely refer to a package, as in this example:
7512
7513 @example
7514 guix refresh -l -e '(@@@@ (gnu packages commencement) glibc-final)'
7515 @end example
7516
7517 This command lists the dependents of the ``final'' libc (essentially all
7518 the packages.)
7519
7520 @item --update
7521 @itemx -u
7522 Update distribution source files (package recipes) in place. This is
7523 usually run from a checkout of the Guix source tree (@pxref{Running
7524 Guix Before It Is Installed}):
7525
7526 @example
7527 $ ./pre-inst-env guix refresh -s non-core -u
7528 @end example
7529
7530 @xref{Defining Packages}, for more information on package definitions.
7531
7532 @item --select=[@var{subset}]
7533 @itemx -s @var{subset}
7534 Select all the packages in @var{subset}, one of @code{core} or
7535 @code{non-core}.
7536
7537 The @code{core} subset refers to all the packages at the core of the
7538 distribution---i.e., packages that are used to build ``everything
7539 else''. This includes GCC, libc, Binutils, Bash, etc. Usually,
7540 changing one of these packages in the distribution entails a rebuild of
7541 all the others. Thus, such updates are an inconvenience to users in
7542 terms of build time or bandwidth used to achieve the upgrade.
7543
7544 The @code{non-core} subset refers to the remaining packages. It is
7545 typically useful in cases where an update of the core packages would be
7546 inconvenient.
7547
7548 @item --manifest=@var{file}
7549 @itemx -m @var{file}
7550 Select all the packages from the manifest in @var{file}. This is useful to
7551 check if any packages of the user manifest can be updated.
7552
7553 @item --type=@var{updater}
7554 @itemx -t @var{updater}
7555 Select only packages handled by @var{updater} (may be a comma-separated
7556 list of updaters). Currently, @var{updater} may be one of:
7557
7558 @table @code
7559 @item gnu
7560 the updater for GNU packages;
7561 @item gnome
7562 the updater for GNOME packages;
7563 @item kde
7564 the updater for KDE packages;
7565 @item xorg
7566 the updater for X.org packages;
7567 @item kernel.org
7568 the updater for packages hosted on kernel.org;
7569 @item elpa
7570 the updater for @uref{http://elpa.gnu.org/, ELPA} packages;
7571 @item cran
7572 the updater for @uref{https://cran.r-project.org/, CRAN} packages;
7573 @item bioconductor
7574 the updater for @uref{https://www.bioconductor.org/, Bioconductor} R packages;
7575 @item cpan
7576 the updater for @uref{http://www.cpan.org/, CPAN} packages;
7577 @item pypi
7578 the updater for @uref{https://pypi.python.org, PyPI} packages.
7579 @item gem
7580 the updater for @uref{https://rubygems.org, RubyGems} packages.
7581 @item github
7582 the updater for @uref{https://github.com, GitHub} packages.
7583 @item hackage
7584 the updater for @uref{https://hackage.haskell.org, Hackage} packages.
7585 @item stackage
7586 the updater for @uref{https://www.stackage.org, Stackage} packages.
7587 @item crate
7588 the updater for @uref{https://crates.io, Crates} packages.
7589 @end table
7590
7591 For instance, the following command only checks for updates of Emacs
7592 packages hosted at @code{elpa.gnu.org} and for updates of CRAN packages:
7593
7594 @example
7595 $ guix refresh --type=elpa,cran
7596 gnu/packages/statistics.scm:819:13: r-testthat would be upgraded from 0.10.0 to 0.11.0
7597 gnu/packages/emacs.scm:856:13: emacs-auctex would be upgraded from 11.88.6 to 11.88.9
7598 @end example
7599
7600 @end table
7601
7602 In addition, @command{guix refresh} can be passed one or more package
7603 names, as in this example:
7604
7605 @example
7606 $ ./pre-inst-env guix refresh -u emacs idutils gcc@@4.8
7607 @end example
7608
7609 @noindent
7610 The command above specifically updates the @code{emacs} and
7611 @code{idutils} packages. The @code{--select} option would have no
7612 effect in this case.
7613
7614 When considering whether to upgrade a package, it is sometimes
7615 convenient to know which packages would be affected by the upgrade and
7616 should be checked for compatibility. For this the following option may
7617 be used when passing @command{guix refresh} one or more package names:
7618
7619 @table @code
7620
7621 @item --list-updaters
7622 @itemx -L
7623 List available updaters and exit (see @option{--type} above.)
7624
7625 For each updater, display the fraction of packages it covers; at the
7626 end, display the fraction of packages covered by all these updaters.
7627
7628 @item --list-dependent
7629 @itemx -l
7630 List top-level dependent packages that would need to be rebuilt as a
7631 result of upgrading one or more packages.
7632
7633 @xref{Invoking guix graph, the @code{reverse-package} type of
7634 @command{guix graph}}, for information on how to visualize the list of
7635 dependents of a package.
7636
7637 @end table
7638
7639 Be aware that the @code{--list-dependent} option only
7640 @emph{approximates} the rebuilds that would be required as a result of
7641 an upgrade. More rebuilds might be required under some circumstances.
7642
7643 @example
7644 $ guix refresh --list-dependent flex
7645 Building the following 120 packages would ensure 213 dependent packages are rebuilt:
7646 hop@@2.4.0 geiser@@0.4 notmuch@@0.18 mu@@0.9.9.5 cflow@@1.4 idutils@@4.6 @dots{}
7647 @end example
7648
7649 The command above lists a set of packages that could be built to check
7650 for compatibility with an upgraded @code{flex} package.
7651
7652 @table @code
7653
7654 @item --list-transitive
7655 List all the packages which one or more packages depend upon.
7656
7657 @example
7658 $ guix refresh --list-transitive flex
7659 flex@@2.6.4 depends on the following 25 packages: perl@@5.28.0 help2man@@1.47.6
7660 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{}
7661 @end example
7662
7663 @end table
7664
7665 The command above lists a set of packages which, when changed, would cause
7666 @code{flex} to be rebuilt.
7667
7668 The following options can be used to customize GnuPG operation:
7669
7670 @table @code
7671
7672 @item --gpg=@var{command}
7673 Use @var{command} as the GnuPG 2.x command. @var{command} is searched
7674 for in @code{$PATH}.
7675
7676 @item --keyring=@var{file}
7677 Use @var{file} as the keyring for upstream keys. @var{file} must be in the
7678 @dfn{keybox format}. Keybox files usually have a name ending in @file{.kbx}
7679 and the GNU@tie{}Privacy Guard (GPG) can manipulate these files
7680 (@pxref{kbxutil, @command{kbxutil},, gnupg, Using the GNU Privacy Guard}, for
7681 information on a tool to manipulate keybox files).
7682
7683 When this option is omitted, @command{guix refresh} uses
7684 @file{~/.config/guix/upstream/trustedkeys.kbx} as the keyring for upstream
7685 signing keys. OpenPGP signatures are checked against keys from this keyring;
7686 missing keys are downloaded to this keyring as well (see
7687 @option{--key-download} below.)
7688
7689 You can export keys from your default GPG keyring into a keybox file using
7690 commands like this one:
7691
7692 @example
7693 gpg --export rms@@gnu.org | kbxutil --import-openpgp >> mykeyring.kbx
7694 @end example
7695
7696 Likewise, you can fetch keys to a specific keybox file like this:
7697
7698 @example
7699 gpg --no-default-keyring --keyring mykeyring.kbx \
7700 --recv-keys @value{OPENPGP-SIGNING-KEY-ID}
7701 @end example
7702
7703 @ref{GPG Configuration Options, @option{--keyring},, gnupg, Using the GNU
7704 Privacy Guard}, for more information on GPG's @option{--keyring} option.
7705
7706 @item --key-download=@var{policy}
7707 Handle missing OpenPGP keys according to @var{policy}, which may be one
7708 of:
7709
7710 @table @code
7711 @item always
7712 Always download missing OpenPGP keys from the key server, and add them
7713 to the user's GnuPG keyring.
7714
7715 @item never
7716 Never try to download missing OpenPGP keys. Instead just bail out.
7717
7718 @item interactive
7719 When a package signed with an unknown OpenPGP key is encountered, ask
7720 the user whether to download it or not. This is the default behavior.
7721 @end table
7722
7723 @item --key-server=@var{host}
7724 Use @var{host} as the OpenPGP key server when importing a public key.
7725
7726 @end table
7727
7728 The @code{github} updater uses the
7729 @uref{https://developer.github.com/v3/, GitHub API} to query for new
7730 releases. When used repeatedly e.g.@: when refreshing all packages,
7731 GitHub will eventually refuse to answer any further API requests. By
7732 default 60 API requests per hour are allowed, and a full refresh on all
7733 GitHub packages in Guix requires more than this. Authentication with
7734 GitHub through the use of an API token alleviates these limits. To use
7735 an API token, set the environment variable @code{GUIX_GITHUB_TOKEN} to a
7736 token procured from @uref{https://github.com/settings/tokens} or
7737 otherwise.
7738
7739
7740 @node Invoking guix lint
7741 @section Invoking @command{guix lint}
7742
7743 @cindex @command{guix lint}
7744 @cindex package, checking for errors
7745 The @command{guix lint} command is meant to help package developers avoid
7746 common errors and use a consistent style. It runs a number of checks on
7747 a given set of packages in order to find common mistakes in their
7748 definitions. Available @dfn{checkers} include (see
7749 @code{--list-checkers} for a complete list):
7750
7751 @table @code
7752 @item synopsis
7753 @itemx description
7754 Validate certain typographical and stylistic rules about package
7755 descriptions and synopses.
7756
7757 @item inputs-should-be-native
7758 Identify inputs that should most likely be native inputs.
7759
7760 @item source
7761 @itemx home-page
7762 @itemx mirror-url
7763 @itemx github-url
7764 @itemx source-file-name
7765 Probe @code{home-page} and @code{source} URLs and report those that are
7766 invalid. Suggest a @code{mirror://} URL when applicable. If the
7767 @code{source} URL redirects to a GitHub URL, recommend usage of the GitHub
7768 URL. Check that the source file name is meaningful, e.g.@: is not just a
7769 version number or ``git-checkout'', without a declared @code{file-name}
7770 (@pxref{origin Reference}).
7771
7772 @item source-unstable-tarball
7773 Parse the @code{source} URL to determine if a tarball from GitHub is
7774 autogenerated or if it is a release tarball. Unfortunately GitHub's
7775 autogenerated tarballs are sometimes regenerated.
7776
7777 @item cve
7778 @cindex security vulnerabilities
7779 @cindex CVE, Common Vulnerabilities and Exposures
7780 Report known vulnerabilities found in the Common Vulnerabilities and
7781 Exposures (CVE) databases of the current and past year
7782 @uref{https://nvd.nist.gov/download.cfm#CVE_FEED, published by the US
7783 NIST}.
7784
7785 To view information about a particular vulnerability, visit pages such as:
7786
7787 @itemize
7788 @item
7789 @indicateurl{https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-YYYY-ABCD}
7790 @item
7791 @indicateurl{https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-YYYY-ABCD}
7792 @end itemize
7793
7794 @noindent
7795 where @code{CVE-YYYY-ABCD} is the CVE identifier---e.g.,
7796 @code{CVE-2015-7554}.
7797
7798 Package developers can specify in package recipes the
7799 @uref{https://nvd.nist.gov/cpe.cfm,Common Platform Enumeration (CPE)}
7800 name and version of the package when they differ from the name or version
7801 that Guix uses, as in this example:
7802
7803 @example
7804 (package
7805 (name "grub")
7806 ;; @dots{}
7807 ;; CPE calls this package "grub2".
7808 (properties '((cpe-name . "grub2")
7809 (cpe-version . "2.3")))
7810 @end example
7811
7812 @c See <http://www.openwall.com/lists/oss-security/2017/03/15/3>.
7813 Some entries in the CVE database do not specify which version of a
7814 package they apply to, and would thus ``stick around'' forever. Package
7815 developers who found CVE alerts and verified they can be ignored can
7816 declare them as in this example:
7817
7818 @example
7819 (package
7820 (name "t1lib")
7821 ;; @dots{}
7822 ;; These CVEs no longer apply and can be safely ignored.
7823 (properties `((lint-hidden-cve . ("CVE-2011-0433"
7824 "CVE-2011-1553"
7825 "CVE-2011-1554"
7826 "CVE-2011-5244")))))
7827 @end example
7828
7829 @item formatting
7830 Warn about obvious source code formatting issues: trailing white space,
7831 use of tabulations, etc.
7832 @end table
7833
7834 The general syntax is:
7835
7836 @example
7837 guix lint @var{options} @var{package}@dots{}
7838 @end example
7839
7840 If no package is given on the command line, then all packages are checked.
7841 The @var{options} may be zero or more of the following:
7842
7843 @table @code
7844 @item --list-checkers
7845 @itemx -l
7846 List and describe all the available checkers that will be run on packages
7847 and exit.
7848
7849 @item --checkers
7850 @itemx -c
7851 Only enable the checkers specified in a comma-separated list using the
7852 names returned by @code{--list-checkers}.
7853
7854 @end table
7855
7856 @node Invoking guix size
7857 @section Invoking @command{guix size}
7858
7859 @cindex size
7860 @cindex package size
7861 @cindex closure
7862 @cindex @command{guix size}
7863 The @command{guix size} command helps package developers profile the
7864 disk usage of packages. It is easy to overlook the impact of an
7865 additional dependency added to a package, or the impact of using a
7866 single output for a package that could easily be split (@pxref{Packages
7867 with Multiple Outputs}). Such are the typical issues that
7868 @command{guix size} can highlight.
7869
7870 The command can be passed one or more package specifications
7871 such as @code{gcc@@4.8}
7872 or @code{guile:debug}, or a file name in the store. Consider this
7873 example:
7874
7875 @example
7876 $ guix size coreutils
7877 store item total self
7878 /gnu/store/@dots{}-gcc-5.5.0-lib 60.4 30.1 38.1%
7879 /gnu/store/@dots{}-glibc-2.27 30.3 28.8 36.6%
7880 /gnu/store/@dots{}-coreutils-8.28 78.9 15.0 19.0%
7881 /gnu/store/@dots{}-gmp-6.1.2 63.1 2.7 3.4%
7882 /gnu/store/@dots{}-bash-static-4.4.12 1.5 1.5 1.9%
7883 /gnu/store/@dots{}-acl-2.2.52 61.1 0.4 0.5%
7884 /gnu/store/@dots{}-attr-2.4.47 60.6 0.2 0.3%
7885 /gnu/store/@dots{}-libcap-2.25 60.5 0.2 0.2%
7886 total: 78.9 MiB
7887 @end example
7888
7889 @cindex closure
7890 The store items listed here constitute the @dfn{transitive closure} of
7891 Coreutils---i.e., Coreutils and all its dependencies, recursively---as
7892 would be returned by:
7893
7894 @example
7895 $ guix gc -R /gnu/store/@dots{}-coreutils-8.23
7896 @end example
7897
7898 Here the output shows three columns next to store items. The first column,
7899 labeled ``total'', shows the size in mebibytes (MiB) of the closure of
7900 the store item---that is, its own size plus the size of all its
7901 dependencies. The next column, labeled ``self'', shows the size of the
7902 item itself. The last column shows the ratio of the size of the item
7903 itself to the space occupied by all the items listed here.
7904
7905 In this example, we see that the closure of Coreutils weighs in at
7906 79@tie{}MiB, most of which is taken by libc and GCC's run-time support
7907 libraries. (That libc and GCC's libraries represent a large fraction of
7908 the closure is not a problem @i{per se} because they are always available
7909 on the system anyway.)
7910
7911 When the package(s) passed to @command{guix size} are available in the
7912 store@footnote{More precisely, @command{guix size} looks for the
7913 @emph{ungrafted} variant of the given package(s), as returned by
7914 @code{guix build @var{package} --no-grafts}. @xref{Security Updates},
7915 for information on grafts.}, @command{guix size} queries the daemon to determine its
7916 dependencies, and measures its size in the store, similar to @command{du
7917 -ms --apparent-size} (@pxref{du invocation,,, coreutils, GNU
7918 Coreutils}).
7919
7920 When the given packages are @emph{not} in the store, @command{guix size}
7921 reports information based on the available substitutes
7922 (@pxref{Substitutes}). This makes it possible it to profile disk usage of
7923 store items that are not even on disk, only available remotely.
7924
7925 You can also specify several package names:
7926
7927 @example
7928 $ guix size coreutils grep sed bash
7929 store item total self
7930 /gnu/store/@dots{}-coreutils-8.24 77.8 13.8 13.4%
7931 /gnu/store/@dots{}-grep-2.22 73.1 0.8 0.8%
7932 /gnu/store/@dots{}-bash-4.3.42 72.3 4.7 4.6%
7933 /gnu/store/@dots{}-readline-6.3 67.6 1.2 1.2%
7934 @dots{}
7935 total: 102.3 MiB
7936 @end example
7937
7938 @noindent
7939 In this example we see that the combination of the four packages takes
7940 102.3@tie{}MiB in total, which is much less than the sum of each closure
7941 since they have a lot of dependencies in common.
7942
7943 The available options are:
7944
7945 @table @option
7946
7947 @item --substitute-urls=@var{urls}
7948 Use substitute information from @var{urls}.
7949 @xref{client-substitute-urls, the same option for @code{guix build}}.
7950
7951 @item --sort=@var{key}
7952 Sort lines according to @var{key}, one of the following options:
7953
7954 @table @code
7955 @item self
7956 the size of each item (the default);
7957 @item closure
7958 the total size of the item's closure.
7959 @end table
7960
7961 @item --map-file=@var{file}
7962 Write a graphical map of disk usage in PNG format to @var{file}.
7963
7964 For the example above, the map looks like this:
7965
7966 @image{images/coreutils-size-map,5in,, map of Coreutils disk usage
7967 produced by @command{guix size}}
7968
7969 This option requires that
7970 @uref{http://wingolog.org/software/guile-charting/, Guile-Charting} be
7971 installed and visible in Guile's module search path. When that is not
7972 the case, @command{guix size} fails as it tries to load it.
7973
7974 @item --system=@var{system}
7975 @itemx -s @var{system}
7976 Consider packages for @var{system}---e.g., @code{x86_64-linux}.
7977
7978 @end table
7979
7980 @node Invoking guix graph
7981 @section Invoking @command{guix graph}
7982
7983 @cindex DAG
7984 @cindex @command{guix graph}
7985 @cindex package dependencies
7986 Packages and their dependencies form a @dfn{graph}, specifically a
7987 directed acyclic graph (DAG). It can quickly become difficult to have a
7988 mental model of the package DAG, so the @command{guix graph} command
7989 provides a visual representation of the DAG. By default,
7990 @command{guix graph} emits a DAG representation in the input format of
7991 @uref{http://www.graphviz.org/, Graphviz}, so its output can be passed
7992 directly to the @command{dot} command of Graphviz. It can also emit an
7993 HTML page with embedded JavaScript code to display a ``chord diagram''
7994 in a Web browser, using the @uref{https://d3js.org/, d3.js} library, or
7995 emit Cypher queries to construct a graph in a graph database supporting
7996 the @uref{http://www.opencypher.org/, openCypher} query language.
7997 The general syntax is:
7998
7999 @example
8000 guix graph @var{options} @var{package}@dots{}
8001 @end example
8002
8003 For example, the following command generates a PDF file representing the
8004 package DAG for the GNU@tie{}Core Utilities, showing its build-time
8005 dependencies:
8006
8007 @example
8008 guix graph coreutils | dot -Tpdf > dag.pdf
8009 @end example
8010
8011 The output looks like this:
8012
8013 @image{images/coreutils-graph,2in,,Dependency graph of the GNU Coreutils}
8014
8015 Nice little graph, no?
8016
8017 But there is more than one graph! The one above is concise: it is the
8018 graph of package objects, omitting implicit inputs such as GCC, libc,
8019 grep, etc. It is often useful to have such a concise graph, but
8020 sometimes one may want to see more details. @command{guix graph} supports
8021 several types of graphs, allowing you to choose the level of detail:
8022
8023 @table @code
8024 @item package
8025 This is the default type used in the example above. It shows the DAG of
8026 package objects, excluding implicit dependencies. It is concise, but
8027 filters out many details.
8028
8029 @item reverse-package
8030 This shows the @emph{reverse} DAG of packages. For example:
8031
8032 @example
8033 guix graph --type=reverse-package ocaml
8034 @end example
8035
8036 ...@: yields the graph of packages that depend on OCaml.
8037
8038 Note that for core packages this can yield huge graphs. If all you want
8039 is to know the number of packages that depend on a given package, use
8040 @command{guix refresh --list-dependent} (@pxref{Invoking guix refresh,
8041 @option{--list-dependent}}).
8042
8043 @item bag-emerged
8044 This is the package DAG, @emph{including} implicit inputs.
8045
8046 For instance, the following command:
8047
8048 @example
8049 guix graph --type=bag-emerged coreutils | dot -Tpdf > dag.pdf
8050 @end example
8051
8052 ...@: yields this bigger graph:
8053
8054 @image{images/coreutils-bag-graph,,5in,Detailed dependency graph of the GNU Coreutils}
8055
8056 At the bottom of the graph, we see all the implicit inputs of
8057 @var{gnu-build-system} (@pxref{Build Systems, @code{gnu-build-system}}).
8058
8059 Now, note that the dependencies of these implicit inputs---that is, the
8060 @dfn{bootstrap dependencies} (@pxref{Bootstrapping})---are not shown
8061 here, for conciseness.
8062
8063 @item bag
8064 Similar to @code{bag-emerged}, but this time including all the bootstrap
8065 dependencies.
8066
8067 @item bag-with-origins
8068 Similar to @code{bag}, but also showing origins and their dependencies.
8069
8070 @item derivation
8071 This is the most detailed representation: It shows the DAG of
8072 derivations (@pxref{Derivations}) and plain store items. Compared to
8073 the above representation, many additional nodes are visible, including
8074 build scripts, patches, Guile modules, etc.
8075
8076 For this type of graph, it is also possible to pass a @file{.drv} file
8077 name instead of a package name, as in:
8078
8079 @example
8080 guix graph -t derivation `guix system build -d my-config.scm`
8081 @end example
8082
8083 @item module
8084 This is the graph of @dfn{package modules} (@pxref{Package Modules}).
8085 For example, the following command shows the graph for the package
8086 module that defines the @code{guile} package:
8087
8088 @example
8089 guix graph -t module guile | dot -Tpdf > module-graph.pdf
8090 @end example
8091 @end table
8092
8093 All the types above correspond to @emph{build-time dependencies}. The
8094 following graph type represents the @emph{run-time dependencies}:
8095
8096 @table @code
8097 @item references
8098 This is the graph of @dfn{references} of a package output, as returned
8099 by @command{guix gc --references} (@pxref{Invoking guix gc}).
8100
8101 If the given package output is not available in the store, @command{guix
8102 graph} attempts to obtain dependency information from substitutes.
8103
8104 Here you can also pass a store file name instead of a package name. For
8105 example, the command below produces the reference graph of your profile
8106 (which can be big!):
8107
8108 @example
8109 guix graph -t references `readlink -f ~/.guix-profile`
8110 @end example
8111
8112 @item referrers
8113 This is the graph of the @dfn{referrers} of a store item, as returned by
8114 @command{guix gc --referrers} (@pxref{Invoking guix gc}).
8115
8116 This relies exclusively on local information from your store. For
8117 instance, let us suppose that the current Inkscape is available in 10
8118 profiles on your machine; @command{guix graph -t referrers inkscape}
8119 will show a graph rooted at Inkscape and with those 10 profiles linked
8120 to it.
8121
8122 It can help determine what is preventing a store item from being garbage
8123 collected.
8124
8125 @end table
8126
8127 The available options are the following:
8128
8129 @table @option
8130 @item --type=@var{type}
8131 @itemx -t @var{type}
8132 Produce a graph output of @var{type}, where @var{type} must be one of
8133 the values listed above.
8134
8135 @item --list-types
8136 List the supported graph types.
8137
8138 @item --backend=@var{backend}
8139 @itemx -b @var{backend}
8140 Produce a graph using the selected @var{backend}.
8141
8142 @item --list-backends
8143 List the supported graph backends.
8144
8145 Currently, the available backends are Graphviz and d3.js.
8146
8147 @item --expression=@var{expr}
8148 @itemx -e @var{expr}
8149 Consider the package @var{expr} evaluates to.
8150
8151 This is useful to precisely refer to a package, as in this example:
8152
8153 @example
8154 guix graph -e '(@@@@ (gnu packages commencement) gnu-make-final)'
8155 @end example
8156
8157 @item --system=@var{system}
8158 @itemx -s @var{system}
8159 Display the graph for @var{system}---e.g., @code{i686-linux}.
8160
8161 The package dependency graph is largely architecture-independent, but there
8162 are some architecture-dependent bits that this option allows you to visualize.
8163 @end table
8164
8165
8166 @node Invoking guix environment
8167 @section Invoking @command{guix environment}
8168
8169 @cindex reproducible build environments
8170 @cindex development environments
8171 @cindex @command{guix environment}
8172 @cindex environment, package build environment
8173 The purpose of @command{guix environment} is to assist hackers in
8174 creating reproducible development environments without polluting their
8175 package profile. The @command{guix environment} tool takes one or more
8176 packages, builds all of their inputs, and creates a shell
8177 environment to use them.
8178
8179 The general syntax is:
8180
8181 @example
8182 guix environment @var{options} @var{package}@dots{}
8183 @end example
8184
8185 The following example spawns a new shell set up for the development of
8186 GNU@tie{}Guile:
8187
8188 @example
8189 guix environment guile
8190 @end example
8191
8192 If the needed dependencies are not built yet, @command{guix environment}
8193 automatically builds them. The environment of the new shell is an augmented
8194 version of the environment that @command{guix environment} was run in.
8195 It contains the necessary search paths for building the given package
8196 added to the existing environment variables. To create a ``pure''
8197 environment, in which the original environment variables have been unset,
8198 use the @code{--pure} option@footnote{Users sometimes wrongfully augment
8199 environment variables such as @code{PATH} in their @file{~/.bashrc}
8200 file. As a consequence, when @code{guix environment} launches it, Bash
8201 may read @file{~/.bashrc}, thereby introducing ``impurities'' in these
8202 environment variables. It is an error to define such environment
8203 variables in @file{.bashrc}; instead, they should be defined in
8204 @file{.bash_profile}, which is sourced only by log-in shells.
8205 @xref{Bash Startup Files,,, bash, The GNU Bash Reference Manual}, for
8206 details on Bash start-up files.}.
8207
8208 @vindex GUIX_ENVIRONMENT
8209 @command{guix environment} defines the @code{GUIX_ENVIRONMENT}
8210 variable in the shell it spawns; its value is the file name of the
8211 profile of this environment. This allows users to, say, define a
8212 specific prompt for development environments in their @file{.bashrc}
8213 (@pxref{Bash Startup Files,,, bash, The GNU Bash Reference Manual}):
8214
8215 @example
8216 if [ -n "$GUIX_ENVIRONMENT" ]
8217 then
8218 export PS1="\u@@\h \w [dev]\$ "
8219 fi
8220 @end example
8221
8222 @noindent
8223 ...@: or to browse the profile:
8224
8225 @example
8226 $ ls "$GUIX_ENVIRONMENT/bin"
8227 @end example
8228
8229 Additionally, more than one package may be specified, in which case the
8230 union of the inputs for the given packages are used. For example, the
8231 command below spawns a shell where all of the dependencies of both Guile
8232 and Emacs are available:
8233
8234 @example
8235 guix environment guile emacs
8236 @end example
8237
8238 Sometimes an interactive shell session is not desired. An arbitrary
8239 command may be invoked by placing the @code{--} token to separate the
8240 command from the rest of the arguments:
8241
8242 @example
8243 guix environment guile -- make -j4
8244 @end example
8245
8246 In other situations, it is more convenient to specify the list of
8247 packages needed in the environment. For example, the following command
8248 runs @command{python} from an environment containing Python@tie{}2.7 and
8249 NumPy:
8250
8251 @example
8252 guix environment --ad-hoc python2-numpy python-2.7 -- python
8253 @end example
8254
8255 Furthermore, one might want the dependencies of a package and also some
8256 additional packages that are not build-time or runtime dependencies, but
8257 are useful when developing nonetheless. Because of this, the
8258 @code{--ad-hoc} flag is positional. Packages appearing before
8259 @code{--ad-hoc} are interpreted as packages whose dependencies will be
8260 added to the environment. Packages appearing after are interpreted as
8261 packages that will be added to the environment directly. For example,
8262 the following command creates a Guix development environment that
8263 additionally includes Git and strace:
8264
8265 @example
8266 guix environment guix --ad-hoc git strace
8267 @end example
8268
8269 Sometimes it is desirable to isolate the environment as much as
8270 possible, for maximal purity and reproducibility. In particular, when
8271 using Guix on a host distro that is not GuixSD, it is desirable to
8272 prevent access to @file{/usr/bin} and other system-wide resources from
8273 the development environment. For example, the following command spawns
8274 a Guile REPL in a ``container'' where only the store and the current
8275 working directory are mounted:
8276
8277 @example
8278 guix environment --ad-hoc --container guile -- guile
8279 @end example
8280
8281 @quotation Note
8282 The @code{--container} option requires Linux-libre 3.19 or newer.
8283 @end quotation
8284
8285 The available options are summarized below.
8286
8287 @table @code
8288 @item --root=@var{file}
8289 @itemx -r @var{file}
8290 @cindex persistent environment
8291 @cindex garbage collector root, for environments
8292 Make @var{file} a symlink to the profile for this environment, and
8293 register it as a garbage collector root.
8294
8295 This is useful if you want to protect your environment from garbage
8296 collection, to make it ``persistent''.
8297
8298 When this option is omitted, the environment is protected from garbage
8299 collection only for the duration of the @command{guix environment}
8300 session. This means that next time you recreate the same environment,
8301 you could have to rebuild or re-download packages. @xref{Invoking guix
8302 gc}, for more on GC roots.
8303
8304 @item --expression=@var{expr}
8305 @itemx -e @var{expr}
8306 Create an environment for the package or list of packages that
8307 @var{expr} evaluates to.
8308
8309 For example, running:
8310
8311 @example
8312 guix environment -e '(@@ (gnu packages maths) petsc-openmpi)'
8313 @end example
8314
8315 starts a shell with the environment for this specific variant of the
8316 PETSc package.
8317
8318 Running:
8319
8320 @example
8321 guix environment --ad-hoc -e '(@@ (gnu) %base-packages)'
8322 @end example
8323
8324 starts a shell with all the GuixSD base packages available.
8325
8326 The above commands only use the default output of the given packages.
8327 To select other outputs, two element tuples can be specified:
8328
8329 @example
8330 guix environment --ad-hoc -e '(list (@@ (gnu packages bash) bash) "include")'
8331 @end example
8332
8333 @item --load=@var{file}
8334 @itemx -l @var{file}
8335 Create an environment for the package or list of packages that the code
8336 within @var{file} evaluates to.
8337
8338 As an example, @var{file} might contain a definition like this
8339 (@pxref{Defining Packages}):
8340
8341 @example
8342 @verbatiminclude environment-gdb.scm
8343 @end example
8344
8345 @item --manifest=@var{file}
8346 @itemx -m @var{file}
8347 Create an environment for the packages contained in the manifest object
8348 returned by the Scheme code in @var{file}.
8349
8350 This is similar to the same-named option in @command{guix package}
8351 (@pxref{profile-manifest, @option{--manifest}}) and uses the same
8352 manifest files.
8353
8354 @item --ad-hoc
8355 Include all specified packages in the resulting environment, as if an
8356 @i{ad hoc} package were defined with them as inputs. This option is
8357 useful for quickly creating an environment without having to write a
8358 package expression to contain the desired inputs.
8359
8360 For instance, the command:
8361
8362 @example
8363 guix environment --ad-hoc guile guile-sdl -- guile
8364 @end example
8365
8366 runs @command{guile} in an environment where Guile and Guile-SDL are
8367 available.
8368
8369 Note that this example implicitly asks for the default output of
8370 @code{guile} and @code{guile-sdl}, but it is possible to ask for a
8371 specific output---e.g., @code{glib:bin} asks for the @code{bin} output
8372 of @code{glib} (@pxref{Packages with Multiple Outputs}).
8373
8374 This option may be composed with the default behavior of @command{guix
8375 environment}. Packages appearing before @code{--ad-hoc} are interpreted
8376 as packages whose dependencies will be added to the environment, the
8377 default behavior. Packages appearing after are interpreted as packages
8378 that will be added to the environment directly.
8379
8380 @item --pure
8381 Unset existing environment variables when building the new environment.
8382 This has the effect of creating an environment in which search paths
8383 only contain package inputs.
8384
8385 @item --search-paths
8386 Display the environment variable definitions that make up the
8387 environment.
8388
8389 @item --system=@var{system}
8390 @itemx -s @var{system}
8391 Attempt to build for @var{system}---e.g., @code{i686-linux}.
8392
8393 @item --container
8394 @itemx -C
8395 @cindex container
8396 Run @var{command} within an isolated container. The current working
8397 directory outside the container is mapped inside the container.
8398 Additionally, unless overridden with @code{--user}, a dummy home
8399 directory is created that matches the current user's home directory, and
8400 @file{/etc/passwd} is configured accordingly. The spawned process runs
8401 as the current user outside the container, but has root privileges in
8402 the context of the container.
8403
8404 @item --network
8405 @itemx -N
8406 For containers, share the network namespace with the host system.
8407 Containers created without this flag only have access to the loopback
8408 device.
8409
8410 @item --link-profile
8411 @itemx -P
8412 For containers, link the environment profile to
8413 @file{~/.guix-profile} within the container. This is equivalent to
8414 running the command @command{ln -s $GUIX_ENVIRONMENT ~/.guix-profile}
8415 within the container. Linking will fail and abort the environment if
8416 the directory already exists, which will certainly be the case if
8417 @command{guix environment} was invoked in the user's home directory.
8418
8419 Certain packages are configured to look in
8420 @code{~/.guix-profile} for configuration files and data;@footnote{For
8421 example, the @code{fontconfig} package inspects
8422 @file{~/.guix-profile/share/fonts} for additional fonts.}
8423 @code{--link-profile} allows these programs to behave as expected within
8424 the environment.
8425
8426 @item --user=@var{user}
8427 @itemx -u @var{user}
8428 For containers, use the username @var{user} in place of the current
8429 user. The generated @file{/etc/passwd} entry within the container will
8430 contain the name @var{user}; the home directory will be
8431 @file{/home/USER}; and no user GECOS data will be copied. @var{user}
8432 need not exist on the system.
8433
8434 Additionally, any shared or exposed path (see @code{--share} and
8435 @code{--expose} respectively) whose target is within the current user's
8436 home directory will be remapped relative to @file{/home/USER}; this
8437 includes the automatic mapping of the current working directory.
8438
8439 @example
8440 # will expose paths as /home/foo/wd, /home/foo/test, and /home/foo/target
8441 cd $HOME/wd
8442 guix environment --container --user=foo \
8443 --expose=$HOME/test \
8444 --expose=/tmp/target=$HOME/target
8445 @end example
8446
8447 While this will limit the leaking of user identity through home paths
8448 and each of the user fields, this is only one useful component of a
8449 broader privacy/anonymity solution---not one in and of itself.
8450
8451 @item --expose=@var{source}[=@var{target}]
8452 For containers, expose the file system @var{source} from the host system
8453 as the read-only file system @var{target} within the container. If
8454 @var{target} is not specified, @var{source} is used as the target mount
8455 point in the container.
8456
8457 The example below spawns a Guile REPL in a container in which the user's
8458 home directory is accessible read-only via the @file{/exchange}
8459 directory:
8460
8461 @example
8462 guix environment --container --expose=$HOME=/exchange --ad-hoc guile -- guile
8463 @end example
8464
8465 @item --share=@var{source}[=@var{target}]
8466 For containers, share the file system @var{source} from the host system
8467 as the writable file system @var{target} within the container. If
8468 @var{target} is not specified, @var{source} is used as the target mount
8469 point in the container.
8470
8471 The example below spawns a Guile REPL in a container in which the user's
8472 home directory is accessible for both reading and writing via the
8473 @file{/exchange} directory:
8474
8475 @example
8476 guix environment --container --share=$HOME=/exchange --ad-hoc guile -- guile
8477 @end example
8478 @end table
8479
8480 @command{guix environment}
8481 also supports all of the common build options that @command{guix
8482 build} supports (@pxref{Common Build Options}) as well as package
8483 transformation options (@pxref{Package Transformation Options}).
8484
8485
8486 @node Invoking guix publish
8487 @section Invoking @command{guix publish}
8488
8489 @cindex @command{guix publish}
8490 The purpose of @command{guix publish} is to enable users to easily share
8491 their store with others, who can then use it as a substitute server
8492 (@pxref{Substitutes}).
8493
8494 When @command{guix publish} runs, it spawns an HTTP server which allows
8495 anyone with network access to obtain substitutes from it. This means
8496 that any machine running Guix can also act as if it were a build farm,
8497 since the HTTP interface is compatible with Hydra, the software behind
8498 the @code{@value{SUBSTITUTE-SERVER}} build farm.
8499
8500 For security, each substitute is signed, allowing recipients to check
8501 their authenticity and integrity (@pxref{Substitutes}). Because
8502 @command{guix publish} uses the signing key of the system, which is only
8503 readable by the system administrator, it must be started as root; the
8504 @code{--user} option makes it drop root privileges early on.
8505
8506 The signing key pair must be generated before @command{guix publish} is
8507 launched, using @command{guix archive --generate-key} (@pxref{Invoking
8508 guix archive}).
8509
8510 The general syntax is:
8511
8512 @example
8513 guix publish @var{options}@dots{}
8514 @end example
8515
8516 Running @command{guix publish} without any additional arguments will
8517 spawn an HTTP server on port 8080:
8518
8519 @example
8520 guix publish
8521 @end example
8522
8523 Once a publishing server has been authorized (@pxref{Invoking guix
8524 archive}), the daemon may download substitutes from it:
8525
8526 @example
8527 guix-daemon --substitute-urls=http://example.org:8080
8528 @end example
8529
8530 By default, @command{guix publish} compresses archives on the fly as it
8531 serves them. This ``on-the-fly'' mode is convenient in that it requires
8532 no setup and is immediately available. However, when serving lots of
8533 clients, we recommend using the @option{--cache} option, which enables
8534 caching of the archives before they are sent to clients---see below for
8535 details. The @command{guix weather} command provides a handy way to
8536 check what a server provides (@pxref{Invoking guix weather}).
8537
8538 As a bonus, @command{guix publish} also serves as a content-addressed
8539 mirror for source files referenced in @code{origin} records
8540 (@pxref{origin Reference}). For instance, assuming @command{guix
8541 publish} is running on @code{example.org}, the following URL returns the
8542 raw @file{hello-2.10.tar.gz} file with the given SHA256 hash
8543 (represented in @code{nix-base32} format, @pxref{Invoking guix hash}):
8544
8545 @example
8546 http://example.org/file/hello-2.10.tar.gz/sha256/0ssi1@dots{}ndq1i
8547 @end example
8548
8549 Obviously, these URLs only work for files that are in the store; in
8550 other cases, they return 404 (``Not Found'').
8551
8552 @cindex build logs, publication
8553 Build logs are available from @code{/log} URLs like:
8554
8555 @example
8556 http://example.org/log/gwspk@dots{}-guile-2.2.3
8557 @end example
8558
8559 @noindent
8560 When @command{guix-daemon} is configured to save compressed build logs,
8561 as is the case by default (@pxref{Invoking guix-daemon}), @code{/log}
8562 URLs return the compressed log as-is, with an appropriate
8563 @code{Content-Type} and/or @code{Content-Encoding} header. We recommend
8564 running @command{guix-daemon} with @code{--log-compression=gzip} since
8565 Web browsers can automatically decompress it, which is not the case with
8566 bzip2 compression.
8567
8568 The following options are available:
8569
8570 @table @code
8571 @item --port=@var{port}
8572 @itemx -p @var{port}
8573 Listen for HTTP requests on @var{port}.
8574
8575 @item --listen=@var{host}
8576 Listen on the network interface for @var{host}. The default is to
8577 accept connections from any interface.
8578
8579 @item --user=@var{user}
8580 @itemx -u @var{user}
8581 Change privileges to @var{user} as soon as possible---i.e., once the
8582 server socket is open and the signing key has been read.
8583
8584 @item --compression[=@var{level}]
8585 @itemx -C [@var{level}]
8586 Compress data using the given @var{level}. When @var{level} is zero,
8587 disable compression. The range 1 to 9 corresponds to different gzip
8588 compression levels: 1 is the fastest, and 9 is the best (CPU-intensive).
8589 The default is 3.
8590
8591 Unless @option{--cache} is used, compression occurs on the fly and
8592 the compressed streams are not
8593 cached. Thus, to reduce load on the machine that runs @command{guix
8594 publish}, it may be a good idea to choose a low compression level, to
8595 run @command{guix publish} behind a caching proxy, or to use
8596 @option{--cache}. Using @option{--cache} has the advantage that it
8597 allows @command{guix publish} to add @code{Content-Length} HTTP header
8598 to its responses.
8599
8600 @item --cache=@var{directory}
8601 @itemx -c @var{directory}
8602 Cache archives and meta-data (@code{.narinfo} URLs) to @var{directory}
8603 and only serve archives that are in cache.
8604
8605 When this option is omitted, archives and meta-data are created
8606 on-the-fly. This can reduce the available bandwidth, especially when
8607 compression is enabled, since this may become CPU-bound. Another
8608 drawback of the default mode is that the length of archives is not known
8609 in advance, so @command{guix publish} does not add a
8610 @code{Content-Length} HTTP header to its responses, which in turn
8611 prevents clients from knowing the amount of data being downloaded.
8612
8613 Conversely, when @option{--cache} is used, the first request for a store
8614 item (@i{via} a @code{.narinfo} URL) returns 404 and triggers a
8615 background process to @dfn{bake} the archive---computing its
8616 @code{.narinfo} and compressing the archive, if needed. Once the
8617 archive is cached in @var{directory}, subsequent requests succeed and
8618 are served directly from the cache, which guarantees that clients get
8619 the best possible bandwidth.
8620
8621 The ``baking'' process is performed by worker threads. By default, one
8622 thread per CPU core is created, but this can be customized. See
8623 @option{--workers} below.
8624
8625 When @option{--ttl} is used, cached entries are automatically deleted
8626 when they have expired.
8627
8628 @item --workers=@var{N}
8629 When @option{--cache} is used, request the allocation of @var{N} worker
8630 threads to ``bake'' archives.
8631
8632 @item --ttl=@var{ttl}
8633 Produce @code{Cache-Control} HTTP headers that advertise a time-to-live
8634 (TTL) of @var{ttl}. @var{ttl} must denote a duration: @code{5d} means 5
8635 days, @code{1m} means 1 month, and so on.
8636
8637 This allows the user's Guix to keep substitute information in cache for
8638 @var{ttl}. However, note that @code{guix publish} does not itself
8639 guarantee that the store items it provides will indeed remain available
8640 for as long as @var{ttl}.
8641
8642 Additionally, when @option{--cache} is used, cached entries that have
8643 not been accessed for @var{ttl} and that no longer have a corresponding
8644 item in the store, may be deleted.
8645
8646 @item --nar-path=@var{path}
8647 Use @var{path} as the prefix for the URLs of ``nar'' files
8648 (@pxref{Invoking guix archive, normalized archives}).
8649
8650 By default, nars are served at a URL such as
8651 @code{/nar/gzip/@dots{}-coreutils-8.25}. This option allows you to
8652 change the @code{/nar} part to @var{path}.
8653
8654 @item --public-key=@var{file}
8655 @itemx --private-key=@var{file}
8656 Use the specific @var{file}s as the public/private key pair used to sign
8657 the store items being published.
8658
8659 The files must correspond to the same key pair (the private key is used
8660 for signing and the public key is merely advertised in the signature
8661 metadata). They must contain keys in the canonical s-expression format
8662 as produced by @command{guix archive --generate-key} (@pxref{Invoking
8663 guix archive}). By default, @file{/etc/guix/signing-key.pub} and
8664 @file{/etc/guix/signing-key.sec} are used.
8665
8666 @item --repl[=@var{port}]
8667 @itemx -r [@var{port}]
8668 Spawn a Guile REPL server (@pxref{REPL Servers,,, guile, GNU Guile
8669 Reference Manual}) on @var{port} (37146 by default). This is used
8670 primarily for debugging a running @command{guix publish} server.
8671 @end table
8672
8673 Enabling @command{guix publish} on a GuixSD system is a one-liner: just
8674 instantiate a @code{guix-publish-service-type} service in the @code{services} field
8675 of the @code{operating-system} declaration (@pxref{guix-publish-service-type,
8676 @code{guix-publish-service-type}}).
8677
8678 If you are instead running Guix on a ``foreign distro'', follow these
8679 instructions:”
8680
8681 @itemize
8682 @item
8683 If your host distro uses the systemd init system:
8684
8685 @example
8686 # ln -s ~root/.guix-profile/lib/systemd/system/guix-publish.service \
8687 /etc/systemd/system/
8688 # systemctl start guix-publish && systemctl enable guix-publish
8689 @end example
8690
8691 @item
8692 If your host distro uses the Upstart init system:
8693
8694 @example
8695 # ln -s ~root/.guix-profile/lib/upstart/system/guix-publish.conf /etc/init/
8696 # start guix-publish
8697 @end example
8698
8699 @item
8700 Otherwise, proceed similarly with your distro's init system.
8701 @end itemize
8702
8703 @node Invoking guix challenge
8704 @section Invoking @command{guix challenge}
8705
8706 @cindex reproducible builds
8707 @cindex verifiable builds
8708 @cindex @command{guix challenge}
8709 @cindex challenge
8710 Do the binaries provided by this server really correspond to the source
8711 code it claims to build? Is a package build process deterministic?
8712 These are the questions the @command{guix challenge} command attempts to
8713 answer.
8714
8715 The former is obviously an important question: Before using a substitute
8716 server (@pxref{Substitutes}), one had better @emph{verify} that it
8717 provides the right binaries, and thus @emph{challenge} it. The latter
8718 is what enables the former: If package builds are deterministic, then
8719 independent builds of the package should yield the exact same result,
8720 bit for bit; if a server provides a binary different from the one
8721 obtained locally, it may be either corrupt or malicious.
8722
8723 We know that the hash that shows up in @file{/gnu/store} file names is
8724 the hash of all the inputs of the process that built the file or
8725 directory---compilers, libraries, build scripts,
8726 etc. (@pxref{Introduction}). Assuming deterministic build processes,
8727 one store file name should map to exactly one build output.
8728 @command{guix challenge} checks whether there is, indeed, a single
8729 mapping by comparing the build outputs of several independent builds of
8730 any given store item.
8731
8732 The command output looks like this:
8733
8734 @smallexample
8735 $ guix challenge --substitute-urls="https://@value{SUBSTITUTE-SERVER} https://guix.example.org"
8736 updating list of substitutes from 'https://@value{SUBSTITUTE-SERVER}'... 100.0%
8737 updating list of substitutes from 'https://guix.example.org'... 100.0%
8738 /gnu/store/@dots{}-openssl-1.0.2d contents differ:
8739 local hash: 0725l22r5jnzazaacncwsvp9kgf42266ayyp814v7djxs7nk963q
8740 https://@value{SUBSTITUTE-SERVER}/nar/@dots{}-openssl-1.0.2d: 0725l22r5jnzazaacncwsvp9kgf42266ayyp814v7djxs7nk963q
8741 https://guix.example.org/nar/@dots{}-openssl-1.0.2d: 1zy4fmaaqcnjrzzajkdn3f5gmjk754b43qkq47llbyak9z0qjyim
8742 /gnu/store/@dots{}-git-2.5.0 contents differ:
8743 local hash: 00p3bmryhjxrhpn2gxs2fy0a15lnip05l97205pgbk5ra395hyha
8744 https://@value{SUBSTITUTE-SERVER}/nar/@dots{}-git-2.5.0: 069nb85bv4d4a6slrwjdy8v1cn4cwspm3kdbmyb81d6zckj3nq9f
8745 https://guix.example.org/nar/@dots{}-git-2.5.0: 0mdqa9w1p6cmli6976v4wi0sw9r4p5prkj7lzfd1877wk11c9c73
8746 /gnu/store/@dots{}-pius-2.1.1 contents differ:
8747 local hash: 0k4v3m9z1zp8xzzizb7d8kjj72f9172xv078sq4wl73vnq9ig3ax
8748 https://@value{SUBSTITUTE-SERVER}/nar/@dots{}-pius-2.1.1: 0k4v3m9z1zp8xzzizb7d8kjj72f9172xv078sq4wl73vnq9ig3ax
8749 https://guix.example.org/nar/@dots{}-pius-2.1.1: 1cy25x1a4fzq5rk0pmvc8xhwyffnqz95h2bpvqsz2mpvlbccy0gs
8750
8751 @dots{}
8752
8753 6,406 store items were analyzed:
8754 - 4,749 (74.1%) were identical
8755 - 525 (8.2%) differed
8756 - 1,132 (17.7%) were inconclusive
8757 @end smallexample
8758
8759 @noindent
8760 In this example, @command{guix challenge} first scans the store to
8761 determine the set of locally-built derivations---as opposed to store
8762 items that were downloaded from a substitute server---and then queries
8763 all the substitute servers. It then reports those store items for which
8764 the servers obtained a result different from the local build.
8765
8766 @cindex non-determinism, in package builds
8767 As an example, @code{guix.example.org} always gets a different answer.
8768 Conversely, @code{@value{SUBSTITUTE-SERVER}} agrees with local builds, except in the
8769 case of Git. This might indicate that the build process of Git is
8770 non-deterministic, meaning that its output varies as a function of
8771 various things that Guix does not fully control, in spite of building
8772 packages in isolated environments (@pxref{Features}). Most common
8773 sources of non-determinism include the addition of timestamps in build
8774 results, the inclusion of random numbers, and directory listings sorted
8775 by inode number. See @uref{https://reproducible-builds.org/docs/}, for
8776 more information.
8777
8778 To find out what is wrong with this Git binary, we can do something along
8779 these lines (@pxref{Invoking guix archive}):
8780
8781 @example
8782 $ wget -q -O - https://@value{SUBSTITUTE-SERVER}/nar/@dots{}-git-2.5.0 \
8783 | guix archive -x /tmp/git
8784 $ diff -ur --no-dereference /gnu/store/@dots{}-git.2.5.0 /tmp/git
8785 @end example
8786
8787 This command shows the difference between the files resulting from the
8788 local build, and the files resulting from the build on
8789 @code{@value{SUBSTITUTE-SERVER}} (@pxref{Overview, Comparing and Merging Files,,
8790 diffutils, Comparing and Merging Files}). The @command{diff} command
8791 works great for text files. When binary files differ, a better option
8792 is @uref{https://diffoscope.org/, Diffoscope}, a tool that helps
8793 visualize differences for all kinds of files.
8794
8795 Once you have done that work, you can tell whether the differences are due
8796 to a non-deterministic build process or to a malicious server. We try
8797 hard to remove sources of non-determinism in packages to make it easier
8798 to verify substitutes, but of course, this is a process that
8799 involves not just Guix, but a large part of the free software community.
8800 In the meantime, @command{guix challenge} is one tool to help address
8801 the problem.
8802
8803 If you are writing packages for Guix, you are encouraged to check
8804 whether @code{@value{SUBSTITUTE-SERVER}} and other substitute servers obtain the
8805 same build result as you did with:
8806
8807 @example
8808 $ guix challenge @var{package}
8809 @end example
8810
8811 @noindent
8812 where @var{package} is a package specification such as
8813 @code{guile@@2.0} or @code{glibc:debug}.
8814
8815 The general syntax is:
8816
8817 @example
8818 guix challenge @var{options} [@var{packages}@dots{}]
8819 @end example
8820
8821 When a difference is found between the hash of a locally-built item and
8822 that of a server-provided substitute, or among substitutes provided by
8823 different servers, the command displays it as in the example above and
8824 its exit code is 2 (other non-zero exit codes denote other kinds of
8825 errors.)
8826
8827 The one option that matters is:
8828
8829 @table @code
8830
8831 @item --substitute-urls=@var{urls}
8832 Consider @var{urls} the whitespace-separated list of substitute source
8833 URLs to compare to.
8834
8835 @item --verbose
8836 @itemx -v
8837 Show details about matches (identical contents) in addition to
8838 information about mismatches.
8839
8840 @end table
8841
8842 @node Invoking guix copy
8843 @section Invoking @command{guix copy}
8844
8845 @cindex copy, of store items, over SSH
8846 @cindex SSH, copy of store items
8847 @cindex sharing store items across machines
8848 @cindex transferring store items across machines
8849 The @command{guix copy} command copies items from the store of one
8850 machine to that of another machine over a secure shell (SSH)
8851 connection@footnote{This command is available only when Guile-SSH was
8852 found. @xref{Requirements}, for details.}. For example, the following
8853 command copies the @code{coreutils} package, the user's profile, and all
8854 their dependencies over to @var{host}, logged in as @var{user}:
8855
8856 @example
8857 guix copy --to=@var{user}@@@var{host} \
8858 coreutils `readlink -f ~/.guix-profile`
8859 @end example
8860
8861 If some of the items to be copied are already present on @var{host},
8862 they are not actually sent.
8863
8864 The command below retrieves @code{libreoffice} and @code{gimp} from
8865 @var{host}, assuming they are available there:
8866
8867 @example
8868 guix copy --from=@var{host} libreoffice gimp
8869 @end example
8870
8871 The SSH connection is established using the Guile-SSH client, which is
8872 compatible with OpenSSH: it honors @file{~/.ssh/known_hosts} and
8873 @file{~/.ssh/config}, and uses the SSH agent for authentication.
8874
8875 The key used to sign items that are sent must be accepted by the remote
8876 machine. Likewise, the key used by the remote machine to sign items you
8877 are retrieving must be in @file{/etc/guix/acl} so it is accepted by your
8878 own daemon. @xref{Invoking guix archive}, for more information about
8879 store item authentication.
8880
8881 The general syntax is:
8882
8883 @example
8884 guix copy [--to=@var{spec}|--from=@var{spec}] @var{items}@dots{}
8885 @end example
8886
8887 You must always specify one of the following options:
8888
8889 @table @code
8890 @item --to=@var{spec}
8891 @itemx --from=@var{spec}
8892 Specify the host to send to or receive from. @var{spec} must be an SSH
8893 spec such as @code{example.org}, @code{charlie@@example.org}, or
8894 @code{charlie@@example.org:2222}.
8895 @end table
8896
8897 The @var{items} can be either package names, such as @code{gimp}, or
8898 store items, such as @file{/gnu/store/@dots{}-idutils-4.6}.
8899
8900 When specifying the name of a package to send, it is first built if
8901 needed, unless @option{--dry-run} was specified. Common build options
8902 are supported (@pxref{Common Build Options}).
8903
8904
8905 @node Invoking guix container
8906 @section Invoking @command{guix container}
8907 @cindex container
8908 @cindex @command{guix container}
8909 @quotation Note
8910 As of version @value{VERSION}, this tool is experimental. The interface
8911 is subject to radical change in the future.
8912 @end quotation
8913
8914 The purpose of @command{guix container} is to manipulate processes
8915 running within an isolated environment, commonly known as a
8916 ``container'', typically created by the @command{guix environment}
8917 (@pxref{Invoking guix environment}) and @command{guix system container}
8918 (@pxref{Invoking guix system}) commands.
8919
8920 The general syntax is:
8921
8922 @example
8923 guix container @var{action} @var{options}@dots{}
8924 @end example
8925
8926 @var{action} specifies the operation to perform with a container, and
8927 @var{options} specifies the context-specific arguments for the action.
8928
8929 The following actions are available:
8930
8931 @table @code
8932 @item exec
8933 Execute a command within the context of a running container.
8934
8935 The syntax is:
8936
8937 @example
8938 guix container exec @var{pid} @var{program} @var{arguments}@dots{}
8939 @end example
8940
8941 @var{pid} specifies the process ID of the running container.
8942 @var{program} specifies an executable file name within the root file
8943 system of the container. @var{arguments} are the additional options that
8944 will be passed to @var{program}.
8945
8946 The following command launches an interactive login shell inside a
8947 GuixSD container, started by @command{guix system container}, and whose
8948 process ID is 9001:
8949
8950 @example
8951 guix container exec 9001 /run/current-system/profile/bin/bash --login
8952 @end example
8953
8954 Note that the @var{pid} cannot be the parent process of a container. It
8955 must be PID 1 of the container or one of its child processes.
8956
8957 @end table
8958
8959 @node Invoking guix weather
8960 @section Invoking @command{guix weather}
8961
8962 Occasionally you're grumpy because substitutes are lacking and you end
8963 up building packages by yourself (@pxref{Substitutes}). The
8964 @command{guix weather} command reports on substitute availability on the
8965 specified servers so you can have an idea of whether you'll be grumpy
8966 today. It can sometimes be useful info as a user, but it is primarily
8967 useful to people running @command{guix publish} (@pxref{Invoking guix
8968 publish}).
8969
8970 @cindex statistics, for substitutes
8971 @cindex availability of substitutes
8972 @cindex substitute availability
8973 @cindex weather, substitute availability
8974 Here's a sample run:
8975
8976 @example
8977 $ guix weather --substitute-urls=https://guix.example.org
8978 computing 5,872 package derivations for x86_64-linux...
8979 looking for 6,128 store items on https://guix.example.org..
8980 updating list of substitutes from 'https://guix.example.org'... 100.0%
8981 https://guix.example.org
8982 43.4% substitutes available (2,658 out of 6,128)
8983 7,032.5 MiB of nars (compressed)
8984 19,824.2 MiB on disk (uncompressed)
8985 0.030 seconds per request (182.9 seconds in total)
8986 33.5 requests per second
8987
8988 9.8% (342 out of 3,470) of the missing items are queued
8989 867 queued builds
8990 x86_64-linux: 518 (59.7%)
8991 i686-linux: 221 (25.5%)
8992 aarch64-linux: 128 (14.8%)
8993 build rate: 23.41 builds per hour
8994 x86_64-linux: 11.16 builds per hour
8995 i686-linux: 6.03 builds per hour
8996 aarch64-linux: 6.41 builds per hour
8997 @end example
8998
8999 @cindex continuous integration, statistics
9000 As you can see, it reports the fraction of all the packages for which
9001 substitutes are available on the server---regardless of whether
9002 substitutes are enabled, and regardless of whether this server's signing
9003 key is authorized. It also reports the size of the compressed archives
9004 (``nars'') provided by the server, the size the corresponding store
9005 items occupy in the store (assuming deduplication is turned off), and
9006 the server's throughput. The second part gives continuous integration
9007 (CI) statistics, if the server supports it.
9008
9009 To achieve that, @command{guix weather} queries over HTTP(S) meta-data
9010 (@dfn{narinfos}) for all the relevant store items. Like @command{guix
9011 challenge}, it ignores signatures on those substitutes, which is
9012 innocuous since the command only gathers statistics and cannot install
9013 those substitutes.
9014
9015 Among other things, it is possible to query specific system types and
9016 specific package sets. The available options are listed below.
9017
9018 @table @code
9019 @item --substitute-urls=@var{urls}
9020 @var{urls} is the space-separated list of substitute server URLs to
9021 query. When this option is omitted, the default set of substitute
9022 servers is queried.
9023
9024 @item --system=@var{system}
9025 @itemx -s @var{system}
9026 Query substitutes for @var{system}---e.g., @code{aarch64-linux}. This
9027 option can be repeated, in which case @command{guix weather} will query
9028 substitutes for several system types.
9029
9030 @item --manifest=@var{file}
9031 Instead of querying substitutes for all the packages, only ask for those
9032 specified in @var{file}. @var{file} must contain a @dfn{manifest}, as
9033 with the @code{-m} option of @command{guix package} (@pxref{Invoking
9034 guix package}).
9035 @end table
9036
9037 @node Invoking guix processes
9038 @section Invoking @command{guix processes}
9039
9040 The @command{guix processes} command can be useful to developers and system
9041 administrators, especially on multi-user machines and on build farms: it lists
9042 the current sessions (connections to the daemon), as well as information about
9043 the processes involved@footnote{Remote sessions, when @command{guix-daemon} is
9044 started with @option{--listen} specifying a TCP endpoint, are @emph{not}
9045 listed.}. Here's an example of the information it returns:
9046
9047 @example
9048 $ sudo guix processes
9049 SessionPID: 19002
9050 ClientPID: 19090
9051 ClientCommand: guix environment --ad-hoc python
9052
9053 SessionPID: 19402
9054 ClientPID: 19367
9055 ClientCommand: guix publish -u guix-publish -p 3000 -C 9 @dots{}
9056
9057 SessionPID: 19444
9058 ClientPID: 19419
9059 ClientCommand: cuirass --cache-directory /var/cache/cuirass @dots{}
9060 LockHeld: /gnu/store/@dots{}-perl-ipc-cmd-0.96.lock
9061 LockHeld: /gnu/store/@dots{}-python-six-bootstrap-1.11.0.lock
9062 LockHeld: /gnu/store/@dots{}-libjpeg-turbo-2.0.0.lock
9063 ChildProcess: 20495: guix offload x86_64-linux 7200 1 28800
9064 ChildProcess: 27733: guix offload x86_64-linux 7200 1 28800
9065 ChildProcess: 27793: guix offload x86_64-linux 7200 1 28800
9066 @end example
9067
9068 In this example we see that @command{guix-daemon} has three clients:
9069 @command{guix environment}, @command{guix publish}, and the Cuirass continuous
9070 integration tool; their process identifier (PID) is given by the
9071 @code{ClientPID} field. The @code{SessionPID} field gives the PID of the
9072 @command{guix-daemon} sub-process of this particular session.
9073
9074 The @code{LockHeld} fields show which store items are currently locked by this
9075 session, which corresponds to store items being built or substituted (the
9076 @code{LockHeld} field is not displayed when @command{guix processes} is not
9077 running as root.) Last, by looking at the @code{ChildProcess} field, we
9078 understand that these three builds are being offloaded (@pxref{Daemon Offload
9079 Setup}).
9080
9081 The output is in Recutils format so we can use the handy @command{recsel}
9082 command to select sessions of interest (@pxref{Selection Expressions,,,
9083 recutils, GNU recutils manual}). As an example, the command shows the command
9084 line and PID of the client that triggered the build of a Perl package:
9085
9086 @example
9087 $ sudo guix processes | \
9088 recsel -p ClientPID,ClientCommand -e 'LockHeld ~ "perl"'
9089 ClientPID: 19419
9090 ClientCommand: cuirass --cache-directory /var/cache/cuirass @dots{}
9091 @end example
9092
9093
9094 @node System Installation
9095 @chapter System Installation
9096
9097 @cindex installing GuixSD
9098 @cindex Guix System Distribution
9099 This section explains how to install the Guix System Distribution (GuixSD)
9100 on a machine. The Guix package manager can
9101 also be installed on top of a running GNU/Linux system,
9102 @pxref{Installation}.
9103
9104 @ifinfo
9105 @quotation Note
9106 @c This paragraph is for people reading this from tty2 of the
9107 @c installation image.
9108 You are reading this documentation with an Info reader. For details on
9109 how to use it, hit the @key{RET} key (``return'' or ``enter'') on the
9110 link that follows: @pxref{Top, Info reader,, info-stnd, Stand-alone GNU
9111 Info}. Hit @kbd{l} afterwards to come back here.
9112
9113 Alternately, run @command{info info} in another tty to keep the manual
9114 available.
9115 @end quotation
9116 @end ifinfo
9117
9118 @menu
9119 * Limitations:: What you can expect.
9120 * Hardware Considerations:: Supported hardware.
9121 * USB Stick and DVD Installation:: Preparing the installation medium.
9122 * Preparing for Installation:: Networking, partitioning, etc.
9123 * Proceeding with the Installation:: The real thing.
9124 * Installing GuixSD in a VM:: GuixSD playground.
9125 * Building the Installation Image:: How this comes to be.
9126 @end menu
9127
9128 @node Limitations
9129 @section Limitations
9130
9131 As of version @value{VERSION}, the Guix System Distribution (GuixSD) is
9132 not production-ready. It may contain bugs and lack important
9133 features. Thus, if you are looking for a stable production system that
9134 respects your freedom as a computer user, a good solution at this point
9135 is to consider @url{http://www.gnu.org/distros/free-distros.html, one of
9136 the more established GNU/Linux distributions}. We hope you can soon switch
9137 to the GuixSD without fear, of course. In the meantime, you can
9138 also keep using your distribution and try out the package manager on top
9139 of it (@pxref{Installation}).
9140
9141 Before you proceed with the installation, be aware of the following
9142 noteworthy limitations applicable to version @value{VERSION}:
9143
9144 @itemize
9145 @item
9146 The installation process does not include a graphical user interface and
9147 requires familiarity with GNU/Linux (see the following subsections to
9148 get a feel of what that means.)
9149
9150 @item
9151 Support for the Logical Volume Manager (LVM) is missing.
9152
9153 @item
9154 More and more system services are provided (@pxref{Services}), but some
9155 may be missing.
9156
9157 @item
9158 More than 8,500 packages are available, but you might
9159 occasionally find that a useful package is missing.
9160
9161 @item
9162 GNOME, Xfce, LXDE, and Enlightenment are available (@pxref{Desktop Services}),
9163 as well as a number of X11 window managers. However, some graphical
9164 applications may be missing, as well as KDE.
9165 @end itemize
9166
9167 You have been warned! But more than a disclaimer, this is an invitation
9168 to report issues (and success stories!), and to join us in improving it.
9169 @xref{Contributing}, for more info.
9170
9171
9172 @node Hardware Considerations
9173 @section Hardware Considerations
9174
9175 @cindex hardware support on GuixSD
9176 GNU@tie{}GuixSD focuses on respecting the user's computing freedom. It
9177 builds around the kernel Linux-libre, which means that only hardware for
9178 which free software drivers and firmware exist is supported. Nowadays,
9179 a wide range of off-the-shelf hardware is supported on
9180 GNU/Linux-libre---from keyboards to graphics cards to scanners and
9181 Ethernet controllers. Unfortunately, there are still areas where
9182 hardware vendors deny users control over their own computing, and such
9183 hardware is not supported on GuixSD.
9184
9185 @cindex WiFi, hardware support
9186 One of the main areas where free drivers or firmware are lacking is WiFi
9187 devices. WiFi devices known to work include those using Atheros chips
9188 (AR9271 and AR7010), which corresponds to the @code{ath9k} Linux-libre
9189 driver, and those using Broadcom/AirForce chips (BCM43xx with
9190 Wireless-Core Revision 5), which corresponds to the @code{b43-open}
9191 Linux-libre driver. Free firmware exists for both and is available
9192 out-of-the-box on GuixSD, as part of @var{%base-firmware}
9193 (@pxref{operating-system Reference, @code{firmware}}).
9194
9195 @cindex RYF, Respects Your Freedom
9196 The @uref{https://www.fsf.org/, Free Software Foundation} runs
9197 @uref{https://www.fsf.org/ryf, @dfn{Respects Your Freedom}} (RYF), a
9198 certification program for hardware products that respect your freedom
9199 and your privacy and ensure that you have control over your device. We
9200 encourage you to check the list of RYF-certified devices.
9201
9202 Another useful resource is the @uref{https://www.h-node.org/, H-Node}
9203 web site. It contains a catalog of hardware devices with information
9204 about their support in GNU/Linux.
9205
9206
9207 @node USB Stick and DVD Installation
9208 @section USB Stick and DVD Installation
9209
9210 An ISO-9660 installation image that can be written to a USB stick or
9211 burnt to a DVD can be downloaded from
9212 @indicateurl{https://alpha.gnu.org/gnu/guix/guixsd-install-@value{VERSION}.@var{system}.iso.xz},
9213 where @var{system} is one of:
9214
9215 @table @code
9216 @item x86_64-linux
9217 for a GNU/Linux system on Intel/AMD-compatible 64-bit CPUs;
9218
9219 @item i686-linux
9220 for a 32-bit GNU/Linux system on Intel-compatible CPUs.
9221 @end table
9222
9223 @c start duplication of authentication part from ``Binary Installation''
9224 Make sure to download the associated @file{.sig} file and to verify the
9225 authenticity of the image against it, along these lines:
9226
9227 @example
9228 $ wget https://alpha.gnu.org/gnu/guix/guixsd-install-@value{VERSION}.@var{system}.iso.xz.sig
9229 $ gpg --verify guixsd-install-@value{VERSION}.@var{system}.iso.xz.sig
9230 @end example
9231
9232 If that command fails because you do not have the required public key,
9233 then run this command to import it:
9234
9235 @example
9236 $ gpg --keyserver @value{KEY-SERVER} \
9237 --recv-keys @value{OPENPGP-SIGNING-KEY-ID}
9238 @end example
9239
9240 @noindent
9241 and rerun the @code{gpg --verify} command.
9242 @c end duplication
9243
9244 This image contains the tools necessary for an installation.
9245 It is meant to be copied @emph{as is} to a large-enough USB stick or DVD.
9246
9247 @unnumberedsubsec Copying to a USB Stick
9248
9249 To copy the image to a USB stick, follow these steps:
9250
9251 @enumerate
9252 @item
9253 Decompress the image using the @command{xz} command:
9254
9255 @example
9256 xz -d guixsd-install-@value{VERSION}.@var{system}.iso.xz
9257 @end example
9258
9259 @item
9260 Insert a USB stick of 1@tie{}GiB or more into your machine, and determine
9261 its device name. Assuming that the USB stick is known as @file{/dev/sdX},
9262 copy the image with:
9263
9264 @example
9265 dd if=guixsd-install-@value{VERSION}.@var{system}.iso of=/dev/sdX
9266 sync
9267 @end example
9268
9269 Access to @file{/dev/sdX} usually requires root privileges.
9270 @end enumerate
9271
9272 @unnumberedsubsec Burning on a DVD
9273
9274 To copy the image to a DVD, follow these steps:
9275
9276 @enumerate
9277 @item
9278 Decompress the image using the @command{xz} command:
9279
9280 @example
9281 xz -d guixsd-install-@value{VERSION}.@var{system}.iso.xz
9282 @end example
9283
9284 @item
9285 Insert a blank DVD into your machine, and determine
9286 its device name. Assuming that the DVD drive is known as @file{/dev/srX},
9287 copy the image with:
9288
9289 @example
9290 growisofs -dvd-compat -Z /dev/srX=guixsd-install-@value{VERSION}.@var{system}.iso
9291 @end example
9292
9293 Access to @file{/dev/srX} usually requires root privileges.
9294 @end enumerate
9295
9296 @unnumberedsubsec Booting
9297
9298 Once this is done, you should be able to reboot the system and boot from
9299 the USB stick or DVD. The latter usually requires you to get in the
9300 BIOS or UEFI boot menu, where you can choose to boot from the USB stick.
9301
9302 @xref{Installing GuixSD in a VM}, if, instead, you would like to install
9303 GuixSD in a virtual machine (VM).
9304
9305
9306 @node Preparing for Installation
9307 @section Preparing for Installation
9308
9309 Once you have successfully booted your computer using the installation medium,
9310 you should end up with the welcome page of the graphical installer. The
9311 graphical installer is a text-based user interface built upon the newt
9312 library. It shall guide you through all the different steps needed to install
9313 GNU GuixSD. However, as the graphical installer is still under heavy
9314 development, you might want to fallback to the original, shell based install
9315 process, by switching to TTYs 3 to 6 with the shortcuts CTRL-ALT-F[3-6]. The
9316 following sections describe the installation procedure assuming you're using
9317 one of those TTYs. They are configured and can be used to run commands as
9318 root.
9319
9320 TTY2 shows this documentation, browsable using the Info reader commands
9321 (@pxref{Top,,, info-stnd, Stand-alone GNU Info}). The installation system
9322 runs the GPM mouse daemon, which allows you to select text with the left mouse
9323 button and to paste it with the middle button.
9324
9325 @quotation Note
9326 Installation requires access to the Internet so that any missing
9327 dependencies of your system configuration can be downloaded. See the
9328 ``Networking'' section below.
9329 @end quotation
9330
9331 The installation system includes many common tools needed for this task.
9332 But it is also a full-blown GuixSD system, which means that you can
9333 install additional packages, should you need it, using @command{guix
9334 package} (@pxref{Invoking guix package}).
9335
9336 @subsection Keyboard Layout
9337
9338 @cindex keyboard layout
9339 The installation image uses the US qwerty keyboard layout. If you want
9340 to change it, you can use the @command{loadkeys} command. For example,
9341 the following command selects the Dvorak keyboard layout:
9342
9343 @example
9344 loadkeys dvorak
9345 @end example
9346
9347 See the files under @file{/run/current-system/profile/share/keymaps} for
9348 a list of available keyboard layouts. Run @command{man loadkeys} for
9349 more information.
9350
9351 @subsection Networking
9352
9353 Run the following command to see what your network interfaces are called:
9354
9355 @example
9356 ifconfig -a
9357 @end example
9358
9359 @noindent
9360 @dots{} or, using the GNU/Linux-specific @command{ip} command:
9361
9362 @example
9363 ip a
9364 @end example
9365
9366 @c http://cgit.freedesktop.org/systemd/systemd/tree/src/udev/udev-builtin-net_id.c#n20
9367 Wired interfaces have a name starting with @samp{e}; for example, the
9368 interface corresponding to the first on-board Ethernet controller is
9369 called @samp{eno1}. Wireless interfaces have a name starting with
9370 @samp{w}, like @samp{w1p2s0}.
9371
9372 @table @asis
9373 @item Wired connection
9374 To configure a wired network run the following command, substituting
9375 @var{interface} with the name of the wired interface you want to use.
9376
9377 @example
9378 ifconfig @var{interface} up
9379 @end example
9380
9381 @item Wireless connection
9382 @cindex wireless
9383 @cindex WiFi
9384 To configure wireless networking, you can create a configuration file
9385 for the @command{wpa_supplicant} configuration tool (its location is not
9386 important) using one of the available text editors such as
9387 @command{nano}:
9388
9389 @example
9390 nano wpa_supplicant.conf
9391 @end example
9392
9393 As an example, the following stanza can go to this file and will work
9394 for many wireless networks, provided you give the actual SSID and
9395 passphrase for the network you are connecting to:
9396
9397 @example
9398 network=@{
9399 ssid="@var{my-ssid}"
9400 key_mgmt=WPA-PSK
9401 psk="the network's secret passphrase"
9402 @}
9403 @end example
9404
9405 Start the wireless service and run it in the background with the
9406 following command (substitute @var{interface} with the name of the
9407 network interface you want to use):
9408
9409 @example
9410 wpa_supplicant -c wpa_supplicant.conf -i @var{interface} -B
9411 @end example
9412
9413 Run @command{man wpa_supplicant} for more information.
9414 @end table
9415
9416 @cindex DHCP
9417 At this point, you need to acquire an IP address. On a network where IP
9418 addresses are automatically assigned @i{via} DHCP, you can run:
9419
9420 @example
9421 dhclient -v @var{interface}
9422 @end example
9423
9424 Try to ping a server to see if networking is up and running:
9425
9426 @example
9427 ping -c 3 gnu.org
9428 @end example
9429
9430 Setting up network access is almost always a requirement because the
9431 image does not contain all the software and tools that may be needed.
9432
9433 @cindex installing over SSH
9434 If you want to, you can continue the installation remotely by starting
9435 an SSH server:
9436
9437 @example
9438 herd start ssh-daemon
9439 @end example
9440
9441 Make sure to either set a password with @command{passwd}, or configure
9442 OpenSSH public key authentication before logging in.
9443
9444 @subsection Disk Partitioning
9445
9446 Unless this has already been done, the next step is to partition, and
9447 then format the target partition(s).
9448
9449 The installation image includes several partitioning tools, including
9450 Parted (@pxref{Overview,,, parted, GNU Parted User Manual}),
9451 @command{fdisk}, and @command{cfdisk}. Run it and set up your disk with
9452 the partition layout you want:
9453
9454 @example
9455 cfdisk
9456 @end example
9457
9458 If your disk uses the GUID Partition Table (GPT) format and you plan to
9459 install BIOS-based GRUB (which is the default), make sure a BIOS Boot
9460 Partition is available (@pxref{BIOS installation,,, grub, GNU GRUB
9461 manual}).
9462
9463 @cindex EFI, installation
9464 @cindex UEFI, installation
9465 @cindex ESP, EFI system partition
9466 If you instead wish to use EFI-based GRUB, a FAT32 @dfn{EFI System Partition}
9467 (ESP) is required. This partition should be mounted at @file{/boot/efi} and
9468 must have the @code{esp} flag set. E.g., for @command{parted}:
9469
9470 @example
9471 parted /dev/sda set 1 esp on
9472 @end example
9473
9474 @quotation Note
9475 @vindex grub-bootloader
9476 @vindex grub-efi-bootloader
9477 Unsure whether to use EFI- or BIOS-based GRUB? If the directory
9478 @file{/sys/firmware/efi} exists in the installation image, then you should
9479 probably perform an EFI installation, using @code{grub-efi-bootloader}.
9480 Otherwise you should use the BIOS-based GRUB, known as
9481 @code{grub-bootloader}. @xref{Bootloader Configuration}, for more info on
9482 bootloaders.
9483 @end quotation
9484
9485 Once you are done partitioning the target hard disk drive, you have to
9486 create a file system on the relevant partition(s)@footnote{Currently
9487 GuixSD only supports ext4 and btrfs file systems. In particular, code
9488 that reads file system UUIDs and labels only works for these file system
9489 types.}. For the ESP, if you have one and assuming it is
9490 @file{/dev/sda1}, run:
9491
9492 @example
9493 mkfs.fat -F32 /dev/sda1
9494 @end example
9495
9496 Preferably, assign file systems a label so that you can easily and
9497 reliably refer to them in @code{file-system} declarations (@pxref{File
9498 Systems}). This is typically done using the @code{-L} option of
9499 @command{mkfs.ext4} and related commands. So, assuming the target root
9500 partition lives at @file{/dev/sda2}, a file system with the label
9501 @code{my-root} can be created with:
9502
9503 @example
9504 mkfs.ext4 -L my-root /dev/sda2
9505 @end example
9506
9507 @cindex encrypted disk
9508 If you are instead planning to encrypt the root partition, you can use
9509 the Cryptsetup/LUKS utilities to do that (see @inlinefmtifelse{html,
9510 @uref{https://linux.die.net/man/8/cryptsetup, @code{man cryptsetup}},
9511 @code{man cryptsetup}} for more information.) Assuming you want to
9512 store the root partition on @file{/dev/sda2}, the command sequence would
9513 be along these lines:
9514
9515 @example
9516 cryptsetup luksFormat /dev/sda2
9517 cryptsetup open --type luks /dev/sda2 my-partition
9518 mkfs.ext4 -L my-root /dev/mapper/my-partition
9519 @end example
9520
9521 Once that is done, mount the target file system under @file{/mnt}
9522 with a command like (again, assuming @code{my-root} is the label of the
9523 root file system):
9524
9525 @example
9526 mount LABEL=my-root /mnt
9527 @end example
9528
9529 Also mount any other file systems you would like to use on the target
9530 system relative to this path. If you have @file{/boot} on a separate
9531 partition for example, mount it at @file{/mnt/boot} now so it is found
9532 by @code{guix system init} afterwards.
9533
9534 Finally, if you plan to use one or more swap partitions (@pxref{Memory
9535 Concepts, swap space,, libc, The GNU C Library Reference Manual}), make
9536 sure to initialize them with @command{mkswap}. Assuming you have one
9537 swap partition on @file{/dev/sda3}, you would run:
9538
9539 @example
9540 mkswap /dev/sda3
9541 swapon /dev/sda3
9542 @end example
9543
9544 Alternatively, you may use a swap file. For example, assuming that in
9545 the new system you want to use the file @file{/swapfile} as a swap file,
9546 you would run@footnote{This example will work for many types of file
9547 systems (e.g., ext4). However, for copy-on-write file systems (e.g.,
9548 btrfs), the required steps may be different. For details, see the
9549 manual pages for @command{mkswap} and @command{swapon}.}:
9550
9551 @example
9552 # This is 10 GiB of swap space. Adjust "count" to change the size.
9553 dd if=/dev/zero of=/mnt/swapfile bs=1MiB count=10240
9554 # For security, make the file readable and writable only by root.
9555 chmod 600 /mnt/swapfile
9556 mkswap /mnt/swapfile
9557 swapon /mnt/swapfile
9558 @end example
9559
9560 Note that if you have encrypted the root partition and created a swap
9561 file in its file system as described above, then the encryption also
9562 protects the swap file, just like any other file in that file system.
9563
9564 @node Proceeding with the Installation
9565 @section Proceeding with the Installation
9566
9567 With the target partitions ready and the target root mounted on
9568 @file{/mnt}, we're ready to go. First, run:
9569
9570 @example
9571 herd start cow-store /mnt
9572 @end example
9573
9574 This makes @file{/gnu/store} copy-on-write, such that packages added to it
9575 during the installation phase are written to the target disk on @file{/mnt}
9576 rather than kept in memory. This is necessary because the first phase of
9577 the @command{guix system init} command (see below) entails downloads or
9578 builds to @file{/gnu/store} which, initially, is an in-memory file system.
9579
9580 Next, you have to edit a file and
9581 provide the declaration of the operating system to be installed. To
9582 that end, the installation system comes with three text editors. We
9583 recommend GNU nano (@pxref{Top,,, nano, GNU nano Manual}), which
9584 supports syntax highlighting and parentheses matching; other editors
9585 include GNU Zile (an Emacs clone), and
9586 nvi (a clone of the original BSD @command{vi} editor).
9587 We strongly recommend storing that file on the target root file system, say,
9588 as @file{/mnt/etc/config.scm}. Failing to do that, you will have lost your
9589 configuration file once you have rebooted into the newly-installed system.
9590
9591 @xref{Using the Configuration System}, for an overview of the
9592 configuration file. The example configurations discussed in that
9593 section are available under @file{/etc/configuration} in the
9594 installation image. Thus, to get started with a system configuration
9595 providing a graphical display server (a ``desktop'' system), you can run
9596 something along these lines:
9597
9598 @example
9599 # mkdir /mnt/etc
9600 # cp /etc/configuration/desktop.scm /mnt/etc/config.scm
9601 # nano /mnt/etc/config.scm
9602 @end example
9603
9604 You should pay attention to what your configuration file contains, and
9605 in particular:
9606
9607 @itemize
9608 @item
9609 Make sure the @code{bootloader-configuration} form refers to the target
9610 you want to install GRUB on. It should mention @code{grub-bootloader} if
9611 you are installing GRUB in the legacy way, or @code{grub-efi-bootloader}
9612 for newer UEFI systems. For legacy systems, the @code{target} field
9613 names a device, like @code{/dev/sda}; for UEFI systems it names a path
9614 to a mounted EFI partition, like @code{/boot/efi}, and do make sure the
9615 path is actually mounted.
9616
9617 @item
9618 Be sure that your file system labels match the value of their respective
9619 @code{device} fields in your @code{file-system} configuration, assuming
9620 your @code{file-system} configuration uses the @code{file-system-label}
9621 procedure in its @code{device} field.
9622
9623 @item
9624 If there are encrypted or RAID partitions, make sure to add a
9625 @code{mapped-devices} field to describe them (@pxref{Mapped Devices}).
9626 @end itemize
9627
9628 Once you are done preparing the configuration file, the new system must
9629 be initialized (remember that the target root file system is mounted
9630 under @file{/mnt}):
9631
9632 @example
9633 guix system init /mnt/etc/config.scm /mnt
9634 @end example
9635
9636 @noindent
9637 This copies all the necessary files and installs GRUB on
9638 @file{/dev/sdX}, unless you pass the @option{--no-bootloader} option. For
9639 more information, @pxref{Invoking guix system}. This command may trigger
9640 downloads or builds of missing packages, which can take some time.
9641
9642 Once that command has completed---and hopefully succeeded!---you can run
9643 @command{reboot} and boot into the new system. The @code{root} password
9644 in the new system is initially empty; other users' passwords need to be
9645 initialized by running the @command{passwd} command as @code{root},
9646 unless your configuration specifies otherwise
9647 (@pxref{user-account-password, user account passwords}).
9648
9649 @cindex upgrading GuixSD
9650 From then on, you can update GuixSD whenever you want by running @command{guix
9651 pull} as @code{root} (@pxref{Invoking guix pull}), and then running
9652 @command{guix system reconfigure /etc/config.scm}, as @code{root} too, to
9653 build a new system generation with the latest packages and services
9654 (@pxref{Invoking guix system}). We recommend doing that regularly so that
9655 your system includes the latest security updates (@pxref{Security Updates}).
9656
9657 Join us on @code{#guix} on the Freenode IRC network or on
9658 @email{guix-devel@@gnu.org} to share your experience---good or not so
9659 good.
9660
9661 @node Installing GuixSD in a VM
9662 @section Installing GuixSD in a Virtual Machine
9663
9664 @cindex virtual machine, GuixSD installation
9665 @cindex virtual private server (VPS)
9666 @cindex VPS (virtual private server)
9667 If you'd like to install GuixSD in a virtual machine (VM) or on a
9668 virtual private server (VPS) rather than on your beloved machine, this
9669 section is for you.
9670
9671 To boot a @uref{http://qemu.org/,QEMU} VM for installing GuixSD in a
9672 disk image, follow these steps:
9673
9674 @enumerate
9675 @item
9676 First, retrieve and decompress the GuixSD installation image as
9677 described previously (@pxref{USB Stick and DVD Installation}).
9678
9679 @item
9680 Create a disk image that will hold the installed system. To make a
9681 qcow2-formatted disk image, use the @command{qemu-img} command:
9682
9683 @example
9684 qemu-img create -f qcow2 guixsd.img 50G
9685 @end example
9686
9687 The resulting file will be much smaller than 50 GB (typically less than
9688 1 MB), but it will grow as the virtualized storage device is filled up.
9689
9690 @item
9691 Boot the USB installation image in an VM:
9692
9693 @example
9694 qemu-system-x86_64 -m 1024 -smp 1 \
9695 -net user -net nic,model=virtio -boot menu=on \
9696 -drive file=guixsd-install-@value{VERSION}.@var{system}.iso \
9697 -drive file=guixsd.img
9698 @end example
9699
9700 The ordering of the drives matters.
9701
9702 In the VM console, quickly press the @kbd{F12} key to enter the boot
9703 menu. Then press the @kbd{2} key and the @kbd{RET} key to validate your
9704 selection.
9705
9706 @item
9707 You're now root in the VM, proceed with the installation process.
9708 @xref{Preparing for Installation}, and follow the instructions.
9709 @end enumerate
9710
9711 Once installation is complete, you can boot the system that's on your
9712 @file{guixsd.img} image. @xref{Running GuixSD in a VM}, for how to do
9713 that.
9714
9715 @node Building the Installation Image
9716 @section Building the Installation Image
9717
9718 @cindex installation image
9719 The installation image described above was built using the @command{guix
9720 system} command, specifically:
9721
9722 @example
9723 guix system disk-image gnu/system/install.scm
9724 @end example
9725
9726 Have a look at @file{gnu/system/install.scm} in the source tree,
9727 and see also @ref{Invoking guix system} for more information
9728 about the installation image.
9729
9730 @section Building the Installation Image for ARM Boards
9731
9732 Many ARM boards require a specific variant of the
9733 @uref{http://www.denx.de/wiki/U-Boot/, U-Boot} bootloader.
9734
9735 If you build a disk image and the bootloader is not available otherwise
9736 (on another boot drive etc), it's advisable to build an image that
9737 includes the bootloader, specifically:
9738
9739 @example
9740 guix system disk-image --system=armhf-linux -e '((@@ (gnu system install) os-with-u-boot) (@@ (gnu system install) installation-os) "A20-OLinuXino-Lime2")'
9741 @end example
9742
9743 @code{A20-OLinuXino-Lime2} is the name of the board. If you specify an invalid
9744 board, a list of possible boards will be printed.
9745
9746 @node System Configuration
9747 @chapter System Configuration
9748
9749 @cindex system configuration
9750 The Guix System Distribution supports a consistent whole-system configuration
9751 mechanism. By that we mean that all aspects of the global system
9752 configuration---such as the available system services, timezone and
9753 locale settings, user accounts---are declared in a single place. Such
9754 a @dfn{system configuration} can be @dfn{instantiated}---i.e., effected.
9755
9756 One of the advantages of putting all the system configuration under the
9757 control of Guix is that it supports transactional system upgrades, and
9758 makes it possible to roll back to a previous system instantiation,
9759 should something go wrong with the new one (@pxref{Features}). Another
9760 advantage is that it makes it easy to replicate the exact same configuration
9761 across different machines, or at different points in time, without
9762 having to resort to additional administration tools layered on top of
9763 the own tools of the system.
9764 @c Yes, we're talking of Puppet, Chef, & co. here. ↑
9765
9766 This section describes this mechanism. First we focus on the system
9767 administrator's viewpoint---explaining how the system is configured and
9768 instantiated. Then we show how this mechanism can be extended, for
9769 instance to support new system services.
9770
9771 @menu
9772 * Using the Configuration System:: Customizing your GNU system.
9773 * operating-system Reference:: Detail of operating-system declarations.
9774 * File Systems:: Configuring file system mounts.
9775 * Mapped Devices:: Block device extra processing.
9776 * User Accounts:: Specifying user accounts.
9777 * Locales:: Language and cultural convention settings.
9778 * Services:: Specifying system services.
9779 * Setuid Programs:: Programs running with root privileges.
9780 * X.509 Certificates:: Authenticating HTTPS servers.
9781 * Name Service Switch:: Configuring libc's name service switch.
9782 * Initial RAM Disk:: Linux-Libre bootstrapping.
9783 * Bootloader Configuration:: Configuring the boot loader.
9784 * Invoking guix system:: Instantiating a system configuration.
9785 * Running GuixSD in a VM:: How to run GuixSD in a virtual machine.
9786 * Defining Services:: Adding new service definitions.
9787 @end menu
9788
9789 @node Using the Configuration System
9790 @section Using the Configuration System
9791
9792 The operating system is configured by providing an
9793 @code{operating-system} declaration in a file that can then be passed to
9794 the @command{guix system} command (@pxref{Invoking guix system}). A
9795 simple setup, with the default system services, the default Linux-Libre
9796 kernel, initial RAM disk, and boot loader looks like this:
9797
9798 @findex operating-system
9799 @lisp
9800 @include os-config-bare-bones.texi
9801 @end lisp
9802
9803 This example should be self-describing. Some of the fields defined
9804 above, such as @code{host-name} and @code{bootloader}, are mandatory.
9805 Others, such as @code{packages} and @code{services}, can be omitted, in
9806 which case they get a default value.
9807
9808 Below we discuss the effect of some of the most important fields
9809 (@pxref{operating-system Reference}, for details about all the available
9810 fields), and how to @dfn{instantiate} the operating system using
9811 @command{guix system}.
9812
9813 @unnumberedsubsec Bootloader
9814
9815 @cindex legacy boot, on Intel machines
9816 @cindex BIOS boot, on Intel machines
9817 @cindex UEFI boot
9818 @cindex EFI boot
9819 The @code{bootloader} field describes the method that will be used to boot
9820 your system. Machines based on Intel processors can boot in ``legacy'' BIOS
9821 mode, as in the example above. However, more recent machines rely instead on
9822 the @dfn{Unified Extensible Firmware Interface} (UEFI) to boot. In that case,
9823 the @code{bootloader} field should contain something along these lines:
9824
9825 @example
9826 (bootloader-configuration
9827 (bootloader grub-efi-bootloader)
9828 (target "/boot/efi"))
9829 @end example
9830
9831 @xref{Bootloader Configuration}, for more information on the available
9832 configuration options.
9833
9834 @unnumberedsubsec Globally-Visible Packages
9835
9836 @vindex %base-packages
9837 The @code{packages} field lists packages that will be globally visible
9838 on the system, for all user accounts---i.e., in every user's @code{PATH}
9839 environment variable---in addition to the per-user profiles
9840 (@pxref{Invoking guix package}). The @var{%base-packages} variable
9841 provides all the tools one would expect for basic user and administrator
9842 tasks---including the GNU Core Utilities, the GNU Networking Utilities,
9843 the GNU Zile lightweight text editor, @command{find}, @command{grep},
9844 etc. The example above adds GNU@tie{}Screen to those,
9845 taken from the @code{(gnu packages screen)}
9846 module (@pxref{Package Modules}). The
9847 @code{(list package output)} syntax can be used to add a specific output
9848 of a package:
9849
9850 @lisp
9851 (use-modules (gnu packages))
9852 (use-modules (gnu packages dns))
9853
9854 (operating-system
9855 ;; ...
9856 (packages (cons (list bind "utils")
9857 %base-packages)))
9858 @end lisp
9859
9860 @findex specification->package
9861 Referring to packages by variable name, like @code{bind} above, has
9862 the advantage of being unambiguous; it also allows typos and such to be
9863 diagnosed right away as ``unbound variables''. The downside is that one
9864 needs to know which module defines which package, and to augment the
9865 @code{use-package-modules} line accordingly. To avoid that, one can use
9866 the @code{specification->package} procedure of the @code{(gnu packages)}
9867 module, which returns the best package for a given name or name and
9868 version:
9869
9870 @lisp
9871 (use-modules (gnu packages))
9872
9873 (operating-system
9874 ;; ...
9875 (packages (append (map specification->package
9876 '("tcpdump" "htop" "gnupg@@2.0"))
9877 %base-packages)))
9878 @end lisp
9879
9880 @unnumberedsubsec System Services
9881
9882 @cindex services
9883 @vindex %base-services
9884 The @code{services} field lists @dfn{system services} to be made
9885 available when the system starts (@pxref{Services}).
9886 The @code{operating-system} declaration above specifies that, in
9887 addition to the basic services, we want the @command{lshd} secure shell
9888 daemon listening on port 2222 (@pxref{Networking Services,
9889 @code{lsh-service}}). Under the hood,
9890 @code{lsh-service} arranges so that @code{lshd} is started with the
9891 right command-line options, possibly with supporting configuration files
9892 generated as needed (@pxref{Defining Services}).
9893
9894 @cindex customization, of services
9895 @findex modify-services
9896 Occasionally, instead of using the base services as is, you will want to
9897 customize them. To do this, use @code{modify-services} (@pxref{Service
9898 Reference, @code{modify-services}}) to modify the list.
9899
9900 For example, suppose you want to modify @code{guix-daemon} and Mingetty
9901 (the console log-in) in the @var{%base-services} list (@pxref{Base
9902 Services, @code{%base-services}}). To do that, you can write the
9903 following in your operating system declaration:
9904
9905 @lisp
9906 (define %my-services
9907 ;; My very own list of services.
9908 (modify-services %base-services
9909 (guix-service-type config =>
9910 (guix-configuration
9911 (inherit config)
9912 (use-substitutes? #f)
9913 (extra-options '("--gc-keep-derivations"))))
9914 (mingetty-service-type config =>
9915 (mingetty-configuration
9916 (inherit config)))))
9917
9918 (operating-system
9919 ;; @dots{}
9920 (services %my-services))
9921 @end lisp
9922
9923 This changes the configuration---i.e., the service parameters---of the
9924 @code{guix-service-type} instance, and that of all the
9925 @code{mingetty-service-type} instances in the @var{%base-services} list.
9926 Observe how this is accomplished: first, we arrange for the original
9927 configuration to be bound to the identifier @code{config} in the
9928 @var{body}, and then we write the @var{body} so that it evaluates to the
9929 desired configuration. In particular, notice how we use @code{inherit}
9930 to create a new configuration which has the same values as the old
9931 configuration, but with a few modifications.
9932
9933 @cindex encrypted disk
9934 The configuration for a typical ``desktop'' usage, with an encrypted
9935 root partition, the X11 display
9936 server, GNOME and Xfce (users can choose which of these desktop
9937 environments to use at the log-in screen by pressing @kbd{F1}), network
9938 management, power management, and more, would look like this:
9939
9940 @lisp
9941 @include os-config-desktop.texi
9942 @end lisp
9943
9944 A graphical system with a choice of lightweight window managers
9945 instead of full-blown desktop environments would look like this:
9946
9947 @lisp
9948 @include os-config-lightweight-desktop.texi
9949 @end lisp
9950
9951 This example refers to the @file{/boot/efi} file system by its UUID,
9952 @code{1234-ABCD}. Replace this UUID with the right UUID on your system,
9953 as returned by the @command{blkid} command.
9954
9955 @xref{Desktop Services}, for the exact list of services provided by
9956 @var{%desktop-services}. @xref{X.509 Certificates}, for background
9957 information about the @code{nss-certs} package that is used here.
9958
9959 Again, @var{%desktop-services} is just a list of service objects. If
9960 you want to remove services from there, you can do so using the
9961 procedures for list filtering (@pxref{SRFI-1 Filtering and
9962 Partitioning,,, guile, GNU Guile Reference Manual}). For instance, the
9963 following expression returns a list that contains all the services in
9964 @var{%desktop-services} minus the Avahi service:
9965
9966 @example
9967 (remove (lambda (service)
9968 (eq? (service-kind service) avahi-service-type))
9969 %desktop-services)
9970 @end example
9971
9972 @unnumberedsubsec Instantiating the System
9973
9974 Assuming the @code{operating-system} declaration
9975 is stored in the @file{my-system-config.scm}
9976 file, the @command{guix system reconfigure my-system-config.scm} command
9977 instantiates that configuration, and makes it the default GRUB boot
9978 entry (@pxref{Invoking guix system}).
9979
9980 The normal way to change the system configuration is by updating this
9981 file and re-running @command{guix system reconfigure}. One should never
9982 have to touch files in @file{/etc} or to run commands that modify the
9983 system state such as @command{useradd} or @command{grub-install}. In
9984 fact, you must avoid that since that would not only void your warranty
9985 but also prevent you from rolling back to previous versions of your
9986 system, should you ever need to.
9987
9988 @cindex roll-back, of the operating system
9989 Speaking of roll-back, each time you run @command{guix system
9990 reconfigure}, a new @dfn{generation} of the system is created---without
9991 modifying or deleting previous generations. Old system generations get
9992 an entry in the bootloader boot menu, allowing you to boot them in case
9993 something went wrong with the latest generation. Reassuring, no? The
9994 @command{guix system list-generations} command lists the system
9995 generations available on disk. It is also possible to roll back the
9996 system via the commands @command{guix system roll-back} and
9997 @command{guix system switch-generation}.
9998
9999 Although the @command{guix system reconfigure} command will not modify
10000 previous generations, you must take care when the current generation is not
10001 the latest (e.g., after invoking @command{guix system roll-back}), since
10002 the operation might overwrite a later generation (@pxref{Invoking guix
10003 system}).
10004
10005 @unnumberedsubsec The Programming Interface
10006
10007 At the Scheme level, the bulk of an @code{operating-system} declaration
10008 is instantiated with the following monadic procedure (@pxref{The Store
10009 Monad}):
10010
10011 @deffn {Monadic Procedure} operating-system-derivation os
10012 Return a derivation that builds @var{os}, an @code{operating-system}
10013 object (@pxref{Derivations}).
10014
10015 The output of the derivation is a single directory that refers to all
10016 the packages, configuration files, and other supporting files needed to
10017 instantiate @var{os}.
10018 @end deffn
10019
10020 This procedure is provided by the @code{(gnu system)} module. Along
10021 with @code{(gnu services)} (@pxref{Services}), this module contains the
10022 guts of GuixSD. Make sure to visit it!
10023
10024
10025 @node operating-system Reference
10026 @section @code{operating-system} Reference
10027
10028 This section summarizes all the options available in
10029 @code{operating-system} declarations (@pxref{Using the Configuration
10030 System}).
10031
10032 @deftp {Data Type} operating-system
10033 This is the data type representing an operating system configuration.
10034 By that, we mean all the global system configuration, not per-user
10035 configuration (@pxref{Using the Configuration System}).
10036
10037 @table @asis
10038 @item @code{kernel} (default: @var{linux-libre})
10039 The package object of the operating system kernel to use@footnote{Currently
10040 only the Linux-libre kernel is supported. In the future, it will be
10041 possible to use the GNU@tie{}Hurd.}.
10042
10043 @item @code{kernel-arguments} (default: @code{'()})
10044 List of strings or gexps representing additional arguments to pass on
10045 the command-line of the kernel---e.g., @code{("console=ttyS0")}.
10046
10047 @item @code{bootloader}
10048 The system bootloader configuration object. @xref{Bootloader Configuration}.
10049
10050 @item @code{initrd-modules} (default: @code{%base-initrd-modules})
10051 @cindex initrd
10052 @cindex initial RAM disk
10053 The list of Linux kernel modules that need to be available in the
10054 initial RAM disk. @xref{Initial RAM Disk}.
10055
10056 @item @code{initrd} (default: @code{base-initrd})
10057 A procedure that returns an initial RAM disk for the Linux
10058 kernel. This field is provided to support low-level customization and
10059 should rarely be needed for casual use. @xref{Initial RAM Disk}.
10060
10061 @item @code{firmware} (default: @var{%base-firmware})
10062 @cindex firmware
10063 List of firmware packages loadable by the operating system kernel.
10064
10065 The default includes firmware needed for Atheros- and Broadcom-based
10066 WiFi devices (Linux-libre modules @code{ath9k} and @code{b43-open},
10067 respectively). @xref{Hardware Considerations}, for more info on
10068 supported hardware.
10069
10070 @item @code{host-name}
10071 The host name.
10072
10073 @item @code{hosts-file}
10074 @cindex hosts file
10075 A file-like object (@pxref{G-Expressions, file-like objects}) for use as
10076 @file{/etc/hosts} (@pxref{Host Names,,, libc, The GNU C Library
10077 Reference Manual}). The default is a file with entries for
10078 @code{localhost} and @var{host-name}.
10079
10080 @item @code{mapped-devices} (default: @code{'()})
10081 A list of mapped devices. @xref{Mapped Devices}.
10082
10083 @item @code{file-systems}
10084 A list of file systems. @xref{File Systems}.
10085
10086 @item @code{swap-devices} (default: @code{'()})
10087 @cindex swap devices
10088 A list of strings identifying devices or files to be used for ``swap
10089 space'' (@pxref{Memory Concepts,,, libc, The GNU C Library Reference
10090 Manual}). For example, @code{'("/dev/sda3")} or @code{'("/swapfile")}.
10091 It is possible to specify a swap file in a file system on a mapped
10092 device, provided that the necessary device mapping and file system are
10093 also specified. @xref{Mapped Devices} and @ref{File Systems}.
10094
10095 @item @code{users} (default: @code{%base-user-accounts})
10096 @itemx @code{groups} (default: @var{%base-groups})
10097 List of user accounts and groups. @xref{User Accounts}.
10098
10099 If the @code{users} list lacks a user account with UID@tie{}0, a
10100 ``root'' account with UID@tie{}0 is automatically added.
10101
10102 @item @code{skeletons} (default: @code{(default-skeletons)})
10103 A list target file name/file-like object tuples (@pxref{G-Expressions,
10104 file-like objects}). These are the skeleton files that will be added to
10105 the home directory of newly-created user accounts.
10106
10107 For instance, a valid value may look like this:
10108
10109 @example
10110 `((".bashrc" ,(plain-file "bashrc" "echo Hello\n"))
10111 (".guile" ,(plain-file "guile"
10112 "(use-modules (ice-9 readline))
10113 (activate-readline)")))
10114 @end example
10115
10116 @item @code{issue} (default: @var{%default-issue})
10117 A string denoting the contents of the @file{/etc/issue} file, which is
10118 displayed when users log in on a text console.
10119
10120 @item @code{packages} (default: @var{%base-packages})
10121 The set of packages installed in the global profile, which is accessible
10122 at @file{/run/current-system/profile}.
10123
10124 The default set includes core utilities and it is good practice to
10125 install non-core utilities in user profiles (@pxref{Invoking guix
10126 package}).
10127
10128 @item @code{timezone}
10129 A timezone identifying string---e.g., @code{"Europe/Paris"}.
10130
10131 You can run the @command{tzselect} command to find out which timezone
10132 string corresponds to your region. Choosing an invalid timezone name
10133 causes @command{guix system} to fail.
10134
10135 @item @code{locale} (default: @code{"en_US.utf8"})
10136 The name of the default locale (@pxref{Locale Names,,, libc, The GNU C
10137 Library Reference Manual}). @xref{Locales}, for more information.
10138
10139 @item @code{locale-definitions} (default: @var{%default-locale-definitions})
10140 The list of locale definitions to be compiled and that may be used at
10141 run time. @xref{Locales}.
10142
10143 @item @code{locale-libcs} (default: @code{(list @var{glibc})})
10144 The list of GNU@tie{}libc packages whose locale data and tools are used
10145 to build the locale definitions. @xref{Locales}, for compatibility
10146 considerations that justify this option.
10147
10148 @item @code{name-service-switch} (default: @var{%default-nss})
10149 Configuration of the libc name service switch (NSS)---a
10150 @code{<name-service-switch>} object. @xref{Name Service Switch}, for
10151 details.
10152
10153 @item @code{services} (default: @var{%base-services})
10154 A list of service objects denoting system services. @xref{Services}.
10155
10156 @item @code{pam-services} (default: @code{(base-pam-services)})
10157 @cindex PAM
10158 @cindex pluggable authentication modules
10159 Linux @dfn{pluggable authentication module} (PAM) services.
10160 @c FIXME: Add xref to PAM services section.
10161
10162 @item @code{setuid-programs} (default: @var{%setuid-programs})
10163 List of string-valued G-expressions denoting setuid programs.
10164 @xref{Setuid Programs}.
10165
10166 @item @code{sudoers-file} (default: @var{%sudoers-specification})
10167 @cindex sudoers file
10168 The contents of the @file{/etc/sudoers} file as a file-like object
10169 (@pxref{G-Expressions, @code{local-file} and @code{plain-file}}).
10170
10171 This file specifies which users can use the @command{sudo} command, what
10172 they are allowed to do, and what privileges they may gain. The default
10173 is that only @code{root} and members of the @code{wheel} group may use
10174 @code{sudo}.
10175
10176 @end table
10177 @end deftp
10178
10179 @node File Systems
10180 @section File Systems
10181
10182 The list of file systems to be mounted is specified in the
10183 @code{file-systems} field of the operating system declaration
10184 (@pxref{Using the Configuration System}). Each file system is declared
10185 using the @code{file-system} form, like this:
10186
10187 @example
10188 (file-system
10189 (mount-point "/home")
10190 (device "/dev/sda3")
10191 (type "ext4"))
10192 @end example
10193
10194 As usual, some of the fields are mandatory---those shown in the example
10195 above---while others can be omitted. These are described below.
10196
10197 @deftp {Data Type} file-system
10198 Objects of this type represent file systems to be mounted. They
10199 contain the following members:
10200
10201 @table @asis
10202 @item @code{type}
10203 This is a string specifying the type of the file system---e.g.,
10204 @code{"ext4"}.
10205
10206 @item @code{mount-point}
10207 This designates the place where the file system is to be mounted.
10208
10209 @item @code{device}
10210 This names the ``source'' of the file system. It can be one of three
10211 things: a file system label, a file system UUID, or the name of a
10212 @file{/dev} node. Labels and UUIDs offer a way to refer to file
10213 systems without having to hard-code their actual device
10214 name@footnote{Note that, while it is tempting to use
10215 @file{/dev/disk/by-uuid} and similar device names to achieve the same
10216 result, this is not recommended: These special device nodes are created
10217 by the udev daemon and may be unavailable at the time the device is
10218 mounted.}.
10219
10220 @findex file-system-label
10221 File system labels are created using the @code{file-system-label}
10222 procedure, UUIDs are created using @code{uuid}, and @file{/dev} node are
10223 plain strings. Here's an example of a file system referred to by its
10224 label, as shown by the @command{e2label} command:
10225
10226 @example
10227 (file-system
10228 (mount-point "/home")
10229 (type "ext4")
10230 (device (file-system-label "my-home")))
10231 @end example
10232
10233 @findex uuid
10234 UUIDs are converted from their string representation (as shown by the
10235 @command{tune2fs -l} command) using the @code{uuid} form@footnote{The
10236 @code{uuid} form expects 16-byte UUIDs as defined in
10237 @uref{https://tools.ietf.org/html/rfc4122, RFC@tie{}4122}. This is the
10238 form of UUID used by the ext2 family of file systems and others, but it
10239 is different from ``UUIDs'' found in FAT file systems, for instance.},
10240 like this:
10241
10242 @example
10243 (file-system
10244 (mount-point "/home")
10245 (type "ext4")
10246 (device (uuid "4dab5feb-d176-45de-b287-9b0a6e4c01cb")))
10247 @end example
10248
10249 When the source of a file system is a mapped device (@pxref{Mapped
10250 Devices}), its @code{device} field @emph{must} refer to the mapped
10251 device name---e.g., @file{"/dev/mapper/root-partition"}.
10252 This is required so that
10253 the system knows that mounting the file system depends on having the
10254 corresponding device mapping established.
10255
10256 @item @code{flags} (default: @code{'()})
10257 This is a list of symbols denoting mount flags. Recognized flags
10258 include @code{read-only}, @code{bind-mount}, @code{no-dev} (disallow
10259 access to special files), @code{no-suid} (ignore setuid and setgid
10260 bits), and @code{no-exec} (disallow program execution.)
10261
10262 @item @code{options} (default: @code{#f})
10263 This is either @code{#f}, or a string denoting mount options.
10264
10265 @item @code{mount?} (default: @code{#t})
10266 This value indicates whether to automatically mount the file system when
10267 the system is brought up. When set to @code{#f}, the file system gets
10268 an entry in @file{/etc/fstab} (read by the @command{mount} command) but
10269 is not automatically mounted.
10270
10271 @item @code{needed-for-boot?} (default: @code{#f})
10272 This Boolean value indicates whether the file system is needed when
10273 booting. If that is true, then the file system is mounted when the
10274 initial RAM disk (initrd) is loaded. This is always the case, for
10275 instance, for the root file system.
10276
10277 @item @code{check?} (default: @code{#t})
10278 This Boolean indicates whether the file system needs to be checked for
10279 errors before being mounted.
10280
10281 @item @code{create-mount-point?} (default: @code{#f})
10282 When true, the mount point is created if it does not exist yet.
10283
10284 @item @code{dependencies} (default: @code{'()})
10285 This is a list of @code{<file-system>} or @code{<mapped-device>} objects
10286 representing file systems that must be mounted or mapped devices that
10287 must be opened before (and unmounted or closed after) this one.
10288
10289 As an example, consider a hierarchy of mounts: @file{/sys/fs/cgroup} is
10290 a dependency of @file{/sys/fs/cgroup/cpu} and
10291 @file{/sys/fs/cgroup/memory}.
10292
10293 Another example is a file system that depends on a mapped device, for
10294 example for an encrypted partition (@pxref{Mapped Devices}).
10295 @end table
10296 @end deftp
10297
10298 The @code{(gnu system file-systems)} exports the following useful
10299 variables.
10300
10301 @defvr {Scheme Variable} %base-file-systems
10302 These are essential file systems that are required on normal systems,
10303 such as @var{%pseudo-terminal-file-system} and @var{%immutable-store} (see
10304 below.) Operating system declarations should always contain at least
10305 these.
10306 @end defvr
10307
10308 @defvr {Scheme Variable} %pseudo-terminal-file-system
10309 This is the file system to be mounted as @file{/dev/pts}. It supports
10310 @dfn{pseudo-terminals} created @i{via} @code{openpty} and similar
10311 functions (@pxref{Pseudo-Terminals,,, libc, The GNU C Library Reference
10312 Manual}). Pseudo-terminals are used by terminal emulators such as
10313 @command{xterm}.
10314 @end defvr
10315
10316 @defvr {Scheme Variable} %shared-memory-file-system
10317 This file system is mounted as @file{/dev/shm} and is used to support
10318 memory sharing across processes (@pxref{Memory-mapped I/O,
10319 @code{shm_open},, libc, The GNU C Library Reference Manual}).
10320 @end defvr
10321
10322 @defvr {Scheme Variable} %immutable-store
10323 This file system performs a read-only ``bind mount'' of
10324 @file{/gnu/store}, making it read-only for all the users including
10325 @code{root}. This prevents against accidental modification by software
10326 running as @code{root} or by system administrators.
10327
10328 The daemon itself is still able to write to the store: it remounts it
10329 read-write in its own ``name space.''
10330 @end defvr
10331
10332 @defvr {Scheme Variable} %binary-format-file-system
10333 The @code{binfmt_misc} file system, which allows handling of arbitrary
10334 executable file types to be delegated to user space. This requires the
10335 @code{binfmt.ko} kernel module to be loaded.
10336 @end defvr
10337
10338 @defvr {Scheme Variable} %fuse-control-file-system
10339 The @code{fusectl} file system, which allows unprivileged users to mount
10340 and unmount user-space FUSE file systems. This requires the
10341 @code{fuse.ko} kernel module to be loaded.
10342 @end defvr
10343
10344 @node Mapped Devices
10345 @section Mapped Devices
10346
10347 @cindex device mapping
10348 @cindex mapped devices
10349 The Linux kernel has a notion of @dfn{device mapping}: a block device,
10350 such as a hard disk partition, can be @dfn{mapped} into another device,
10351 usually in @code{/dev/mapper/},
10352 with additional processing over the data that flows through
10353 it@footnote{Note that the GNU@tie{}Hurd makes no difference between the
10354 concept of a ``mapped device'' and that of a file system: both boil down
10355 to @emph{translating} input/output operations made on a file to
10356 operations on its backing store. Thus, the Hurd implements mapped
10357 devices, like file systems, using the generic @dfn{translator} mechanism
10358 (@pxref{Translators,,, hurd, The GNU Hurd Reference Manual}).}. A
10359 typical example is encryption device mapping: all writes to the mapped
10360 device are encrypted, and all reads are deciphered, transparently.
10361 Guix extends this notion by considering any device or set of devices that
10362 are @dfn{transformed} in some way to create a new device; for instance,
10363 RAID devices are obtained by @dfn{assembling} several other devices, such
10364 as hard disks or partitions, into a new one that behaves as one partition.
10365 Other examples, not yet implemented, are LVM logical volumes.
10366
10367 Mapped devices are declared using the @code{mapped-device} form,
10368 defined as follows; for examples, see below.
10369
10370 @deftp {Data Type} mapped-device
10371 Objects of this type represent device mappings that will be made when
10372 the system boots up.
10373
10374 @table @code
10375 @item source
10376 This is either a string specifying the name of the block device to be mapped,
10377 such as @code{"/dev/sda3"}, or a list of such strings when several devices
10378 need to be assembled for creating a new one.
10379
10380 @item target
10381 This string specifies the name of the resulting mapped device. For
10382 kernel mappers such as encrypted devices of type @code{luks-device-mapping},
10383 specifying @code{"my-partition"} leads to the creation of
10384 the @code{"/dev/mapper/my-partition"} device.
10385 For RAID devices of type @code{raid-device-mapping}, the full device name
10386 such as @code{"/dev/md0"} needs to be given.
10387
10388 @item type
10389 This must be a @code{mapped-device-kind} object, which specifies how
10390 @var{source} is mapped to @var{target}.
10391 @end table
10392 @end deftp
10393
10394 @defvr {Scheme Variable} luks-device-mapping
10395 This defines LUKS block device encryption using the @command{cryptsetup}
10396 command from the package with the same name. It relies on the
10397 @code{dm-crypt} Linux kernel module.
10398 @end defvr
10399
10400 @defvr {Scheme Variable} raid-device-mapping
10401 This defines a RAID device, which is assembled using the @code{mdadm}
10402 command from the package with the same name. It requires a Linux kernel
10403 module for the appropriate RAID level to be loaded, such as @code{raid456}
10404 for RAID-4, RAID-5 or RAID-6, or @code{raid10} for RAID-10.
10405 @end defvr
10406
10407 @cindex disk encryption
10408 @cindex LUKS
10409 The following example specifies a mapping from @file{/dev/sda3} to
10410 @file{/dev/mapper/home} using LUKS---the
10411 @url{https://gitlab.com/cryptsetup/cryptsetup,Linux Unified Key Setup}, a
10412 standard mechanism for disk encryption.
10413 The @file{/dev/mapper/home}
10414 device can then be used as the @code{device} of a @code{file-system}
10415 declaration (@pxref{File Systems}).
10416
10417 @example
10418 (mapped-device
10419 (source "/dev/sda3")
10420 (target "home")
10421 (type luks-device-mapping))
10422 @end example
10423
10424 Alternatively, to become independent of device numbering, one may obtain
10425 the LUKS UUID (@dfn{unique identifier}) of the source device by a
10426 command like:
10427
10428 @example
10429 cryptsetup luksUUID /dev/sda3
10430 @end example
10431
10432 and use it as follows:
10433
10434 @example
10435 (mapped-device
10436 (source (uuid "cb67fc72-0d54-4c88-9d4b-b225f30b0f44"))
10437 (target "home")
10438 (type luks-device-mapping))
10439 @end example
10440
10441 @cindex swap encryption
10442 It is also desirable to encrypt swap space, since swap space may contain
10443 sensitive data. One way to accomplish that is to use a swap file in a
10444 file system on a device mapped via LUKS encryption. In this way, the
10445 swap file is encrypted because the entire device is encrypted.
10446 @xref{Preparing for Installation,,Disk Partitioning}, for an example.
10447
10448 A RAID device formed of the partitions @file{/dev/sda1} and @file{/dev/sdb1}
10449 may be declared as follows:
10450
10451 @example
10452 (mapped-device
10453 (source (list "/dev/sda1" "/dev/sdb1"))
10454 (target "/dev/md0")
10455 (type raid-device-mapping))
10456 @end example
10457
10458 The @file{/dev/md0} device can then be used as the @code{device} of a
10459 @code{file-system} declaration (@pxref{File Systems}).
10460 Note that the RAID level need not be given; it is chosen during the
10461 initial creation and formatting of the RAID device and is determined
10462 automatically later.
10463
10464
10465 @node User Accounts
10466 @section User Accounts
10467
10468 @cindex users
10469 @cindex accounts
10470 @cindex user accounts
10471 User accounts and groups are entirely managed through the
10472 @code{operating-system} declaration. They are specified with the
10473 @code{user-account} and @code{user-group} forms:
10474
10475 @example
10476 (user-account
10477 (name "alice")
10478 (group "users")
10479 (supplementary-groups '("wheel" ;allow use of sudo, etc.
10480 "audio" ;sound card
10481 "video" ;video devices such as webcams
10482 "cdrom")) ;the good ol' CD-ROM
10483 (comment "Bob's sister")
10484 (home-directory "/home/alice"))
10485 @end example
10486
10487 When booting or upon completion of @command{guix system reconfigure},
10488 the system ensures that only the user accounts and groups specified in
10489 the @code{operating-system} declaration exist, and with the specified
10490 properties. Thus, account or group creations or modifications made by
10491 directly invoking commands such as @command{useradd} are lost upon
10492 reconfiguration or reboot. This ensures that the system remains exactly
10493 as declared.
10494
10495 @deftp {Data Type} user-account
10496 Objects of this type represent user accounts. The following members may
10497 be specified:
10498
10499 @table @asis
10500 @item @code{name}
10501 The name of the user account.
10502
10503 @item @code{group}
10504 @cindex groups
10505 This is the name (a string) or identifier (a number) of the user group
10506 this account belongs to.
10507
10508 @item @code{supplementary-groups} (default: @code{'()})
10509 Optionally, this can be defined as a list of group names that this
10510 account belongs to.
10511
10512 @item @code{uid} (default: @code{#f})
10513 This is the user ID for this account (a number), or @code{#f}. In the
10514 latter case, a number is automatically chosen by the system when the
10515 account is created.
10516
10517 @item @code{comment} (default: @code{""})
10518 A comment about the account, such as the account owner's full name.
10519
10520 @item @code{home-directory}
10521 This is the name of the home directory for the account.
10522
10523 @item @code{create-home-directory?} (default: @code{#t})
10524 Indicates whether the home directory of this account should be created
10525 if it does not exist yet.
10526
10527 @item @code{shell} (default: Bash)
10528 This is a G-expression denoting the file name of a program to be used as
10529 the shell (@pxref{G-Expressions}).
10530
10531 @item @code{system?} (default: @code{#f})
10532 This Boolean value indicates whether the account is a ``system''
10533 account. System accounts are sometimes treated specially; for instance,
10534 graphical login managers do not list them.
10535
10536 @anchor{user-account-password}
10537 @item @code{password} (default: @code{#f})
10538 You would normally leave this field to @code{#f}, initialize user
10539 passwords as @code{root} with the @command{passwd} command, and then let
10540 users change it with @command{passwd}. Passwords set with
10541 @command{passwd} are of course preserved across reboot and
10542 reconfiguration.
10543
10544 If you @emph{do} want to have a preset password for an account, then
10545 this field must contain the encrypted password, as a string.
10546 @xref{crypt,,, libc, The GNU C Library Reference Manual}, for more information
10547 on password encryption, and @ref{Encryption,,, guile, GNU Guile Reference
10548 Manual}, for information on Guile's @code{crypt} procedure.
10549
10550 @end table
10551 @end deftp
10552
10553 @cindex groups
10554 User group declarations are even simpler:
10555
10556 @example
10557 (user-group (name "students"))
10558 @end example
10559
10560 @deftp {Data Type} user-group
10561 This type is for, well, user groups. There are just a few fields:
10562
10563 @table @asis
10564 @item @code{name}
10565 The name of the group.
10566
10567 @item @code{id} (default: @code{#f})
10568 The group identifier (a number). If @code{#f}, a new number is
10569 automatically allocated when the group is created.
10570
10571 @item @code{system?} (default: @code{#f})
10572 This Boolean value indicates whether the group is a ``system'' group.
10573 System groups have low numerical IDs.
10574
10575 @item @code{password} (default: @code{#f})
10576 What, user groups can have a password? Well, apparently yes. Unless
10577 @code{#f}, this field specifies the password of the group.
10578
10579 @end table
10580 @end deftp
10581
10582 For convenience, a variable lists all the basic user groups one may
10583 expect:
10584
10585 @defvr {Scheme Variable} %base-groups
10586 This is the list of basic user groups that users and/or packages expect
10587 to be present on the system. This includes groups such as ``root'',
10588 ``wheel'', and ``users'', as well as groups used to control access to
10589 specific devices such as ``audio'', ``disk'', and ``cdrom''.
10590 @end defvr
10591
10592 @defvr {Scheme Variable} %base-user-accounts
10593 This is the list of basic system accounts that programs may expect to
10594 find on a GNU/Linux system, such as the ``nobody'' account.
10595
10596 Note that the ``root'' account is not included here. It is a
10597 special-case and is automatically added whether or not it is specified.
10598 @end defvr
10599
10600 @node Locales
10601 @section Locales
10602
10603 @cindex locale
10604 A @dfn{locale} defines cultural conventions for a particular language
10605 and region of the world (@pxref{Locales,,, libc, The GNU C Library
10606 Reference Manual}). Each locale has a name that typically has the form
10607 @code{@var{language}_@var{territory}.@var{codeset}}---e.g.,
10608 @code{fr_LU.utf8} designates the locale for the French language, with
10609 cultural conventions from Luxembourg, and using the UTF-8 encoding.
10610
10611 @cindex locale definition
10612 Usually, you will want to specify the default locale for the machine
10613 using the @code{locale} field of the @code{operating-system} declaration
10614 (@pxref{operating-system Reference, @code{locale}}).
10615
10616 The selected locale is automatically added to the @dfn{locale
10617 definitions} known to the system if needed, with its codeset inferred
10618 from its name---e.g., @code{bo_CN.utf8} will be assumed to use the
10619 @code{UTF-8} codeset. Additional locale definitions can be specified in
10620 the @code{locale-definitions} slot of @code{operating-system}---this is
10621 useful, for instance, if the codeset could not be inferred from the
10622 locale name. The default set of locale definitions includes some widely
10623 used locales, but not all the available locales, in order to save space.
10624
10625 For instance, to add the North Frisian locale for Germany, the value of
10626 that field may be:
10627
10628 @example
10629 (cons (locale-definition
10630 (name "fy_DE.utf8") (source "fy_DE"))
10631 %default-locale-definitions)
10632 @end example
10633
10634 Likewise, to save space, one might want @code{locale-definitions} to
10635 list only the locales that are actually used, as in:
10636
10637 @example
10638 (list (locale-definition
10639 (name "ja_JP.eucjp") (source "ja_JP")
10640 (charset "EUC-JP")))
10641 @end example
10642
10643 @vindex LOCPATH
10644 The compiled locale definitions are available at
10645 @file{/run/current-system/locale/X.Y}, where @code{X.Y} is the libc
10646 version, which is the default location where the GNU@tie{}libc provided
10647 by Guix looks for locale data. This can be overridden using the
10648 @code{LOCPATH} environment variable (@pxref{locales-and-locpath,
10649 @code{LOCPATH} and locale packages}).
10650
10651 The @code{locale-definition} form is provided by the @code{(gnu system
10652 locale)} module. Details are given below.
10653
10654 @deftp {Data Type} locale-definition
10655 This is the data type of a locale definition.
10656
10657 @table @asis
10658
10659 @item @code{name}
10660 The name of the locale. @xref{Locale Names,,, libc, The GNU C Library
10661 Reference Manual}, for more information on locale names.
10662
10663 @item @code{source}
10664 The name of the source for that locale. This is typically the
10665 @code{@var{language}_@var{territory}} part of the locale name.
10666
10667 @item @code{charset} (default: @code{"UTF-8"})
10668 The ``character set'' or ``code set'' for that locale,
10669 @uref{http://www.iana.org/assignments/character-sets, as defined by
10670 IANA}.
10671
10672 @end table
10673 @end deftp
10674
10675 @defvr {Scheme Variable} %default-locale-definitions
10676 A list of commonly used UTF-8 locales, used as the default
10677 value of the @code{locale-definitions} field of @code{operating-system}
10678 declarations.
10679
10680 @cindex locale name
10681 @cindex normalized codeset in locale names
10682 These locale definitions use the @dfn{normalized codeset} for the part
10683 that follows the dot in the name (@pxref{Using gettextized software,
10684 normalized codeset,, libc, The GNU C Library Reference Manual}). So for
10685 instance it has @code{uk_UA.utf8} but @emph{not}, say,
10686 @code{uk_UA.UTF-8}.
10687 @end defvr
10688
10689 @subsection Locale Data Compatibility Considerations
10690
10691 @cindex incompatibility, of locale data
10692 @code{operating-system} declarations provide a @code{locale-libcs} field
10693 to specify the GNU@tie{}libc packages that are used to compile locale
10694 declarations (@pxref{operating-system Reference}). ``Why would I
10695 care?'', you may ask. Well, it turns out that the binary format of
10696 locale data is occasionally incompatible from one libc version to
10697 another.
10698
10699 @c See <https://sourceware.org/ml/libc-alpha/2015-09/msg00575.html>
10700 @c and <https://lists.gnu.org/archive/html/guix-devel/2015-08/msg00737.html>.
10701 For instance, a program linked against libc version 2.21 is unable to
10702 read locale data produced with libc 2.22; worse, that program
10703 @emph{aborts} instead of simply ignoring the incompatible locale
10704 data@footnote{Versions 2.23 and later of GNU@tie{}libc will simply skip
10705 the incompatible locale data, which is already an improvement.}.
10706 Similarly, a program linked against libc 2.22 can read most, but not
10707 all, of the locale data from libc 2.21 (specifically, @code{LC_COLLATE}
10708 data is incompatible); thus calls to @code{setlocale} may fail, but
10709 programs will not abort.
10710
10711 The ``problem'' in GuixSD is that users have a lot of freedom: They can
10712 choose whether and when to upgrade software in their profiles, and might
10713 be using a libc version different from the one the system administrator
10714 used to build the system-wide locale data.
10715
10716 Fortunately, unprivileged users can also install their own locale data
10717 and define @var{GUIX_LOCPATH} accordingly (@pxref{locales-and-locpath,
10718 @code{GUIX_LOCPATH} and locale packages}).
10719
10720 Still, it is best if the system-wide locale data at
10721 @file{/run/current-system/locale} is built for all the libc versions
10722 actually in use on the system, so that all the programs can access
10723 it---this is especially crucial on a multi-user system. To do that, the
10724 administrator can specify several libc packages in the
10725 @code{locale-libcs} field of @code{operating-system}:
10726
10727 @example
10728 (use-package-modules base)
10729
10730 (operating-system
10731 ;; @dots{}
10732 (locale-libcs (list glibc-2.21 (canonical-package glibc))))
10733 @end example
10734
10735 This example would lead to a system containing locale definitions for
10736 both libc 2.21 and the current version of libc in
10737 @file{/run/current-system/locale}.
10738
10739
10740 @node Services
10741 @section Services
10742
10743 @cindex system services
10744 An important part of preparing an @code{operating-system} declaration is
10745 listing @dfn{system services} and their configuration (@pxref{Using the
10746 Configuration System}). System services are typically daemons launched
10747 when the system boots, or other actions needed at that time---e.g.,
10748 configuring network access.
10749
10750 GuixSD has a broad definition of ``service'' (@pxref{Service
10751 Composition}), but many services are managed by the GNU@tie{}Shepherd
10752 (@pxref{Shepherd Services}). On a running system, the @command{herd}
10753 command allows you to list the available services, show their status,
10754 start and stop them, or do other specific operations (@pxref{Jump
10755 Start,,, shepherd, The GNU Shepherd Manual}). For example:
10756
10757 @example
10758 # herd status
10759 @end example
10760
10761 The above command, run as @code{root}, lists the currently defined
10762 services. The @command{herd doc} command shows a synopsis of the given
10763 service and its associated actions:
10764
10765 @example
10766 # herd doc nscd
10767 Run libc's name service cache daemon (nscd).
10768
10769 # herd doc nscd action invalidate
10770 invalidate: Invalidate the given cache--e.g., 'hosts' for host name lookups.
10771 @end example
10772
10773 The @command{start}, @command{stop}, and @command{restart} sub-commands
10774 have the effect you would expect. For instance, the commands below stop
10775 the nscd service and restart the Xorg display server:
10776
10777 @example
10778 # herd stop nscd
10779 Service nscd has been stopped.
10780 # herd restart xorg-server
10781 Service xorg-server has been stopped.
10782 Service xorg-server has been started.
10783 @end example
10784
10785 The following sections document the available services, starting with
10786 the core services, that may be used in an @code{operating-system}
10787 declaration.
10788
10789 @menu
10790 * Base Services:: Essential system services.
10791 * Scheduled Job Execution:: The mcron service.
10792 * Log Rotation:: The rottlog service.
10793 * Networking Services:: Network setup, SSH daemon, etc.
10794 * X Window:: Graphical display.
10795 * Printing Services:: Local and remote printer support.
10796 * Desktop Services:: D-Bus and desktop services.
10797 * Sound Services:: ALSA and Pulseaudio services.
10798 * Database Services:: SQL databases, key-value stores, etc.
10799 * Mail Services:: IMAP, POP3, SMTP, and all that.
10800 * Messaging Services:: Messaging services.
10801 * Telephony Services:: Telephony services.
10802 * Monitoring Services:: Monitoring services.
10803 * Kerberos Services:: Kerberos services.
10804 * Web Services:: Web servers.
10805 * Certificate Services:: TLS certificates via Let's Encrypt.
10806 * DNS Services:: DNS daemons.
10807 * VPN Services:: VPN daemons.
10808 * Network File System:: NFS related services.
10809 * Continuous Integration:: The Cuirass service.
10810 * Power Management Services:: Extending battery life.
10811 * Audio Services:: The MPD.
10812 * Virtualization Services:: Virtualization services.
10813 * Version Control Services:: Providing remote access to Git repositories.
10814 * Game Services:: Game servers.
10815 * Miscellaneous Services:: Other services.
10816 @end menu
10817
10818 @node Base Services
10819 @subsection Base Services
10820
10821 The @code{(gnu services base)} module provides definitions for the basic
10822 services that one expects from the system. The services exported by
10823 this module are listed below.
10824
10825 @defvr {Scheme Variable} %base-services
10826 This variable contains a list of basic services (@pxref{Service Types
10827 and Services}, for more information on service objects) one would
10828 expect from the system: a login service (mingetty) on each tty, syslogd,
10829 the libc name service cache daemon (nscd), the udev device manager, and
10830 more.
10831
10832 This is the default value of the @code{services} field of
10833 @code{operating-system} declarations. Usually, when customizing a
10834 system, you will want to append services to @var{%base-services}, like
10835 this:
10836
10837 @example
10838 (cons* (service avahi-service-type)
10839 (service openssh-service-type)
10840 %base-services)
10841 @end example
10842 @end defvr
10843
10844 @defvr {Scheme Variable} special-files-service-type
10845 This is the service that sets up ``special files'' such as
10846 @file{/bin/sh}; an instance of it is part of @code{%base-services}.
10847
10848 The value associated with @code{special-files-service-type} services
10849 must be a list of tuples where the first element is the ``special file''
10850 and the second element is its target. By default it is:
10851
10852 @cindex @file{/bin/sh}
10853 @cindex @file{sh}, in @file{/bin}
10854 @example
10855 `(("/bin/sh" ,(file-append @var{bash} "/bin/sh")))
10856 @end example
10857
10858 @cindex @file{/usr/bin/env}
10859 @cindex @file{env}, in @file{/usr/bin}
10860 If you want to add, say, @code{/usr/bin/env} to your system, you can
10861 change it to:
10862
10863 @example
10864 `(("/bin/sh" ,(file-append @var{bash} "/bin/sh"))
10865 ("/usr/bin/env" ,(file-append @var{coreutils} "/bin/env")))
10866 @end example
10867
10868 Since this is part of @code{%base-services}, you can use
10869 @code{modify-services} to customize the set of special files
10870 (@pxref{Service Reference, @code{modify-services}}). But the simple way
10871 to add a special file is @i{via} the @code{extra-special-file} procedure
10872 (see below.)
10873 @end defvr
10874
10875 @deffn {Scheme Procedure} extra-special-file @var{file} @var{target}
10876 Use @var{target} as the ``special file'' @var{file}.
10877
10878 For example, adding the following lines to the @code{services} field of
10879 your operating system declaration leads to a @file{/usr/bin/env}
10880 symlink:
10881
10882 @example
10883 (extra-special-file "/usr/bin/env"
10884 (file-append coreutils "/bin/env"))
10885 @end example
10886 @end deffn
10887
10888 @deffn {Scheme Procedure} host-name-service @var{name}
10889 Return a service that sets the host name to @var{name}.
10890 @end deffn
10891
10892 @deffn {Scheme Procedure} login-service @var{config}
10893 Return a service to run login according to @var{config}, a
10894 @code{<login-configuration>} object, which specifies the message of the day,
10895 among other things.
10896 @end deffn
10897
10898 @deftp {Data Type} login-configuration
10899 This is the data type representing the configuration of login.
10900
10901 @table @asis
10902
10903 @item @code{motd}
10904 @cindex message of the day
10905 A file-like object containing the ``message of the day''.
10906
10907 @item @code{allow-empty-passwords?} (default: @code{#t})
10908 Allow empty passwords by default so that first-time users can log in when
10909 the 'root' account has just been created.
10910
10911 @end table
10912 @end deftp
10913
10914 @deffn {Scheme Procedure} mingetty-service @var{config}
10915 Return a service to run mingetty according to @var{config}, a
10916 @code{<mingetty-configuration>} object, which specifies the tty to run, among
10917 other things.
10918 @end deffn
10919
10920 @deftp {Data Type} mingetty-configuration
10921 This is the data type representing the configuration of Mingetty, which
10922 provides the default implementation of virtual console log-in.
10923
10924 @table @asis
10925
10926 @item @code{tty}
10927 The name of the console this Mingetty runs on---e.g., @code{"tty1"}.
10928
10929 @item @code{auto-login} (default: @code{#f})
10930 When true, this field must be a string denoting the user name under
10931 which the system automatically logs in. When it is @code{#f}, a
10932 user name and password must be entered to log in.
10933
10934 @item @code{login-program} (default: @code{#f})
10935 This must be either @code{#f}, in which case the default log-in program
10936 is used (@command{login} from the Shadow tool suite), or a gexp denoting
10937 the name of the log-in program.
10938
10939 @item @code{login-pause?} (default: @code{#f})
10940 When set to @code{#t} in conjunction with @var{auto-login}, the user
10941 will have to press a key before the log-in shell is launched.
10942
10943 @item @code{mingetty} (default: @var{mingetty})
10944 The Mingetty package to use.
10945
10946 @end table
10947 @end deftp
10948
10949 @deffn {Scheme Procedure} agetty-service @var{config}
10950 Return a service to run agetty according to @var{config}, an
10951 @code{<agetty-configuration>} object, which specifies the tty to run,
10952 among other things.
10953 @end deffn
10954
10955 @deftp {Data Type} agetty-configuration
10956 This is the data type representing the configuration of agetty, which
10957 implements virtual and serial console log-in. See the @code{agetty(8)}
10958 man page for more information.
10959
10960 @table @asis
10961
10962 @item @code{tty}
10963 The name of the console this agetty runs on, as a string---e.g.,
10964 @code{"ttyS0"}. This argument is optional, it will default to
10965 a reasonable default serial port used by the kernel Linux.
10966
10967 For this, if there is a value for an option @code{agetty.tty} in the kernel
10968 command line, agetty will extract the device name of the serial port
10969 from it and use that.
10970
10971 If not and if there is a value for an option @code{console} with a tty in
10972 the Linux command line, agetty will extract the device name of the
10973 serial port from it and use that.
10974
10975 In both cases, agetty will leave the other serial device settings
10976 (baud rate etc.)@: alone---in the hope that Linux pinned them to the
10977 correct values.
10978
10979 @item @code{baud-rate} (default: @code{#f})
10980 A string containing a comma-separated list of one or more baud rates, in
10981 descending order.
10982
10983 @item @code{term} (default: @code{#f})
10984 A string containing the value used for the @code{TERM} environment
10985 variable.
10986
10987 @item @code{eight-bits?} (default: @code{#f})
10988 When @code{#t}, the tty is assumed to be 8-bit clean, and parity detection is
10989 disabled.
10990
10991 @item @code{auto-login} (default: @code{#f})
10992 When passed a login name, as a string, the specified user will be logged
10993 in automatically without prompting for their login name or password.
10994
10995 @item @code{no-reset?} (default: @code{#f})
10996 When @code{#t}, don't reset terminal cflags (control modes).
10997
10998 @item @code{host} (default: @code{#f})
10999 This accepts a string containing the "login_host", which will be written
11000 into the @file{/var/run/utmpx} file.
11001
11002 @item @code{remote?} (default: @code{#f})
11003 When set to @code{#t} in conjunction with @var{host}, this will add an
11004 @code{-r} fakehost option to the command line of the login program
11005 specified in @var{login-program}.
11006
11007 @item @code{flow-control?} (default: @code{#f})
11008 When set to @code{#t}, enable hardware (RTS/CTS) flow control.
11009
11010 @item @code{no-issue?} (default: @code{#f})
11011 When set to @code{#t}, the contents of the @file{/etc/issue} file will
11012 not be displayed before presenting the login prompt.
11013
11014 @item @code{init-string} (default: @code{#f})
11015 This accepts a string that will be sent to the tty or modem before
11016 sending anything else. It can be used to initialize a modem.
11017
11018 @item @code{no-clear?} (default: @code{#f})
11019 When set to @code{#t}, agetty will not clear the screen before showing
11020 the login prompt.
11021
11022 @item @code{login-program} (default: (file-append shadow "/bin/login"))
11023 This must be either a gexp denoting the name of a log-in program, or
11024 unset, in which case the default value is the @command{login} from the
11025 Shadow tool suite.
11026
11027 @item @code{local-line} (default: @code{#f})
11028 Control the CLOCAL line flag. This accepts one of three symbols as
11029 arguments, @code{'auto}, @code{'always}, or @code{'never}. If @code{#f},
11030 the default value chosen by agetty is @code{'auto}.
11031
11032 @item @code{extract-baud?} (default: @code{#f})
11033 When set to @code{#t}, instruct agetty to try to extract the baud rate
11034 from the status messages produced by certain types of modems.
11035
11036 @item @code{skip-login?} (default: @code{#f})
11037 When set to @code{#t}, do not prompt the user for a login name. This
11038 can be used with @var{login-program} field to use non-standard login
11039 systems.
11040
11041 @item @code{no-newline?} (default: @code{#f})
11042 When set to @code{#t}, do not print a newline before printing the
11043 @file{/etc/issue} file.
11044
11045 @c Is this dangerous only when used with login-program, or always?
11046 @item @code{login-options} (default: @code{#f})
11047 This option accepts a string containing options that are passed to the
11048 login program. When used with the @var{login-program}, be aware that a
11049 malicious user could try to enter a login name containing embedded
11050 options that could be parsed by the login program.
11051
11052 @item @code{login-pause} (default: @code{#f})
11053 When set to @code{#t}, wait for any key before showing the login prompt.
11054 This can be used in conjunction with @var{auto-login} to save memory by
11055 lazily spawning shells.
11056
11057 @item @code{chroot} (default: @code{#f})
11058 Change root to the specified directory. This option accepts a directory
11059 path as a string.
11060
11061 @item @code{hangup?} (default: @code{#f})
11062 Use the Linux system call @code{vhangup} to do a virtual hangup of the
11063 specified terminal.
11064
11065 @item @code{keep-baud?} (default: @code{#f})
11066 When set to @code{#t}, try to keep the existing baud rate. The baud
11067 rates from @var{baud-rate} are used when agetty receives a @key{BREAK}
11068 character.
11069
11070 @item @code{timeout} (default: @code{#f})
11071 When set to an integer value, terminate if no user name could be read
11072 within @var{timeout} seconds.
11073
11074 @item @code{detect-case?} (default: @code{#f})
11075 When set to @code{#t}, turn on support for detecting an uppercase-only
11076 terminal. This setting will detect a login name containing only
11077 uppercase letters as indicating an uppercase-only terminal and turn on
11078 some upper-to-lower case conversions. Note that this will not support
11079 Unicode characters.
11080
11081 @item @code{wait-cr?} (default: @code{#f})
11082 When set to @code{#t}, wait for the user or modem to send a
11083 carriage-return or linefeed character before displaying
11084 @file{/etc/issue} or login prompt. This is typically used with the
11085 @var{init-string} option.
11086
11087 @item @code{no-hints?} (default: @code{#f})
11088 When set to @code{#t}, do not print hints about Num, Caps, and Scroll
11089 locks.
11090
11091 @item @code{no-hostname?} (default: @code{#f})
11092 By default, the hostname is printed. When this option is set to
11093 @code{#t}, no hostname will be shown at all.
11094
11095 @item @code{long-hostname?} (default: @code{#f})
11096 By default, the hostname is only printed until the first dot. When this
11097 option is set to @code{#t}, the fully qualified hostname by
11098 @code{gethostname} or @code{getaddrinfo} is shown.
11099
11100 @item @code{erase-characters} (default: @code{#f})
11101 This option accepts a string of additional characters that should be
11102 interpreted as backspace when the user types their login name.
11103
11104 @item @code{kill-characters} (default: @code{#f})
11105 This option accepts a string that should be interpreted to mean "ignore
11106 all previous characters" (also called a "kill" character) when the types
11107 their login name.
11108
11109 @item @code{chdir} (default: @code{#f})
11110 This option accepts, as a string, a directory path that will be changed
11111 to before login.
11112
11113 @item @code{delay} (default: @code{#f})
11114 This options accepts, as an integer, the number of seconds to sleep
11115 before opening the tty and displaying the login prompt.
11116
11117 @item @code{nice} (default: @code{#f})
11118 This option accepts, as an integer, the nice value with which to run the
11119 @command{login} program.
11120
11121 @item @code{extra-options} (default: @code{'()})
11122 This option provides an "escape hatch" for the user to provide arbitrary
11123 command-line arguments to @command{agetty} as a list of strings.
11124
11125 @end table
11126 @end deftp
11127
11128 @deffn {Scheme Procedure} kmscon-service-type @var{config}
11129 Return a service to run @uref{https://www.freedesktop.org/wiki/Software/kmscon,kmscon}
11130 according to @var{config}, a @code{<kmscon-configuration>} object, which
11131 specifies the tty to run, among other things.
11132 @end deffn
11133
11134 @deftp {Data Type} kmscon-configuration
11135 This is the data type representing the configuration of Kmscon, which
11136 implements virtual console log-in.
11137
11138 @table @asis
11139
11140 @item @code{virtual-terminal}
11141 The name of the console this Kmscon runs on---e.g., @code{"tty1"}.
11142
11143 @item @code{login-program} (default: @code{#~(string-append #$shadow "/bin/login")})
11144 A gexp denoting the name of the log-in program. The default log-in program is
11145 @command{login} from the Shadow tool suite.
11146
11147 @item @code{login-arguments} (default: @code{'("-p")})
11148 A list of arguments to pass to @command{login}.
11149
11150 @item @code{auto-login} (default: @code{#f})
11151 When passed a login name, as a string, the specified user will be logged
11152 in automatically without prompting for their login name or password.
11153
11154 @item @code{hardware-acceleration?} (default: #f)
11155 Whether to use hardware acceleration.
11156
11157 @item @code{kmscon} (default: @var{kmscon})
11158 The Kmscon package to use.
11159
11160 @end table
11161 @end deftp
11162
11163 @cindex name service cache daemon
11164 @cindex nscd
11165 @deffn {Scheme Procedure} nscd-service [@var{config}] [#:glibc glibc] @
11166 [#:name-services '()]
11167 Return a service that runs the libc name service cache daemon (nscd) with the
11168 given @var{config}---an @code{<nscd-configuration>} object. @xref{Name
11169 Service Switch}, for an example.
11170
11171 For convenience, the Shepherd service for nscd provides the following actions:
11172
11173 @table @code
11174 @item invalidate
11175 @cindex cache invalidation, nscd
11176 @cindex nscd, cache invalidation
11177 This invalidate the given cache. For instance, running:
11178
11179 @example
11180 herd invalidate nscd hosts
11181 @end example
11182
11183 @noindent
11184 invalidates the host name lookup cache of nscd.
11185
11186 @item statistics
11187 Running @command{herd statistics nscd} displays information about nscd usage
11188 and caches.
11189 @end table
11190
11191 @end deffn
11192
11193 @defvr {Scheme Variable} %nscd-default-configuration
11194 This is the default @code{<nscd-configuration>} value (see below) used
11195 by @code{nscd-service}. It uses the caches defined by
11196 @var{%nscd-default-caches}; see below.
11197 @end defvr
11198
11199 @deftp {Data Type} nscd-configuration
11200 This is the data type representing the name service cache daemon (nscd)
11201 configuration.
11202
11203 @table @asis
11204
11205 @item @code{name-services} (default: @code{'()})
11206 List of packages denoting @dfn{name services} that must be visible to
11207 the nscd---e.g., @code{(list @var{nss-mdns})}.
11208
11209 @item @code{glibc} (default: @var{glibc})
11210 Package object denoting the GNU C Library providing the @command{nscd}
11211 command.
11212
11213 @item @code{log-file} (default: @code{"/var/log/nscd.log"})
11214 Name of the nscd log file. This is where debugging output goes when
11215 @code{debug-level} is strictly positive.
11216
11217 @item @code{debug-level} (default: @code{0})
11218 Integer denoting the debugging levels. Higher numbers mean that more
11219 debugging output is logged.
11220
11221 @item @code{caches} (default: @var{%nscd-default-caches})
11222 List of @code{<nscd-cache>} objects denoting things to be cached; see
11223 below.
11224
11225 @end table
11226 @end deftp
11227
11228 @deftp {Data Type} nscd-cache
11229 Data type representing a cache database of nscd and its parameters.
11230
11231 @table @asis
11232
11233 @item @code{database}
11234 This is a symbol representing the name of the database to be cached.
11235 Valid values are @code{passwd}, @code{group}, @code{hosts}, and
11236 @code{services}, which designate the corresponding NSS database
11237 (@pxref{NSS Basics,,, libc, The GNU C Library Reference Manual}).
11238
11239 @item @code{positive-time-to-live}
11240 @itemx @code{negative-time-to-live} (default: @code{20})
11241 A number representing the number of seconds during which a positive or
11242 negative lookup result remains in cache.
11243
11244 @item @code{check-files?} (default: @code{#t})
11245 Whether to check for updates of the files corresponding to
11246 @var{database}.
11247
11248 For instance, when @var{database} is @code{hosts}, setting this flag
11249 instructs nscd to check for updates in @file{/etc/hosts} and to take
11250 them into account.
11251
11252 @item @code{persistent?} (default: @code{#t})
11253 Whether the cache should be stored persistently on disk.
11254
11255 @item @code{shared?} (default: @code{#t})
11256 Whether the cache should be shared among users.
11257
11258 @item @code{max-database-size} (default: 32@tie{}MiB)
11259 Maximum size in bytes of the database cache.
11260
11261 @c XXX: 'suggested-size' and 'auto-propagate?' seem to be expert
11262 @c settings, so leave them out.
11263
11264 @end table
11265 @end deftp
11266
11267 @defvr {Scheme Variable} %nscd-default-caches
11268 List of @code{<nscd-cache>} objects used by default by
11269 @code{nscd-configuration} (see above).
11270
11271 It enables persistent and aggressive caching of service and host name
11272 lookups. The latter provides better host name lookup performance,
11273 resilience in the face of unreliable name servers, and also better
11274 privacy---often the result of host name lookups is in local cache, so
11275 external name servers do not even need to be queried.
11276 @end defvr
11277
11278 @anchor{syslog-configuration-type}
11279 @cindex syslog
11280 @cindex logging
11281 @deftp {Data Type} syslog-configuration
11282 This data type represents the configuration of the syslog daemon.
11283
11284 @table @asis
11285 @item @code{syslogd} (default: @code{#~(string-append #$inetutils "/libexec/syslogd")})
11286 The syslog daemon to use.
11287
11288 @item @code{config-file} (default: @code{%default-syslog.conf})
11289 The syslog configuration file to use.
11290
11291 @end table
11292 @end deftp
11293
11294 @anchor{syslog-service}
11295 @cindex syslog
11296 @deffn {Scheme Procedure} syslog-service @var{config}
11297 Return a service that runs a syslog daemon according to @var{config}.
11298
11299 @xref{syslogd invocation,,, inetutils, GNU Inetutils}, for more
11300 information on the configuration file syntax.
11301 @end deffn
11302
11303 @defvr {Scheme Variable} guix-service-type
11304 This is the type of the service that runs the build daemon,
11305 @command{guix-daemon} (@pxref{Invoking guix-daemon}). Its value must be a
11306 @code{guix-configuration} record as described below.
11307 @end defvr
11308
11309 @anchor{guix-configuration-type}
11310 @deftp {Data Type} guix-configuration
11311 This data type represents the configuration of the Guix build daemon.
11312 @xref{Invoking guix-daemon}, for more information.
11313
11314 @table @asis
11315 @item @code{guix} (default: @var{guix})
11316 The Guix package to use.
11317
11318 @item @code{build-group} (default: @code{"guixbuild"})
11319 Name of the group for build user accounts.
11320
11321 @item @code{build-accounts} (default: @code{10})
11322 Number of build user accounts to create.
11323
11324 @item @code{authorize-key?} (default: @code{#t})
11325 @cindex substitutes, authorization thereof
11326 Whether to authorize the substitute keys listed in
11327 @code{authorized-keys}---by default that of @code{@value{SUBSTITUTE-SERVER}}
11328 (@pxref{Substitutes}).
11329
11330 @vindex %default-authorized-guix-keys
11331 @item @code{authorized-keys} (default: @var{%default-authorized-guix-keys})
11332 The list of authorized key files for archive imports, as a list of
11333 string-valued gexps (@pxref{Invoking guix archive}). By default, it
11334 contains that of @code{@value{SUBSTITUTE-SERVER}} (@pxref{Substitutes}).
11335
11336 @item @code{use-substitutes?} (default: @code{#t})
11337 Whether to use substitutes.
11338
11339 @item @code{substitute-urls} (default: @var{%default-substitute-urls})
11340 The list of URLs where to look for substitutes by default.
11341
11342 @item @code{max-silent-time} (default: @code{0})
11343 @itemx @code{timeout} (default: @code{0})
11344 The number of seconds of silence and the number of seconds of activity,
11345 respectively, after which a build process times out. A value of zero
11346 disables the timeout.
11347
11348 @item @code{log-compression} (default: @code{'bzip2})
11349 The type of compression used for build logs---one of @code{gzip},
11350 @code{bzip2}, or @code{none}.
11351
11352 @item @code{extra-options} (default: @code{'()})
11353 List of extra command-line options for @command{guix-daemon}.
11354
11355 @item @code{log-file} (default: @code{"/var/log/guix-daemon.log"})
11356 File where @command{guix-daemon}'s standard output and standard error
11357 are written.
11358
11359 @item @code{http-proxy} (default: @code{#f})
11360 The HTTP proxy used for downloading fixed-output derivations and
11361 substitutes.
11362
11363 @item @code{tmpdir} (default: @code{#f})
11364 A directory path where the @command{guix-daemon} will perform builds.
11365
11366 @end table
11367 @end deftp
11368
11369 @deffn {Scheme Procedure} udev-service [#:udev @var{eudev} #:rules @code{'()}]
11370 Run @var{udev}, which populates the @file{/dev} directory dynamically.
11371 udev rules can be provided as a list of files through the @var{rules}
11372 variable. The procedures @var{udev-rule} and @var{file->udev-rule} from
11373 @code{(gnu services base)} simplify the creation of such rule files.
11374 @end deffn
11375
11376 @deffn {Scheme Procedure} udev-rule [@var{file-name} @var{contents}]
11377 Return a udev-rule file named @var{file-name} containing the rules
11378 defined by the @var{contents} literal.
11379
11380 In the following example, a rule for a USB device is defined to be
11381 stored in the file @file{90-usb-thing.rules}. The rule runs a script
11382 upon detecting a USB device with a given product identifier.
11383
11384 @example
11385 (define %example-udev-rule
11386 (udev-rule
11387 "90-usb-thing.rules"
11388 (string-append "ACTION==\"add\", SUBSYSTEM==\"usb\", "
11389 "ATTR@{product@}==\"Example\", "
11390 "RUN+=\"/path/to/script\"")))
11391 @end example
11392
11393 The @command{herd rules udev} command, as root, returns the name of the
11394 directory containing all the active udev rules.
11395 @end deffn
11396
11397 Here we show how the default @var{udev-service} can be extended with it.
11398
11399 @example
11400 (operating-system
11401 ;; @dots{}
11402 (services
11403 (modify-services %desktop-services
11404 (udev-service-type config =>
11405 (udev-configuration (inherit config)
11406 (rules (append (udev-configuration-rules config)
11407 (list %example-udev-rule))))))))
11408 @end example
11409
11410 @deffn {Scheme Procedure} file->udev-rule [@var{file-name} @var{file}]
11411 Return a udev file named @var{file-name} containing the rules defined
11412 within @var{file}, a file-like object.
11413
11414 The following example showcases how we can use an existing rule file.
11415
11416 @example
11417 (use-modules (guix download) ;for url-fetch
11418 (guix packages) ;for origin
11419 ;; @dots{})
11420
11421 (define %android-udev-rules
11422 (file->udev-rule
11423 "51-android-udev.rules"
11424 (let ((version "20170910"))
11425 (origin
11426 (method url-fetch)
11427 (uri (string-append "https://raw.githubusercontent.com/M0Rf30/"
11428 "android-udev-rules/" version "/51-android.rules"))
11429 (sha256
11430 (base32 "0lmmagpyb6xsq6zcr2w1cyx9qmjqmajkvrdbhjx32gqf1d9is003"))))))
11431 @end example
11432 @end deffn
11433
11434 Additionally, Guix package definitions can be included in @var{rules} in
11435 order to extend the udev rules with the definitions found under their
11436 @file{lib/udev/rules.d} sub-directory. In lieu of the previous
11437 @var{file->udev-rule} example, we could have used the
11438 @var{android-udev-rules} package which exists in Guix in the @code{(gnu
11439 packages android)} module.
11440
11441 The following example shows how to use the @var{android-udev-rules}
11442 package so that the Android tool @command{adb} can detect devices
11443 without root privileges. It also details how to create the
11444 @code{adbusers} group, which is required for the proper functioning of
11445 the rules defined within the @var{android-udev-rules} package. To
11446 create such a group, we must define it both as part of the
11447 @var{supplementary-groups} of our @var{user-account} declaration, as
11448 well as in the @var{groups} field of the @var{operating-system} record.
11449
11450 @example
11451 (use-modules (gnu packages android) ;for android-udev-rules
11452 (gnu system shadow) ;for user-group
11453 ;; @dots{})
11454
11455 (operating-system
11456 ;; @dots{}
11457 (users (cons (user-acount
11458 ;; @dots{}
11459 (supplementary-groups
11460 '("adbusers" ;for adb
11461 "wheel" "netdev" "audio" "video"))
11462 ;; @dots{})))
11463
11464 (groups (cons (user-group (system? #t) (name "adbusers"))
11465 %base-groups))
11466
11467 ;; @dots{}
11468
11469 (services
11470 (modify-services %desktop-services
11471 (udev-service-type config =>
11472 (udev-configuration (inherit config)
11473 (rules (cons* android-udev-rules
11474 (udev-configuration-rules config))))))))
11475 @end example
11476
11477 @defvr {Scheme Variable} urandom-seed-service-type
11478 Save some entropy in @var{%random-seed-file} to seed @file{/dev/urandom}
11479 when rebooting. It also tries to seed @file{/dev/urandom} from
11480 @file{/dev/hwrng} while booting, if @file{/dev/hwrng} exists and is
11481 readable.
11482 @end defvr
11483
11484 @defvr {Scheme Variable} %random-seed-file
11485 This is the name of the file where some random bytes are saved by
11486 @var{urandom-seed-service} to seed @file{/dev/urandom} when rebooting.
11487 It defaults to @file{/var/lib/random-seed}.
11488 @end defvr
11489
11490 @cindex keymap
11491 @cindex keyboard
11492 @deffn {Scheme Procedure} console-keymap-service @var{files} ...
11493 @cindex keyboard layout
11494 Return a service to load console keymaps from @var{files} using
11495 @command{loadkeys} command. Most likely, you want to load some default
11496 keymap, which can be done like this:
11497
11498 @example
11499 (console-keymap-service "dvorak")
11500 @end example
11501
11502 Or, for example, for a Swedish keyboard, you may need to combine
11503 the following keymaps:
11504 @example
11505 (console-keymap-service "se-lat6" "se-fi-lat6")
11506 @end example
11507
11508 Also you can specify a full file name (or file names) of your keymap(s).
11509 See @code{man loadkeys} for details.
11510
11511 @end deffn
11512
11513 @cindex mouse
11514 @cindex gpm
11515 @defvr {Scheme Variable} gpm-service-type
11516 This is the type of the service that runs GPM, the @dfn{general-purpose
11517 mouse daemon}, which provides mouse support to the Linux console. GPM
11518 allows users to use the mouse in the console, notably to select, copy,
11519 and paste text.
11520
11521 The value for services of this type must be a @code{gpm-configuration}
11522 (see below). This service is not part of @var{%base-services}.
11523 @end defvr
11524
11525 @deftp {Data Type} gpm-configuration
11526 Data type representing the configuration of GPM.
11527
11528 @table @asis
11529 @item @code{options} (default: @code{%default-gpm-options})
11530 Command-line options passed to @command{gpm}. The default set of
11531 options instruct @command{gpm} to listen to mouse events on
11532 @file{/dev/input/mice}. @xref{Command Line,,, gpm, gpm manual}, for
11533 more information.
11534
11535 @item @code{gpm} (default: @code{gpm})
11536 The GPM package to use.
11537
11538 @end table
11539 @end deftp
11540
11541 @anchor{guix-publish-service-type}
11542 @deffn {Scheme Variable} guix-publish-service-type
11543 This is the service type for @command{guix publish} (@pxref{Invoking
11544 guix publish}). Its value must be a @code{guix-configuration}
11545 object, as described below.
11546
11547 This assumes that @file{/etc/guix} already contains a signing key pair as
11548 created by @command{guix archive --generate-key} (@pxref{Invoking guix
11549 archive}). If that is not the case, the service will fail to start.
11550 @end deffn
11551
11552 @deftp {Data Type} guix-publish-configuration
11553 Data type representing the configuration of the @code{guix publish}
11554 service.
11555
11556 @table @asis
11557 @item @code{guix} (default: @code{guix})
11558 The Guix package to use.
11559
11560 @item @code{port} (default: @code{80})
11561 The TCP port to listen for connections.
11562
11563 @item @code{host} (default: @code{"localhost"})
11564 The host (and thus, network interface) to listen to. Use
11565 @code{"0.0.0.0"} to listen on all the network interfaces.
11566
11567 @item @code{compression-level} (default: @code{3})
11568 The gzip compression level at which substitutes are compressed. Use
11569 @code{0} to disable compression altogether, and @code{9} to get the best
11570 compression ratio at the expense of increased CPU usage.
11571
11572 @item @code{nar-path} (default: @code{"nar"})
11573 The URL path at which ``nars'' can be fetched. @xref{Invoking guix
11574 publish, @code{--nar-path}}, for details.
11575
11576 @item @code{cache} (default: @code{#f})
11577 When it is @code{#f}, disable caching and instead generate archives on
11578 demand. Otherwise, this should be the name of a directory---e.g.,
11579 @code{"/var/cache/guix/publish"}---where @command{guix publish} caches
11580 archives and meta-data ready to be sent. @xref{Invoking guix publish,
11581 @option{--cache}}, for more information on the tradeoffs involved.
11582
11583 @item @code{workers} (default: @code{#f})
11584 When it is an integer, this is the number of worker threads used for
11585 caching; when @code{#f}, the number of processors is used.
11586 @xref{Invoking guix publish, @option{--workers}}, for more information.
11587
11588 @item @code{ttl} (default: @code{#f})
11589 When it is an integer, this denotes the @dfn{time-to-live} in seconds
11590 of the published archives. @xref{Invoking guix publish, @option{--ttl}},
11591 for more information.
11592 @end table
11593 @end deftp
11594
11595 @anchor{rngd-service}
11596 @deffn {Scheme Procedure} rngd-service [#:rng-tools @var{rng-tools}] @
11597 [#:device "/dev/hwrng"]
11598 Return a service that runs the @command{rngd} program from @var{rng-tools}
11599 to add @var{device} to the kernel's entropy pool. The service will fail if
11600 @var{device} does not exist.
11601 @end deffn
11602
11603 @anchor{pam-limits-service}
11604 @cindex session limits
11605 @cindex ulimit
11606 @cindex priority
11607 @cindex realtime
11608 @cindex jackd
11609 @deffn {Scheme Procedure} pam-limits-service [#:limits @code{'()}]
11610
11611 Return a service that installs a configuration file for the
11612 @uref{http://linux-pam.org/Linux-PAM-html/sag-pam_limits.html,
11613 @code{pam_limits} module}. The procedure optionally takes a list of
11614 @code{pam-limits-entry} values, which can be used to specify
11615 @code{ulimit} limits and nice priority limits to user sessions.
11616
11617 The following limits definition sets two hard and soft limits for all
11618 login sessions of users in the @code{realtime} group:
11619
11620 @example
11621 (pam-limits-service
11622 (list
11623 (pam-limits-entry "@@realtime" 'both 'rtprio 99)
11624 (pam-limits-entry "@@realtime" 'both 'memlock 'unlimited)))
11625 @end example
11626
11627 The first entry increases the maximum realtime priority for
11628 non-privileged processes; the second entry lifts any restriction of the
11629 maximum address space that can be locked in memory. These settings are
11630 commonly used for real-time audio systems.
11631 @end deffn
11632
11633 @node Scheduled Job Execution
11634 @subsection Scheduled Job Execution
11635
11636 @cindex cron
11637 @cindex mcron
11638 @cindex scheduling jobs
11639 The @code{(gnu services mcron)} module provides an interface to
11640 GNU@tie{}mcron, a daemon to run jobs at scheduled times (@pxref{Top,,,
11641 mcron, GNU@tie{}mcron}). GNU@tie{}mcron is similar to the traditional
11642 Unix @command{cron} daemon; the main difference is that it is
11643 implemented in Guile Scheme, which provides a lot of flexibility when
11644 specifying the scheduling of jobs and their actions.
11645
11646 The example below defines an operating system that runs the
11647 @command{updatedb} (@pxref{Invoking updatedb,,, find, Finding Files})
11648 and the @command{guix gc} commands (@pxref{Invoking guix gc}) daily, as
11649 well as the @command{mkid} command on behalf of an unprivileged user
11650 (@pxref{mkid invocation,,, idutils, ID Database Utilities}). It uses
11651 gexps to introduce job definitions that are passed to mcron
11652 (@pxref{G-Expressions}).
11653
11654 @lisp
11655 (use-modules (guix) (gnu) (gnu services mcron))
11656 (use-package-modules base idutils)
11657
11658 (define updatedb-job
11659 ;; Run 'updatedb' at 3AM every day. Here we write the
11660 ;; job's action as a Scheme procedure.
11661 #~(job '(next-hour '(3))
11662 (lambda ()
11663 (execl (string-append #$findutils "/bin/updatedb")
11664 "updatedb"
11665 "--prunepaths=/tmp /var/tmp /gnu/store"))))
11666
11667 (define garbage-collector-job
11668 ;; Collect garbage 5 minutes after midnight every day.
11669 ;; The job's action is a shell command.
11670 #~(job "5 0 * * *" ;Vixie cron syntax
11671 "guix gc -F 1G"))
11672
11673 (define idutils-job
11674 ;; Update the index database as user "charlie" at 12:15PM
11675 ;; and 19:15PM. This runs from the user's home directory.
11676 #~(job '(next-minute-from (next-hour '(12 19)) '(15))
11677 (string-append #$idutils "/bin/mkid src")
11678 #:user "charlie"))
11679
11680 (operating-system
11681 ;; @dots{}
11682 (services (cons (service mcron-service-type
11683 (mcron-configuration
11684 (jobs (list garbage-collector-job
11685 updatedb-job
11686 idutils-job))))
11687 %base-services)))
11688 @end lisp
11689
11690 @xref{Guile Syntax, mcron job specifications,, mcron, GNU@tie{}mcron},
11691 for more information on mcron job specifications. Below is the
11692 reference of the mcron service.
11693
11694 On a running system, you can use the @code{schedule} action of the service to
11695 visualize the mcron jobs that will be executed next:
11696
11697 @example
11698 # herd schedule mcron
11699 @end example
11700
11701 @noindent
11702 The example above lists the next five tasks that will be executed, but you can
11703 also specify the number of tasks to display:
11704
11705 @example
11706 # herd schedule mcron 10
11707 @end example
11708
11709 @defvr {Scheme Variable} mcron-service-type
11710 This is the type of the @code{mcron} service, whose value is an
11711 @code{mcron-configuration} object.
11712
11713 This service type can be the target of a service extension that provides
11714 it additional job specifications (@pxref{Service Composition}). In
11715 other words, it is possible to define services that provide additional
11716 mcron jobs to run.
11717 @end defvr
11718
11719 @deftp {Data Type} mcron-configuration
11720 Data type representing the configuration of mcron.
11721
11722 @table @asis
11723 @item @code{mcron} (default: @var{mcron})
11724 The mcron package to use.
11725
11726 @item @code{jobs}
11727 This is a list of gexps (@pxref{G-Expressions}), where each gexp
11728 corresponds to an mcron job specification (@pxref{Syntax, mcron job
11729 specifications,, mcron, GNU@tie{}mcron}).
11730 @end table
11731 @end deftp
11732
11733
11734 @node Log Rotation
11735 @subsection Log Rotation
11736
11737 @cindex rottlog
11738 @cindex log rotation
11739 @cindex logging
11740 Log files such as those found in @file{/var/log} tend to grow endlessly,
11741 so it's a good idea to @dfn{rotate} them once in a while---i.e., archive
11742 their contents in separate files, possibly compressed. The @code{(gnu
11743 services admin)} module provides an interface to GNU@tie{}Rot[t]log, a
11744 log rotation tool (@pxref{Top,,, rottlog, GNU Rot[t]log Manual}).
11745
11746 The example below defines an operating system that provides log rotation
11747 with the default settings, for commonly encountered log files.
11748
11749 @lisp
11750 (use-modules (guix) (gnu))
11751 (use-service-modules admin mcron)
11752 (use-package-modules base idutils)
11753
11754 (operating-system
11755 ;; @dots{}
11756 (services (cons (service rottlog-service-type)
11757 %base-services)))
11758 @end lisp
11759
11760 @defvr {Scheme Variable} rottlog-service-type
11761 This is the type of the Rottlog service, whose value is a
11762 @code{rottlog-configuration} object.
11763
11764 Other services can extend this one with new @code{log-rotation} objects
11765 (see below), thereby augmenting the set of files to be rotated.
11766
11767 This service type can define mcron jobs (@pxref{Scheduled Job
11768 Execution}) to run the rottlog service.
11769 @end defvr
11770
11771 @deftp {Data Type} rottlog-configuration
11772 Data type representing the configuration of rottlog.
11773
11774 @table @asis
11775 @item @code{rottlog} (default: @code{rottlog})
11776 The Rottlog package to use.
11777
11778 @item @code{rc-file} (default: @code{(file-append rottlog "/etc/rc")})
11779 The Rottlog configuration file to use (@pxref{Mandatory RC Variables,,,
11780 rottlog, GNU Rot[t]log Manual}).
11781
11782 @item @code{rotations} (default: @code{%default-rotations})
11783 A list of @code{log-rotation} objects as defined below.
11784
11785 @item @code{jobs}
11786 This is a list of gexps where each gexp corresponds to an mcron job
11787 specification (@pxref{Scheduled Job Execution}).
11788 @end table
11789 @end deftp
11790
11791 @deftp {Data Type} log-rotation
11792 Data type representing the rotation of a group of log files.
11793
11794 Taking an example from the Rottlog manual (@pxref{Period Related File
11795 Examples,,, rottlog, GNU Rot[t]log Manual}), a log rotation might be
11796 defined like this:
11797
11798 @example
11799 (log-rotation
11800 (frequency 'daily)
11801 (files '("/var/log/apache/*"))
11802 (options '("storedir apache-archives"
11803 "rotate 6"
11804 "notifempty"
11805 "nocompress")))
11806 @end example
11807
11808 The list of fields is as follows:
11809
11810 @table @asis
11811 @item @code{frequency} (default: @code{'weekly})
11812 The log rotation frequency, a symbol.
11813
11814 @item @code{files}
11815 The list of files or file glob patterns to rotate.
11816
11817 @item @code{options} (default: @code{'()})
11818 The list of rottlog options for this rotation (@pxref{Configuration
11819 parameters,,, rottlog, GNU Rot[t]lg Manual}).
11820
11821 @item @code{post-rotate} (default: @code{#f})
11822 Either @code{#f} or a gexp to execute once the rotation has completed.
11823 @end table
11824 @end deftp
11825
11826 @defvr {Scheme Variable} %default-rotations
11827 Specifies weekly rotation of @var{%rotated-files} and
11828 a couple of other files.
11829 @end defvr
11830
11831 @defvr {Scheme Variable} %rotated-files
11832 The list of syslog-controlled files to be rotated. By default it is:
11833 @code{'("/var/log/messages" "/var/log/secure")}.
11834 @end defvr
11835
11836 @node Networking Services
11837 @subsection Networking Services
11838
11839 The @code{(gnu services networking)} module provides services to configure
11840 the network interface.
11841
11842 @cindex DHCP, networking service
11843 @defvr {Scheme Variable} dhcp-client-service-type
11844 This is the type of services that run @var{dhcp}, a Dynamic Host Configuration
11845 Protocol (DHCP) client, on all the non-loopback network interfaces. Its value
11846 is the DHCP client package to use, @code{isc-dhcp} by default.
11847 @end defvr
11848
11849 @deffn {Scheme Procedure} dhcpd-service-type
11850 This type defines a service that runs a DHCP daemon. To create a
11851 service of this type, you must supply a @code{<dhcpd-configuration>}.
11852 For example:
11853
11854 @example
11855 (service dhcpd-service-type
11856 (dhcpd-configuration
11857 (config-file (local-file "my-dhcpd.conf"))
11858 (interfaces '("enp0s25"))))
11859 @end example
11860 @end deffn
11861
11862 @deftp {Data Type} dhcpd-configuration
11863 @table @asis
11864 @item @code{package} (default: @code{isc-dhcp})
11865 The package that provides the DHCP daemon. This package is expected to
11866 provide the daemon at @file{sbin/dhcpd} relative to its output
11867 directory. The default package is the
11868 @uref{http://www.isc.org/products/DHCP, ISC's DHCP server}.
11869 @item @code{config-file} (default: @code{#f})
11870 The configuration file to use. This is required. It will be passed to
11871 @code{dhcpd} via its @code{-cf} option. This may be any ``file-like''
11872 object (@pxref{G-Expressions, file-like objects}). See @code{man
11873 dhcpd.conf} for details on the configuration file syntax.
11874 @item @code{version} (default: @code{"4"})
11875 The DHCP version to use. The ISC DHCP server supports the values ``4'',
11876 ``6'', and ``4o6''. These correspond to the @code{dhcpd} program
11877 options @code{-4}, @code{-6}, and @code{-4o6}. See @code{man dhcpd} for
11878 details.
11879 @item @code{run-directory} (default: @code{"/run/dhcpd"})
11880 The run directory to use. At service activation time, this directory
11881 will be created if it does not exist.
11882 @item @code{pid-file} (default: @code{"/run/dhcpd/dhcpd.pid"})
11883 The PID file to use. This corresponds to the @code{-pf} option of
11884 @code{dhcpd}. See @code{man dhcpd} for details.
11885 @item @code{interfaces} (default: @code{'()})
11886 The names of the network interfaces on which dhcpd should listen for
11887 broadcasts. If this list is not empty, then its elements (which must be
11888 strings) will be appended to the @code{dhcpd} invocation when starting
11889 the daemon. It may not be necessary to explicitly specify any
11890 interfaces here; see @code{man dhcpd} for details.
11891 @end table
11892 @end deftp
11893
11894 @defvr {Scheme Variable} static-networking-service-type
11895 This is the type for statically-configured network interfaces.
11896 @c TODO Document <static-networking> data structures.
11897 @end defvr
11898
11899 @deffn {Scheme Procedure} static-networking-service @var{interface} @var{ip} @
11900 [#:netmask #f] [#:gateway #f] [#:name-servers @code{'()}] @
11901 [#:requirement @code{'(udev)}]
11902 Return a service that starts @var{interface} with address @var{ip}. If
11903 @var{netmask} is true, use it as the network mask. If @var{gateway} is true,
11904 it must be a string specifying the default network gateway. @var{requirement}
11905 can be used to declare a dependency on another service before configuring the
11906 interface.
11907
11908 This procedure can be called several times, one for each network
11909 interface of interest. Behind the scenes what it does is extend
11910 @code{static-networking-service-type} with additional network interfaces
11911 to handle.
11912
11913 For example:
11914
11915 @example
11916 (static-networking-service "eno1" "192.168.1.82"
11917 #:gateway "192.168.1.2"
11918 #:name-servers '("192.168.1.2"))
11919 @end example
11920 @end deffn
11921
11922 @cindex wicd
11923 @cindex wireless
11924 @cindex WiFi
11925 @cindex network management
11926 @deffn {Scheme Procedure} wicd-service [#:wicd @var{wicd}]
11927 Return a service that runs @url{https://launchpad.net/wicd,Wicd}, a network
11928 management daemon that aims to simplify wired and wireless networking.
11929
11930 This service adds the @var{wicd} package to the global profile, providing
11931 several commands to interact with the daemon and configure networking:
11932 @command{wicd-client}, a graphical user interface, and the @command{wicd-cli}
11933 and @command{wicd-curses} user interfaces.
11934 @end deffn
11935
11936 @cindex ModemManager
11937
11938 @defvr {Scheme Variable} modem-manager-service-type
11939 This is the service type for the
11940 @uref{https://wiki.gnome.org/Projects/ModemManager, ModemManager}
11941 service. The value for this service type is a
11942 @code{modem-manager-configuration} record.
11943
11944 This service is part of @code{%desktop-services} (@pxref{Desktop
11945 Services}).
11946 @end defvr
11947
11948 @deftp {Data Type} modem-manager-configuration
11949 Data type representing the configuration of ModemManager.
11950
11951 @table @asis
11952 @item @code{modem-manager} (default: @code{modem-manager})
11953 The ModemManager package to use.
11954
11955 @end table
11956 @end deftp
11957
11958 @cindex NetworkManager
11959
11960 @defvr {Scheme Variable} network-manager-service-type
11961 This is the service type for the
11962 @uref{https://wiki.gnome.org/Projects/NetworkManager, NetworkManager}
11963 service. The value for this service type is a
11964 @code{network-manager-configuration} record.
11965
11966 This service is part of @code{%desktop-services} (@pxref{Desktop
11967 Services}).
11968 @end defvr
11969
11970 @deftp {Data Type} network-manager-configuration
11971 Data type representing the configuration of NetworkManager.
11972
11973 @table @asis
11974 @item @code{network-manager} (default: @code{network-manager})
11975 The NetworkManager package to use.
11976
11977 @item @code{dns} (default: @code{"default"})
11978 Processing mode for DNS, which affects how NetworkManager uses the
11979 @code{resolv.conf} configuration file.
11980
11981 @table @samp
11982 @item default
11983 NetworkManager will update @code{resolv.conf} to reflect the nameservers
11984 provided by currently active connections.
11985
11986 @item dnsmasq
11987 NetworkManager will run @code{dnsmasq} as a local caching nameserver,
11988 using a "split DNS" configuration if you are connected to a VPN, and
11989 then update @code{resolv.conf} to point to the local nameserver.
11990
11991 @item none
11992 NetworkManager will not modify @code{resolv.conf}.
11993 @end table
11994
11995 @item @code{vpn-plugins} (default: @code{'()})
11996 This is the list of available plugins for virtual private networks
11997 (VPNs). An example of this is the @code{network-manager-openvpn}
11998 package, which allows NetworkManager to manage VPNs @i{via} OpenVPN.
11999
12000 @end table
12001 @end deftp
12002
12003 @cindex Connman
12004 @deffn {Scheme Variable} connman-service-type
12005 This is the service type to run @url{https://01.org/connman,Connman},
12006 a network connection manager.
12007
12008 Its value must be an
12009 @code{connman-configuration} record as in this example:
12010
12011 @example
12012 (service connman-service-type
12013 (connman-configuration
12014 (disable-vpn? #t)))
12015 @end example
12016
12017 See below for details about @code{connman-configuration}.
12018 @end deffn
12019
12020 @deftp {Data Type} connman-configuration
12021 Data Type representing the configuration of connman.
12022
12023 @table @asis
12024 @item @code{connman} (default: @var{connman})
12025 The connman package to use.
12026
12027 @item @code{disable-vpn?} (default: @code{#f})
12028 When true, disable connman's vpn plugin.
12029 @end table
12030 @end deftp
12031
12032 @cindex WPA Supplicant
12033 @defvr {Scheme Variable} wpa-supplicant-service-type
12034 This is the service type to run @url{https://w1.fi/wpa_supplicant/,WPA
12035 supplicant}, an authentication daemon required to authenticate against
12036 encrypted WiFi or ethernet networks.
12037 @end defvr
12038
12039 @deftp {Data Type} wpa-supplicant-configuration
12040 Data type representing the configuration of WPA Supplicant.
12041
12042 It takes the following parameters:
12043
12044 @table @asis
12045 @item @code{wpa-supplicant} (default: @code{wpa-supplicant})
12046 The WPA Supplicant package to use.
12047
12048 @item @code{dbus?} (default: @code{#t})
12049 Whether to listen for requests on D-Bus.
12050
12051 @item @code{pid-file} (default: @code{"/var/run/wpa_supplicant.pid"})
12052 Where to store the PID file.
12053
12054 @item @code{interface} (default: @code{#f})
12055 If this is set, it must specify the name of a network interface that
12056 WPA supplicant will control.
12057
12058 @item @code{config-file} (default: @code{#f})
12059 Optional configuration file to use.
12060
12061 @item @code{extra-options} (default: @code{'()})
12062 List of additional command-line arguments to pass to the daemon.
12063 @end table
12064 @end deftp
12065
12066 @cindex iptables
12067 @defvr {Scheme Variable} iptables-service-type
12068 This is the service type to set up an iptables configuration. iptables is a
12069 packet filtering framework supported by the Linux kernel. This service
12070 supports configuring iptables for both IPv4 and IPv6. A simple example
12071 configuration rejecting all incoming connections except those to the ssh port
12072 22 is shown below.
12073
12074 @lisp
12075 (service iptables-service-type
12076 (iptables-configuration
12077 (ipv4-rules (plain-file "iptables.rules" "*filter
12078 :INPUT ACCEPT
12079 :FORWARD ACCEPT
12080 :OUTPUT ACCEPT
12081 -A INPUT -p tcp --dport 22 -j ACCEPT
12082 -A INPUT -j REJECT --reject-with icmp-port-unreachable
12083 COMMIT
12084 "))
12085 (ipv6-rules (plain-file "ip6tables.rules" "*filter
12086 :INPUT ACCEPT
12087 :FORWARD ACCEPT
12088 :OUTPUT ACCEPT
12089 -A INPUT -p tcp --dport 22 -j ACCEPT
12090 -A INPUT -j REJECT --reject-with icmp6-port-unreachable
12091 COMMIT
12092 "))))
12093 @end lisp
12094 @end defvr
12095
12096 @deftp {Data Type} iptables-configuration
12097 The data type representing the configuration of iptables.
12098
12099 @table @asis
12100 @item @code{iptables} (default: @code{iptables})
12101 The iptables package that provides @code{iptables-restore} and
12102 @code{ip6tables-restore}.
12103 @item @code{ipv4-rules} (default: @code{%iptables-accept-all-rules})
12104 The iptables rules to use. It will be passed to @code{iptables-restore}.
12105 This may be any ``file-like'' object (@pxref{G-Expressions, file-like
12106 objects}).
12107 @item @code{ipv6-rules} (default: @code{%iptables-accept-all-rules})
12108 The ip6tables rules to use. It will be passed to @code{ip6tables-restore}.
12109 This may be any ``file-like'' object (@pxref{G-Expressions, file-like
12110 objects}).
12111 @end table
12112 @end deftp
12113
12114 @cindex NTP (Network Time Protocol), service
12115 @cindex real time clock
12116 @defvr {Scheme Variable} ntp-service-type
12117 This is the type of the service running the @uref{http://www.ntp.org,
12118 Network Time Protocol (NTP)} daemon, @command{ntpd}. The daemon will keep the
12119 system clock synchronized with that of the specified NTP servers.
12120
12121 The value of this service is an @code{ntpd-configuration} object, as described
12122 below.
12123 @end defvr
12124
12125 @deftp {Data Type} ntp-configuration
12126 This is the data type for the NTP service configuration.
12127
12128 @table @asis
12129 @item @code{servers} (default: @code{%ntp-servers})
12130 This is the list of servers (host names) with which @command{ntpd} will be
12131 synchronized.
12132
12133 @item @code{allow-large-adjustment?} (default: @code{#f})
12134 This determines whether @command{ntpd} is allowed to make an initial
12135 adjustment of more than 1,000 seconds.
12136
12137 @item @code{ntp} (default: @code{ntp})
12138 The NTP package to use.
12139 @end table
12140 @end deftp
12141
12142 @defvr {Scheme Variable} %ntp-servers
12143 List of host names used as the default NTP servers. These are servers of the
12144 @uref{https://www.ntppool.org/en/, NTP Pool Project}.
12145 @end defvr
12146
12147 @cindex OpenNTPD
12148 @deffn {Scheme Procedure} openntpd-service-type
12149 Run the @command{ntpd}, the Network Time Protocol (NTP) daemon, as implemented
12150 by @uref{http://www.openntpd.org, OpenNTPD}. The daemon will keep the system
12151 clock synchronized with that of the given servers.
12152
12153 @example
12154 (service
12155 openntpd-service-type
12156 (openntpd-configuration
12157 (listen-on '("127.0.0.1" "::1"))
12158 (sensor '("udcf0 correction 70000"))
12159 (constraint-from '("www.gnu.org"))
12160 (constraints-from '("https://www.google.com/"))
12161 (allow-large-adjustment? #t)))
12162
12163 @end example
12164 @end deffn
12165
12166 @deftp {Data Type} openntpd-configuration
12167 @table @asis
12168 @item @code{openntpd} (default: @code{(file-append openntpd "/sbin/ntpd")})
12169 The openntpd executable to use.
12170 @item @code{listen-on} (default: @code{'("127.0.0.1" "::1")})
12171 A list of local IP addresses or hostnames the ntpd daemon should listen on.
12172 @item @code{query-from} (default: @code{'()})
12173 A list of local IP address the ntpd daemon should use for outgoing queries.
12174 @item @code{sensor} (default: @code{'()})
12175 Specify a list of timedelta sensor devices ntpd should use. @code{ntpd}
12176 will listen to each sensor that acutally exists and ignore non-existant ones.
12177 See @uref{https://man.openbsd.org/ntpd.conf, upstream documentation} for more
12178 information.
12179 @item @code{server} (default: @var{%ntp-servers})
12180 Specify a list of IP addresses or hostnames of NTP servers to synchronize to.
12181 @item @code{servers} (default: @code{'()})
12182 Specify a list of IP addresses or hostnames of NTP pools to synchronize to.
12183 @item @code{constraint-from} (default: @code{'()})
12184 @code{ntpd} can be configured to query the ‘Date’ from trusted HTTPS servers via TLS.
12185 This time information is not used for precision but acts as an authenticated
12186 constraint, thereby reducing the impact of unauthenticated NTP
12187 man-in-the-middle attacks.
12188 Specify a list of URLs, IP addresses or hostnames of HTTPS servers to provide
12189 a constraint.
12190 @item @code{constraints-from} (default: @code{'()})
12191 As with constraint from, specify a list of URLs, IP addresses or hostnames of
12192 HTTPS servers to provide a constraint. Should the hostname resolve to multiple
12193 IP addresses, @code{ntpd} will calculate a median constraint from all of them.
12194 @item @code{allow-large-adjustment?} (default: @code{#f})
12195 Determines if @code{ntpd} is allowed to make an initial adjustment of more
12196 than 180 seconds.
12197 @end table
12198 @end deftp
12199
12200 @cindex inetd
12201 @deffn {Scheme variable} inetd-service-type
12202 This service runs the @command{inetd} (@pxref{inetd invocation,,,
12203 inetutils, GNU Inetutils}) daemon. @command{inetd} listens for
12204 connections on internet sockets, and lazily starts the specified server
12205 program when a connection is made on one of these sockets.
12206
12207 The value of this service is an @code{inetd-configuration} object. The
12208 following example configures the @command{inetd} daemon to provide the
12209 built-in @command{echo} service, as well as an smtp service which
12210 forwards smtp traffic over ssh to a server @code{smtp-server} behind a
12211 gateway @code{hostname}:
12212
12213 @example
12214 (service
12215 inetd-service-type
12216 (inetd-configuration
12217 (entries (list
12218 (inetd-entry
12219 (name "echo")
12220 (socket-type 'stream)
12221 (protocol "tcp")
12222 (wait? #f)
12223 (user "root"))
12224 (inetd-entry
12225 (node "127.0.0.1")
12226 (name "smtp")
12227 (socket-type 'stream)
12228 (protocol "tcp")
12229 (wait? #f)
12230 (user "root")
12231 (program (file-append openssh "/bin/ssh"))
12232 (arguments
12233 '("ssh" "-qT" "-i" "/path/to/ssh_key"
12234 "-W" "smtp-server:25" "user@@hostname")))))
12235 @end example
12236
12237 See below for more details about @code{inetd-configuration}.
12238 @end deffn
12239
12240 @deftp {Data Type} inetd-configuration
12241 Data type representing the configuration of @command{inetd}.
12242
12243 @table @asis
12244 @item @code{program} (default: @code{(file-append inetutils "/libexec/inetd")})
12245 The @command{inetd} executable to use.
12246
12247 @item @code{entries} (default: @code{'()})
12248 A list of @command{inetd} service entries. Each entry should be created
12249 by the @code{inetd-entry} constructor.
12250 @end table
12251 @end deftp
12252
12253 @deftp {Data Type} inetd-entry
12254 Data type representing an entry in the @command{inetd} configuration.
12255 Each entry corresponds to a socket where @command{inetd} will listen for
12256 requests.
12257
12258 @table @asis
12259 @item @code{node} (default: @code{#f})
12260 Optional string, a comma-separated list of local addresses
12261 @command{inetd} should use when listening for this service.
12262 @xref{Configuration file,,, inetutils, GNU Inetutils} for a complete
12263 description of all options.
12264 @item @code{name}
12265 A string, the name must correspond to an entry in @code{/etc/services}.
12266 @item @code{socket-type}
12267 One of @code{'stream}, @code{'dgram}, @code{'raw}, @code{'rdm} or
12268 @code{'seqpacket}.
12269 @item @code{protocol}
12270 A string, must correspond to an entry in @code{/etc/protocols}.
12271 @item @code{wait?} (default: @code{#t})
12272 Whether @command{inetd} should wait for the server to exit before
12273 listening to new service requests.
12274 @item @code{user}
12275 A string containing the user (and, optionally, group) name of the user
12276 as whom the server should run. The group name can be specified in a
12277 suffix, separated by a colon or period, i.e.@: @code{"user"},
12278 @code{"user:group"} or @code{"user.group"}.
12279 @item @code{program} (default: @code{"internal"})
12280 The server program which will serve the requests, or @code{"internal"}
12281 if @command{inetd} should use a built-in service.
12282 @item @code{arguments} (default: @code{'()})
12283 A list strings or file-like objects, which are the server program's
12284 arguments, starting with the zeroth argument, i.e.@: the name of the
12285 program itself. For @command{inetd}'s internal services, this entry
12286 must be @code{'()} or @code{'("internal")}.
12287 @end table
12288
12289 @xref{Configuration file,,, inetutils, GNU Inetutils} for a more
12290 detailed discussion of each configuration field.
12291 @end deftp
12292
12293 @cindex Tor
12294 @defvr {Scheme Variable} tor-service-type
12295 This is the type for a service that runs the @uref{https://torproject.org,
12296 Tor} anonymous networking daemon. The service is configured using a
12297 @code{<tor-configuration>} record. By default, the Tor daemon runs as the
12298 @code{tor} unprivileged user, which is a member of the @code{tor} group.
12299
12300 @end defvr
12301
12302 @deftp {Data Type} tor-configuration
12303 @table @asis
12304 @item @code{tor} (default: @code{tor})
12305 The package that provides the Tor daemon. This package is expected to provide
12306 the daemon at @file{bin/tor} relative to its output directory. The default
12307 package is the @uref{https://www.torproject.org, Tor Project's}
12308 implementation.
12309
12310 @item @code{config-file} (default: @code{(plain-file "empty" "")})
12311 The configuration file to use. It will be appended to a default configuration
12312 file, and the final configuration file will be passed to @code{tor} via its
12313 @code{-f} option. This may be any ``file-like'' object (@pxref{G-Expressions,
12314 file-like objects}). See @code{man tor} for details on the configuration file
12315 syntax.
12316
12317 @item @code{hidden-services} (default: @code{'()})
12318 The list of @code{<hidden-service>} records to use. For any hidden service
12319 you include in this list, appropriate configuration to enable the hidden
12320 service will be automatically added to the default configuration file. You
12321 may conveniently create @code{<hidden-service>} records using the
12322 @code{tor-hidden-service} procedure described below.
12323
12324 @item @code{socks-socket-type} (default: @code{'tcp})
12325 The default socket type that Tor should use for its SOCKS socket. This must
12326 be either @code{'tcp} or @code{'unix}. If it is @code{'tcp}, then by default
12327 Tor will listen on TCP port 9050 on the loopback interface (i.e., localhost).
12328 If it is @code{'unix}, then Tor will listen on the UNIX domain socket
12329 @file{/var/run/tor/socks-sock}, which will be made writable by members of the
12330 @code{tor} group.
12331
12332 If you want to customize the SOCKS socket in more detail, leave
12333 @code{socks-socket-type} at its default value of @code{'tcp} and use
12334 @code{config-file} to override the default by providing your own
12335 @code{SocksPort} option.
12336 @end table
12337 @end deftp
12338
12339 @cindex hidden service
12340 @deffn {Scheme Procedure} tor-hidden-service @var{name} @var{mapping}
12341 Define a new Tor @dfn{hidden service} called @var{name} and implementing
12342 @var{mapping}. @var{mapping} is a list of port/host tuples, such as:
12343
12344 @example
12345 '((22 "127.0.0.1:22")
12346 (80 "127.0.0.1:8080"))
12347 @end example
12348
12349 In this example, port 22 of the hidden service is mapped to local port 22, and
12350 port 80 is mapped to local port 8080.
12351
12352 This creates a @file{/var/lib/tor/hidden-services/@var{name}} directory, where
12353 the @file{hostname} file contains the @code{.onion} host name for the hidden
12354 service.
12355
12356 See @uref{https://www.torproject.org/docs/tor-hidden-service.html.en, the Tor
12357 project's documentation} for more information.
12358 @end deffn
12359
12360 The @code{(gnu services rsync)} module provides the following services:
12361
12362 You might want an rsync daemon if you have files that you want available
12363 so anyone (or just yourself) can download existing files or upload new
12364 files.
12365
12366 @deffn {Scheme Variable} rsync-service-type
12367 This is the type for the @uref{https://rsync.samba.org, rsync} rsync daemon,
12368 @command{rsync-configuration} record as in this example:
12369
12370 @example
12371 (service rsync-service-type)
12372 @end example
12373
12374 See below for details about @code{rsync-configuration}.
12375 @end deffn
12376
12377 @deftp {Data Type} rsync-configuration
12378 Data type representing the configuration for @code{rsync-service}.
12379
12380 @table @asis
12381 @item @code{package} (default: @var{rsync})
12382 @code{rsync} package to use.
12383
12384 @item @code{port-number} (default: @code{873})
12385 TCP port on which @command{rsync} listens for incoming connections. If port
12386 is less than @code{1024} @command{rsync} needs to be started as the
12387 @code{root} user and group.
12388
12389 @item @code{pid-file} (default: @code{"/var/run/rsyncd/rsyncd.pid"})
12390 Name of the file where @command{rsync} writes its PID.
12391
12392 @item @code{lock-file} (default: @code{"/var/run/rsyncd/rsyncd.lock"})
12393 Name of the file where @command{rsync} writes its lock file.
12394
12395 @item @code{log-file} (default: @code{"/var/log/rsyncd.log"})
12396 Name of the file where @command{rsync} writes its log file.
12397
12398 @item @code{use-chroot?} (default: @var{#t})
12399 Whether to use chroot for @command{rsync} shared directory.
12400
12401 @item @code{share-path} (default: @file{/srv/rsync})
12402 Location of the @command{rsync} shared directory.
12403
12404 @item @code{share-comment} (default: @code{"Rsync share"})
12405 Comment of the @command{rsync} shared directory.
12406
12407 @item @code{read-only?} (default: @var{#f})
12408 Read-write permissions to shared directory.
12409
12410 @item @code{timeout} (default: @code{300})
12411 I/O timeout in seconds.
12412
12413 @item @code{user} (default: @var{"root"})
12414 Owner of the @code{rsync} process.
12415
12416 @item @code{group} (default: @var{"root"})
12417 Group of the @code{rsync} process.
12418
12419 @item @code{uid} (default: @var{"rsyncd"})
12420 User name or user ID that file transfers to and from that module should take
12421 place as when the daemon was run as @code{root}.
12422
12423 @item @code{gid} (default: @var{"rsyncd"})
12424 Group name or group ID that will be used when accessing the module.
12425
12426 @end table
12427 @end deftp
12428
12429 Furthermore, @code{(gnu services ssh)} provides the following services.
12430 @cindex SSH
12431 @cindex SSH server
12432
12433 @deffn {Scheme Procedure} lsh-service [#:host-key "/etc/lsh/host-key"] @
12434 [#:daemonic? #t] [#:interfaces '()] [#:port-number 22] @
12435 [#:allow-empty-passwords? #f] [#:root-login? #f] @
12436 [#:syslog-output? #t] [#:x11-forwarding? #t] @
12437 [#:tcp/ip-forwarding? #t] [#:password-authentication? #t] @
12438 [#:public-key-authentication? #t] [#:initialize? #t]
12439 Run the @command{lshd} program from @var{lsh} to listen on port @var{port-number}.
12440 @var{host-key} must designate a file containing the host key, and readable
12441 only by root.
12442
12443 When @var{daemonic?} is true, @command{lshd} will detach from the
12444 controlling terminal and log its output to syslogd, unless one sets
12445 @var{syslog-output?} to false. Obviously, it also makes lsh-service
12446 depend on existence of syslogd service. When @var{pid-file?} is true,
12447 @command{lshd} writes its PID to the file called @var{pid-file}.
12448
12449 When @var{initialize?} is true, automatically create the seed and host key
12450 upon service activation if they do not exist yet. This may take long and
12451 require interaction.
12452
12453 When @var{initialize?} is false, it is up to the user to initialize the
12454 randomness generator (@pxref{lsh-make-seed,,, lsh, LSH Manual}), and to create
12455 a key pair with the private key stored in file @var{host-key} (@pxref{lshd
12456 basics,,, lsh, LSH Manual}).
12457
12458 When @var{interfaces} is empty, lshd listens for connections on all the
12459 network interfaces; otherwise, @var{interfaces} must be a list of host names
12460 or addresses.
12461
12462 @var{allow-empty-passwords?} specifies whether to accept log-ins with empty
12463 passwords, and @var{root-login?} specifies whether to accept log-ins as
12464 root.
12465
12466 The other options should be self-descriptive.
12467 @end deffn
12468
12469 @cindex SSH
12470 @cindex SSH server
12471 @deffn {Scheme Variable} openssh-service-type
12472 This is the type for the @uref{http://www.openssh.org, OpenSSH} secure
12473 shell daemon, @command{sshd}. Its value must be an
12474 @code{openssh-configuration} record as in this example:
12475
12476 @example
12477 (service openssh-service-type
12478 (openssh-configuration
12479 (x11-forwarding? #t)
12480 (permit-root-login 'without-password)
12481 (authorized-keys
12482 `(("alice" ,(local-file "alice.pub"))
12483 ("bob" ,(local-file "bob.pub"))))))
12484 @end example
12485
12486 See below for details about @code{openssh-configuration}.
12487
12488 This service can be extended with extra authorized keys, as in this
12489 example:
12490
12491 @example
12492 (service-extension openssh-service-type
12493 (const `(("charlie"
12494 ,(local-file "charlie.pub")))))
12495 @end example
12496 @end deffn
12497
12498 @deftp {Data Type} openssh-configuration
12499 This is the configuration record for OpenSSH's @command{sshd}.
12500
12501 @table @asis
12502 @item @code{pid-file} (default: @code{"/var/run/sshd.pid"})
12503 Name of the file where @command{sshd} writes its PID.
12504
12505 @item @code{port-number} (default: @code{22})
12506 TCP port on which @command{sshd} listens for incoming connections.
12507
12508 @item @code{permit-root-login} (default: @code{#f})
12509 This field determines whether and when to allow logins as root. If
12510 @code{#f}, root logins are disallowed; if @code{#t}, they are allowed.
12511 If it's the symbol @code{'without-password}, then root logins are
12512 permitted but not with password-based authentication.
12513
12514 @item @code{allow-empty-passwords?} (default: @code{#f})
12515 When true, users with empty passwords may log in. When false, they may
12516 not.
12517
12518 @item @code{password-authentication?} (default: @code{#t})
12519 When true, users may log in with their password. When false, they have
12520 other authentication methods.
12521
12522 @item @code{public-key-authentication?} (default: @code{#t})
12523 When true, users may log in using public key authentication. When
12524 false, users have to use other authentication method.
12525
12526 Authorized public keys are stored in @file{~/.ssh/authorized_keys}.
12527 This is used only by protocol version 2.
12528
12529 @item @code{x11-forwarding?} (default: @code{#f})
12530 When true, forwarding of X11 graphical client connections is
12531 enabled---in other words, @command{ssh} options @option{-X} and
12532 @option{-Y} will work.
12533
12534 @item @code{allow-agent-forwarding?} (default: @code{#t})
12535 Whether to allow agent forwarding.
12536
12537 @item @code{allow-tcp-forwarding?} (default: @code{#t})
12538 Whether to allow TCP forwarding.
12539
12540 @item @code{gateway-ports?} (default: @code{#f})
12541 Whether to allow gateway ports.
12542
12543 @item @code{challenge-response-authentication?} (default: @code{#f})
12544 Specifies whether challenge response authentication is allowed (e.g.@: via
12545 PAM).
12546
12547 @item @code{use-pam?} (default: @code{#t})
12548 Enables the Pluggable Authentication Module interface. If set to
12549 @code{#t}, this will enable PAM authentication using
12550 @code{challenge-response-authentication?} and
12551 @code{password-authentication?}, in addition to PAM account and session
12552 module processing for all authentication types.
12553
12554 Because PAM challenge response authentication usually serves an
12555 equivalent role to password authentication, you should disable either
12556 @code{challenge-response-authentication?} or
12557 @code{password-authentication?}.
12558
12559 @item @code{print-last-log?} (default: @code{#t})
12560 Specifies whether @command{sshd} should print the date and time of the
12561 last user login when a user logs in interactively.
12562
12563 @item @code{subsystems} (default: @code{'(("sftp" "internal-sftp"))})
12564 Configures external subsystems (e.g.@: file transfer daemon).
12565
12566 This is a list of two-element lists, each of which containing the
12567 subsystem name and a command (with optional arguments) to execute upon
12568 subsystem request.
12569
12570 The command @command{internal-sftp} implements an in-process SFTP
12571 server. Alternately, one can specify the @command{sftp-server} command:
12572 @example
12573 (service openssh-service-type
12574 (openssh-configuration
12575 (subsystems
12576 `(("sftp" ,(file-append openssh "/libexec/sftp-server"))))))
12577 @end example
12578
12579 @item @code{accepted-environment} (default: @code{'()})
12580 List of strings describing which environment variables may be exported.
12581
12582 Each string gets on its own line. See the @code{AcceptEnv} option in
12583 @code{man sshd_config}.
12584
12585 This example allows ssh-clients to export the @code{COLORTERM} variable.
12586 It is set by terminal emulators, which support colors. You can use it in
12587 your shell's ressource file to enable colors for the prompt and commands
12588 if this variable is set.
12589
12590 @example
12591 (service openssh-service-type
12592 (openssh-configuration
12593 (accepted-environment '("COLORTERM"))))
12594 @end example
12595
12596 @item @code{authorized-keys} (default: @code{'()})
12597 @cindex authorized keys, SSH
12598 @cindex SSH authorized keys
12599 This is the list of authorized keys. Each element of the list is a user
12600 name followed by one or more file-like objects that represent SSH public
12601 keys. For example:
12602
12603 @example
12604 (openssh-configuration
12605 (authorized-keys
12606 `(("rekado" ,(local-file "rekado.pub"))
12607 ("chris" ,(local-file "chris.pub"))
12608 ("root" ,(local-file "rekado.pub") ,(local-file "chris.pub")))))
12609 @end example
12610
12611 @noindent
12612 registers the specified public keys for user accounts @code{rekado},
12613 @code{chris}, and @code{root}.
12614
12615 Additional authorized keys can be specified @i{via}
12616 @code{service-extension}.
12617
12618 Note that this does @emph{not} interfere with the use of
12619 @file{~/.ssh/authorized_keys}.
12620
12621 @item @code{log-level} (default: @code{'info})
12622 This is a symbol specifying the logging level: @code{quiet}, @code{fatal},
12623 @code{error}, @code{info}, @code{verbose}, @code{debug}, etc. See the man
12624 page for @file{sshd_config} for the full list of level names.
12625
12626 @item @code{extra-content} (default: @code{""})
12627 This field can be used to append arbitrary text to the configuration file. It
12628 is especially useful for elaborate configurations that cannot be expressed
12629 otherwise. This configuration, for example, would generally disable root
12630 logins, but permit them from one specific IP address:
12631
12632 @example
12633 (openssh-configuration
12634 (extra-content "\
12635 Match Address 192.168.0.1
12636 PermitRootLogin yes"))
12637 @end example
12638
12639 @end table
12640 @end deftp
12641
12642 @deffn {Scheme Procedure} dropbear-service [@var{config}]
12643 Run the @uref{https://matt.ucc.asn.au/dropbear/dropbear.html,Dropbear SSH
12644 daemon} with the given @var{config}, a @code{<dropbear-configuration>}
12645 object.
12646
12647 For example, to specify a Dropbear service listening on port 1234, add
12648 this call to the operating system's @code{services} field:
12649
12650 @example
12651 (dropbear-service (dropbear-configuration
12652 (port-number 1234)))
12653 @end example
12654 @end deffn
12655
12656 @deftp {Data Type} dropbear-configuration
12657 This data type represents the configuration of a Dropbear SSH daemon.
12658
12659 @table @asis
12660 @item @code{dropbear} (default: @var{dropbear})
12661 The Dropbear package to use.
12662
12663 @item @code{port-number} (default: 22)
12664 The TCP port where the daemon waits for incoming connections.
12665
12666 @item @code{syslog-output?} (default: @code{#t})
12667 Whether to enable syslog output.
12668
12669 @item @code{pid-file} (default: @code{"/var/run/dropbear.pid"})
12670 File name of the daemon's PID file.
12671
12672 @item @code{root-login?} (default: @code{#f})
12673 Whether to allow @code{root} logins.
12674
12675 @item @code{allow-empty-passwords?} (default: @code{#f})
12676 Whether to allow empty passwords.
12677
12678 @item @code{password-authentication?} (default: @code{#t})
12679 Whether to enable password-based authentication.
12680 @end table
12681 @end deftp
12682
12683 @defvr {Scheme Variable} %facebook-host-aliases
12684 This variable contains a string for use in @file{/etc/hosts}
12685 (@pxref{Host Names,,, libc, The GNU C Library Reference Manual}). Each
12686 line contains a entry that maps a known server name of the Facebook
12687 on-line service---e.g., @code{www.facebook.com}---to the local
12688 host---@code{127.0.0.1} or its IPv6 equivalent, @code{::1}.
12689
12690 This variable is typically used in the @code{hosts-file} field of an
12691 @code{operating-system} declaration (@pxref{operating-system Reference,
12692 @file{/etc/hosts}}):
12693
12694 @example
12695 (use-modules (gnu) (guix))
12696
12697 (operating-system
12698 (host-name "mymachine")
12699 ;; ...
12700 (hosts-file
12701 ;; Create a /etc/hosts file with aliases for "localhost"
12702 ;; and "mymachine", as well as for Facebook servers.
12703 (plain-file "hosts"
12704 (string-append (local-host-aliases host-name)
12705 %facebook-host-aliases))))
12706 @end example
12707
12708 This mechanism can prevent programs running locally, such as Web
12709 browsers, from accessing Facebook.
12710 @end defvr
12711
12712 The @code{(gnu services avahi)} provides the following definition.
12713
12714 @defvr {Scheme Variable} avahi-service-type
12715 This is the service that runs @command{avahi-daemon}, a system-wide
12716 mDNS/DNS-SD responder that allows for service discovery and
12717 ``zero-configuration'' host name lookups (see @uref{http://avahi.org/}).
12718 Its value must be a @code{zero-configuration} record---see below.
12719
12720 This service extends the name service cache daemon (nscd) so that it can
12721 resolve @code{.local} host names using
12722 @uref{http://0pointer.de/lennart/projects/nss-mdns/, nss-mdns}. @xref{Name
12723 Service Switch}, for information on host name resolution.
12724
12725 Additionally, add the @var{avahi} package to the system profile so that
12726 commands such as @command{avahi-browse} are directly usable.
12727 @end defvr
12728
12729 @deftp {Data Type} avahi-configuration
12730 Data type representation the configuration for Avahi.
12731
12732 @table @asis
12733
12734 @item @code{host-name} (default: @code{#f})
12735 If different from @code{#f}, use that as the host name to
12736 publish for this machine; otherwise, use the machine's actual host name.
12737
12738 @item @code{publish?} (default: @code{#t})
12739 When true, allow host names and services to be published (broadcast) over the
12740 network.
12741
12742 @item @code{publish-workstation?} (default: @code{#t})
12743 When true, @command{avahi-daemon} publishes the machine's host name and IP
12744 address via mDNS on the local network. To view the host names published on
12745 your local network, you can run:
12746
12747 @example
12748 avahi-browse _workstation._tcp
12749 @end example
12750
12751 @item @code{wide-area?} (default: @code{#f})
12752 When true, DNS-SD over unicast DNS is enabled.
12753
12754 @item @code{ipv4?} (default: @code{#t})
12755 @itemx @code{ipv6?} (default: @code{#t})
12756 These fields determine whether to use IPv4/IPv6 sockets.
12757
12758 @item @code{domains-to-browse} (default: @code{'()})
12759 This is a list of domains to browse.
12760 @end table
12761 @end deftp
12762
12763 @deffn {Scheme Variable} openvswitch-service-type
12764 This is the type of the @uref{http://www.openvswitch.org, Open vSwitch}
12765 service, whose value should be an @code{openvswitch-configuration}
12766 object.
12767 @end deffn
12768
12769 @deftp {Data Type} openvswitch-configuration
12770 Data type representing the configuration of Open vSwitch, a multilayer
12771 virtual switch which is designed to enable massive network automation
12772 through programmatic extension.
12773
12774 @table @asis
12775 @item @code{package} (default: @var{openvswitch})
12776 Package object of the Open vSwitch.
12777
12778 @end table
12779 @end deftp
12780
12781 @node X Window
12782 @subsection X Window
12783
12784 @cindex X11
12785 @cindex X Window System
12786 @cindex login manager
12787 Support for the X Window graphical display system---specifically
12788 Xorg---is provided by the @code{(gnu services xorg)} module. Note that
12789 there is no @code{xorg-service} procedure. Instead, the X server is
12790 started by the @dfn{login manager}, by default SLiM.
12791
12792 @cindex window manager
12793 To use X11, you must install at least one @dfn{window manager}---for
12794 example the @code{windowmaker} or @code{openbox} packages---preferably
12795 by adding it to the @code{packages} field of your operating system
12796 definition (@pxref{operating-system Reference, system-wide packages}).
12797
12798 @defvr {Scheme Variable} slim-service-type
12799 This is the type for the SLiM graphical login manager for X11.
12800
12801 @cindex session types (X11)
12802 @cindex X11 session types
12803 SLiM looks for @dfn{session types} described by the @file{.desktop} files in
12804 @file{/run/current-system/profile/share/xsessions} and allows users to
12805 choose a session from the log-in screen using @kbd{F1}. Packages such
12806 as @code{xfce}, @code{sawfish}, and @code{ratpoison} provide
12807 @file{.desktop} files; adding them to the system-wide set of packages
12808 automatically makes them available at the log-in screen.
12809
12810 In addition, @file{~/.xsession} files are honored. When available,
12811 @file{~/.xsession} must be an executable that starts a window manager
12812 and/or other X clients.
12813 @end defvr
12814
12815 @deftp {Data Type} slim-configuration
12816 Data type representing the configuration of @code{slim-service-type}.
12817
12818 @table @asis
12819 @item @code{allow-empty-passwords?} (default: @code{#t})
12820 Whether to allow logins with empty passwords.
12821
12822 @item @code{auto-login?} (default: @code{#f})
12823 @itemx @code{default-user} (default: @code{""})
12824 When @code{auto-login?} is false, SLiM presents a log-in screen.
12825
12826 When @code{auto-login?} is true, SLiM logs in directly as
12827 @code{default-user}.
12828
12829 @item @code{theme} (default: @code{%default-slim-theme})
12830 @itemx @code{theme-name} (default: @code{%default-slim-theme-name})
12831 The graphical theme to use and its name.
12832
12833 @item @code{auto-login-session} (default: @code{#f})
12834 If true, this must be the name of the executable to start as the default
12835 session---e.g., @code{(file-append windowmaker "/bin/windowmaker")}.
12836
12837 If false, a session described by one of the available @file{.desktop}
12838 files in @code{/run/current-system/profile} and @code{~/.guix-profile}
12839 will be used.
12840
12841 @quotation Note
12842 You must install at least one window manager in the system profile or in
12843 your user profile. Failing to do that, if @code{auto-login-session} is
12844 false, you will be unable to log in.
12845 @end quotation
12846
12847 @item @code{startx} (default: @code{(xorg-start-command)})
12848 The command used to start the X11 graphical server.
12849
12850 @item @code{xauth} (default: @code{xauth})
12851 The XAuth package to use.
12852
12853 @item @code{shepherd} (default: @code{shepherd})
12854 The Shepherd package used when invoking @command{halt} and
12855 @command{reboot}.
12856
12857 @item @code{sessreg} (default: @code{sessreg})
12858 The sessreg package used in order to register the session.
12859
12860 @item @code{slim} (default: @code{slim})
12861 The SLiM package to use.
12862 @end table
12863 @end deftp
12864
12865 @defvr {Scheme Variable} %default-theme
12866 @defvrx {Scheme Variable} %default-theme-name
12867 The default SLiM theme and its name.
12868 @end defvr
12869
12870
12871 @deftp {Data Type} sddm-configuration
12872 This is the data type representing the sddm service configuration.
12873
12874 @table @asis
12875 @item @code{display-server} (default: "x11")
12876 Select display server to use for the greeter. Valid values are "x11"
12877 or "wayland".
12878
12879 @item @code{numlock} (default: "on")
12880 Valid values are "on", "off" or "none".
12881
12882 @item @code{halt-command} (default @code{#~(string-apppend #$shepherd "/sbin/halt")})
12883 Command to run when halting.
12884
12885 @item @code{reboot-command} (default @code{#~(string-append #$shepherd "/sbin/reboot")})
12886 Command to run when rebooting.
12887
12888 @item @code{theme} (default "maldives")
12889 Theme to use. Default themes provided by SDDM are "elarun" or "maldives".
12890
12891 @item @code{themes-directory} (default "/run/current-system/profile/share/sddm/themes")
12892 Directory to look for themes.
12893
12894 @item @code{faces-directory} (default "/run/current-system/profile/share/sddm/faces")
12895 Directory to look for faces.
12896
12897 @item @code{default-path} (default "/run/current-system/profile/bin")
12898 Default PATH to use.
12899
12900 @item @code{minimum-uid} (default 1000)
12901 Minimum UID to display in SDDM.
12902
12903 @item @code{maximum-uid} (default 2000)
12904 Maximum UID to display in SDDM
12905
12906 @item @code{remember-last-user?} (default #t)
12907 Remember last user.
12908
12909 @item @code{remember-last-session?} (default #t)
12910 Remember last session.
12911
12912 @item @code{hide-users} (default "")
12913 Usernames to hide from SDDM greeter.
12914
12915 @item @code{hide-shells} (default @code{#~(string-append #$shadow "/sbin/nologin")})
12916 Users with shells listed will be hidden from the SDDM greeter.
12917
12918 @item @code{session-command} (default @code{#~(string-append #$sddm "/share/sddm/scripts/wayland-session")})
12919 Script to run before starting a wayland session.
12920
12921 @item @code{sessions-directory} (default "/run/current-system/profile/share/wayland-sessions")
12922 Directory to look for desktop files starting wayland sessions.
12923
12924 @item @code{xorg-server-path} (default @code{xorg-start-command})
12925 Path to xorg-server.
12926
12927 @item @code{xauth-path} (default @code{#~(string-append #$xauth "/bin/xauth")})
12928 Path to xauth.
12929
12930 @item @code{xephyr-path} (default @code{#~(string-append #$xorg-server "/bin/Xephyr")})
12931 Path to Xephyr.
12932
12933 @item @code{xdisplay-start} (default @code{#~(string-append #$sddm "/share/sddm/scripts/Xsetup")})
12934 Script to run after starting xorg-server.
12935
12936 @item @code{xdisplay-stop} (default @code{#~(string-append #$sddm "/share/sddm/scripts/Xstop")})
12937 Script to run before stopping xorg-server.
12938
12939 @item @code{xsession-command} (default: @code{xinitrc})
12940 Script to run before starting a X session.
12941
12942 @item @code{xsessions-directory} (default: "/run/current-system/profile/share/xsessions")
12943 Directory to look for desktop files starting X sessions.
12944
12945 @item @code{minimum-vt} (default: 7)
12946 Minimum VT to use.
12947
12948 @item @code{xserver-arguments} (default "-nolisten tcp")
12949 Arguments to pass to xorg-server.
12950
12951 @item @code{auto-login-user} (default "")
12952 User to use for auto-login.
12953
12954 @item @code{auto-login-session} (default "")
12955 Desktop file to use for auto-login.
12956
12957 @item @code{relogin?} (default #f)
12958 Relogin after logout.
12959
12960 @end table
12961 @end deftp
12962
12963 @cindex login manager
12964 @cindex X11 login
12965 @deffn {Scheme Procedure} sddm-service config
12966 Return a service that spawns the SDDM graphical login manager for config of
12967 type @code{<sddm-configuration>}.
12968
12969 @example
12970 (sddm-service (sddm-configuration
12971 (auto-login-user "Alice")
12972 (auto-login-session "xfce.desktop")))
12973 @end example
12974 @end deffn
12975
12976 @deffn {Scheme Procedure} xorg-start-command [#:guile] @
12977 [#:modules %default-xorg-modules] @
12978 [#:fonts %default-xorg-fonts] @
12979 [#:configuration-file (xorg-configuration-file @dots{})] @
12980 [#:xorg-server @var{xorg-server}]
12981 Return a @code{startx} script in which @var{modules}, a list of X module
12982 packages, and @var{fonts}, a list of X font directories, are available. See
12983 @code{xorg-wrapper} for more details on the arguments. The result should be
12984 used in place of @code{startx}.
12985
12986 Usually the X server is started by a login manager.
12987 @end deffn
12988
12989 @deffn {Scheme Procedure} xorg-configuration-file @
12990 [#:modules %default-xorg-modules] @
12991 [#:fonts %default-xorg-fonts] @
12992 [#:drivers '()] [#:resolutions '()] [#:extra-config '()]
12993 Return a configuration file for the Xorg server containing search paths for
12994 all the common drivers.
12995
12996 @var{modules} must be a list of @dfn{module packages} loaded by the Xorg
12997 server---e.g., @code{xf86-video-vesa}, @code{xf86-input-keyboard}, and so on.
12998 @var{fonts} must be a list of font directories to add to the server's
12999 @dfn{font path}.
13000
13001 @var{drivers} must be either the empty list, in which case Xorg chooses a
13002 graphics driver automatically, or a list of driver names that will be tried in
13003 this order---e.g., @code{("modesetting" "vesa")}.
13004
13005 Likewise, when @var{resolutions} is the empty list, Xorg chooses an
13006 appropriate screen resolution; otherwise, it must be a list of
13007 resolutions---e.g., @code{((1024 768) (640 480))}.
13008
13009 Last, @var{extra-config} is a list of strings or objects appended to the
13010 configuration file. It is used to pass extra text to be
13011 added verbatim to the configuration file.
13012
13013 @cindex keymap
13014 @cindex keyboard layout
13015 This procedure is especially useful to configure a different keyboard layout
13016 than the default US keymap. For instance, to use the ``bépo'' keymap by
13017 default on the display manager:
13018
13019 @example
13020 (define bepo-evdev
13021 "Section \"InputClass\"
13022 Identifier \"evdev keyboard catchall\"
13023 Driver \"evdev\"
13024 MatchIsKeyboard \"on\"
13025 Option \"xkb_layout\" \"fr\"
13026 Option \"xkb_variant\" \"bepo\"
13027 EndSection")
13028
13029 (operating-system
13030 ...
13031 (services
13032 (modify-services %desktop-services
13033 (slim-service-type config =>
13034 (slim-configuration
13035 (inherit config)
13036 (startx (xorg-start-command
13037 #:configuration-file
13038 (xorg-configuration-file
13039 #:extra-config
13040 (list bepo-evdev)))))))))
13041 @end example
13042
13043 The @code{MatchIsKeyboard} line specifies that we only apply the configuration
13044 to keyboards. Without this line, other devices such as touchpad may not work
13045 correctly because they will be attached to the wrong driver. In this example,
13046 the user typically used @code{setxkbmap fr bepo} to set their favorite keymap
13047 once logged in. The first argument corresponds to the layout, while the second
13048 argument corresponds to the variant. The @code{xkb_variant} line can be omitted
13049 to select the default variant.
13050 @end deffn
13051
13052 @deffn {Scheme Procedure} screen-locker-service @var{package} [@var{program}]
13053 Add @var{package}, a package for a screen locker or screen saver whose
13054 command is @var{program}, to the set of setuid programs and add a PAM entry
13055 for it. For example:
13056
13057 @lisp
13058 (screen-locker-service xlockmore "xlock")
13059 @end lisp
13060
13061 makes the good ol' XlockMore usable.
13062 @end deffn
13063
13064
13065 @node Printing Services
13066 @subsection Printing Services
13067
13068 @cindex printer support with CUPS
13069 The @code{(gnu services cups)} module provides a Guix service definition
13070 for the CUPS printing service. To add printer support to a GuixSD
13071 system, add a @code{cups-service} to the operating system definition:
13072
13073 @deffn {Scheme Variable} cups-service-type
13074 The service type for the CUPS print server. Its value should be a valid
13075 CUPS configuration (see below). To use the default settings, simply
13076 write:
13077 @example
13078 (service cups-service-type)
13079 @end example
13080 @end deffn
13081
13082 The CUPS configuration controls the basic things about your CUPS
13083 installation: what interfaces it listens on, what to do if a print job
13084 fails, how much logging to do, and so on. To actually add a printer,
13085 you have to visit the @url{http://localhost:631} URL, or use a tool such
13086 as GNOME's printer configuration services. By default, configuring a
13087 CUPS service will generate a self-signed certificate if needed, for
13088 secure connections to the print server.
13089
13090 Suppose you want to enable the Web interface of CUPS and also add
13091 support for Epson printers @i{via} the @code{escpr} package and for HP
13092 printers @i{via} the @code{hplip-minimal} package. You can do that directly,
13093 like this (you need to use the @code{(gnu packages cups)} module):
13094
13095 @example
13096 (service cups-service-type
13097 (cups-configuration
13098 (web-interface? #t)
13099 (extensions
13100 (list cups-filters escpr hplip-minimal))))
13101 @end example
13102
13103 Note: If you wish to use the Qt5 based GUI which comes with the hplip
13104 package then it is suggested that you install the @code{hplip} package,
13105 either in your OS configuration file or as your user.
13106
13107 The available configuration parameters follow. Each parameter
13108 definition is preceded by its type; for example, @samp{string-list foo}
13109 indicates that the @code{foo} parameter should be specified as a list of
13110 strings. There is also a way to specify the configuration as a string,
13111 if you have an old @code{cupsd.conf} file that you want to port over
13112 from some other system; see the end for more details.
13113
13114 @c The following documentation was initially generated by
13115 @c (generate-documentation) in (gnu services cups). Manually maintained
13116 @c documentation is better, so we shouldn't hesitate to edit below as
13117 @c needed. However if the change you want to make to this documentation
13118 @c can be done in an automated way, it's probably easier to change
13119 @c (generate-documentation) than to make it below and have to deal with
13120 @c the churn as CUPS updates.
13121
13122
13123 Available @code{cups-configuration} fields are:
13124
13125 @deftypevr {@code{cups-configuration} parameter} package cups
13126 The CUPS package.
13127 @end deftypevr
13128
13129 @deftypevr {@code{cups-configuration} parameter} package-list extensions
13130 Drivers and other extensions to the CUPS package.
13131 @end deftypevr
13132
13133 @deftypevr {@code{cups-configuration} parameter} files-configuration files-configuration
13134 Configuration of where to write logs, what directories to use for print
13135 spools, and related privileged configuration parameters.
13136
13137 Available @code{files-configuration} fields are:
13138
13139 @deftypevr {@code{files-configuration} parameter} log-location access-log
13140 Defines the access log filename. Specifying a blank filename disables
13141 access log generation. The value @code{stderr} causes log entries to be
13142 sent to the standard error file when the scheduler is running in the
13143 foreground, or to the system log daemon when run in the background. The
13144 value @code{syslog} causes log entries to be sent to the system log
13145 daemon. The server name may be included in filenames using the string
13146 @code{%s}, as in @code{/var/log/cups/%s-access_log}.
13147
13148 Defaults to @samp{"/var/log/cups/access_log"}.
13149 @end deftypevr
13150
13151 @deftypevr {@code{files-configuration} parameter} file-name cache-dir
13152 Where CUPS should cache data.
13153
13154 Defaults to @samp{"/var/cache/cups"}.
13155 @end deftypevr
13156
13157 @deftypevr {@code{files-configuration} parameter} string config-file-perm
13158 Specifies the permissions for all configuration files that the scheduler
13159 writes.
13160
13161 Note that the permissions for the printers.conf file are currently
13162 masked to only allow access from the scheduler user (typically root).
13163 This is done because printer device URIs sometimes contain sensitive
13164 authentication information that should not be generally known on the
13165 system. There is no way to disable this security feature.
13166
13167 Defaults to @samp{"0640"}.
13168 @end deftypevr
13169
13170 @deftypevr {@code{files-configuration} parameter} log-location error-log
13171 Defines the error log filename. Specifying a blank filename disables
13172 access log generation. The value @code{stderr} causes log entries to be
13173 sent to the standard error file when the scheduler is running in the
13174 foreground, or to the system log daemon when run in the background. The
13175 value @code{syslog} causes log entries to be sent to the system log
13176 daemon. The server name may be included in filenames using the string
13177 @code{%s}, as in @code{/var/log/cups/%s-error_log}.
13178
13179 Defaults to @samp{"/var/log/cups/error_log"}.
13180 @end deftypevr
13181
13182 @deftypevr {@code{files-configuration} parameter} string fatal-errors
13183 Specifies which errors are fatal, causing the scheduler to exit. The
13184 kind strings are:
13185
13186 @table @code
13187 @item none
13188 No errors are fatal.
13189
13190 @item all
13191 All of the errors below are fatal.
13192
13193 @item browse
13194 Browsing initialization errors are fatal, for example failed connections
13195 to the DNS-SD daemon.
13196
13197 @item config
13198 Configuration file syntax errors are fatal.
13199
13200 @item listen
13201 Listen or Port errors are fatal, except for IPv6 failures on the
13202 loopback or @code{any} addresses.
13203
13204 @item log
13205 Log file creation or write errors are fatal.
13206
13207 @item permissions
13208 Bad startup file permissions are fatal, for example shared TLS
13209 certificate and key files with world-read permissions.
13210 @end table
13211
13212 Defaults to @samp{"all -browse"}.
13213 @end deftypevr
13214
13215 @deftypevr {@code{files-configuration} parameter} boolean file-device?
13216 Specifies whether the file pseudo-device can be used for new printer
13217 queues. The URI @uref{file:///dev/null} is always allowed.
13218
13219 Defaults to @samp{#f}.
13220 @end deftypevr
13221
13222 @deftypevr {@code{files-configuration} parameter} string group
13223 Specifies the group name or ID that will be used when executing external
13224 programs.
13225
13226 Defaults to @samp{"lp"}.
13227 @end deftypevr
13228
13229 @deftypevr {@code{files-configuration} parameter} string log-file-perm
13230 Specifies the permissions for all log files that the scheduler writes.
13231
13232 Defaults to @samp{"0644"}.
13233 @end deftypevr
13234
13235 @deftypevr {@code{files-configuration} parameter} log-location page-log
13236 Defines the page log filename. Specifying a blank filename disables
13237 access log generation. The value @code{stderr} causes log entries to be
13238 sent to the standard error file when the scheduler is running in the
13239 foreground, or to the system log daemon when run in the background. The
13240 value @code{syslog} causes log entries to be sent to the system log
13241 daemon. The server name may be included in filenames using the string
13242 @code{%s}, as in @code{/var/log/cups/%s-page_log}.
13243
13244 Defaults to @samp{"/var/log/cups/page_log"}.
13245 @end deftypevr
13246
13247 @deftypevr {@code{files-configuration} parameter} string remote-root
13248 Specifies the username that is associated with unauthenticated accesses
13249 by clients claiming to be the root user. The default is @code{remroot}.
13250
13251 Defaults to @samp{"remroot"}.
13252 @end deftypevr
13253
13254 @deftypevr {@code{files-configuration} parameter} file-name request-root
13255 Specifies the directory that contains print jobs and other HTTP request
13256 data.
13257
13258 Defaults to @samp{"/var/spool/cups"}.
13259 @end deftypevr
13260
13261 @deftypevr {@code{files-configuration} parameter} sandboxing sandboxing
13262 Specifies the level of security sandboxing that is applied to print
13263 filters, backends, and other child processes of the scheduler; either
13264 @code{relaxed} or @code{strict}. This directive is currently only
13265 used/supported on macOS.
13266
13267 Defaults to @samp{strict}.
13268 @end deftypevr
13269
13270 @deftypevr {@code{files-configuration} parameter} file-name server-keychain
13271 Specifies the location of TLS certificates and private keys. CUPS will
13272 look for public and private keys in this directory: a @code{.crt} files
13273 for PEM-encoded certificates and corresponding @code{.key} files for
13274 PEM-encoded private keys.
13275
13276 Defaults to @samp{"/etc/cups/ssl"}.
13277 @end deftypevr
13278
13279 @deftypevr {@code{files-configuration} parameter} file-name server-root
13280 Specifies the directory containing the server configuration files.
13281
13282 Defaults to @samp{"/etc/cups"}.
13283 @end deftypevr
13284
13285 @deftypevr {@code{files-configuration} parameter} boolean sync-on-close?
13286 Specifies whether the scheduler calls fsync(2) after writing
13287 configuration or state files.
13288
13289 Defaults to @samp{#f}.
13290 @end deftypevr
13291
13292 @deftypevr {@code{files-configuration} parameter} space-separated-string-list system-group
13293 Specifies the group(s) to use for @code{@@SYSTEM} group authentication.
13294 @end deftypevr
13295
13296 @deftypevr {@code{files-configuration} parameter} file-name temp-dir
13297 Specifies the directory where temporary files are stored.
13298
13299 Defaults to @samp{"/var/spool/cups/tmp"}.
13300 @end deftypevr
13301
13302 @deftypevr {@code{files-configuration} parameter} string user
13303 Specifies the user name or ID that is used when running external
13304 programs.
13305
13306 Defaults to @samp{"lp"}.
13307 @end deftypevr
13308 @end deftypevr
13309
13310 @deftypevr {@code{cups-configuration} parameter} access-log-level access-log-level
13311 Specifies the logging level for the AccessLog file. The @code{config}
13312 level logs when printers and classes are added, deleted, or modified and
13313 when configuration files are accessed or updated. The @code{actions}
13314 level logs when print jobs are submitted, held, released, modified, or
13315 canceled, and any of the conditions for @code{config}. The @code{all}
13316 level logs all requests.
13317
13318 Defaults to @samp{actions}.
13319 @end deftypevr
13320
13321 @deftypevr {@code{cups-configuration} parameter} boolean auto-purge-jobs?
13322 Specifies whether to purge job history data automatically when it is no
13323 longer required for quotas.
13324
13325 Defaults to @samp{#f}.
13326 @end deftypevr
13327
13328 @deftypevr {@code{cups-configuration} parameter} browse-local-protocols browse-local-protocols
13329 Specifies which protocols to use for local printer sharing.
13330
13331 Defaults to @samp{dnssd}.
13332 @end deftypevr
13333
13334 @deftypevr {@code{cups-configuration} parameter} boolean browse-web-if?
13335 Specifies whether the CUPS web interface is advertised.
13336
13337 Defaults to @samp{#f}.
13338 @end deftypevr
13339
13340 @deftypevr {@code{cups-configuration} parameter} boolean browsing?
13341 Specifies whether shared printers are advertised.
13342
13343 Defaults to @samp{#f}.
13344 @end deftypevr
13345
13346 @deftypevr {@code{cups-configuration} parameter} string classification
13347 Specifies the security classification of the server. Any valid banner
13348 name can be used, including "classified", "confidential", "secret",
13349 "topsecret", and "unclassified", or the banner can be omitted to disable
13350 secure printing functions.
13351
13352 Defaults to @samp{""}.
13353 @end deftypevr
13354
13355 @deftypevr {@code{cups-configuration} parameter} boolean classify-override?
13356 Specifies whether users may override the classification (cover page) of
13357 individual print jobs using the @code{job-sheets} option.
13358
13359 Defaults to @samp{#f}.
13360 @end deftypevr
13361
13362 @deftypevr {@code{cups-configuration} parameter} default-auth-type default-auth-type
13363 Specifies the default type of authentication to use.
13364
13365 Defaults to @samp{Basic}.
13366 @end deftypevr
13367
13368 @deftypevr {@code{cups-configuration} parameter} default-encryption default-encryption
13369 Specifies whether encryption will be used for authenticated requests.
13370
13371 Defaults to @samp{Required}.
13372 @end deftypevr
13373
13374 @deftypevr {@code{cups-configuration} parameter} string default-language
13375 Specifies the default language to use for text and web content.
13376
13377 Defaults to @samp{"en"}.
13378 @end deftypevr
13379
13380 @deftypevr {@code{cups-configuration} parameter} string default-paper-size
13381 Specifies the default paper size for new print queues. @samp{"Auto"}
13382 uses a locale-specific default, while @samp{"None"} specifies there is
13383 no default paper size. Specific size names are typically
13384 @samp{"Letter"} or @samp{"A4"}.
13385
13386 Defaults to @samp{"Auto"}.
13387 @end deftypevr
13388
13389 @deftypevr {@code{cups-configuration} parameter} string default-policy
13390 Specifies the default access policy to use.
13391
13392 Defaults to @samp{"default"}.
13393 @end deftypevr
13394
13395 @deftypevr {@code{cups-configuration} parameter} boolean default-shared?
13396 Specifies whether local printers are shared by default.
13397
13398 Defaults to @samp{#t}.
13399 @end deftypevr
13400
13401 @deftypevr {@code{cups-configuration} parameter} non-negative-integer dirty-clean-interval
13402 Specifies the delay for updating of configuration and state files, in
13403 seconds. A value of 0 causes the update to happen as soon as possible,
13404 typically within a few milliseconds.
13405
13406 Defaults to @samp{30}.
13407 @end deftypevr
13408
13409 @deftypevr {@code{cups-configuration} parameter} error-policy error-policy
13410 Specifies what to do when an error occurs. Possible values are
13411 @code{abort-job}, which will discard the failed print job;
13412 @code{retry-job}, which will retry the job at a later time;
13413 @code{retry-this-job}, which retries the failed job immediately; and
13414 @code{stop-printer}, which stops the printer.
13415
13416 Defaults to @samp{stop-printer}.
13417 @end deftypevr
13418
13419 @deftypevr {@code{cups-configuration} parameter} non-negative-integer filter-limit
13420 Specifies the maximum cost of filters that are run concurrently, which
13421 can be used to minimize disk, memory, and CPU resource problems. A
13422 limit of 0 disables filter limiting. An average print to a
13423 non-PostScript printer needs a filter limit of about 200. A PostScript
13424 printer needs about half that (100). Setting the limit below these
13425 thresholds will effectively limit the scheduler to printing a single job
13426 at any time.
13427
13428 Defaults to @samp{0}.
13429 @end deftypevr
13430
13431 @deftypevr {@code{cups-configuration} parameter} non-negative-integer filter-nice
13432 Specifies the scheduling priority of filters that are run to print a
13433 job. The nice value ranges from 0, the highest priority, to 19, the
13434 lowest priority.
13435
13436 Defaults to @samp{0}.
13437 @end deftypevr
13438
13439 @deftypevr {@code{cups-configuration} parameter} host-name-lookups host-name-lookups
13440 Specifies whether to do reverse lookups on connecting clients. The
13441 @code{double} setting causes @code{cupsd} to verify that the hostname
13442 resolved from the address matches one of the addresses returned for that
13443 hostname. Double lookups also prevent clients with unregistered
13444 addresses from connecting to your server. Only set this option to
13445 @code{#t} or @code{double} if absolutely required.
13446
13447 Defaults to @samp{#f}.
13448 @end deftypevr
13449
13450 @deftypevr {@code{cups-configuration} parameter} non-negative-integer job-kill-delay
13451 Specifies the number of seconds to wait before killing the filters and
13452 backend associated with a canceled or held job.
13453
13454 Defaults to @samp{30}.
13455 @end deftypevr
13456
13457 @deftypevr {@code{cups-configuration} parameter} non-negative-integer job-retry-interval
13458 Specifies the interval between retries of jobs in seconds. This is
13459 typically used for fax queues but can also be used with normal print
13460 queues whose error policy is @code{retry-job} or
13461 @code{retry-current-job}.
13462
13463 Defaults to @samp{30}.
13464 @end deftypevr
13465
13466 @deftypevr {@code{cups-configuration} parameter} non-negative-integer job-retry-limit
13467 Specifies the number of retries that are done for jobs. This is
13468 typically used for fax queues but can also be used with normal print
13469 queues whose error policy is @code{retry-job} or
13470 @code{retry-current-job}.
13471
13472 Defaults to @samp{5}.
13473 @end deftypevr
13474
13475 @deftypevr {@code{cups-configuration} parameter} boolean keep-alive?
13476 Specifies whether to support HTTP keep-alive connections.
13477
13478 Defaults to @samp{#t}.
13479 @end deftypevr
13480
13481 @deftypevr {@code{cups-configuration} parameter} non-negative-integer keep-alive-timeout
13482 Specifies how long an idle client connection remains open, in seconds.
13483
13484 Defaults to @samp{30}.
13485 @end deftypevr
13486
13487 @deftypevr {@code{cups-configuration} parameter} non-negative-integer limit-request-body
13488 Specifies the maximum size of print files, IPP requests, and HTML form
13489 data. A limit of 0 disables the limit check.
13490
13491 Defaults to @samp{0}.
13492 @end deftypevr
13493
13494 @deftypevr {@code{cups-configuration} parameter} multiline-string-list listen
13495 Listens on the specified interfaces for connections. Valid values are
13496 of the form @var{address}:@var{port}, where @var{address} is either an
13497 IPv6 address enclosed in brackets, an IPv4 address, or @code{*} to
13498 indicate all addresses. Values can also be file names of local UNIX
13499 domain sockets. The Listen directive is similar to the Port directive
13500 but allows you to restrict access to specific interfaces or networks.
13501 @end deftypevr
13502
13503 @deftypevr {@code{cups-configuration} parameter} non-negative-integer listen-back-log
13504 Specifies the number of pending connections that will be allowed. This
13505 normally only affects very busy servers that have reached the MaxClients
13506 limit, but can also be triggered by large numbers of simultaneous
13507 connections. When the limit is reached, the operating system will
13508 refuse additional connections until the scheduler can accept the pending
13509 ones.
13510
13511 Defaults to @samp{128}.
13512 @end deftypevr
13513
13514 @deftypevr {@code{cups-configuration} parameter} location-access-control-list location-access-controls
13515 Specifies a set of additional access controls.
13516
13517 Available @code{location-access-controls} fields are:
13518
13519 @deftypevr {@code{location-access-controls} parameter} file-name path
13520 Specifies the URI path to which the access control applies.
13521 @end deftypevr
13522
13523 @deftypevr {@code{location-access-controls} parameter} access-control-list access-controls
13524 Access controls for all access to this path, in the same format as the
13525 @code{access-controls} of @code{operation-access-control}.
13526
13527 Defaults to @samp{()}.
13528 @end deftypevr
13529
13530 @deftypevr {@code{location-access-controls} parameter} method-access-control-list method-access-controls
13531 Access controls for method-specific access to this path.
13532
13533 Defaults to @samp{()}.
13534
13535 Available @code{method-access-controls} fields are:
13536
13537 @deftypevr {@code{method-access-controls} parameter} boolean reverse?
13538 If @code{#t}, apply access controls to all methods except the listed
13539 methods. Otherwise apply to only the listed methods.
13540
13541 Defaults to @samp{#f}.
13542 @end deftypevr
13543
13544 @deftypevr {@code{method-access-controls} parameter} method-list methods
13545 Methods to which this access control applies.
13546
13547 Defaults to @samp{()}.
13548 @end deftypevr
13549
13550 @deftypevr {@code{method-access-controls} parameter} access-control-list access-controls
13551 Access control directives, as a list of strings. Each string should be
13552 one directive, such as "Order allow,deny".
13553
13554 Defaults to @samp{()}.
13555 @end deftypevr
13556 @end deftypevr
13557 @end deftypevr
13558
13559 @deftypevr {@code{cups-configuration} parameter} non-negative-integer log-debug-history
13560 Specifies the number of debugging messages that are retained for logging
13561 if an error occurs in a print job. Debug messages are logged regardless
13562 of the LogLevel setting.
13563
13564 Defaults to @samp{100}.
13565 @end deftypevr
13566
13567 @deftypevr {@code{cups-configuration} parameter} log-level log-level
13568 Specifies the level of logging for the ErrorLog file. The value
13569 @code{none} stops all logging while @code{debug2} logs everything.
13570
13571 Defaults to @samp{info}.
13572 @end deftypevr
13573
13574 @deftypevr {@code{cups-configuration} parameter} log-time-format log-time-format
13575 Specifies the format of the date and time in the log files. The value
13576 @code{standard} logs whole seconds while @code{usecs} logs microseconds.
13577
13578 Defaults to @samp{standard}.
13579 @end deftypevr
13580
13581 @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-clients
13582 Specifies the maximum number of simultaneous clients that are allowed by
13583 the scheduler.
13584
13585 Defaults to @samp{100}.
13586 @end deftypevr
13587
13588 @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-clients-per-host
13589 Specifies the maximum number of simultaneous clients that are allowed
13590 from a single address.
13591
13592 Defaults to @samp{100}.
13593 @end deftypevr
13594
13595 @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-copies
13596 Specifies the maximum number of copies that a user can print of each
13597 job.
13598
13599 Defaults to @samp{9999}.
13600 @end deftypevr
13601
13602 @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-hold-time
13603 Specifies the maximum time a job may remain in the @code{indefinite}
13604 hold state before it is canceled. A value of 0 disables cancellation of
13605 held jobs.
13606
13607 Defaults to @samp{0}.
13608 @end deftypevr
13609
13610 @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-jobs
13611 Specifies the maximum number of simultaneous jobs that are allowed. Set
13612 to 0 to allow an unlimited number of jobs.
13613
13614 Defaults to @samp{500}.
13615 @end deftypevr
13616
13617 @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-jobs-per-printer
13618 Specifies the maximum number of simultaneous jobs that are allowed per
13619 printer. A value of 0 allows up to MaxJobs jobs per printer.
13620
13621 Defaults to @samp{0}.
13622 @end deftypevr
13623
13624 @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-jobs-per-user
13625 Specifies the maximum number of simultaneous jobs that are allowed per
13626 user. A value of 0 allows up to MaxJobs jobs per user.
13627
13628 Defaults to @samp{0}.
13629 @end deftypevr
13630
13631 @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-job-time
13632 Specifies the maximum time a job may take to print before it is
13633 canceled, in seconds. Set to 0 to disable cancellation of "stuck" jobs.
13634
13635 Defaults to @samp{10800}.
13636 @end deftypevr
13637
13638 @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-log-size
13639 Specifies the maximum size of the log files before they are rotated, in
13640 bytes. The value 0 disables log rotation.
13641
13642 Defaults to @samp{1048576}.
13643 @end deftypevr
13644
13645 @deftypevr {@code{cups-configuration} parameter} non-negative-integer multiple-operation-timeout
13646 Specifies the maximum amount of time to allow between files in a
13647 multiple file print job, in seconds.
13648
13649 Defaults to @samp{300}.
13650 @end deftypevr
13651
13652 @deftypevr {@code{cups-configuration} parameter} string page-log-format
13653 Specifies the format of PageLog lines. Sequences beginning with percent
13654 (@samp{%}) characters are replaced with the corresponding information,
13655 while all other characters are copied literally. The following percent
13656 sequences are recognized:
13657
13658 @table @samp
13659 @item %%
13660 insert a single percent character
13661
13662 @item %@{name@}
13663 insert the value of the specified IPP attribute
13664
13665 @item %C
13666 insert the number of copies for the current page
13667
13668 @item %P
13669 insert the current page number
13670
13671 @item %T
13672 insert the current date and time in common log format
13673
13674 @item %j
13675 insert the job ID
13676
13677 @item %p
13678 insert the printer name
13679
13680 @item %u
13681 insert the username
13682 @end table
13683
13684 A value of the empty string disables page logging. The string @code{%p
13685 %u %j %T %P %C %@{job-billing@} %@{job-originating-host-name@}
13686 %@{job-name@} %@{media@} %@{sides@}} creates a page log with the
13687 standard items.
13688
13689 Defaults to @samp{""}.
13690 @end deftypevr
13691
13692 @deftypevr {@code{cups-configuration} parameter} environment-variables environment-variables
13693 Passes the specified environment variable(s) to child processes; a list
13694 of strings.
13695
13696 Defaults to @samp{()}.
13697 @end deftypevr
13698
13699 @deftypevr {@code{cups-configuration} parameter} policy-configuration-list policies
13700 Specifies named access control policies.
13701
13702 Available @code{policy-configuration} fields are:
13703
13704 @deftypevr {@code{policy-configuration} parameter} string name
13705 Name of the policy.
13706 @end deftypevr
13707
13708 @deftypevr {@code{policy-configuration} parameter} string job-private-access
13709 Specifies an access list for a job's private values. @code{@@ACL} maps
13710 to the printer's requesting-user-name-allowed or
13711 requesting-user-name-denied values. @code{@@OWNER} maps to the job's
13712 owner. @code{@@SYSTEM} maps to the groups listed for the
13713 @code{system-group} field of the @code{files-config} configuration,
13714 which is reified into the @code{cups-files.conf(5)} file. Other
13715 possible elements of the access list include specific user names, and
13716 @code{@@@var{group}} to indicate members of a specific group. The
13717 access list may also be simply @code{all} or @code{default}.
13718
13719 Defaults to @samp{"@@OWNER @@SYSTEM"}.
13720 @end deftypevr
13721
13722 @deftypevr {@code{policy-configuration} parameter} string job-private-values
13723 Specifies the list of job values to make private, or @code{all},
13724 @code{default}, or @code{none}.
13725
13726 Defaults to @samp{"job-name job-originating-host-name
13727 job-originating-user-name phone"}.
13728 @end deftypevr
13729
13730 @deftypevr {@code{policy-configuration} parameter} string subscription-private-access
13731 Specifies an access list for a subscription's private values.
13732 @code{@@ACL} maps to the printer's requesting-user-name-allowed or
13733 requesting-user-name-denied values. @code{@@OWNER} maps to the job's
13734 owner. @code{@@SYSTEM} maps to the groups listed for the
13735 @code{system-group} field of the @code{files-config} configuration,
13736 which is reified into the @code{cups-files.conf(5)} file. Other
13737 possible elements of the access list include specific user names, and
13738 @code{@@@var{group}} to indicate members of a specific group. The
13739 access list may also be simply @code{all} or @code{default}.
13740
13741 Defaults to @samp{"@@OWNER @@SYSTEM"}.
13742 @end deftypevr
13743
13744 @deftypevr {@code{policy-configuration} parameter} string subscription-private-values
13745 Specifies the list of job values to make private, or @code{all},
13746 @code{default}, or @code{none}.
13747
13748 Defaults to @samp{"notify-events notify-pull-method notify-recipient-uri
13749 notify-subscriber-user-name notify-user-data"}.
13750 @end deftypevr
13751
13752 @deftypevr {@code{policy-configuration} parameter} operation-access-control-list access-controls
13753 Access control by IPP operation.
13754
13755 Defaults to @samp{()}.
13756 @end deftypevr
13757 @end deftypevr
13758
13759 @deftypevr {@code{cups-configuration} parameter} boolean-or-non-negative-integer preserve-job-files
13760 Specifies whether job files (documents) are preserved after a job is
13761 printed. If a numeric value is specified, job files are preserved for
13762 the indicated number of seconds after printing. Otherwise a boolean
13763 value applies indefinitely.
13764
13765 Defaults to @samp{86400}.
13766 @end deftypevr
13767
13768 @deftypevr {@code{cups-configuration} parameter} boolean-or-non-negative-integer preserve-job-history
13769 Specifies whether the job history is preserved after a job is printed.
13770 If a numeric value is specified, the job history is preserved for the
13771 indicated number of seconds after printing. If @code{#t}, the job
13772 history is preserved until the MaxJobs limit is reached.
13773
13774 Defaults to @samp{#t}.
13775 @end deftypevr
13776
13777 @deftypevr {@code{cups-configuration} parameter} non-negative-integer reload-timeout
13778 Specifies the amount of time to wait for job completion before
13779 restarting the scheduler.
13780
13781 Defaults to @samp{30}.
13782 @end deftypevr
13783
13784 @deftypevr {@code{cups-configuration} parameter} string rip-cache
13785 Specifies the maximum amount of memory to use when converting documents
13786 into bitmaps for a printer.
13787
13788 Defaults to @samp{"128m"}.
13789 @end deftypevr
13790
13791 @deftypevr {@code{cups-configuration} parameter} string server-admin
13792 Specifies the email address of the server administrator.
13793
13794 Defaults to @samp{"root@@localhost.localdomain"}.
13795 @end deftypevr
13796
13797 @deftypevr {@code{cups-configuration} parameter} host-name-list-or-* server-alias
13798 The ServerAlias directive is used for HTTP Host header validation when
13799 clients connect to the scheduler from external interfaces. Using the
13800 special name @code{*} can expose your system to known browser-based DNS
13801 rebinding attacks, even when accessing sites through a firewall. If the
13802 auto-discovery of alternate names does not work, we recommend listing
13803 each alternate name with a ServerAlias directive instead of using
13804 @code{*}.
13805
13806 Defaults to @samp{*}.
13807 @end deftypevr
13808
13809 @deftypevr {@code{cups-configuration} parameter} string server-name
13810 Specifies the fully-qualified host name of the server.
13811
13812 Defaults to @samp{"localhost"}.
13813 @end deftypevr
13814
13815 @deftypevr {@code{cups-configuration} parameter} server-tokens server-tokens
13816 Specifies what information is included in the Server header of HTTP
13817 responses. @code{None} disables the Server header. @code{ProductOnly}
13818 reports @code{CUPS}. @code{Major} reports @code{CUPS 2}. @code{Minor}
13819 reports @code{CUPS 2.0}. @code{Minimal} reports @code{CUPS 2.0.0}.
13820 @code{OS} reports @code{CUPS 2.0.0 (@var{uname})} where @var{uname} is
13821 the output of the @code{uname} command. @code{Full} reports @code{CUPS
13822 2.0.0 (@var{uname}) IPP/2.0}.
13823
13824 Defaults to @samp{Minimal}.
13825 @end deftypevr
13826
13827 @deftypevr {@code{cups-configuration} parameter} string set-env
13828 Set the specified environment variable to be passed to child processes.
13829
13830 Defaults to @samp{"variable value"}.
13831 @end deftypevr
13832
13833 @deftypevr {@code{cups-configuration} parameter} multiline-string-list ssl-listen
13834 Listens on the specified interfaces for encrypted connections. Valid
13835 values are of the form @var{address}:@var{port}, where @var{address} is
13836 either an IPv6 address enclosed in brackets, an IPv4 address, or
13837 @code{*} to indicate all addresses.
13838
13839 Defaults to @samp{()}.
13840 @end deftypevr
13841
13842 @deftypevr {@code{cups-configuration} parameter} ssl-options ssl-options
13843 Sets encryption options. By default, CUPS only supports encryption
13844 using TLS v1.0 or higher using known secure cipher suites. The
13845 @code{AllowRC4} option enables the 128-bit RC4 cipher suites, which are
13846 required for some older clients that do not implement newer ones. The
13847 @code{AllowSSL3} option enables SSL v3.0, which is required for some
13848 older clients that do not support TLS v1.0.
13849
13850 Defaults to @samp{()}.
13851 @end deftypevr
13852
13853 @deftypevr {@code{cups-configuration} parameter} boolean strict-conformance?
13854 Specifies whether the scheduler requires clients to strictly adhere to
13855 the IPP specifications.
13856
13857 Defaults to @samp{#f}.
13858 @end deftypevr
13859
13860 @deftypevr {@code{cups-configuration} parameter} non-negative-integer timeout
13861 Specifies the HTTP request timeout, in seconds.
13862
13863 Defaults to @samp{300}.
13864
13865 @end deftypevr
13866
13867 @deftypevr {@code{cups-configuration} parameter} boolean web-interface?
13868 Specifies whether the web interface is enabled.
13869
13870 Defaults to @samp{#f}.
13871 @end deftypevr
13872
13873 At this point you're probably thinking ``oh dear, Guix manual, I like
13874 you but you can stop already with the configuration options''. Indeed.
13875 However, one more point: it could be that you have an existing
13876 @code{cupsd.conf} that you want to use. In that case, you can pass an
13877 @code{opaque-cups-configuration} as the configuration of a
13878 @code{cups-service-type}.
13879
13880 Available @code{opaque-cups-configuration} fields are:
13881
13882 @deftypevr {@code{opaque-cups-configuration} parameter} package cups
13883 The CUPS package.
13884 @end deftypevr
13885
13886 @deftypevr {@code{opaque-cups-configuration} parameter} string cupsd.conf
13887 The contents of the @code{cupsd.conf}, as a string.
13888 @end deftypevr
13889
13890 @deftypevr {@code{opaque-cups-configuration} parameter} string cups-files.conf
13891 The contents of the @code{cups-files.conf} file, as a string.
13892 @end deftypevr
13893
13894 For example, if your @code{cupsd.conf} and @code{cups-files.conf} are in
13895 strings of the same name, you could instantiate a CUPS service like
13896 this:
13897
13898 @example
13899 (service cups-service-type
13900 (opaque-cups-configuration
13901 (cupsd.conf cupsd.conf)
13902 (cups-files.conf cups-files.conf)))
13903 @end example
13904
13905
13906 @node Desktop Services
13907 @subsection Desktop Services
13908
13909 The @code{(gnu services desktop)} module provides services that are
13910 usually useful in the context of a ``desktop'' setup---that is, on a
13911 machine running a graphical display server, possibly with graphical user
13912 interfaces, etc. It also defines services that provide specific desktop
13913 environments like GNOME, XFCE or MATE.
13914
13915 To simplify things, the module defines a variable containing the set of
13916 services that users typically expect on a machine with a graphical
13917 environment and networking:
13918
13919 @defvr {Scheme Variable} %desktop-services
13920 This is a list of services that builds upon @var{%base-services} and
13921 adds or adjusts services for a typical ``desktop'' setup.
13922
13923 In particular, it adds a graphical login manager (@pxref{X Window,
13924 @code{slim-service}}), screen lockers, a network management tool
13925 (@pxref{Networking Services, @code{network-manager-service-type}}), energy and color
13926 management services, the @code{elogind} login and seat manager, the
13927 Polkit privilege service, the GeoClue location service, the
13928 AccountsService daemon that allows authorized users change system
13929 passwords, an NTP client (@pxref{Networking Services}), the Avahi
13930 daemon, and has the name service switch service configured to be able to
13931 use @code{nss-mdns} (@pxref{Name Service Switch, mDNS}).
13932 @end defvr
13933
13934 The @var{%desktop-services} variable can be used as the @code{services}
13935 field of an @code{operating-system} declaration (@pxref{operating-system
13936 Reference, @code{services}}).
13937
13938 Additionally, the @code{gnome-desktop-service},
13939 @code{xfce-desktop-service}, @code{mate-desktop-service} and
13940 @code{enlightenment-desktop-service-type} procedures can add GNOME, XFCE, MATE
13941 and/or Enlightenment to a system. To ``add GNOME'' means that system-level
13942 services like the backlight adjustment helpers and the power management
13943 utilities are added to the system, extending @code{polkit} and @code{dbus}
13944 appropriately, allowing GNOME to operate with elevated privileges on a
13945 limited number of special-purpose system interfaces. Additionally,
13946 adding a service made by @code{gnome-desktop-service} adds the GNOME
13947 metapackage to the system profile. Likewise, adding the XFCE service
13948 not only adds the @code{xfce} metapackage to the system profile, but it
13949 also gives the Thunar file manager the ability to open a ``root-mode''
13950 file management window, if the user authenticates using the
13951 administrator's password via the standard polkit graphical interface.
13952 To ``add MATE'' means that @code{polkit} and @code{dbus} are extended
13953 appropriately, allowing MATE to operate with elevated privileges on a
13954 limited number of special-purpose system interfaces. Additionally,
13955 adding a service made by @code{mate-desktop-service} adds the MATE
13956 metapackage to the system profile. ``Adding ENLIGHTENMENT'' means that
13957 @code{dbus} is extended appropriately, and several of Enlightenment's binaries
13958 are set as setuid, allowing Enlightenment's screen locker and other
13959 functionality to work as expetected.
13960
13961 The desktop environments in Guix use the Xorg display server by
13962 default. If you'd like to use the newer display server protocol
13963 called Wayland, you need to use the @code{sddm-service} instead of the
13964 @code{slim-service} for the graphical login manager. You should then
13965 select the ``GNOME (Wayland)'' session in SDDM. Alternatively you can
13966 also try starting GNOME on Wayland manually from a TTY with the
13967 command ``XDG_SESSION_TYPE=wayland exec dbus-run-session
13968 gnome-session``. Currently only GNOME has support for Wayland.
13969
13970 @deffn {Scheme Procedure} gnome-desktop-service
13971 Return a service that adds the @code{gnome} package to the system
13972 profile, and extends polkit with the actions from
13973 @code{gnome-settings-daemon}.
13974 @end deffn
13975
13976 @deffn {Scheme Procedure} xfce-desktop-service
13977 Return a service that adds the @code{xfce} package to the system profile,
13978 and extends polkit with the ability for @code{thunar} to manipulate the
13979 file system as root from within a user session, after the user has
13980 authenticated with the administrator's password.
13981 @end deffn
13982
13983 @deffn {Scheme Procedure} mate-desktop-service
13984 Return a service that adds the @code{mate} package to the system
13985 profile, and extends polkit with the actions from
13986 @code{mate-settings-daemon}.
13987 @end deffn
13988
13989 @deffn {Scheme Procedure} enlightenment-desktop-service-type
13990 Return a service that adds the @code{enlightenment} package to the system
13991 profile, and extends dbus with actions from @code{efl}.
13992 @end deffn
13993
13994 @deftp {Data Type} enlightenment-desktop-service-configuration
13995 @table @asis
13996 @item @code{enlightenment} (default @code{enlightenment})
13997 The enlightenment package to use.
13998 @end table
13999 @end deftp
14000
14001 Because the GNOME, XFCE and MATE desktop services pull in so many packages,
14002 the default @code{%desktop-services} variable doesn't include any of
14003 them by default. To add GNOME, XFCE or MATE, just @code{cons} them onto
14004 @code{%desktop-services} in the @code{services} field of your
14005 @code{operating-system}:
14006
14007 @example
14008 (use-modules (gnu))
14009 (use-service-modules desktop)
14010 (operating-system
14011 ...
14012 ;; cons* adds items to the list given as its last argument.
14013 (services (cons* (gnome-desktop-service)
14014 (xfce-desktop-service)
14015 %desktop-services))
14016 ...)
14017 @end example
14018
14019 These desktop environments will then be available as options in the
14020 graphical login window.
14021
14022 The actual service definitions included in @code{%desktop-services} and
14023 provided by @code{(gnu services dbus)} and @code{(gnu services desktop)}
14024 are described below.
14025
14026 @deffn {Scheme Procedure} dbus-service [#:dbus @var{dbus}] [#:services '()]
14027 Return a service that runs the ``system bus'', using @var{dbus}, with
14028 support for @var{services}.
14029
14030 @uref{http://dbus.freedesktop.org/, D-Bus} is an inter-process communication
14031 facility. Its system bus is used to allow system services to communicate
14032 and to be notified of system-wide events.
14033
14034 @var{services} must be a list of packages that provide an
14035 @file{etc/dbus-1/system.d} directory containing additional D-Bus configuration
14036 and policy files. For example, to allow avahi-daemon to use the system bus,
14037 @var{services} must be equal to @code{(list avahi)}.
14038 @end deffn
14039
14040 @deffn {Scheme Procedure} elogind-service [#:config @var{config}]
14041 Return a service that runs the @code{elogind} login and
14042 seat management daemon. @uref{https://github.com/elogind/elogind,
14043 Elogind} exposes a D-Bus interface that can be used to know which users
14044 are logged in, know what kind of sessions they have open, suspend the
14045 system, inhibit system suspend, reboot the system, and other tasks.
14046
14047 Elogind handles most system-level power events for a computer, for
14048 example suspending the system when a lid is closed, or shutting it down
14049 when the power button is pressed.
14050
14051 The @var{config} keyword argument specifies the configuration for
14052 elogind, and should be the result of an @code{(elogind-configuration
14053 (@var{parameter} @var{value})...)} invocation. Available parameters and
14054 their default values are:
14055
14056 @table @code
14057 @item kill-user-processes?
14058 @code{#f}
14059 @item kill-only-users
14060 @code{()}
14061 @item kill-exclude-users
14062 @code{("root")}
14063 @item inhibit-delay-max-seconds
14064 @code{5}
14065 @item handle-power-key
14066 @code{poweroff}
14067 @item handle-suspend-key
14068 @code{suspend}
14069 @item handle-hibernate-key
14070 @code{hibernate}
14071 @item handle-lid-switch
14072 @code{suspend}
14073 @item handle-lid-switch-docked
14074 @code{ignore}
14075 @item power-key-ignore-inhibited?
14076 @code{#f}
14077 @item suspend-key-ignore-inhibited?
14078 @code{#f}
14079 @item hibernate-key-ignore-inhibited?
14080 @code{#f}
14081 @item lid-switch-ignore-inhibited?
14082 @code{#t}
14083 @item holdoff-timeout-seconds
14084 @code{30}
14085 @item idle-action
14086 @code{ignore}
14087 @item idle-action-seconds
14088 @code{(* 30 60)}
14089 @item runtime-directory-size-percent
14090 @code{10}
14091 @item runtime-directory-size
14092 @code{#f}
14093 @item remove-ipc?
14094 @code{#t}
14095 @item suspend-state
14096 @code{("mem" "standby" "freeze")}
14097 @item suspend-mode
14098 @code{()}
14099 @item hibernate-state
14100 @code{("disk")}
14101 @item hibernate-mode
14102 @code{("platform" "shutdown")}
14103 @item hybrid-sleep-state
14104 @code{("disk")}
14105 @item hybrid-sleep-mode
14106 @code{("suspend" "platform" "shutdown")}
14107 @end table
14108 @end deffn
14109
14110 @deffn {Scheme Procedure} accountsservice-service @
14111 [#:accountsservice @var{accountsservice}]
14112 Return a service that runs AccountsService, a system service that can
14113 list available accounts, change their passwords, and so on.
14114 AccountsService integrates with PolicyKit to enable unprivileged users
14115 to acquire the capability to modify their system configuration.
14116 @uref{https://www.freedesktop.org/wiki/Software/AccountsService/, the
14117 accountsservice web site} for more information.
14118
14119 The @var{accountsservice} keyword argument is the @code{accountsservice}
14120 package to expose as a service.
14121 @end deffn
14122
14123 @deffn {Scheme Procedure} polkit-service @
14124 [#:polkit @var{polkit}]
14125 Return a service that runs the
14126 @uref{http://www.freedesktop.org/wiki/Software/polkit/, Polkit privilege
14127 management service}, which allows system administrators to grant access to
14128 privileged operations in a structured way. By querying the Polkit service, a
14129 privileged system component can know when it should grant additional
14130 capabilities to ordinary users. For example, an ordinary user can be granted
14131 the capability to suspend the system if the user is logged in locally.
14132 @end deffn
14133
14134 @deffn {Scheme Procedure} upower-service [#:upower @var{upower}] @
14135 [#:watts-up-pro? #f] @
14136 [#:poll-batteries? #t] @
14137 [#:ignore-lid? #f] @
14138 [#:use-percentage-for-policy? #f] @
14139 [#:percentage-low 10] @
14140 [#:percentage-critical 3] @
14141 [#:percentage-action 2] @
14142 [#:time-low 1200] @
14143 [#:time-critical 300] @
14144 [#:time-action 120] @
14145 [#:critical-power-action 'hybrid-sleep]
14146 Return a service that runs @uref{http://upower.freedesktop.org/,
14147 @command{upowerd}}, a system-wide monitor for power consumption and battery
14148 levels, with the given configuration settings. It implements the
14149 @code{org.freedesktop.UPower} D-Bus interface, and is notably used by
14150 GNOME.
14151 @end deffn
14152
14153 @deffn {Scheme Procedure} udisks-service [#:udisks @var{udisks}]
14154 Return a service for @uref{http://udisks.freedesktop.org/docs/latest/,
14155 UDisks}, a @dfn{disk management} daemon that provides user interfaces with
14156 notifications and ways to mount/unmount disks. Programs that talk to UDisks
14157 include the @command{udisksctl} command, part of UDisks, and GNOME Disks.
14158 @end deffn
14159
14160 @deffn {Scheme Procedure} colord-service [#:colord @var{colord}]
14161 Return a service that runs @command{colord}, a system service with a D-Bus
14162 interface to manage the color profiles of input and output devices such as
14163 screens and scanners. It is notably used by the GNOME Color Manager graphical
14164 tool. See @uref{http://www.freedesktop.org/software/colord/, the colord web
14165 site} for more information.
14166 @end deffn
14167
14168 @deffn {Scheme Procedure} geoclue-application name [#:allowed? #t] [#:system? #f] [#:users '()]
14169 Return a configuration allowing an application to access GeoClue
14170 location data. @var{name} is the Desktop ID of the application, without
14171 the @code{.desktop} part. If @var{allowed?} is true, the application
14172 will have access to location information by default. The boolean
14173 @var{system?} value indicates whether an application is a system component
14174 or not. Finally @var{users} is a list of UIDs of all users for which
14175 this application is allowed location info access. An empty users list
14176 means that all users are allowed.
14177 @end deffn
14178
14179 @defvr {Scheme Variable} %standard-geoclue-applications
14180 The standard list of well-known GeoClue application configurations,
14181 granting authority to the GNOME date-and-time utility to ask for the
14182 current location in order to set the time zone, and allowing the
14183 IceCat and Epiphany web browsers to request location information.
14184 IceCat and Epiphany both query the user before allowing a web page to
14185 know the user's location.
14186 @end defvr
14187
14188 @deffn {Scheme Procedure} geoclue-service [#:colord @var{colord}] @
14189 [#:whitelist '()] @
14190 [#:wifi-geolocation-url "https://location.services.mozilla.com/v1/geolocate?key=geoclue"] @
14191 [#:submit-data? #f]
14192 [#:wifi-submission-url "https://location.services.mozilla.com/v1/submit?key=geoclue"] @
14193 [#:submission-nick "geoclue"] @
14194 [#:applications %standard-geoclue-applications]
14195 Return a service that runs the GeoClue location service. This service
14196 provides a D-Bus interface to allow applications to request access to a
14197 user's physical location, and optionally to add information to online
14198 location databases. See
14199 @uref{https://wiki.freedesktop.org/www/Software/GeoClue/, the GeoClue
14200 web site} for more information.
14201 @end deffn
14202
14203 @deffn {Scheme Procedure} bluetooth-service [#:bluez @var{bluez}] @
14204 [@w{#:auto-enable? #f}]
14205 Return a service that runs the @command{bluetoothd} daemon, which
14206 manages all the Bluetooth devices and provides a number of D-Bus
14207 interfaces. When AUTO-ENABLE? is true, the bluetooth controller is
14208 powered automatically at boot, which can be useful when using a
14209 bluetooth keyboard or mouse.
14210
14211 Users need to be in the @code{lp} group to access the D-Bus service.
14212 @end deffn
14213
14214 @node Sound Services
14215 @subsection Sound Services
14216
14217 @cindex sound support
14218 @cindex ALSA
14219 @cindex PulseAudio, sound support
14220
14221 The @code{(gnu services sound)} module provides a service to configure the
14222 Advanced Linux Sound Architecture (ALSA) system, which makes PulseAudio the
14223 preferred ALSA output driver.
14224
14225 @deffn {Scheme Variable} alsa-service-type
14226 This is the type for the @uref{https://alsa-project.org/, Advanced Linux Sound
14227 Architecture} (ALSA) system, which generates the @file{/etc/asound.conf}
14228 configuration file. The value for this type is a @command{alsa-configuration}
14229 record as in this example:
14230
14231 @example
14232 (service alsa-service-type)
14233 @end example
14234
14235 See below for details about @code{alsa-configuration}.
14236 @end deffn
14237
14238 @deftp {Data Type} alsa-configuration
14239 Data type representing the configuration for @code{alsa-service}.
14240
14241 @table @asis
14242 @item @code{alsa-plugins} (default: @var{alsa-plugins})
14243 @code{alsa-plugins} package to use.
14244
14245 @item @code{pulseaudio?} (default: @var{#t})
14246 Whether ALSA applications should transparently be made to use the
14247 @uref{http://www.pulseaudio.org/, PulseAudio} sound server.
14248
14249 Using PulseAudio allows you to run several sound-producing applications
14250 at the same time and to individual control them @i{via}
14251 @command{pavucontrol}, among other things.
14252
14253 @item @code{extra-options} (default: @var{""})
14254 String to append to the @file{/etc/asound.conf} file.
14255
14256 @end table
14257 @end deftp
14258
14259 Individual users who want to override the system configuration of ALSA can do
14260 it with the @file{~/.asoundrc} file:
14261
14262 @example
14263 # In guix, we have to specify the absolute path for plugins.
14264 pcm_type.jack @{
14265 lib "/home/alice/.guix-profile/lib/alsa-lib/libasound_module_pcm_jack.so"
14266 @}
14267
14268 # Routing ALSA to jack:
14269 # <http://jackaudio.org/faq/routing_alsa.html>.
14270 pcm.rawjack @{
14271 type jack
14272 playback_ports @{
14273 0 system:playback_1
14274 1 system:playback_2
14275 @}
14276
14277 capture_ports @{
14278 0 system:capture_1
14279 1 system:capture_2
14280 @}
14281 @}
14282
14283 pcm.!default @{
14284 type plug
14285 slave @{
14286 pcm "rawjack"
14287 @}
14288 @}
14289 @end example
14290
14291 See @uref{https://www.alsa-project.org/main/index.php/Asoundrc} for the
14292 details.
14293
14294
14295 @node Database Services
14296 @subsection Database Services
14297
14298 @cindex database
14299 @cindex SQL
14300 The @code{(gnu services databases)} module provides the following services.
14301
14302 @deffn {Scheme Procedure} postgresql-service [#:postgresql postgresql] @
14303 [#:config-file] [#:data-directory ``/var/lib/postgresql/data''] @
14304 [#:port 5432] [#:locale ``en_US.utf8'']
14305 Return a service that runs @var{postgresql}, the PostgreSQL database
14306 server.
14307
14308 The PostgreSQL daemon loads its runtime configuration from @var{config-file},
14309 creates a database cluster with @var{locale} as the default
14310 locale, stored in @var{data-directory}. It then listens on @var{port}.
14311 @end deffn
14312
14313 @deffn {Scheme Procedure} mysql-service [#:config (mysql-configuration)]
14314 Return a service that runs @command{mysqld}, the MySQL or MariaDB
14315 database server.
14316
14317 The optional @var{config} argument specifies the configuration for
14318 @command{mysqld}, which should be a @code{<mysql-configuration>} object.
14319 @end deffn
14320
14321 @deftp {Data Type} mysql-configuration
14322 Data type representing the configuration of @var{mysql-service}.
14323
14324 @table @asis
14325 @item @code{mysql} (default: @var{mariadb})
14326 Package object of the MySQL database server, can be either @var{mariadb}
14327 or @var{mysql}.
14328
14329 For MySQL, a temporary root password will be displayed at activation time.
14330 For MariaDB, the root password is empty.
14331
14332 @item @code{port} (default: @code{3306})
14333 TCP port on which the database server listens for incoming connections.
14334 @end table
14335 @end deftp
14336
14337 @defvr {Scheme Variable} memcached-service-type
14338 This is the service type for the @uref{https://memcached.org/,
14339 Memcached} service, which provides a distributed in memory cache. The
14340 value for the service type is a @code{memcached-configuration} object.
14341 @end defvr
14342
14343 @example
14344 (service memcached-service-type)
14345 @end example
14346
14347 @deftp {Data Type} memcached-configuration
14348 Data type representing the configuration of memcached.
14349
14350 @table @asis
14351 @item @code{memcached} (default: @code{memcached})
14352 The Memcached package to use.
14353
14354 @item @code{interfaces} (default: @code{'("0.0.0.0")})
14355 Network interfaces on which to listen.
14356
14357 @item @code{tcp-port} (default: @code{11211})
14358 Port on which to accept connections on,
14359
14360 @item @code{udp-port} (default: @code{11211})
14361 Port on which to accept UDP connections on, a value of 0 will disable
14362 listening on a UDP socket.
14363
14364 @item @code{additional-options} (default: @code{'()})
14365 Additional command line options to pass to @code{memcached}.
14366 @end table
14367 @end deftp
14368
14369 @defvr {Scheme Variable} mongodb-service-type
14370 This is the service type for @uref{https://www.mongodb.com/, MongoDB}.
14371 The value for the service type is a @code{mongodb-configuration} object.
14372 @end defvr
14373
14374 @example
14375 (service mongodb-service-type)
14376 @end example
14377
14378 @deftp {Data Type} mongodb-configuration
14379 Data type representing the configuration of mongodb.
14380
14381 @table @asis
14382 @item @code{mongodb} (default: @code{mongodb})
14383 The MongoDB package to use.
14384
14385 @item @code{config-file} (default: @code{%default-mongodb-configuration-file})
14386 The configuration file for MongoDB.
14387
14388 @item @code{data-directory} (default: @code{"/var/lib/mongodb"})
14389 This value is used to create the directory, so that it exists and is
14390 owned by the mongodb user. It should match the data-directory which
14391 MongoDB is configured to use through the configuration file.
14392 @end table
14393 @end deftp
14394
14395 @defvr {Scheme Variable} redis-service-type
14396 This is the service type for the @uref{https://redis.io/, Redis}
14397 key/value store, whose value is a @code{redis-configuration} object.
14398 @end defvr
14399
14400 @deftp {Data Type} redis-configuration
14401 Data type representing the configuration of redis.
14402
14403 @table @asis
14404 @item @code{redis} (default: @code{redis})
14405 The Redis package to use.
14406
14407 @item @code{bind} (default: @code{"127.0.0.1"})
14408 Network interface on which to listen.
14409
14410 @item @code{port} (default: @code{6379})
14411 Port on which to accept connections on, a value of 0 will disable
14412 listening on a TCP socket.
14413
14414 @item @code{working-directory} (default: @code{"/var/lib/redis"})
14415 Directory in which to store the database and related files.
14416 @end table
14417 @end deftp
14418
14419 @node Mail Services
14420 @subsection Mail Services
14421
14422 @cindex mail
14423 @cindex email
14424 The @code{(gnu services mail)} module provides Guix service definitions
14425 for email services: IMAP, POP3, and LMTP servers, as well as mail
14426 transport agents (MTAs). Lots of acronyms! These services are detailed
14427 in the subsections below.
14428
14429 @subsubheading Dovecot Service
14430
14431 @deffn {Scheme Procedure} dovecot-service [#:config (dovecot-configuration)]
14432 Return a service that runs the Dovecot IMAP/POP3/LMTP mail server.
14433 @end deffn
14434
14435 By default, Dovecot does not need much configuration; the default
14436 configuration object created by @code{(dovecot-configuration)} will
14437 suffice if your mail is delivered to @code{~/Maildir}. A self-signed
14438 certificate will be generated for TLS-protected connections, though
14439 Dovecot will also listen on cleartext ports by default. There are a
14440 number of options, though, which mail administrators might need to change,
14441 and as is the case with other services, Guix allows the system
14442 administrator to specify these parameters via a uniform Scheme interface.
14443
14444 For example, to specify that mail is located at @code{maildir~/.mail},
14445 one would instantiate the Dovecot service like this:
14446
14447 @example
14448 (dovecot-service #:config
14449 (dovecot-configuration
14450 (mail-location "maildir:~/.mail")))
14451 @end example
14452
14453 The available configuration parameters follow. Each parameter
14454 definition is preceded by its type; for example, @samp{string-list foo}
14455 indicates that the @code{foo} parameter should be specified as a list of
14456 strings. There is also a way to specify the configuration as a string,
14457 if you have an old @code{dovecot.conf} file that you want to port over
14458 from some other system; see the end for more details.
14459
14460 @c The following documentation was initially generated by
14461 @c (generate-documentation) in (gnu services mail). Manually maintained
14462 @c documentation is better, so we shouldn't hesitate to edit below as
14463 @c needed. However if the change you want to make to this documentation
14464 @c can be done in an automated way, it's probably easier to change
14465 @c (generate-documentation) than to make it below and have to deal with
14466 @c the churn as dovecot updates.
14467
14468 Available @code{dovecot-configuration} fields are:
14469
14470 @deftypevr {@code{dovecot-configuration} parameter} package dovecot
14471 The dovecot package.
14472 @end deftypevr
14473
14474 @deftypevr {@code{dovecot-configuration} parameter} comma-separated-string-list listen
14475 A list of IPs or hosts where to listen for connections. @samp{*}
14476 listens on all IPv4 interfaces, @samp{::} listens on all IPv6
14477 interfaces. If you want to specify non-default ports or anything more
14478 complex, customize the address and port fields of the
14479 @samp{inet-listener} of the specific services you are interested in.
14480 @end deftypevr
14481
14482 @deftypevr {@code{dovecot-configuration} parameter} protocol-configuration-list protocols
14483 List of protocols we want to serve. Available protocols include
14484 @samp{imap}, @samp{pop3}, and @samp{lmtp}.
14485
14486 Available @code{protocol-configuration} fields are:
14487
14488 @deftypevr {@code{protocol-configuration} parameter} string name
14489 The name of the protocol.
14490 @end deftypevr
14491
14492 @deftypevr {@code{protocol-configuration} parameter} string auth-socket-path
14493 UNIX socket path to the master authentication server to find users.
14494 This is used by imap (for shared users) and lda.
14495 It defaults to @samp{"/var/run/dovecot/auth-userdb"}.
14496 @end deftypevr
14497
14498 @deftypevr {@code{protocol-configuration} parameter} space-separated-string-list mail-plugins
14499 Space separated list of plugins to load.
14500 @end deftypevr
14501
14502 @deftypevr {@code{protocol-configuration} parameter} non-negative-integer mail-max-userip-connections
14503 Maximum number of IMAP connections allowed for a user from each IP
14504 address. NOTE: The username is compared case-sensitively.
14505 Defaults to @samp{10}.
14506 @end deftypevr
14507
14508 @end deftypevr
14509
14510 @deftypevr {@code{dovecot-configuration} parameter} service-configuration-list services
14511 List of services to enable. Available services include @samp{imap},
14512 @samp{imap-login}, @samp{pop3}, @samp{pop3-login}, @samp{auth}, and
14513 @samp{lmtp}.
14514
14515 Available @code{service-configuration} fields are:
14516
14517 @deftypevr {@code{service-configuration} parameter} string kind
14518 The service kind. Valid values include @code{director},
14519 @code{imap-login}, @code{pop3-login}, @code{lmtp}, @code{imap},
14520 @code{pop3}, @code{auth}, @code{auth-worker}, @code{dict},
14521 @code{tcpwrap}, @code{quota-warning}, or anything else.
14522 @end deftypevr
14523
14524 @deftypevr {@code{service-configuration} parameter} listener-configuration-list listeners
14525 Listeners for the service. A listener is either a
14526 @code{unix-listener-configuration}, a @code{fifo-listener-configuration}, or
14527 an @code{inet-listener-configuration}.
14528 Defaults to @samp{()}.
14529
14530 Available @code{unix-listener-configuration} fields are:
14531
14532 @deftypevr {@code{unix-listener-configuration} parameter} string path
14533 Path to the file, relative to @code{base-dir} field. This is also used as
14534 the section name.
14535 @end deftypevr
14536
14537 @deftypevr {@code{unix-listener-configuration} parameter} string mode
14538 The access mode for the socket.
14539 Defaults to @samp{"0600"}.
14540 @end deftypevr
14541
14542 @deftypevr {@code{unix-listener-configuration} parameter} string user
14543 The user to own the socket.
14544 Defaults to @samp{""}.
14545 @end deftypevr
14546
14547 @deftypevr {@code{unix-listener-configuration} parameter} string group
14548 The group to own the socket.
14549 Defaults to @samp{""}.
14550 @end deftypevr
14551
14552
14553 Available @code{fifo-listener-configuration} fields are:
14554
14555 @deftypevr {@code{fifo-listener-configuration} parameter} string path
14556 Path to the file, relative to @code{base-dir} field. This is also used as
14557 the section name.
14558 @end deftypevr
14559
14560 @deftypevr {@code{fifo-listener-configuration} parameter} string mode
14561 The access mode for the socket.
14562 Defaults to @samp{"0600"}.
14563 @end deftypevr
14564
14565 @deftypevr {@code{fifo-listener-configuration} parameter} string user
14566 The user to own the socket.
14567 Defaults to @samp{""}.
14568 @end deftypevr
14569
14570 @deftypevr {@code{fifo-listener-configuration} parameter} string group
14571 The group to own the socket.
14572 Defaults to @samp{""}.
14573 @end deftypevr
14574
14575
14576 Available @code{inet-listener-configuration} fields are:
14577
14578 @deftypevr {@code{inet-listener-configuration} parameter} string protocol
14579 The protocol to listen for.
14580 @end deftypevr
14581
14582 @deftypevr {@code{inet-listener-configuration} parameter} string address
14583 The address on which to listen, or empty for all addresses.
14584 Defaults to @samp{""}.
14585 @end deftypevr
14586
14587 @deftypevr {@code{inet-listener-configuration} parameter} non-negative-integer port
14588 The port on which to listen.
14589 @end deftypevr
14590
14591 @deftypevr {@code{inet-listener-configuration} parameter} boolean ssl?
14592 Whether to use SSL for this service; @samp{yes}, @samp{no}, or
14593 @samp{required}.
14594 Defaults to @samp{#t}.
14595 @end deftypevr
14596
14597 @end deftypevr
14598
14599 @deftypevr {@code{service-configuration} parameter} non-negative-integer client-limit
14600 Maximum number of simultaneous client connections per process. Once
14601 this number of connections is received, the next incoming connection
14602 will prompt Dovecot to spawn another process. If set to 0,
14603 @code{default-client-limit} is used instead.
14604
14605 Defaults to @samp{0}.
14606
14607 @end deftypevr
14608
14609 @deftypevr {@code{service-configuration} parameter} non-negative-integer service-count
14610 Number of connections to handle before starting a new process.
14611 Typically the only useful values are 0 (unlimited) or 1. 1 is more
14612 secure, but 0 is faster. <doc/wiki/LoginProcess.txt>.
14613 Defaults to @samp{1}.
14614
14615 @end deftypevr
14616
14617 @deftypevr {@code{service-configuration} parameter} non-negative-integer process-limit
14618 Maximum number of processes that can exist for this service. If set to
14619 0, @code{default-process-limit} is used instead.
14620
14621 Defaults to @samp{0}.
14622
14623 @end deftypevr
14624
14625 @deftypevr {@code{service-configuration} parameter} non-negative-integer process-min-avail
14626 Number of processes to always keep waiting for more connections.
14627 Defaults to @samp{0}.
14628 @end deftypevr
14629
14630 @deftypevr {@code{service-configuration} parameter} non-negative-integer vsz-limit
14631 If you set @samp{service-count 0}, you probably need to grow
14632 this.
14633 Defaults to @samp{256000000}.
14634 @end deftypevr
14635
14636 @end deftypevr
14637
14638 @deftypevr {@code{dovecot-configuration} parameter} dict-configuration dict
14639 Dict configuration, as created by the @code{dict-configuration}
14640 constructor.
14641
14642 Available @code{dict-configuration} fields are:
14643
14644 @deftypevr {@code{dict-configuration} parameter} free-form-fields entries
14645 A list of key-value pairs that this dict should hold.
14646 Defaults to @samp{()}.
14647 @end deftypevr
14648
14649 @end deftypevr
14650
14651 @deftypevr {@code{dovecot-configuration} parameter} passdb-configuration-list passdbs
14652 A list of passdb configurations, each one created by the
14653 @code{passdb-configuration} constructor.
14654
14655 Available @code{passdb-configuration} fields are:
14656
14657 @deftypevr {@code{passdb-configuration} parameter} string driver
14658 The driver that the passdb should use. Valid values include
14659 @samp{pam}, @samp{passwd}, @samp{shadow}, @samp{bsdauth}, and
14660 @samp{static}.
14661 Defaults to @samp{"pam"}.
14662 @end deftypevr
14663
14664 @deftypevr {@code{passdb-configuration} parameter} space-separated-string-list args
14665 Space separated list of arguments to the passdb driver.
14666 Defaults to @samp{""}.
14667 @end deftypevr
14668
14669 @end deftypevr
14670
14671 @deftypevr {@code{dovecot-configuration} parameter} userdb-configuration-list userdbs
14672 List of userdb configurations, each one created by the
14673 @code{userdb-configuration} constructor.
14674
14675 Available @code{userdb-configuration} fields are:
14676
14677 @deftypevr {@code{userdb-configuration} parameter} string driver
14678 The driver that the userdb should use. Valid values include
14679 @samp{passwd} and @samp{static}.
14680 Defaults to @samp{"passwd"}.
14681 @end deftypevr
14682
14683 @deftypevr {@code{userdb-configuration} parameter} space-separated-string-list args
14684 Space separated list of arguments to the userdb driver.
14685 Defaults to @samp{""}.
14686 @end deftypevr
14687
14688 @deftypevr {@code{userdb-configuration} parameter} free-form-args override-fields
14689 Override fields from passwd.
14690 Defaults to @samp{()}.
14691 @end deftypevr
14692
14693 @end deftypevr
14694
14695 @deftypevr {@code{dovecot-configuration} parameter} plugin-configuration plugin-configuration
14696 Plug-in configuration, created by the @code{plugin-configuration}
14697 constructor.
14698 @end deftypevr
14699
14700 @deftypevr {@code{dovecot-configuration} parameter} list-of-namespace-configuration namespaces
14701 List of namespaces. Each item in the list is created by the
14702 @code{namespace-configuration} constructor.
14703
14704 Available @code{namespace-configuration} fields are:
14705
14706 @deftypevr {@code{namespace-configuration} parameter} string name
14707 Name for this namespace.
14708 @end deftypevr
14709
14710 @deftypevr {@code{namespace-configuration} parameter} string type
14711 Namespace type: @samp{private}, @samp{shared} or @samp{public}.
14712 Defaults to @samp{"private"}.
14713 @end deftypevr
14714
14715 @deftypevr {@code{namespace-configuration} parameter} string separator
14716 Hierarchy separator to use. You should use the same separator for
14717 all namespaces or some clients get confused. @samp{/} is usually a good
14718 one. The default however depends on the underlying mail storage
14719 format.
14720 Defaults to @samp{""}.
14721 @end deftypevr
14722
14723 @deftypevr {@code{namespace-configuration} parameter} string prefix
14724 Prefix required to access this namespace. This needs to be
14725 different for all namespaces. For example @samp{Public/}.
14726 Defaults to @samp{""}.
14727 @end deftypevr
14728
14729 @deftypevr {@code{namespace-configuration} parameter} string location
14730 Physical location of the mailbox. This is in the same format as
14731 mail_location, which is also the default for it.
14732 Defaults to @samp{""}.
14733 @end deftypevr
14734
14735 @deftypevr {@code{namespace-configuration} parameter} boolean inbox?
14736 There can be only one INBOX, and this setting defines which
14737 namespace has it.
14738 Defaults to @samp{#f}.
14739 @end deftypevr
14740
14741 @deftypevr {@code{namespace-configuration} parameter} boolean hidden?
14742 If namespace is hidden, it's not advertised to clients via NAMESPACE
14743 extension. You'll most likely also want to set @samp{list? #f}. This is mostly
14744 useful when converting from another server with different namespaces
14745 which you want to deprecate but still keep working. For example you can
14746 create hidden namespaces with prefixes @samp{~/mail/}, @samp{~%u/mail/}
14747 and @samp{mail/}.
14748 Defaults to @samp{#f}.
14749 @end deftypevr
14750
14751 @deftypevr {@code{namespace-configuration} parameter} boolean list?
14752 Show the mailboxes under this namespace with the LIST command. This
14753 makes the namespace visible for clients that do not support the NAMESPACE
14754 extension. The special @code{children} value lists child mailboxes, but
14755 hides the namespace prefix.
14756 Defaults to @samp{#t}.
14757 @end deftypevr
14758
14759 @deftypevr {@code{namespace-configuration} parameter} boolean subscriptions?
14760 Namespace handles its own subscriptions. If set to @code{#f}, the
14761 parent namespace handles them. The empty prefix should always have this
14762 as @code{#t}).
14763 Defaults to @samp{#t}.
14764 @end deftypevr
14765
14766 @deftypevr {@code{namespace-configuration} parameter} mailbox-configuration-list mailboxes
14767 List of predefined mailboxes in this namespace.
14768 Defaults to @samp{()}.
14769
14770 Available @code{mailbox-configuration} fields are:
14771
14772 @deftypevr {@code{mailbox-configuration} parameter} string name
14773 Name for this mailbox.
14774 @end deftypevr
14775
14776 @deftypevr {@code{mailbox-configuration} parameter} string auto
14777 @samp{create} will automatically create this mailbox.
14778 @samp{subscribe} will both create and subscribe to the mailbox.
14779 Defaults to @samp{"no"}.
14780 @end deftypevr
14781
14782 @deftypevr {@code{mailbox-configuration} parameter} space-separated-string-list special-use
14783 List of IMAP @code{SPECIAL-USE} attributes as specified by RFC 6154.
14784 Valid values are @code{\All}, @code{\Archive}, @code{\Drafts},
14785 @code{\Flagged}, @code{\Junk}, @code{\Sent}, and @code{\Trash}.
14786 Defaults to @samp{()}.
14787 @end deftypevr
14788
14789 @end deftypevr
14790
14791 @end deftypevr
14792
14793 @deftypevr {@code{dovecot-configuration} parameter} file-name base-dir
14794 Base directory where to store runtime data.
14795 Defaults to @samp{"/var/run/dovecot/"}.
14796 @end deftypevr
14797
14798 @deftypevr {@code{dovecot-configuration} parameter} string login-greeting
14799 Greeting message for clients.
14800 Defaults to @samp{"Dovecot ready."}.
14801 @end deftypevr
14802
14803 @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list login-trusted-networks
14804 List of trusted network ranges. Connections from these IPs are
14805 allowed to override their IP addresses and ports (for logging and for
14806 authentication checks). @samp{disable-plaintext-auth} is also ignored
14807 for these networks. Typically you would specify your IMAP proxy servers
14808 here.
14809 Defaults to @samp{()}.
14810 @end deftypevr
14811
14812 @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list login-access-sockets
14813 List of login access check sockets (e.g.@: tcpwrap).
14814 Defaults to @samp{()}.
14815 @end deftypevr
14816
14817 @deftypevr {@code{dovecot-configuration} parameter} boolean verbose-proctitle?
14818 Show more verbose process titles (in ps). Currently shows user name
14819 and IP address. Useful for seeing who is actually using the IMAP
14820 processes (e.g.@: shared mailboxes or if the same uid is used for multiple
14821 accounts).
14822 Defaults to @samp{#f}.
14823 @end deftypevr
14824
14825 @deftypevr {@code{dovecot-configuration} parameter} boolean shutdown-clients?
14826 Should all processes be killed when Dovecot master process shuts down.
14827 Setting this to @code{#f} means that Dovecot can be upgraded without
14828 forcing existing client connections to close (although that could also
14829 be a problem if the upgrade is e.g.@: due to a security fix).
14830 Defaults to @samp{#t}.
14831 @end deftypevr
14832
14833 @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer doveadm-worker-count
14834 If non-zero, run mail commands via this many connections to doveadm
14835 server, instead of running them directly in the same process.
14836 Defaults to @samp{0}.
14837 @end deftypevr
14838
14839 @deftypevr {@code{dovecot-configuration} parameter} string doveadm-socket-path
14840 UNIX socket or host:port used for connecting to doveadm server.
14841 Defaults to @samp{"doveadm-server"}.
14842 @end deftypevr
14843
14844 @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list import-environment
14845 List of environment variables that are preserved on Dovecot startup
14846 and passed down to all of its child processes. You can also give
14847 key=value pairs to always set specific settings.
14848 @end deftypevr
14849
14850 @deftypevr {@code{dovecot-configuration} parameter} boolean disable-plaintext-auth?
14851 Disable LOGIN command and all other plaintext authentications unless
14852 SSL/TLS is used (LOGINDISABLED capability). Note that if the remote IP
14853 matches the local IP (i.e.@: you're connecting from the same computer),
14854 the connection is considered secure and plaintext authentication is
14855 allowed. See also ssl=required setting.
14856 Defaults to @samp{#t}.
14857 @end deftypevr
14858
14859 @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer auth-cache-size
14860 Authentication cache size (e.g.@: @samp{#e10e6}). 0 means it's disabled.
14861 Note that bsdauth, PAM and vpopmail require @samp{cache-key} to be set
14862 for caching to be used.
14863 Defaults to @samp{0}.
14864 @end deftypevr
14865
14866 @deftypevr {@code{dovecot-configuration} parameter} string auth-cache-ttl
14867 Time to live for cached data. After TTL expires the cached record
14868 is no longer used, *except* if the main database lookup returns internal
14869 failure. We also try to handle password changes automatically: If
14870 user's previous authentication was successful, but this one wasn't, the
14871 cache isn't used. For now this works only with plaintext
14872 authentication.
14873 Defaults to @samp{"1 hour"}.
14874 @end deftypevr
14875
14876 @deftypevr {@code{dovecot-configuration} parameter} string auth-cache-negative-ttl
14877 TTL for negative hits (user not found, password mismatch).
14878 0 disables caching them completely.
14879 Defaults to @samp{"1 hour"}.
14880 @end deftypevr
14881
14882 @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list auth-realms
14883 List of realms for SASL authentication mechanisms that need them.
14884 You can leave it empty if you don't want to support multiple realms.
14885 Many clients simply use the first one listed here, so keep the default
14886 realm first.
14887 Defaults to @samp{()}.
14888 @end deftypevr
14889
14890 @deftypevr {@code{dovecot-configuration} parameter} string auth-default-realm
14891 Default realm/domain to use if none was specified. This is used for
14892 both SASL realms and appending @@domain to username in plaintext
14893 logins.
14894 Defaults to @samp{""}.
14895 @end deftypevr
14896
14897 @deftypevr {@code{dovecot-configuration} parameter} string auth-username-chars
14898 List of allowed characters in username. If the user-given username
14899 contains a character not listed in here, the login automatically fails.
14900 This is just an extra check to make sure user can't exploit any
14901 potential quote escaping vulnerabilities with SQL/LDAP databases. If
14902 you want to allow all characters, set this value to empty.
14903 Defaults to @samp{"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890.-_@@"}.
14904 @end deftypevr
14905
14906 @deftypevr {@code{dovecot-configuration} parameter} string auth-username-translation
14907 Username character translations before it's looked up from
14908 databases. The value contains series of from -> to characters. For
14909 example @samp{#@@/@@} means that @samp{#} and @samp{/} characters are
14910 translated to @samp{@@}.
14911 Defaults to @samp{""}.
14912 @end deftypevr
14913
14914 @deftypevr {@code{dovecot-configuration} parameter} string auth-username-format
14915 Username formatting before it's looked up from databases. You can
14916 use the standard variables here, e.g.@: %Lu would lowercase the username,
14917 %n would drop away the domain if it was given, or @samp{%n-AT-%d} would
14918 change the @samp{@@} into @samp{-AT-}. This translation is done after
14919 @samp{auth-username-translation} changes.
14920 Defaults to @samp{"%Lu"}.
14921 @end deftypevr
14922
14923 @deftypevr {@code{dovecot-configuration} parameter} string auth-master-user-separator
14924 If you want to allow master users to log in by specifying the master
14925 username within the normal username string (i.e.@: not using SASL
14926 mechanism's support for it), you can specify the separator character
14927 here. The format is then <username><separator><master username>.
14928 UW-IMAP uses @samp{*} as the separator, so that could be a good
14929 choice.
14930 Defaults to @samp{""}.
14931 @end deftypevr
14932
14933 @deftypevr {@code{dovecot-configuration} parameter} string auth-anonymous-username
14934 Username to use for users logging in with ANONYMOUS SASL
14935 mechanism.
14936 Defaults to @samp{"anonymous"}.
14937 @end deftypevr
14938
14939 @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer auth-worker-max-count
14940 Maximum number of dovecot-auth worker processes. They're used to
14941 execute blocking passdb and userdb queries (e.g.@: MySQL and PAM).
14942 They're automatically created and destroyed as needed.
14943 Defaults to @samp{30}.
14944 @end deftypevr
14945
14946 @deftypevr {@code{dovecot-configuration} parameter} string auth-gssapi-hostname
14947 Host name to use in GSSAPI principal names. The default is to use
14948 the name returned by gethostname(). Use @samp{$ALL} (with quotes) to
14949 allow all keytab entries.
14950 Defaults to @samp{""}.
14951 @end deftypevr
14952
14953 @deftypevr {@code{dovecot-configuration} parameter} string auth-krb5-keytab
14954 Kerberos keytab to use for the GSSAPI mechanism. Will use the
14955 system default (usually @file{/etc/krb5.keytab}) if not specified. You may
14956 need to change the auth service to run as root to be able to read this
14957 file.
14958 Defaults to @samp{""}.
14959 @end deftypevr
14960
14961 @deftypevr {@code{dovecot-configuration} parameter} boolean auth-use-winbind?
14962 Do NTLM and GSS-SPNEGO authentication using Samba's winbind daemon
14963 and @samp{ntlm-auth} helper.
14964 <doc/wiki/Authentication/Mechanisms/Winbind.txt>.
14965 Defaults to @samp{#f}.
14966 @end deftypevr
14967
14968 @deftypevr {@code{dovecot-configuration} parameter} file-name auth-winbind-helper-path
14969 Path for Samba's @samp{ntlm-auth} helper binary.
14970 Defaults to @samp{"/usr/bin/ntlm_auth"}.
14971 @end deftypevr
14972
14973 @deftypevr {@code{dovecot-configuration} parameter} string auth-failure-delay
14974 Time to delay before replying to failed authentications.
14975 Defaults to @samp{"2 secs"}.
14976 @end deftypevr
14977
14978 @deftypevr {@code{dovecot-configuration} parameter} boolean auth-ssl-require-client-cert?
14979 Require a valid SSL client certificate or the authentication
14980 fails.
14981 Defaults to @samp{#f}.
14982 @end deftypevr
14983
14984 @deftypevr {@code{dovecot-configuration} parameter} boolean auth-ssl-username-from-cert?
14985 Take the username from client's SSL certificate, using
14986 @code{X509_NAME_get_text_by_NID()} which returns the subject's DN's
14987 CommonName.
14988 Defaults to @samp{#f}.
14989 @end deftypevr
14990
14991 @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list auth-mechanisms
14992 List of wanted authentication mechanisms. Supported mechanisms are:
14993 @samp{plain}, @samp{login}, @samp{digest-md5}, @samp{cram-md5},
14994 @samp{ntlm}, @samp{rpa}, @samp{apop}, @samp{anonymous}, @samp{gssapi},
14995 @samp{otp}, @samp{skey}, and @samp{gss-spnego}. NOTE: See also
14996 @samp{disable-plaintext-auth} setting.
14997 @end deftypevr
14998
14999 @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list director-servers
15000 List of IPs or hostnames to all director servers, including ourself.
15001 Ports can be specified as ip:port. The default port is the same as what
15002 director service's @samp{inet-listener} is using.
15003 Defaults to @samp{()}.
15004 @end deftypevr
15005
15006 @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list director-mail-servers
15007 List of IPs or hostnames to all backend mail servers. Ranges are
15008 allowed too, like 10.0.0.10-10.0.0.30.
15009 Defaults to @samp{()}.
15010 @end deftypevr
15011
15012 @deftypevr {@code{dovecot-configuration} parameter} string director-user-expire
15013 How long to redirect users to a specific server after it no longer
15014 has any connections.
15015 Defaults to @samp{"15 min"}.
15016 @end deftypevr
15017
15018 @deftypevr {@code{dovecot-configuration} parameter} string director-username-hash
15019 How the username is translated before being hashed. Useful values
15020 include %Ln if user can log in with or without @@domain, %Ld if mailboxes
15021 are shared within domain.
15022 Defaults to @samp{"%Lu"}.
15023 @end deftypevr
15024
15025 @deftypevr {@code{dovecot-configuration} parameter} string log-path
15026 Log file to use for error messages. @samp{syslog} logs to syslog,
15027 @samp{/dev/stderr} logs to stderr.
15028 Defaults to @samp{"syslog"}.
15029 @end deftypevr
15030
15031 @deftypevr {@code{dovecot-configuration} parameter} string info-log-path
15032 Log file to use for informational messages. Defaults to
15033 @samp{log-path}.
15034 Defaults to @samp{""}.
15035 @end deftypevr
15036
15037 @deftypevr {@code{dovecot-configuration} parameter} string debug-log-path
15038 Log file to use for debug messages. Defaults to
15039 @samp{info-log-path}.
15040 Defaults to @samp{""}.
15041 @end deftypevr
15042
15043 @deftypevr {@code{dovecot-configuration} parameter} string syslog-facility
15044 Syslog facility to use if you're logging to syslog. Usually if you
15045 don't want to use @samp{mail}, you'll use local0..local7. Also other
15046 standard facilities are supported.
15047 Defaults to @samp{"mail"}.
15048 @end deftypevr
15049
15050 @deftypevr {@code{dovecot-configuration} parameter} boolean auth-verbose?
15051 Log unsuccessful authentication attempts and the reasons why they
15052 failed.
15053 Defaults to @samp{#f}.
15054 @end deftypevr
15055
15056 @deftypevr {@code{dovecot-configuration} parameter} boolean auth-verbose-passwords?
15057 In case of password mismatches, log the attempted password. Valid
15058 values are no, plain and sha1. sha1 can be useful for detecting brute
15059 force password attempts vs. user simply trying the same password over
15060 and over again. You can also truncate the value to n chars by appending
15061 ":n" (e.g.@: sha1:6).
15062 Defaults to @samp{#f}.
15063 @end deftypevr
15064
15065 @deftypevr {@code{dovecot-configuration} parameter} boolean auth-debug?
15066 Even more verbose logging for debugging purposes. Shows for example
15067 SQL queries.
15068 Defaults to @samp{#f}.
15069 @end deftypevr
15070
15071 @deftypevr {@code{dovecot-configuration} parameter} boolean auth-debug-passwords?
15072 In case of password mismatches, log the passwords and used scheme so
15073 the problem can be debugged. Enabling this also enables
15074 @samp{auth-debug}.
15075 Defaults to @samp{#f}.
15076 @end deftypevr
15077
15078 @deftypevr {@code{dovecot-configuration} parameter} boolean mail-debug?
15079 Enable mail process debugging. This can help you figure out why
15080 Dovecot isn't finding your mails.
15081 Defaults to @samp{#f}.
15082 @end deftypevr
15083
15084 @deftypevr {@code{dovecot-configuration} parameter} boolean verbose-ssl?
15085 Show protocol level SSL errors.
15086 Defaults to @samp{#f}.
15087 @end deftypevr
15088
15089 @deftypevr {@code{dovecot-configuration} parameter} string log-timestamp
15090 Prefix for each line written to log file. % codes are in
15091 strftime(3) format.
15092 Defaults to @samp{"\"%b %d %H:%M:%S \""}.
15093 @end deftypevr
15094
15095 @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list login-log-format-elements
15096 List of elements we want to log. The elements which have a
15097 non-empty variable value are joined together to form a comma-separated
15098 string.
15099 @end deftypevr
15100
15101 @deftypevr {@code{dovecot-configuration} parameter} string login-log-format
15102 Login log format. %s contains @samp{login-log-format-elements}
15103 string, %$ contains the data we want to log.
15104 Defaults to @samp{"%$: %s"}.
15105 @end deftypevr
15106
15107 @deftypevr {@code{dovecot-configuration} parameter} string mail-log-prefix
15108 Log prefix for mail processes. See doc/wiki/Variables.txt for list
15109 of possible variables you can use.
15110 Defaults to @samp{"\"%s(%u)<%@{pid@}><%@{session@}>: \""}.
15111 @end deftypevr
15112
15113 @deftypevr {@code{dovecot-configuration} parameter} string deliver-log-format
15114 Format to use for logging mail deliveries. You can use variables:
15115 @table @code
15116 @item %$
15117 Delivery status message (e.g.@: @samp{saved to INBOX})
15118 @item %m
15119 Message-ID
15120 @item %s
15121 Subject
15122 @item %f
15123 From address
15124 @item %p
15125 Physical size
15126 @item %w
15127 Virtual size.
15128 @end table
15129 Defaults to @samp{"msgid=%m: %$"}.
15130 @end deftypevr
15131
15132 @deftypevr {@code{dovecot-configuration} parameter} string mail-location
15133 Location for users' mailboxes. The default is empty, which means
15134 that Dovecot tries to find the mailboxes automatically. This won't work
15135 if the user doesn't yet have any mail, so you should explicitly tell
15136 Dovecot the full location.
15137
15138 If you're using mbox, giving a path to the INBOX
15139 file (e.g.@: /var/mail/%u) isn't enough. You'll also need to tell Dovecot
15140 where the other mailboxes are kept. This is called the "root mail
15141 directory", and it must be the first path given in the
15142 @samp{mail-location} setting.
15143
15144 There are a few special variables you can use, eg.:
15145
15146 @table @samp
15147 @item %u
15148 username
15149 @item %n
15150 user part in user@@domain, same as %u if there's no domain
15151 @item %d
15152 domain part in user@@domain, empty if there's no domain
15153 @item %h
15154 home director
15155 @end table
15156
15157 See doc/wiki/Variables.txt for full list. Some examples:
15158 @table @samp
15159 @item maildir:~/Maildir
15160 @item mbox:~/mail:INBOX=/var/mail/%u
15161 @item mbox:/var/mail/%d/%1n/%n:INDEX=/var/indexes/%d/%1n/%
15162 @end table
15163 Defaults to @samp{""}.
15164 @end deftypevr
15165
15166 @deftypevr {@code{dovecot-configuration} parameter} string mail-uid
15167 System user and group used to access mails. If you use multiple,
15168 userdb can override these by returning uid or gid fields. You can use
15169 either numbers or names. <doc/wiki/UserIds.txt>.
15170 Defaults to @samp{""}.
15171 @end deftypevr
15172
15173 @deftypevr {@code{dovecot-configuration} parameter} string mail-gid
15174
15175 Defaults to @samp{""}.
15176 @end deftypevr
15177
15178 @deftypevr {@code{dovecot-configuration} parameter} string mail-privileged-group
15179 Group to enable temporarily for privileged operations. Currently
15180 this is used only with INBOX when either its initial creation or
15181 dotlocking fails. Typically this is set to "mail" to give access to
15182 /var/mail.
15183 Defaults to @samp{""}.
15184 @end deftypevr
15185
15186 @deftypevr {@code{dovecot-configuration} parameter} string mail-access-groups
15187 Grant access to these supplementary groups for mail processes.
15188 Typically these are used to set up access to shared mailboxes. Note
15189 that it may be dangerous to set these if users can create
15190 symlinks (e.g.@: if "mail" group is set here, ln -s /var/mail ~/mail/var
15191 could allow a user to delete others' mailboxes, or ln -s
15192 /secret/shared/box ~/mail/mybox would allow reading it).
15193 Defaults to @samp{""}.
15194 @end deftypevr
15195
15196 @deftypevr {@code{dovecot-configuration} parameter} boolean mail-full-filesystem-access?
15197 Allow full file system access to clients. There's no access checks
15198 other than what the operating system does for the active UID/GID. It
15199 works with both maildir and mboxes, allowing you to prefix mailboxes
15200 names with e.g.@: /path/ or ~user/.
15201 Defaults to @samp{#f}.
15202 @end deftypevr
15203
15204 @deftypevr {@code{dovecot-configuration} parameter} boolean mmap-disable?
15205 Don't use mmap() at all. This is required if you store indexes to
15206 shared file systems (NFS or clustered file system).
15207 Defaults to @samp{#f}.
15208 @end deftypevr
15209
15210 @deftypevr {@code{dovecot-configuration} parameter} boolean dotlock-use-excl?
15211 Rely on @samp{O_EXCL} to work when creating dotlock files. NFS
15212 supports @samp{O_EXCL} since version 3, so this should be safe to use
15213 nowadays by default.
15214 Defaults to @samp{#t}.
15215 @end deftypevr
15216
15217 @deftypevr {@code{dovecot-configuration} parameter} string mail-fsync
15218 When to use fsync() or fdatasync() calls:
15219 @table @code
15220 @item optimized
15221 Whenever necessary to avoid losing important data
15222 @item always
15223 Useful with e.g.@: NFS when write()s are delayed
15224 @item never
15225 Never use it (best performance, but crashes can lose data).
15226 @end table
15227 Defaults to @samp{"optimized"}.
15228 @end deftypevr
15229
15230 @deftypevr {@code{dovecot-configuration} parameter} boolean mail-nfs-storage?
15231 Mail storage exists in NFS. Set this to yes to make Dovecot flush
15232 NFS caches whenever needed. If you're using only a single mail server
15233 this isn't needed.
15234 Defaults to @samp{#f}.
15235 @end deftypevr
15236
15237 @deftypevr {@code{dovecot-configuration} parameter} boolean mail-nfs-index?
15238 Mail index files also exist in NFS. Setting this to yes requires
15239 @samp{mmap-disable? #t} and @samp{fsync-disable? #f}.
15240 Defaults to @samp{#f}.
15241 @end deftypevr
15242
15243 @deftypevr {@code{dovecot-configuration} parameter} string lock-method
15244 Locking method for index files. Alternatives are fcntl, flock and
15245 dotlock. Dotlocking uses some tricks which may create more disk I/O
15246 than other locking methods. NFS users: flock doesn't work, remember to
15247 change @samp{mmap-disable}.
15248 Defaults to @samp{"fcntl"}.
15249 @end deftypevr
15250
15251 @deftypevr {@code{dovecot-configuration} parameter} file-name mail-temp-dir
15252 Directory in which LDA/LMTP temporarily stores incoming mails >128
15253 kB.
15254 Defaults to @samp{"/tmp"}.
15255 @end deftypevr
15256
15257 @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer first-valid-uid
15258 Valid UID range for users. This is mostly to make sure that users can't
15259 log in as daemons or other system users. Note that denying root logins is
15260 hardcoded to dovecot binary and can't be done even if @samp{first-valid-uid}
15261 is set to 0.
15262 Defaults to @samp{500}.
15263 @end deftypevr
15264
15265 @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer last-valid-uid
15266
15267 Defaults to @samp{0}.
15268 @end deftypevr
15269
15270 @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer first-valid-gid
15271 Valid GID range for users. Users having non-valid GID as primary group ID
15272 aren't allowed to log in. If user belongs to supplementary groups with
15273 non-valid GIDs, those groups are not set.
15274 Defaults to @samp{1}.
15275 @end deftypevr
15276
15277 @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer last-valid-gid
15278
15279 Defaults to @samp{0}.
15280 @end deftypevr
15281
15282 @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mail-max-keyword-length
15283 Maximum allowed length for mail keyword name. It's only forced when
15284 trying to create new keywords.
15285 Defaults to @samp{50}.
15286 @end deftypevr
15287
15288 @deftypevr {@code{dovecot-configuration} parameter} colon-separated-file-name-list valid-chroot-dirs
15289 List of directories under which chrooting is allowed for mail
15290 processes (i.e.@: /var/mail will allow chrooting to /var/mail/foo/bar
15291 too). This setting doesn't affect @samp{login-chroot}
15292 @samp{mail-chroot} or auth chroot settings. If this setting is empty,
15293 "/./" in home dirs are ignored. WARNING: Never add directories here
15294 which local users can modify, that may lead to root exploit. Usually
15295 this should be done only if you don't allow shell access for users.
15296 <doc/wiki/Chrooting.txt>.
15297 Defaults to @samp{()}.
15298 @end deftypevr
15299
15300 @deftypevr {@code{dovecot-configuration} parameter} string mail-chroot
15301 Default chroot directory for mail processes. This can be overridden
15302 for specific users in user database by giving /./ in user's home
15303 directory (e.g.@: /home/./user chroots into /home). Note that usually
15304 there is no real need to do chrooting, Dovecot doesn't allow users to
15305 access files outside their mail directory anyway. If your home
15306 directories are prefixed with the chroot directory, append "/."@: to
15307 @samp{mail-chroot}. <doc/wiki/Chrooting.txt>.
15308 Defaults to @samp{""}.
15309 @end deftypevr
15310
15311 @deftypevr {@code{dovecot-configuration} parameter} file-name auth-socket-path
15312 UNIX socket path to master authentication server to find users.
15313 This is used by imap (for shared users) and lda.
15314 Defaults to @samp{"/var/run/dovecot/auth-userdb"}.
15315 @end deftypevr
15316
15317 @deftypevr {@code{dovecot-configuration} parameter} file-name mail-plugin-dir
15318 Directory where to look up mail plugins.
15319 Defaults to @samp{"/usr/lib/dovecot"}.
15320 @end deftypevr
15321
15322 @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list mail-plugins
15323 List of plugins to load for all services. Plugins specific to IMAP,
15324 LDA, etc.@: are added to this list in their own .conf files.
15325 Defaults to @samp{()}.
15326 @end deftypevr
15327
15328 @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mail-cache-min-mail-count
15329 The minimum number of mails in a mailbox before updates are done to
15330 cache file. This allows optimizing Dovecot's behavior to do less disk
15331 writes at the cost of more disk reads.
15332 Defaults to @samp{0}.
15333 @end deftypevr
15334
15335 @deftypevr {@code{dovecot-configuration} parameter} string mailbox-idle-check-interval
15336 When IDLE command is running, mailbox is checked once in a while to
15337 see if there are any new mails or other changes. This setting defines
15338 the minimum time to wait between those checks. Dovecot can also use
15339 dnotify, inotify and kqueue to find out immediately when changes
15340 occur.
15341 Defaults to @samp{"30 secs"}.
15342 @end deftypevr
15343
15344 @deftypevr {@code{dovecot-configuration} parameter} boolean mail-save-crlf?
15345 Save mails with CR+LF instead of plain LF. This makes sending those
15346 mails take less CPU, especially with sendfile() syscall with Linux and
15347 FreeBSD. But it also creates a bit more disk I/O which may just make it
15348 slower. Also note that if other software reads the mboxes/maildirs,
15349 they may handle the extra CRs wrong and cause problems.
15350 Defaults to @samp{#f}.
15351 @end deftypevr
15352
15353 @deftypevr {@code{dovecot-configuration} parameter} boolean maildir-stat-dirs?
15354 By default LIST command returns all entries in maildir beginning
15355 with a dot. Enabling this option makes Dovecot return only entries
15356 which are directories. This is done by stat()ing each entry, so it
15357 causes more disk I/O.
15358 (For systems setting struct @samp{dirent->d_type} this check is free
15359 and it's done always regardless of this setting).
15360 Defaults to @samp{#f}.
15361 @end deftypevr
15362
15363 @deftypevr {@code{dovecot-configuration} parameter} boolean maildir-copy-with-hardlinks?
15364 When copying a message, do it with hard links whenever possible.
15365 This makes the performance much better, and it's unlikely to have any
15366 side effects.
15367 Defaults to @samp{#t}.
15368 @end deftypevr
15369
15370 @deftypevr {@code{dovecot-configuration} parameter} boolean maildir-very-dirty-syncs?
15371 Assume Dovecot is the only MUA accessing Maildir: Scan cur/
15372 directory only when its mtime changes unexpectedly or when we can't find
15373 the mail otherwise.
15374 Defaults to @samp{#f}.
15375 @end deftypevr
15376
15377 @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list mbox-read-locks
15378 Which locking methods to use for locking mbox. There are four
15379 available:
15380
15381 @table @code
15382 @item dotlock
15383 Create <mailbox>.lock file. This is the oldest and most NFS-safe
15384 solution. If you want to use /var/mail/ like directory, the users will
15385 need write access to that directory.
15386 @item dotlock-try
15387 Same as dotlock, but if it fails because of permissions or because there
15388 isn't enough disk space, just skip it.
15389 @item fcntl
15390 Use this if possible. Works with NFS too if lockd is used.
15391 @item flock
15392 May not exist in all systems. Doesn't work with NFS.
15393 @item lockf
15394 May not exist in all systems. Doesn't work with NFS.
15395 @end table
15396
15397 You can use multiple locking methods; if you do the order they're declared
15398 in is important to avoid deadlocks if other MTAs/MUAs are using multiple
15399 locking methods as well. Some operating systems don't allow using some of
15400 them simultaneously.
15401 @end deftypevr
15402
15403 @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list mbox-write-locks
15404
15405 @end deftypevr
15406
15407 @deftypevr {@code{dovecot-configuration} parameter} string mbox-lock-timeout
15408 Maximum time to wait for lock (all of them) before aborting.
15409 Defaults to @samp{"5 mins"}.
15410 @end deftypevr
15411
15412 @deftypevr {@code{dovecot-configuration} parameter} string mbox-dotlock-change-timeout
15413 If dotlock exists but the mailbox isn't modified in any way,
15414 override the lock file after this much time.
15415 Defaults to @samp{"2 mins"}.
15416 @end deftypevr
15417
15418 @deftypevr {@code{dovecot-configuration} parameter} boolean mbox-dirty-syncs?
15419 When mbox changes unexpectedly we have to fully read it to find out
15420 what changed. If the mbox is large this can take a long time. Since
15421 the change is usually just a newly appended mail, it'd be faster to
15422 simply read the new mails. If this setting is enabled, Dovecot does
15423 this but still safely fallbacks to re-reading the whole mbox file
15424 whenever something in mbox isn't how it's expected to be. The only real
15425 downside to this setting is that if some other MUA changes message
15426 flags, Dovecot doesn't notice it immediately. Note that a full sync is
15427 done with SELECT, EXAMINE, EXPUNGE and CHECK commands.
15428 Defaults to @samp{#t}.
15429 @end deftypevr
15430
15431 @deftypevr {@code{dovecot-configuration} parameter} boolean mbox-very-dirty-syncs?
15432 Like @samp{mbox-dirty-syncs}, but don't do full syncs even with SELECT,
15433 EXAMINE, EXPUNGE or CHECK commands. If this is set,
15434 @samp{mbox-dirty-syncs} is ignored.
15435 Defaults to @samp{#f}.
15436 @end deftypevr
15437
15438 @deftypevr {@code{dovecot-configuration} parameter} boolean mbox-lazy-writes?
15439 Delay writing mbox headers until doing a full write sync (EXPUNGE
15440 and CHECK commands and when closing the mailbox). This is especially
15441 useful for POP3 where clients often delete all mails. The downside is
15442 that our changes aren't immediately visible to other MUAs.
15443 Defaults to @samp{#t}.
15444 @end deftypevr
15445
15446 @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mbox-min-index-size
15447 If mbox size is smaller than this (e.g.@: 100k), don't write index
15448 files. If an index file already exists it's still read, just not
15449 updated.
15450 Defaults to @samp{0}.
15451 @end deftypevr
15452
15453 @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mdbox-rotate-size
15454 Maximum dbox file size until it's rotated.
15455 Defaults to @samp{10000000}.
15456 @end deftypevr
15457
15458 @deftypevr {@code{dovecot-configuration} parameter} string mdbox-rotate-interval
15459 Maximum dbox file age until it's rotated. Typically in days. Day
15460 begins from midnight, so 1d = today, 2d = yesterday, etc. 0 = check
15461 disabled.
15462 Defaults to @samp{"1d"}.
15463 @end deftypevr
15464
15465 @deftypevr {@code{dovecot-configuration} parameter} boolean mdbox-preallocate-space?
15466 When creating new mdbox files, immediately preallocate their size to
15467 @samp{mdbox-rotate-size}. This setting currently works only in Linux
15468 with some file systems (ext4, xfs).
15469 Defaults to @samp{#f}.
15470 @end deftypevr
15471
15472 @deftypevr {@code{dovecot-configuration} parameter} string mail-attachment-dir
15473 sdbox and mdbox support saving mail attachments to external files,
15474 which also allows single instance storage for them. Other backends
15475 don't support this for now.
15476
15477 WARNING: This feature hasn't been tested much yet. Use at your own risk.
15478
15479 Directory root where to store mail attachments. Disabled, if empty.
15480 Defaults to @samp{""}.
15481 @end deftypevr
15482
15483 @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mail-attachment-min-size
15484 Attachments smaller than this aren't saved externally. It's also
15485 possible to write a plugin to disable saving specific attachments
15486 externally.
15487 Defaults to @samp{128000}.
15488 @end deftypevr
15489
15490 @deftypevr {@code{dovecot-configuration} parameter} string mail-attachment-fs
15491 File system backend to use for saving attachments:
15492 @table @code
15493 @item posix
15494 No SiS done by Dovecot (but this might help FS's own deduplication)
15495 @item sis posix
15496 SiS with immediate byte-by-byte comparison during saving
15497 @item sis-queue posix
15498 SiS with delayed comparison and deduplication.
15499 @end table
15500 Defaults to @samp{"sis posix"}.
15501 @end deftypevr
15502
15503 @deftypevr {@code{dovecot-configuration} parameter} string mail-attachment-hash
15504 Hash format to use in attachment filenames. You can add any text and
15505 variables: @code{%@{md4@}}, @code{%@{md5@}}, @code{%@{sha1@}},
15506 @code{%@{sha256@}}, @code{%@{sha512@}}, @code{%@{size@}}. Variables can be
15507 truncated, e.g.@: @code{%@{sha256:80@}} returns only first 80 bits.
15508 Defaults to @samp{"%@{sha1@}"}.
15509 @end deftypevr
15510
15511 @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer default-process-limit
15512
15513 Defaults to @samp{100}.
15514 @end deftypevr
15515
15516 @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer default-client-limit
15517
15518 Defaults to @samp{1000}.
15519 @end deftypevr
15520
15521 @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer default-vsz-limit
15522 Default VSZ (virtual memory size) limit for service processes.
15523 This is mainly intended to catch and kill processes that leak memory
15524 before they eat up everything.
15525 Defaults to @samp{256000000}.
15526 @end deftypevr
15527
15528 @deftypevr {@code{dovecot-configuration} parameter} string default-login-user
15529 Login user is internally used by login processes. This is the most
15530 untrusted user in Dovecot system. It shouldn't have access to anything
15531 at all.
15532 Defaults to @samp{"dovenull"}.
15533 @end deftypevr
15534
15535 @deftypevr {@code{dovecot-configuration} parameter} string default-internal-user
15536 Internal user is used by unprivileged processes. It should be
15537 separate from login user, so that login processes can't disturb other
15538 processes.
15539 Defaults to @samp{"dovecot"}.
15540 @end deftypevr
15541
15542 @deftypevr {@code{dovecot-configuration} parameter} string ssl?
15543 SSL/TLS support: yes, no, required. <doc/wiki/SSL.txt>.
15544 Defaults to @samp{"required"}.
15545 @end deftypevr
15546
15547 @deftypevr {@code{dovecot-configuration} parameter} string ssl-cert
15548 PEM encoded X.509 SSL/TLS certificate (public key).
15549 Defaults to @samp{"</etc/dovecot/default.pem"}.
15550 @end deftypevr
15551
15552 @deftypevr {@code{dovecot-configuration} parameter} string ssl-key
15553 PEM encoded SSL/TLS private key. The key is opened before
15554 dropping root privileges, so keep the key file unreadable by anyone but
15555 root.
15556 Defaults to @samp{"</etc/dovecot/private/default.pem"}.
15557 @end deftypevr
15558
15559 @deftypevr {@code{dovecot-configuration} parameter} string ssl-key-password
15560 If key file is password protected, give the password here.
15561 Alternatively give it when starting dovecot with -p parameter. Since
15562 this file is often world-readable, you may want to place this setting
15563 instead to a different.
15564 Defaults to @samp{""}.
15565 @end deftypevr
15566
15567 @deftypevr {@code{dovecot-configuration} parameter} string ssl-ca
15568 PEM encoded trusted certificate authority. Set this only if you
15569 intend to use @samp{ssl-verify-client-cert? #t}. The file should
15570 contain the CA certificate(s) followed by the matching
15571 CRL(s). (e.g.@: @samp{ssl-ca </etc/ssl/certs/ca.pem}).
15572 Defaults to @samp{""}.
15573 @end deftypevr
15574
15575 @deftypevr {@code{dovecot-configuration} parameter} boolean ssl-require-crl?
15576 Require that CRL check succeeds for client certificates.
15577 Defaults to @samp{#t}.
15578 @end deftypevr
15579
15580 @deftypevr {@code{dovecot-configuration} parameter} boolean ssl-verify-client-cert?
15581 Request client to send a certificate. If you also want to require
15582 it, set @samp{auth-ssl-require-client-cert? #t} in auth section.
15583 Defaults to @samp{#f}.
15584 @end deftypevr
15585
15586 @deftypevr {@code{dovecot-configuration} parameter} string ssl-cert-username-field
15587 Which field from certificate to use for username. commonName and
15588 x500UniqueIdentifier are the usual choices. You'll also need to set
15589 @samp{auth-ssl-username-from-cert? #t}.
15590 Defaults to @samp{"commonName"}.
15591 @end deftypevr
15592
15593 @deftypevr {@code{dovecot-configuration} parameter} string ssl-min-protocol
15594 Minimum SSL protocol version to accept.
15595 Defaults to @samp{"TLSv1"}.
15596 @end deftypevr
15597
15598 @deftypevr {@code{dovecot-configuration} parameter} string ssl-cipher-list
15599 SSL ciphers to use.
15600 Defaults to @samp{"ALL:!kRSA:!SRP:!kDHd:!DSS:!aNULL:!eNULL:!EXPORT:!DES:!3DES:!MD5:!PSK:!RC4:!ADH:!LOW@@STRENGTH"}.
15601 @end deftypevr
15602
15603 @deftypevr {@code{dovecot-configuration} parameter} string ssl-crypto-device
15604 SSL crypto device to use, for valid values run "openssl engine".
15605 Defaults to @samp{""}.
15606 @end deftypevr
15607
15608 @deftypevr {@code{dovecot-configuration} parameter} string postmaster-address
15609 Address to use when sending rejection mails.
15610 %d expands to recipient domain.
15611 Defaults to @samp{"postmaster@@%d"}.
15612 @end deftypevr
15613
15614 @deftypevr {@code{dovecot-configuration} parameter} string hostname
15615 Hostname to use in various parts of sent mails (e.g.@: in Message-Id)
15616 and in LMTP replies. Default is the system's real hostname@@domain.
15617 Defaults to @samp{""}.
15618 @end deftypevr
15619
15620 @deftypevr {@code{dovecot-configuration} parameter} boolean quota-full-tempfail?
15621 If user is over quota, return with temporary failure instead of
15622 bouncing the mail.
15623 Defaults to @samp{#f}.
15624 @end deftypevr
15625
15626 @deftypevr {@code{dovecot-configuration} parameter} file-name sendmail-path
15627 Binary to use for sending mails.
15628 Defaults to @samp{"/usr/sbin/sendmail"}.
15629 @end deftypevr
15630
15631 @deftypevr {@code{dovecot-configuration} parameter} string submission-host
15632 If non-empty, send mails via this SMTP host[:port] instead of
15633 sendmail.
15634 Defaults to @samp{""}.
15635 @end deftypevr
15636
15637 @deftypevr {@code{dovecot-configuration} parameter} string rejection-subject
15638 Subject: header to use for rejection mails. You can use the same
15639 variables as for @samp{rejection-reason} below.
15640 Defaults to @samp{"Rejected: %s"}.
15641 @end deftypevr
15642
15643 @deftypevr {@code{dovecot-configuration} parameter} string rejection-reason
15644 Human readable error message for rejection mails. You can use
15645 variables:
15646
15647 @table @code
15648 @item %n
15649 CRLF
15650 @item %r
15651 reason
15652 @item %s
15653 original subject
15654 @item %t
15655 recipient
15656 @end table
15657 Defaults to @samp{"Your message to <%t> was automatically rejected:%n%r"}.
15658 @end deftypevr
15659
15660 @deftypevr {@code{dovecot-configuration} parameter} string recipient-delimiter
15661 Delimiter character between local-part and detail in email
15662 address.
15663 Defaults to @samp{"+"}.
15664 @end deftypevr
15665
15666 @deftypevr {@code{dovecot-configuration} parameter} string lda-original-recipient-header
15667 Header where the original recipient address (SMTP's RCPT TO:
15668 address) is taken from if not available elsewhere. With dovecot-lda -a
15669 parameter overrides this. A commonly used header for this is
15670 X-Original-To.
15671 Defaults to @samp{""}.
15672 @end deftypevr
15673
15674 @deftypevr {@code{dovecot-configuration} parameter} boolean lda-mailbox-autocreate?
15675 Should saving a mail to a nonexistent mailbox automatically create
15676 it?.
15677 Defaults to @samp{#f}.
15678 @end deftypevr
15679
15680 @deftypevr {@code{dovecot-configuration} parameter} boolean lda-mailbox-autosubscribe?
15681 Should automatically created mailboxes be also automatically
15682 subscribed?.
15683 Defaults to @samp{#f}.
15684 @end deftypevr
15685
15686 @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer imap-max-line-length
15687 Maximum IMAP command line length. Some clients generate very long
15688 command lines with huge mailboxes, so you may need to raise this if you
15689 get "Too long argument" or "IMAP command line too large" errors
15690 often.
15691 Defaults to @samp{64000}.
15692 @end deftypevr
15693
15694 @deftypevr {@code{dovecot-configuration} parameter} string imap-logout-format
15695 IMAP logout format string:
15696 @table @code
15697 @item %i
15698 total number of bytes read from client
15699 @item %o
15700 total number of bytes sent to client.
15701 @end table
15702 See @file{doc/wiki/Variables.txt} for a list of all the variables you can use.
15703 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@}"}.
15704 @end deftypevr
15705
15706 @deftypevr {@code{dovecot-configuration} parameter} string imap-capability
15707 Override the IMAP CAPABILITY response. If the value begins with '+',
15708 add the given capabilities on top of the defaults (e.g.@: +XFOO XBAR).
15709 Defaults to @samp{""}.
15710 @end deftypevr
15711
15712 @deftypevr {@code{dovecot-configuration} parameter} string imap-idle-notify-interval
15713 How long to wait between "OK Still here" notifications when client
15714 is IDLEing.
15715 Defaults to @samp{"2 mins"}.
15716 @end deftypevr
15717
15718 @deftypevr {@code{dovecot-configuration} parameter} string imap-id-send
15719 ID field names and values to send to clients. Using * as the value
15720 makes Dovecot use the default value. The following fields have default
15721 values currently: name, version, os, os-version, support-url,
15722 support-email.
15723 Defaults to @samp{""}.
15724 @end deftypevr
15725
15726 @deftypevr {@code{dovecot-configuration} parameter} string imap-id-log
15727 ID fields sent by client to log. * means everything.
15728 Defaults to @samp{""}.
15729 @end deftypevr
15730
15731 @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list imap-client-workarounds
15732 Workarounds for various client bugs:
15733
15734 @table @code
15735 @item delay-newmail
15736 Send EXISTS/RECENT new mail notifications only when replying to NOOP and
15737 CHECK commands. Some clients ignore them otherwise, for example OSX
15738 Mail (<v2.1). Outlook Express breaks more badly though, without this it
15739 may show user "Message no longer in server" errors. Note that OE6
15740 still breaks even with this workaround if synchronization is set to
15741 "Headers Only".
15742
15743 @item tb-extra-mailbox-sep
15744 Thunderbird gets somehow confused with LAYOUT=fs (mbox and dbox) and
15745 adds extra @samp{/} suffixes to mailbox names. This option causes Dovecot to
15746 ignore the extra @samp{/} instead of treating it as invalid mailbox name.
15747
15748 @item tb-lsub-flags
15749 Show \Noselect flags for LSUB replies with LAYOUT=fs (e.g.@: mbox).
15750 This makes Thunderbird realize they aren't selectable and show them
15751 greyed out, instead of only later giving "not selectable" popup error.
15752 @end table
15753 Defaults to @samp{()}.
15754 @end deftypevr
15755
15756 @deftypevr {@code{dovecot-configuration} parameter} string imap-urlauth-host
15757 Host allowed in URLAUTH URLs sent by client. "*" allows all.
15758 Defaults to @samp{""}.
15759 @end deftypevr
15760
15761
15762 Whew! Lots of configuration options. The nice thing about it though is
15763 that GuixSD has a complete interface to Dovecot's configuration
15764 language. This allows not only a nice way to declare configurations,
15765 but also offers reflective capabilities as well: users can write code to
15766 inspect and transform configurations from within Scheme.
15767
15768 However, it could be that you just want to get a @code{dovecot.conf} up
15769 and running. In that case, you can pass an
15770 @code{opaque-dovecot-configuration} as the @code{#:config} parameter to
15771 @code{dovecot-service}. As its name indicates, an opaque configuration
15772 does not have easy reflective capabilities.
15773
15774 Available @code{opaque-dovecot-configuration} fields are:
15775
15776 @deftypevr {@code{opaque-dovecot-configuration} parameter} package dovecot
15777 The dovecot package.
15778 @end deftypevr
15779
15780 @deftypevr {@code{opaque-dovecot-configuration} parameter} string string
15781 The contents of the @code{dovecot.conf}, as a string.
15782 @end deftypevr
15783
15784 For example, if your @code{dovecot.conf} is just the empty string, you
15785 could instantiate a dovecot service like this:
15786
15787 @example
15788 (dovecot-service #:config
15789 (opaque-dovecot-configuration
15790 (string "")))
15791 @end example
15792
15793 @subsubheading OpenSMTPD Service
15794
15795 @deffn {Scheme Variable} opensmtpd-service-type
15796 This is the type of the @uref{https://www.opensmtpd.org, OpenSMTPD}
15797 service, whose value should be an @code{opensmtpd-configuration} object
15798 as in this example:
15799
15800 @example
15801 (service opensmtpd-service-type
15802 (opensmtpd-configuration
15803 (config-file (local-file "./my-smtpd.conf"))))
15804 @end example
15805 @end deffn
15806
15807 @deftp {Data Type} opensmtpd-configuration
15808 Data type representing the configuration of opensmtpd.
15809
15810 @table @asis
15811 @item @code{package} (default: @var{opensmtpd})
15812 Package object of the OpenSMTPD SMTP server.
15813
15814 @item @code{config-file} (default: @var{%default-opensmtpd-file})
15815 File-like object of the OpenSMTPD configuration file to use. By default
15816 it listens on the loopback network interface, and allows for mail from
15817 users and daemons on the local machine, as well as permitting email to
15818 remote servers. Run @command{man smtpd.conf} for more information.
15819
15820 @end table
15821 @end deftp
15822
15823 @subsubheading Exim Service
15824
15825 @cindex mail transfer agent (MTA)
15826 @cindex MTA (mail transfer agent)
15827 @cindex SMTP
15828
15829 @deffn {Scheme Variable} exim-service-type
15830 This is the type of the @uref{https://exim.org, Exim} mail transfer
15831 agent (MTA), whose value should be an @code{exim-configuration} object
15832 as in this example:
15833
15834 @example
15835 (service exim-service-type
15836 (exim-configuration
15837 (config-file (local-file "./my-exim.conf"))))
15838 @end example
15839 @end deffn
15840
15841 In order to use an @code{exim-service-type} service you must also have a
15842 @code{mail-aliases-service-type} service present in your
15843 @code{operating-system} (even if it has no aliases).
15844
15845 @deftp {Data Type} exim-configuration
15846 Data type representing the configuration of exim.
15847
15848 @table @asis
15849 @item @code{package} (default: @var{exim})
15850 Package object of the Exim server.
15851
15852 @item @code{config-file} (default: @code{#f})
15853 File-like object of the Exim configuration file to use. If its value is
15854 @code{#f} then use the default configuration file from the package
15855 provided in @code{package}. The resulting configuration file is loaded
15856 after setting the @code{exim_user} and @code{exim_group} configuration
15857 variables.
15858
15859 @end table
15860 @end deftp
15861
15862 @subsubheading Mail Aliases Service
15863
15864 @cindex email aliases
15865 @cindex aliases, for email addresses
15866
15867 @deffn {Scheme Variable} mail-aliases-service-type
15868 This is the type of the service which provides @code{/etc/aliases},
15869 specifying how to deliver mail to users on this system.
15870
15871 @example
15872 (service mail-aliases-service-type
15873 '(("postmaster" "bob")
15874 ("bob" "bob@@example.com" "bob@@example2.com")))
15875 @end example
15876 @end deffn
15877
15878 The configuration for a @code{mail-aliases-service-type} service is an
15879 association list denoting how to deliver mail that comes to this
15880 system. Each entry is of the form @code{(alias addresses ...)}, with
15881 @code{alias} specifying the local alias and @code{addresses} specifying
15882 where to deliver this user's mail.
15883
15884 The aliases aren't required to exist as users on the local system. In
15885 the above example, there doesn't need to be a @code{postmaster} entry in
15886 the @code{operating-system}'s @code{user-accounts} in order to deliver
15887 the @code{postmaster} mail to @code{bob} (which subsequently would
15888 deliver mail to @code{bob@@example.com} and @code{bob@@example2.com}).
15889
15890 @node Messaging Services
15891 @subsection Messaging Services
15892
15893 @cindex messaging
15894 @cindex jabber
15895 @cindex XMPP
15896 The @code{(gnu services messaging)} module provides Guix service
15897 definitions for messaging services: currently only Prosody is supported.
15898
15899 @subsubheading Prosody Service
15900
15901 @deffn {Scheme Variable} prosody-service-type
15902 This is the type for the @uref{https://prosody.im, Prosody XMPP
15903 communication server}. Its value must be a @code{prosody-configuration}
15904 record as in this example:
15905
15906 @example
15907 (service prosody-service-type
15908 (prosody-configuration
15909 (modules-enabled (cons "groups" "mam" %default-modules-enabled))
15910 (int-components
15911 (list
15912 (int-component-configuration
15913 (hostname "conference.example.net")
15914 (plugin "muc")
15915 (mod-muc (mod-muc-configuration)))))
15916 (virtualhosts
15917 (list
15918 (virtualhost-configuration
15919 (domain "example.net"))))))
15920 @end example
15921
15922 See below for details about @code{prosody-configuration}.
15923
15924 @end deffn
15925
15926 By default, Prosody does not need much configuration. Only one
15927 @code{virtualhosts} field is needed: it specifies the domain you wish
15928 Prosody to serve.
15929
15930 You can perform various sanity checks on the generated configuration
15931 with the @code{prosodyctl check} command.
15932
15933 Prosodyctl will also help you to import certificates from the
15934 @code{letsencrypt} directory so that the @code{prosody} user can access
15935 them. See @url{https://prosody.im/doc/letsencrypt}.
15936
15937 @example
15938 prosodyctl --root cert import /etc/letsencrypt/live
15939 @end example
15940
15941 The available configuration parameters follow. Each parameter
15942 definition is preceded by its type; for example, @samp{string-list foo}
15943 indicates that the @code{foo} parameter should be specified as a list of
15944 strings. Types starting with @code{maybe-} denote parameters that won't
15945 show up in @code{prosody.cfg.lua} when their value is @code{'disabled}.
15946
15947 There is also a way to specify the configuration as a string, if you
15948 have an old @code{prosody.cfg.lua} file that you want to port over from
15949 some other system; see the end for more details.
15950
15951 The @code{file-object} type designates either a file-like object
15952 (@pxref{G-Expressions, file-like objects}) or a file name.
15953
15954 @c The following documentation was initially generated by
15955 @c (generate-documentation) in (gnu services messaging). Manually maintained
15956 @c documentation is better, so we shouldn't hesitate to edit below as
15957 @c needed. However if the change you want to make to this documentation
15958 @c can be done in an automated way, it's probably easier to change
15959 @c (generate-documentation) than to make it below and have to deal with
15960 @c the churn as Prosody updates.
15961
15962 Available @code{prosody-configuration} fields are:
15963
15964 @deftypevr {@code{prosody-configuration} parameter} package prosody
15965 The Prosody package.
15966 @end deftypevr
15967
15968 @deftypevr {@code{prosody-configuration} parameter} file-name data-path
15969 Location of the Prosody data storage directory. See
15970 @url{https://prosody.im/doc/configure}.
15971 Defaults to @samp{"/var/lib/prosody"}.
15972 @end deftypevr
15973
15974 @deftypevr {@code{prosody-configuration} parameter} file-object-list plugin-paths
15975 Additional plugin directories. They are searched in all the specified
15976 paths in order. See @url{https://prosody.im/doc/plugins_directory}.
15977 Defaults to @samp{()}.
15978 @end deftypevr
15979
15980 @deftypevr {@code{prosody-configuration} parameter} file-name certificates
15981 Every virtual host and component needs a certificate so that clients and
15982 servers can securely verify its identity. Prosody will automatically load
15983 certificates/keys from the directory specified here.
15984 Defaults to @samp{"/etc/prosody/certs"}.
15985 @end deftypevr
15986
15987 @deftypevr {@code{prosody-configuration} parameter} string-list admins
15988 This is a list of accounts that are admins for the server. Note that you
15989 must create the accounts separately. See @url{https://prosody.im/doc/admins} and
15990 @url{https://prosody.im/doc/creating_accounts}.
15991 Example: @code{(admins '("user1@@example.com" "user2@@example.net"))}
15992 Defaults to @samp{()}.
15993 @end deftypevr
15994
15995 @deftypevr {@code{prosody-configuration} parameter} boolean use-libevent?
15996 Enable use of libevent for better performance under high load. See
15997 @url{https://prosody.im/doc/libevent}.
15998 Defaults to @samp{#f}.
15999 @end deftypevr
16000
16001 @deftypevr {@code{prosody-configuration} parameter} module-list modules-enabled
16002 This is the list of modules Prosody will load on startup. It looks for
16003 @code{mod_modulename.lua} in the plugins folder, so make sure that exists too.
16004 Documentation on modules can be found at:
16005 @url{https://prosody.im/doc/modules}.
16006 Defaults to @samp{("roster" "saslauth" "tls" "dialback" "disco" "carbons" "private" "blocklist" "vcard" "version" "uptime" "time" "ping" "pep" "register" "admin_adhoc")}.
16007 @end deftypevr
16008
16009 @deftypevr {@code{prosody-configuration} parameter} string-list modules-disabled
16010 @samp{"offline"}, @samp{"c2s"} and @samp{"s2s"} are auto-loaded, but
16011 should you want to disable them then add them to this list.
16012 Defaults to @samp{()}.
16013 @end deftypevr
16014
16015 @deftypevr {@code{prosody-configuration} parameter} file-object groups-file
16016 Path to a text file where the shared groups are defined. If this path is
16017 empty then @samp{mod_groups} does nothing. See
16018 @url{https://prosody.im/doc/modules/mod_groups}.
16019 Defaults to @samp{"/var/lib/prosody/sharedgroups.txt"}.
16020 @end deftypevr
16021
16022 @deftypevr {@code{prosody-configuration} parameter} boolean allow-registration?
16023 Disable account creation by default, for security. See
16024 @url{https://prosody.im/doc/creating_accounts}.
16025 Defaults to @samp{#f}.
16026 @end deftypevr
16027
16028 @deftypevr {@code{prosody-configuration} parameter} maybe-ssl-configuration ssl
16029 These are the SSL/TLS-related settings. Most of them are disabled so to
16030 use Prosody's defaults. If you do not completely understand these options, do
16031 not add them to your config, it is easy to lower the security of your server
16032 using them. See @url{https://prosody.im/doc/advanced_ssl_config}.
16033
16034 Available @code{ssl-configuration} fields are:
16035
16036 @deftypevr {@code{ssl-configuration} parameter} maybe-string protocol
16037 This determines what handshake to use.
16038 @end deftypevr
16039
16040 @deftypevr {@code{ssl-configuration} parameter} maybe-file-name key
16041 Path to your private key file.
16042 @end deftypevr
16043
16044 @deftypevr {@code{ssl-configuration} parameter} maybe-file-name certificate
16045 Path to your certificate file.
16046 @end deftypevr
16047
16048 @deftypevr {@code{ssl-configuration} parameter} file-object capath
16049 Path to directory containing root certificates that you wish Prosody to
16050 trust when verifying the certificates of remote servers.
16051 Defaults to @samp{"/etc/ssl/certs"}.
16052 @end deftypevr
16053
16054 @deftypevr {@code{ssl-configuration} parameter} maybe-file-object cafile
16055 Path to a file containing root certificates that you wish Prosody to trust.
16056 Similar to @code{capath} but with all certificates concatenated together.
16057 @end deftypevr
16058
16059 @deftypevr {@code{ssl-configuration} parameter} maybe-string-list verify
16060 A list of verification options (these mostly map to OpenSSL's
16061 @code{set_verify()} flags).
16062 @end deftypevr
16063
16064 @deftypevr {@code{ssl-configuration} parameter} maybe-string-list options
16065 A list of general options relating to SSL/TLS. These map to OpenSSL's
16066 @code{set_options()}. For a full list of options available in LuaSec, see the
16067 LuaSec source.
16068 @end deftypevr
16069
16070 @deftypevr {@code{ssl-configuration} parameter} maybe-non-negative-integer depth
16071 How long a chain of certificate authorities to check when looking for a
16072 trusted root certificate.
16073 @end deftypevr
16074
16075 @deftypevr {@code{ssl-configuration} parameter} maybe-string ciphers
16076 An OpenSSL cipher string. This selects what ciphers Prosody will offer to
16077 clients, and in what order.
16078 @end deftypevr
16079
16080 @deftypevr {@code{ssl-configuration} parameter} maybe-file-name dhparam
16081 A path to a file containing parameters for Diffie-Hellman key exchange. You
16082 can create such a file with:
16083 @code{openssl dhparam -out /etc/prosody/certs/dh-2048.pem 2048}
16084 @end deftypevr
16085
16086 @deftypevr {@code{ssl-configuration} parameter} maybe-string curve
16087 Curve for Elliptic curve Diffie-Hellman. Prosody's default is
16088 @samp{"secp384r1"}.
16089 @end deftypevr
16090
16091 @deftypevr {@code{ssl-configuration} parameter} maybe-string-list verifyext
16092 A list of "extra" verification options.
16093 @end deftypevr
16094
16095 @deftypevr {@code{ssl-configuration} parameter} maybe-string password
16096 Password for encrypted private keys.
16097 @end deftypevr
16098
16099 @end deftypevr
16100
16101 @deftypevr {@code{prosody-configuration} parameter} boolean c2s-require-encryption?
16102 Whether to force all client-to-server connections to be encrypted or not.
16103 See @url{https://prosody.im/doc/modules/mod_tls}.
16104 Defaults to @samp{#f}.
16105 @end deftypevr
16106
16107 @deftypevr {@code{prosody-configuration} parameter} string-list disable-sasl-mechanisms
16108 Set of mechanisms that will never be offered. See
16109 @url{https://prosody.im/doc/modules/mod_saslauth}.
16110 Defaults to @samp{("DIGEST-MD5")}.
16111 @end deftypevr
16112
16113 @deftypevr {@code{prosody-configuration} parameter} boolean s2s-require-encryption?
16114 Whether to force all server-to-server connections to be encrypted or not.
16115 See @url{https://prosody.im/doc/modules/mod_tls}.
16116 Defaults to @samp{#f}.
16117 @end deftypevr
16118
16119 @deftypevr {@code{prosody-configuration} parameter} boolean s2s-secure-auth?
16120 Whether to require encryption and certificate authentication. This
16121 provides ideal security, but requires servers you communicate with to support
16122 encryption AND present valid, trusted certificates. See
16123 @url{https://prosody.im/doc/s2s#security}.
16124 Defaults to @samp{#f}.
16125 @end deftypevr
16126
16127 @deftypevr {@code{prosody-configuration} parameter} string-list s2s-insecure-domains
16128 Many servers don't support encryption or have invalid or self-signed
16129 certificates. You can list domains here that will not be required to
16130 authenticate using certificates. They will be authenticated using DNS. See
16131 @url{https://prosody.im/doc/s2s#security}.
16132 Defaults to @samp{()}.
16133 @end deftypevr
16134
16135 @deftypevr {@code{prosody-configuration} parameter} string-list s2s-secure-domains
16136 Even if you leave @code{s2s-secure-auth?} disabled, you can still require
16137 valid certificates for some domains by specifying a list here. See
16138 @url{https://prosody.im/doc/s2s#security}.
16139 Defaults to @samp{()}.
16140 @end deftypevr
16141
16142 @deftypevr {@code{prosody-configuration} parameter} string authentication
16143 Select the authentication backend to use. The default provider stores
16144 passwords in plaintext and uses Prosody's configured data storage to store the
16145 authentication data. If you do not trust your server please see
16146 @url{https://prosody.im/doc/modules/mod_auth_internal_hashed} for information
16147 about using the hashed backend. See also
16148 @url{https://prosody.im/doc/authentication}
16149 Defaults to @samp{"internal_plain"}.
16150 @end deftypevr
16151
16152 @deftypevr {@code{prosody-configuration} parameter} maybe-string log
16153 Set logging options. Advanced logging configuration is not yet supported
16154 by the GuixSD Prosody Service. See @url{https://prosody.im/doc/logging}.
16155 Defaults to @samp{"*syslog"}.
16156 @end deftypevr
16157
16158 @deftypevr {@code{prosody-configuration} parameter} file-name pidfile
16159 File to write pid in. See @url{https://prosody.im/doc/modules/mod_posix}.
16160 Defaults to @samp{"/var/run/prosody/prosody.pid"}.
16161 @end deftypevr
16162
16163 @deftypevr {@code{prosody-configuration} parameter} maybe-non-negative-integer http-max-content-size
16164 Maximum allowed size of the HTTP body (in bytes).
16165 @end deftypevr
16166
16167 @deftypevr {@code{prosody-configuration} parameter} maybe-string http-external-url
16168 Some modules expose their own URL in various ways. This URL is built
16169 from the protocol, host and port used. If Prosody sits behind a proxy, the
16170 public URL will be @code{http-external-url} instead. See
16171 @url{https://prosody.im/doc/http#external_url}.
16172 @end deftypevr
16173
16174 @deftypevr {@code{prosody-configuration} parameter} virtualhost-configuration-list virtualhosts
16175 A host in Prosody is a domain on which user accounts can be created. For
16176 example if you want your users to have addresses like
16177 @samp{"john.smith@@example.com"} then you need to add a host
16178 @samp{"example.com"}. All options in this list will apply only to this host.
16179
16180 Note: the name "virtual" host is used in configuration to avoid confusion with
16181 the actual physical host that Prosody is installed on. A single Prosody
16182 instance can serve many domains, each one defined as a VirtualHost entry in
16183 Prosody's configuration. Conversely a server that hosts a single domain would
16184 have just one VirtualHost entry.
16185
16186 See @url{https://prosody.im/doc/configure#virtual_host_settings}.
16187
16188 Available @code{virtualhost-configuration} fields are:
16189
16190 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:
16191 @deftypevr {@code{virtualhost-configuration} parameter} string domain
16192 Domain you wish Prosody to serve.
16193 @end deftypevr
16194
16195 @end deftypevr
16196
16197 @deftypevr {@code{prosody-configuration} parameter} int-component-configuration-list int-components
16198 Components are extra services on a server which are available to clients,
16199 usually on a subdomain of the main server (such as
16200 @samp{"mycomponent.example.com"}). Example components might be chatroom
16201 servers, user directories, or gateways to other protocols.
16202
16203 Internal components are implemented with Prosody-specific plugins. To add an
16204 internal component, you simply fill the hostname field, and the plugin you wish
16205 to use for the component.
16206
16207 See @url{https://prosody.im/doc/components}.
16208 Defaults to @samp{()}.
16209
16210 Available @code{int-component-configuration} fields are:
16211
16212 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:
16213 @deftypevr {@code{int-component-configuration} parameter} string hostname
16214 Hostname of the component.
16215 @end deftypevr
16216
16217 @deftypevr {@code{int-component-configuration} parameter} string plugin
16218 Plugin you wish to use for the component.
16219 @end deftypevr
16220
16221 @deftypevr {@code{int-component-configuration} parameter} maybe-mod-muc-configuration mod-muc
16222 Multi-user chat (MUC) is Prosody's module for allowing you to create
16223 hosted chatrooms/conferences for XMPP users.
16224
16225 General information on setting up and using multi-user chatrooms can be found
16226 in the "Chatrooms" documentation (@url{https://prosody.im/doc/chatrooms}),
16227 which you should read if you are new to XMPP chatrooms.
16228
16229 See also @url{https://prosody.im/doc/modules/mod_muc}.
16230
16231 Available @code{mod-muc-configuration} fields are:
16232
16233 @deftypevr {@code{mod-muc-configuration} parameter} string name
16234 The name to return in service discovery responses.
16235 Defaults to @samp{"Prosody Chatrooms"}.
16236 @end deftypevr
16237
16238 @deftypevr {@code{mod-muc-configuration} parameter} string-or-boolean restrict-room-creation
16239 If @samp{#t}, this will only allow admins to create new chatrooms.
16240 Otherwise anyone can create a room. The value @samp{"local"} restricts room
16241 creation to users on the service's parent domain. E.g.@: @samp{user@@example.com}
16242 can create rooms on @samp{rooms.example.com}. The value @samp{"admin"}
16243 restricts to service administrators only.
16244 Defaults to @samp{#f}.
16245 @end deftypevr
16246
16247 @deftypevr {@code{mod-muc-configuration} parameter} non-negative-integer max-history-messages
16248 Maximum number of history messages that will be sent to the member that has
16249 just joined the room.
16250 Defaults to @samp{20}.
16251 @end deftypevr
16252
16253 @end deftypevr
16254
16255 @end deftypevr
16256
16257 @deftypevr {@code{prosody-configuration} parameter} ext-component-configuration-list ext-components
16258 External components use XEP-0114, which most standalone components
16259 support. To add an external component, you simply fill the hostname field. See
16260 @url{https://prosody.im/doc/components}.
16261 Defaults to @samp{()}.
16262
16263 Available @code{ext-component-configuration} fields are:
16264
16265 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:
16266 @deftypevr {@code{ext-component-configuration} parameter} string component-secret
16267 Password which the component will use to log in.
16268 @end deftypevr
16269
16270 @deftypevr {@code{ext-component-configuration} parameter} string hostname
16271 Hostname of the component.
16272 @end deftypevr
16273
16274 @end deftypevr
16275
16276 @deftypevr {@code{prosody-configuration} parameter} non-negative-integer-list component-ports
16277 Port(s) Prosody listens on for component connections.
16278 Defaults to @samp{(5347)}.
16279 @end deftypevr
16280
16281 @deftypevr {@code{prosody-configuration} parameter} string component-interface
16282 Interface Prosody listens on for component connections.
16283 Defaults to @samp{"127.0.0.1"}.
16284 @end deftypevr
16285
16286 @deftypevr {@code{prosody-configuration} parameter} maybe-raw-content raw-content
16287 Raw content that will be added to the configuration file.
16288 @end deftypevr
16289
16290 It could be that you just want to get a @code{prosody.cfg.lua}
16291 up and running. In that case, you can pass an
16292 @code{opaque-prosody-configuration} record as the value of
16293 @code{prosody-service-type}. As its name indicates, an opaque configuration
16294 does not have easy reflective capabilities.
16295 Available @code{opaque-prosody-configuration} fields are:
16296
16297 @deftypevr {@code{opaque-prosody-configuration} parameter} package prosody
16298 The prosody package.
16299 @end deftypevr
16300
16301 @deftypevr {@code{opaque-prosody-configuration} parameter} string prosody.cfg.lua
16302 The contents of the @code{prosody.cfg.lua} to use.
16303 @end deftypevr
16304
16305 For example, if your @code{prosody.cfg.lua} is just the empty
16306 string, you could instantiate a prosody service like this:
16307
16308 @example
16309 (service prosody-service-type
16310 (opaque-prosody-configuration
16311 (prosody.cfg.lua "")))
16312 @end example
16313
16314 @c end of Prosody auto-generated documentation
16315
16316 @subsubheading BitlBee Service
16317
16318 @cindex IRC (Internet Relay Chat)
16319 @cindex IRC gateway
16320 @url{http://bitlbee.org,BitlBee} is a gateway that provides an IRC
16321 interface to a variety of messaging protocols such as XMPP.
16322
16323 @defvr {Scheme Variable} bitlbee-service-type
16324 This is the service type for the @url{http://bitlbee.org,BitlBee} IRC
16325 gateway daemon. Its value is a @code{bitlbee-configuration} (see
16326 below).
16327
16328 To have BitlBee listen on port 6667 on localhost, add this line to your
16329 services:
16330
16331 @example
16332 (service bitlbee-service-type)
16333 @end example
16334 @end defvr
16335
16336 @deftp {Data Type} bitlbee-configuration
16337 This is the configuration for BitlBee, with the following fields:
16338
16339 @table @asis
16340 @item @code{interface} (default: @code{"127.0.0.1"})
16341 @itemx @code{port} (default: @code{6667})
16342 Listen on the network interface corresponding to the IP address
16343 specified in @var{interface}, on @var{port}.
16344
16345 When @var{interface} is @code{127.0.0.1}, only local clients can
16346 connect; when it is @code{0.0.0.0}, connections can come from any
16347 networking interface.
16348
16349 @item @code{package} (default: @code{bitlbee})
16350 The BitlBee package to use.
16351
16352 @item @code{plugins} (default: @code{'()})
16353 List of plugin packages to use---e.g., @code{bitlbee-discord}.
16354
16355 @item @code{extra-settings} (default: @code{""})
16356 Configuration snippet added as-is to the BitlBee configuration file.
16357 @end table
16358 @end deftp
16359
16360 @subsubheading Quassel Service
16361
16362 @cindex IRC (Internet Relay Chat)
16363 @url{https://quassel-irc.org/,Quassel} is a distributed IRC client,
16364 meaning that one or more clients can attach to and detach from the
16365 central core.
16366
16367 @defvr {Scheme Variable} quassel-service-type
16368 This is the service type for the @url{https://quassel-irc.org/,Quassel}
16369 IRC backend daemon. Its value is a @code{quassel-configuration}
16370 (see below).
16371 @end defvr
16372
16373 @deftp {Data Type} quassel-configuration
16374 This is the configuration for Quassel, with the following fields:
16375
16376 @table @asis
16377 @item @code{quassel} (default: @code{quassel})
16378 The Quassel package to use.
16379
16380 @item @code{interface} (default: @code{"::,0.0.0.0"})
16381 @item @code{port} (default: @code{4242})
16382 Listen on the network interface(s) corresponding to the IPv4 or IPv6
16383 interfaces specified in the comma delimited @var{interface}, on
16384 @var{port}.
16385
16386 @item @code{loglevel} (default: @code{"Info"})
16387 The level of logging desired. Accepted values are Debug, Info, Warning
16388 and Error.
16389 @end table
16390 @end deftp
16391
16392 @node Telephony Services
16393 @subsection Telephony Services
16394
16395 @cindex Murmur (VoIP server)
16396 @cindex VoIP server
16397 This section describes how to set up and run a Murmur server. Murmur is
16398 the server of the @uref{https://mumble.info, Mumble} voice-over-IP
16399 (VoIP) suite.
16400
16401 @deftp {Data Type} murmur-configuration
16402 The service type for the Murmur server. An example configuration can
16403 look like this:
16404
16405 @example
16406 (service murmur-service-type
16407 (murmur-configuration
16408 (welcome-text
16409 "Welcome to this Mumble server running on GuixSD!")
16410 (cert-required? #t) ;disallow text password logins
16411 (ssl-cert "/etc/letsencrypt/live/mumble.example.com/fullchain.pem")
16412 (ssl-key "/etc/letsencrypt/live/mumble.example.com/privkey.pem")))
16413 @end example
16414
16415 After reconfiguring your system, you can manually set the murmur @code{SuperUser}
16416 password with the command that is printed during the activation phase.
16417
16418 It is recommended to register a normal Mumble user account
16419 and grant it admin or moderator rights.
16420 You can use the @code{mumble} client to
16421 login as new normal user, register yourself, and log out.
16422 For the next step login with the name @code{SuperUser} use
16423 the @code{SuperUser} password that you set previously,
16424 and grant your newly registered mumble user administrator or moderator
16425 rights and create some channels.
16426
16427 Available @code{murmur-configuration} fields are:
16428
16429 @table @asis
16430 @item @code{package} (default: @code{mumble})
16431 Package that contains @code{bin/murmurd}.
16432
16433 @item @code{user} (default: @code{"murmur"})
16434 User who will run the Murmur server.
16435
16436 @item @code{group} (default: @code{"murmur"})
16437 Group of the user who will run the murmur server.
16438
16439 @item @code{port} (default: @code{64738})
16440 Port on which the server will listen.
16441
16442 @item @code{welcome-text} (default: @code{""})
16443 Welcome text sent to clients when they connect.
16444
16445 @item @code{server-password} (default: @code{""})
16446 Password the clients have to enter in order to connect.
16447
16448 @item @code{max-users} (default: @code{100})
16449 Maximum of users that can be connected to the server at once.
16450
16451 @item @code{max-user-bandwidth} (default: @code{#f})
16452 Maximum voice traffic a user can send per second.
16453
16454 @item @code{database-file} (default: @code{"/var/lib/murmur/db.sqlite"})
16455 File name of the sqlite database.
16456 The service's user will become the owner of the directory.
16457
16458 @item @code{log-file} (default: @code{"/var/log/murmur/murmur.log"})
16459 File name of the log file.
16460 The service's user will become the owner of the directory.
16461
16462 @item @code{autoban-attempts} (default: @code{10})
16463 Maximum number of logins a user can make in @code{autoban-timeframe}
16464 without getting auto banned for @code{autoban-time}.
16465
16466 @item @code{autoban-timeframe} (default: @code{120})
16467 Timeframe for autoban in seconds.
16468
16469 @item @code{autoban-time} (default: @code{300})
16470 Amount of time in seconds for which a client gets banned
16471 when violating the autoban limits.
16472
16473 @item @code{opus-threshold} (default: @code{100})
16474 Percentage of clients that need to support opus
16475 before switching over to opus audio codec.
16476
16477 @item @code{channel-nesting-limit} (default: @code{10})
16478 How deep channels can be nested at maximum.
16479
16480 @item @code{channelname-regex} (default: @code{#f})
16481 A string in form of a Qt regular expression that channel names must conform to.
16482
16483 @item @code{username-regex} (default: @code{#f})
16484 A string in form of a Qt regular expression that user names must conform to.
16485
16486 @item @code{text-message-length} (default: @code{5000})
16487 Maximum size in bytes that a user can send in one text chat message.
16488
16489 @item @code{image-message-length} (default: @code{(* 128 1024)})
16490 Maximum size in bytes that a user can send in one image message.
16491
16492 @item @code{cert-required?} (default: @code{#f})
16493 If it is set to @code{#t} clients that use weak password authentification
16494 will not be accepted. Users must have completed the certificate wizard to join.
16495
16496 @item @code{remember-channel?} (default: @code{#f})
16497 Should murmur remember the last channel each user was in when they disconnected
16498 and put them into the remembered channel when they rejoin.
16499
16500 @item @code{allow-html?} (default: @code{#f})
16501 Should html be allowed in text messages, user comments, and channel descriptions.
16502
16503 @item @code{allow-ping?} (default: @code{#f})
16504 Setting to true exposes the current user count, the maximum user count, and
16505 the server's maximum bandwidth per client to unauthenticated users. In the
16506 Mumble client, this information is shown in the Connect dialog.
16507
16508 Disabling this setting will prevent public listing of the server.
16509
16510 @item @code{bonjour?} (default: @code{#f})
16511 Should the server advertise itself in the local network through the bonjour protocol.
16512
16513 @item @code{send-version?} (default: @code{#f})
16514 Should the murmur server version be exposed in ping requests.
16515
16516 @item @code{log-days} (default: @code{31})
16517 Murmur also stores logs in the database, which are accessible via RPC.
16518 The default is 31 days of months, but you can set this setting to 0 to keep logs forever,
16519 or -1 to disable logging to the database.
16520
16521 @item @code{obfuscate-ips?} (default: @code{#t})
16522 Should logged ips be obfuscated to protect the privacy of users.
16523
16524 @item @code{ssl-cert} (default: @code{#f})
16525 File name of the SSL/TLS certificate used for encrypted connections.
16526
16527 @example
16528 (ssl-cert "/etc/letsencrypt/live/example.com/fullchain.pem")
16529 @end example
16530 @item @code{ssl-key} (default: @code{#f})
16531 Filepath to the ssl private key used for encrypted connections.
16532 @example
16533 (ssl-key "/etc/letsencrypt/live/example.com/privkey.pem")
16534 @end example
16535
16536 @item @code{ssl-dh-params} (default: @code{#f})
16537 File name of a PEM-encoded file with Diffie-Hellman parameters
16538 for the SSL/TLS encryption. Alternatively you set it to
16539 @code{"@@ffdhe2048"}, @code{"@@ffdhe3072"}, @code{"@@ffdhe4096"}, @code{"@@ffdhe6144"}
16540 or @code{"@@ffdhe8192"} to use bundled parameters from RFC 7919.
16541
16542 @item @code{ssl-ciphers} (default: @code{#f})
16543 The @code{ssl-ciphers} option chooses the cipher suites to make available for use
16544 in SSL/TLS.
16545
16546 This option is specified using
16547 @uref{https://www.openssl.org/docs/apps/ciphers.html#CIPHER-LIST-FORMAT,
16548 OpenSSL cipher list notation}.
16549
16550 It is recommended that you try your cipher string using 'openssl ciphers <string>'
16551 before setting it here, to get a feel for which cipher suites you will get.
16552 After setting this option, it is recommend that you inspect your Murmur log
16553 to ensure that Murmur is using the cipher suites that you expected it to.
16554
16555 Note: Changing this option may impact the backwards compatibility of your
16556 Murmur server, and can remove the ability for older Mumble clients to be able
16557 to connect to it.
16558
16559 @item @code{public-registration} (default: @code{#f})
16560 Must be a @code{<murmur-public-registration-configuration>} record or @code{#f}.
16561
16562 You can optionally register your server in the public server list that the
16563 @code{mumble} client shows on startup.
16564 You cannot register your server if you have set a @code{server-password},
16565 or set @code{allow-ping} to @code{#f}.
16566
16567 It might take a few hours until it shows up in the public list.
16568
16569 @item @code{file} (default: @code{#f})
16570 Optional alternative override for this configuration.
16571 @end table
16572 @end deftp
16573
16574 @deftp {Data Type} murmur-public-registration-configuration
16575 Configuration for public registration of a murmur service.
16576
16577 @table @asis
16578 @item @code{name}
16579 This is a display name for your server. Not to be confused with the hostname.
16580
16581 @item @code{password}
16582 A password to identify your registration.
16583 Subsequent updates will need the same password. Don't lose your password.
16584
16585 @item @code{url}
16586 This should be a @code{http://} or @code{https://} link to your web
16587 site.
16588
16589 @item @code{hostname} (default: @code{#f})
16590 By default your server will be listed by its IP address.
16591 If it is set your server will be linked by this host name instead.
16592 @end table
16593 @end deftp
16594
16595
16596
16597 @node Monitoring Services
16598 @subsection Monitoring Services
16599
16600 @subsubheading Tailon Service
16601
16602 @uref{https://tailon.readthedocs.io/, Tailon} is a web application for
16603 viewing and searching log files.
16604
16605 The following example will configure the service with default values.
16606 By default, Tailon can be accessed on port 8080 (@code{http://localhost:8080}).
16607
16608 @example
16609 (service tailon-service-type)
16610 @end example
16611
16612 The following example customises more of the Tailon configuration,
16613 adding @command{sed} to the list of allowed commands.
16614
16615 @example
16616 (service tailon-service-type
16617 (tailon-configuration
16618 (config-file
16619 (tailon-configuration-file
16620 (allowed-commands '("tail" "grep" "awk" "sed"))))))
16621 @end example
16622
16623
16624 @deftp {Data Type} tailon-configuration
16625 Data type representing the configuration of Tailon.
16626 This type has the following parameters:
16627
16628 @table @asis
16629 @item @code{config-file} (default: @code{(tailon-configuration-file)})
16630 The configuration file to use for Tailon. This can be set to a
16631 @dfn{tailon-configuration-file} record value, or any gexp
16632 (@pxref{G-Expressions}).
16633
16634 For example, to instead use a local file, the @code{local-file} function
16635 can be used:
16636
16637 @example
16638 (service tailon-service-type
16639 (tailon-configuration
16640 (config-file (local-file "./my-tailon.conf"))))
16641 @end example
16642
16643 @item @code{package} (default: @code{tailon})
16644 The tailon package to use.
16645
16646 @end table
16647 @end deftp
16648
16649 @deftp {Data Type} tailon-configuration-file
16650 Data type representing the configuration options for Tailon.
16651 This type has the following parameters:
16652
16653 @table @asis
16654 @item @code{files} (default: @code{(list "/var/log")})
16655 List of files to display. The list can include strings for a single file
16656 or directory, or a list, where the first item is the name of a
16657 subsection, and the remaining items are the files or directories in that
16658 subsection.
16659
16660 @item @code{bind} (default: @code{"localhost:8080"})
16661 Address and port to which Tailon should bind on.
16662
16663 @item @code{relative-root} (default: @code{#f})
16664 URL path to use for Tailon, set to @code{#f} to not use a path.
16665
16666 @item @code{allow-transfers?} (default: @code{#t})
16667 Allow downloading the log files in the web interface.
16668
16669 @item @code{follow-names?} (default: @code{#t})
16670 Allow tailing of not-yet existent files.
16671
16672 @item @code{tail-lines} (default: @code{200})
16673 Number of lines to read initially from each file.
16674
16675 @item @code{allowed-commands} (default: @code{(list "tail" "grep" "awk")})
16676 Commands to allow running. By default, @code{sed} is disabled.
16677
16678 @item @code{debug?} (default: @code{#f})
16679 Set @code{debug?} to @code{#t} to show debug messages.
16680
16681 @item @code{wrap-lines} (default: @code{#t})
16682 Initial line wrapping state in the web interface. Set to @code{#t} to
16683 initially wrap lines (the default), or to @code{#f} to initially not
16684 wrap lines.
16685
16686 @item @code{http-auth} (default: @code{#f})
16687 HTTP authentication type to use. Set to @code{#f} to disable
16688 authentication (the default). Supported values are @code{"digest"} or
16689 @code{"basic"}.
16690
16691 @item @code{users} (default: @code{#f})
16692 If HTTP authentication is enabled (see @code{http-auth}), access will be
16693 restricted to the credentials provided here. To configure users, use a
16694 list of pairs, where the first element of the pair is the username, and
16695 the 2nd element of the pair is the password.
16696
16697 @example
16698 (tailon-configuration-file
16699 (http-auth "basic")
16700 (users '(("user1" . "password1")
16701 ("user2" . "password2"))))
16702 @end example
16703
16704 @end table
16705 @end deftp
16706
16707
16708 @subsubheading Darkstat Service
16709 @cindex darkstat
16710 Darkstat is a packet sniffer that captures network traffic, calculates
16711 statistics about usage, and serves reports over HTTP.
16712
16713 @defvar {Scheme Variable} darkstat-service-type
16714 This is the service type for the
16715 @uref{https://unix4lyfe.org/darkstat/, darkstat}
16716 service, its value must be a @code{darkstat-configuration} record as in
16717 this example:
16718
16719 @example
16720 (service darkstat-service-type
16721 (darkstat-configuration
16722 (interface "eno1")))
16723 @end example
16724 @end defvar
16725
16726 @deftp {Data Type} darkstat-configuration
16727 Data type representing the configuration of @command{darkstat}.
16728
16729 @table @asis
16730 @item @code{package} (default: @code{darkstat})
16731 The darkstat package to use.
16732
16733 @item @code{interface}
16734 Capture traffic on the specified network interface.
16735
16736 @item @code{port} (default: @code{"667"})
16737 Bind the web interface to the specified port.
16738
16739 @item @code{bind-address} (default: @code{"127.0.0.1"})
16740 Bind the web interface to the specified address.
16741
16742 @item @code{base} (default: @code{"/"})
16743 Specify the path of the base URL. This can be useful if
16744 @command{darkstat} is accessed via a reverse proxy.
16745
16746 @end table
16747 @end deftp
16748
16749 @subsubheading Prometheus Node Exporter Service
16750
16751 @cindex prometheus-node-exporter
16752 The Prometheus ``node exporter'' makes hardware and operating system statistics
16753 provided by the Linux kernel available for the Prometheus monitoring system.
16754 This service should be deployed on all physical nodes and virtual machines,
16755 where monitoring these statistics is desirable.
16756
16757 @defvar {Scheme variable} prometheus-node-exporter-service-type
16758 This is the service type for the
16759 @uref{https://github.com/prometheus/node_exporter/, prometheus-node-exporter}
16760 service, its value must be a @code{prometheus-node-exporter-configuration}
16761 record as in this example:
16762
16763 @example
16764 (service prometheus-node-exporter-service-type
16765 (prometheus-node-exporter-configuration
16766 (web-listen-address ":9100")))
16767 @end example
16768 @end defvar
16769
16770 @deftp {Data Type} prometheus-node-exporter-configuration
16771 Data type representing the configuration of @command{node_exporter}.
16772
16773 @table @asis
16774 @item @code{package} (default: @code{go-github-com-prometheus-node-exporter})
16775 The prometheus-node-exporter package to use.
16776
16777 @item @code{web-listen-address} (default: @code{":9100"})
16778 Bind the web interface to the specified address.
16779
16780 @end table
16781 @end deftp
16782
16783 @subsubheading Zabbix server
16784 @cindex zabbix zabbix-server
16785 Zabbix provides monitoring metrics, among others network utilization, CPU load
16786 and disk space consumption:
16787
16788 @itemize
16789 @item High performance, high capacity (able to monitor hundreds of thousands of devices).
16790 @item Auto-discovery of servers and network devices and interfaces.
16791 @item Low-level discovery, allows to automatically start monitoring new items, file systems or network interfaces among others.
16792 @item Distributed monitoring with centralized web administration.
16793 @item Native high performance agents.
16794 @item SLA, and ITIL KPI metrics on reporting.
16795 @item High-level (business) view of monitored resources through user-defined visual console screens and dashboards.
16796 @item Remote command execution through Zabbix proxies.
16797 @end itemize
16798
16799 @c %start of fragment
16800
16801 Available @code{zabbix-server-configuration} fields are:
16802
16803 @deftypevr {@code{zabbix-server-configuration} parameter} package zabbix-server
16804 The zabbix-server package.
16805
16806 @end deftypevr
16807
16808 @deftypevr {@code{zabbix-server-configuration} parameter} string user
16809 User who will run the Zabbix server.
16810
16811 Defaults to @samp{"zabbix"}.
16812
16813 @end deftypevr
16814
16815 @deftypevr {@code{zabbix-server-configuration} parameter} group group
16816 Group who will run the Zabbix server.
16817
16818 Defaults to @samp{"zabbix"}.
16819
16820 @end deftypevr
16821
16822 @deftypevr {@code{zabbix-server-configuration} parameter} string db-host
16823 Database host name.
16824
16825 Defaults to @samp{"127.0.0.1"}.
16826
16827 @end deftypevr
16828
16829 @deftypevr {@code{zabbix-server-configuration} parameter} string db-name
16830 Database name.
16831
16832 Defaults to @samp{"zabbix"}.
16833
16834 @end deftypevr
16835
16836 @deftypevr {@code{zabbix-server-configuration} parameter} string db-user
16837 Database user.
16838
16839 Defaults to @samp{"zabbix"}.
16840
16841 @end deftypevr
16842
16843 @deftypevr {@code{zabbix-server-configuration} parameter} string db-password
16844 Database password. Please, use @code{include-files} with
16845 @code{DBPassword=SECRET} inside a specified file instead.
16846
16847 Defaults to @samp{""}.
16848
16849 @end deftypevr
16850
16851 @deftypevr {@code{zabbix-server-configuration} parameter} number db-port
16852 Database port.
16853
16854 Defaults to @samp{5432}.
16855
16856 @end deftypevr
16857
16858 @deftypevr {@code{zabbix-server-configuration} parameter} string log-type
16859 Specifies where log messages are written to:
16860
16861 @itemize @bullet
16862 @item
16863 @code{system} - syslog.
16864
16865 @item
16866 @code{file} - file specified with @code{log-file} parameter.
16867
16868 @item
16869 @code{console} - standard output.
16870
16871 @end itemize
16872
16873 Defaults to @samp{""}.
16874
16875 @end deftypevr
16876
16877 @deftypevr {@code{zabbix-server-configuration} parameter} string log-file
16878 Log file name for @code{log-type} @code{file} parameter.
16879
16880 Defaults to @samp{"/var/log/zabbix/server.log"}.
16881
16882 @end deftypevr
16883
16884 @deftypevr {@code{zabbix-server-configuration} parameter} string pid-file
16885 Name of PID file.
16886
16887 Defaults to @samp{"/var/run/zabbix/zabbix_server.pid"}.
16888
16889 @end deftypevr
16890
16891 @deftypevr {@code{zabbix-server-configuration} parameter} string ssl-ca-location
16892 The location of certificate authority (CA) files for SSL server
16893 certificate verification.
16894
16895 Defaults to @samp{"/etc/ssl/certs/ca-certificates.crt"}.
16896
16897 @end deftypevr
16898
16899 @deftypevr {@code{zabbix-server-configuration} parameter} string ssl-cert-location
16900 Location of SSL client certificates.
16901
16902 Defaults to @samp{"/etc/ssl/certs"}.
16903
16904 @end deftypevr
16905
16906 @deftypevr {@code{zabbix-server-configuration} parameter} string extra-options
16907 Extra options will be appended to Zabbix server configuration file.
16908
16909 Defaults to @samp{""}.
16910
16911 @end deftypevr
16912
16913 @deftypevr {@code{zabbix-server-configuration} parameter} include-files include-files
16914 You may include individual files or all files in a directory in the
16915 configuration file.
16916
16917 Defaults to @samp{()}.
16918
16919 @end deftypevr
16920
16921 @c %end of fragment
16922
16923 @subsubheading Zabbix agent
16924 @cindex zabbix zabbix-agent
16925
16926 Zabbix agent gathers information for Zabbix server.
16927
16928 @c %start of fragment
16929
16930 Available @code{zabbix-agent-configuration} fields are:
16931
16932 @deftypevr {@code{zabbix-agent-configuration} parameter} package zabbix-agent
16933 The zabbix-agent package.
16934
16935 @end deftypevr
16936
16937 @deftypevr {@code{zabbix-agent-configuration} parameter} string user
16938 User who will run the Zabbix agent.
16939
16940 Defaults to @samp{"zabbix"}.
16941
16942 @end deftypevr
16943
16944 @deftypevr {@code{zabbix-agent-configuration} parameter} group group
16945 Group who will run the Zabbix agent.
16946
16947 Defaults to @samp{"zabbix"}.
16948
16949 @end deftypevr
16950
16951 @deftypevr {@code{zabbix-agent-configuration} parameter} string hostname
16952 Unique, case sensitive hostname which is required for active checks and
16953 must match hostname as configured on the server.
16954
16955 Defaults to @samp{"Zabbix server"}.
16956
16957 @end deftypevr
16958
16959 @deftypevr {@code{zabbix-agent-configuration} parameter} string log-type
16960 Specifies where log messages are written to:
16961
16962 @itemize @bullet
16963 @item
16964 @code{system} - syslog.
16965
16966 @item
16967 @code{file} - file specified with @code{log-file} parameter.
16968
16969 @item
16970 @code{console} - standard output.
16971
16972 @end itemize
16973
16974 Defaults to @samp{""}.
16975
16976 @end deftypevr
16977
16978 @deftypevr {@code{zabbix-agent-configuration} parameter} string log-file
16979 Log file name for @code{log-type} @code{file} parameter.
16980
16981 Defaults to @samp{"/var/log/zabbix/agent.log"}.
16982
16983 @end deftypevr
16984
16985 @deftypevr {@code{zabbix-agent-configuration} parameter} string pid-file
16986 Name of PID file.
16987
16988 Defaults to @samp{"/var/run/zabbix/zabbix_agent.pid"}.
16989
16990 @end deftypevr
16991
16992 @deftypevr {@code{zabbix-agent-configuration} parameter} list server
16993 List of IP addresses, optionally in CIDR notation, or hostnames of
16994 Zabbix servers and Zabbix proxies. Incoming connections will be
16995 accepted only from the hosts listed here.
16996
16997 Defaults to @samp{("127.0.0.1")}.
16998
16999 @end deftypevr
17000
17001 @deftypevr {@code{zabbix-agent-configuration} parameter} list server-active
17002 List of IP:port (or hostname:port) pairs of Zabbix servers and Zabbix
17003 proxies for active checks. If port is not specified, default port is
17004 used. If this parameter is not specified, active checks are disabled.
17005
17006 Defaults to @samp{("127.0.0.1")}.
17007
17008 @end deftypevr
17009
17010 @deftypevr {@code{zabbix-agent-configuration} parameter} string extra-options
17011 Extra options will be appended to Zabbix server configuration file.
17012
17013 Defaults to @samp{""}.
17014
17015 @end deftypevr
17016
17017 @deftypevr {@code{zabbix-agent-configuration} parameter} include-files include-files
17018 You may include individual files or all files in a directory in the
17019 configuration file.
17020
17021 Defaults to @samp{()}.
17022
17023 @end deftypevr
17024
17025 @c %end of fragment
17026
17027 @subsubheading Zabbix front-end
17028 @cindex zabbix zabbix-front-end
17029
17030 This service provides a WEB interface to Zabbix server.
17031
17032 @c %start of fragment
17033
17034 Available @code{zabbix-front-end-configuration} fields are:
17035
17036 @deftypevr {@code{zabbix-front-end-configuration} parameter} nginx-server-configuration-list nginx
17037 NGINX configuration.
17038
17039 @end deftypevr
17040
17041 @deftypevr {@code{zabbix-front-end-configuration} parameter} string db-host
17042 Database host name.
17043
17044 Defaults to @samp{"localhost"}.
17045
17046 @end deftypevr
17047
17048 @deftypevr {@code{zabbix-front-end-configuration} parameter} number db-port
17049 Database port.
17050
17051 Defaults to @samp{5432}.
17052
17053 @end deftypevr
17054
17055 @deftypevr {@code{zabbix-front-end-configuration} parameter} string db-name
17056 Database name.
17057
17058 Defaults to @samp{"zabbix"}.
17059
17060 @end deftypevr
17061
17062 @deftypevr {@code{zabbix-front-end-configuration} parameter} string db-user
17063 Database user.
17064
17065 Defaults to @samp{"zabbix"}.
17066
17067 @end deftypevr
17068
17069 @deftypevr {@code{zabbix-front-end-configuration} parameter} string db-password
17070 Database password. Please, use @code{db-secret-file} instead.
17071
17072 Defaults to @samp{""}.
17073
17074 @end deftypevr
17075
17076 @deftypevr {@code{zabbix-front-end-configuration} parameter} string db-secret-file
17077 Secret file which will be appended to @file{zabbix.conf.php} file. This
17078 file contains credentials for use by Zabbix front-end. You are expected
17079 to create it manually.
17080
17081 Defaults to @samp{""}.
17082
17083 @end deftypevr
17084
17085 @deftypevr {@code{zabbix-front-end-configuration} parameter} string zabbix-host
17086 Zabbix server hostname.
17087
17088 Defaults to @samp{"localhost"}.
17089
17090 @end deftypevr
17091
17092 @deftypevr {@code{zabbix-front-end-configuration} parameter} number zabbix-port
17093 Zabbix server port.
17094
17095 Defaults to @samp{10051}.
17096
17097 @end deftypevr
17098
17099
17100 @c %end of fragment
17101
17102 @node Kerberos Services
17103 @subsection Kerberos Services
17104 @cindex Kerberos
17105
17106 The @code{(gnu services kerberos)} module provides services relating to
17107 the authentication protocol @dfn{Kerberos}.
17108
17109 @subsubheading Krb5 Service
17110
17111 Programs using a Kerberos client library normally
17112 expect a configuration file in @file{/etc/krb5.conf}.
17113 This service generates such a file from a definition provided in the
17114 operating system declaration.
17115 It does not cause any daemon to be started.
17116
17117 No ``keytab'' files are provided by this service---you must explicitly create them.
17118 This service is known to work with the MIT client library, @code{mit-krb5}.
17119 Other implementations have not been tested.
17120
17121 @defvr {Scheme Variable} krb5-service-type
17122 A service type for Kerberos 5 clients.
17123 @end defvr
17124
17125 @noindent
17126 Here is an example of its use:
17127 @lisp
17128 (service krb5-service-type
17129 (krb5-configuration
17130 (default-realm "EXAMPLE.COM")
17131 (allow-weak-crypto? #t)
17132 (realms (list
17133 (krb5-realm
17134 (name "EXAMPLE.COM")
17135 (admin-server "groucho.example.com")
17136 (kdc "karl.example.com"))
17137 (krb5-realm
17138 (name "ARGRX.EDU")
17139 (admin-server "kerb-admin.argrx.edu")
17140 (kdc "keys.argrx.edu"))))))
17141 @end lisp
17142
17143 @noindent
17144 This example provides a Kerberos@tie{}5 client configuration which:
17145 @itemize
17146 @item Recognizes two realms, @i{viz:} ``EXAMPLE.COM'' and ``ARGRX.EDU'', both
17147 of which have distinct administration servers and key distribution centers;
17148 @item Will default to the realm ``EXAMPLE.COM'' if the realm is not explicitly
17149 specified by clients;
17150 @item Accepts services which only support encryption types known to be weak.
17151 @end itemize
17152
17153 The @code{krb5-realm} and @code{krb5-configuration} types have many fields.
17154 Only the most commonly used ones are described here.
17155 For a full list, and more detailed explanation of each, see the MIT
17156 @uref{http://web.mit.edu/kerberos/krb5-devel/doc/admin/conf_files/krb5_conf.html,,krb5.conf}
17157 documentation.
17158
17159
17160 @deftp {Data Type} krb5-realm
17161 @cindex realm, kerberos
17162 @table @asis
17163 @item @code{name}
17164 This field is a string identifying the name of the realm.
17165 A common convention is to use the fully qualified DNS name of your organization,
17166 converted to upper case.
17167
17168 @item @code{admin-server}
17169 This field is a string identifying the host where the administration server is
17170 running.
17171
17172 @item @code{kdc}
17173 This field is a string identifying the key distribution center
17174 for the realm.
17175 @end table
17176 @end deftp
17177
17178 @deftp {Data Type} krb5-configuration
17179
17180 @table @asis
17181 @item @code{allow-weak-crypto?} (default: @code{#f})
17182 If this flag is @code{#t} then services which only offer encryption algorithms
17183 known to be weak will be accepted.
17184
17185 @item @code{default-realm} (default: @code{#f})
17186 This field should be a string identifying the default Kerberos
17187 realm for the client.
17188 You should set this field to the name of your Kerberos realm.
17189 If this value is @code{#f}
17190 then a realm must be specified with every Kerberos principal when invoking programs
17191 such as @command{kinit}.
17192
17193 @item @code{realms}
17194 This should be a non-empty list of @code{krb5-realm} objects, which clients may
17195 access.
17196 Normally, one of them will have a @code{name} field matching the @code{default-realm}
17197 field.
17198 @end table
17199 @end deftp
17200
17201
17202 @subsubheading PAM krb5 Service
17203 @cindex pam-krb5
17204
17205 The @code{pam-krb5} service allows for login authentication and password
17206 management via Kerberos.
17207 You will need this service if you want PAM enabled applications to authenticate
17208 users using Kerberos.
17209
17210 @defvr {Scheme Variable} pam-krb5-service-type
17211 A service type for the Kerberos 5 PAM module.
17212 @end defvr
17213
17214 @deftp {Data Type} pam-krb5-configuration
17215 Data type representing the configuration of the Kerberos 5 PAM module
17216 This type has the following parameters:
17217 @table @asis
17218 @item @code{pam-krb5} (default: @code{pam-krb5})
17219 The pam-krb5 package to use.
17220
17221 @item @code{minimum-uid} (default: @code{1000})
17222 The smallest user ID for which Kerberos authentications should be attempted.
17223 Local accounts with lower values will silently fail to authenticate.
17224 @end table
17225 @end deftp
17226
17227
17228 @node Web Services
17229 @subsection Web Services
17230
17231 @cindex web
17232 @cindex www
17233 @cindex HTTP
17234 The @code{(gnu services web)} module provides the Apache HTTP Server,
17235 the nginx web server, and also a fastcgi wrapper daemon.
17236
17237 @subsubheading Apache HTTP Server
17238
17239 @deffn {Scheme Variable} httpd-service-type
17240 Service type for the @uref{https://httpd.apache.org/,Apache HTTP} server
17241 (@dfn{httpd}). The value for this service type is a
17242 @code{httpd-configuration} record.
17243
17244 A simple example configuration is given below.
17245
17246 @example
17247 (service httpd-service-type
17248 (httpd-configuration
17249 (config
17250 (httpd-config-file
17251 (server-name "www.example.com")
17252 (document-root "/srv/http/www.example.com")))))
17253 @end example
17254
17255 Other services can also extend the @code{httpd-service-type} to add to
17256 the configuration.
17257
17258 @example
17259 (simple-service 'my-extra-server httpd-service-type
17260 (list
17261 (httpd-virtualhost
17262 "*:80"
17263 (list (string-append
17264 "ServerName "www.example.com
17265 DocumentRoot \"/srv/http/www.example.com\"")))))
17266 @end example
17267 @end deffn
17268
17269 The details for the @code{httpd-configuration}, @code{httpd-module},
17270 @code{httpd-config-file} and @code{httpd-virtualhost} record types are
17271 given below.
17272
17273 @deffn {Data Type} httpd-configuration
17274 This data type represents the configuration for the httpd service.
17275
17276 @table @asis
17277 @item @code{package} (default: @code{httpd})
17278 The httpd package to use.
17279
17280 @item @code{pid-file} (default: @code{"/var/run/httpd"})
17281 The pid file used by the shepherd-service.
17282
17283 @item @code{config} (default: @code{(httpd-config-file)})
17284 The configuration file to use with the httpd service. The default value
17285 is a @code{httpd-config-file} record, but this can also be a different
17286 G-expression that generates a file, for example a @code{plain-file}. A
17287 file outside of the store can also be specified through a string.
17288
17289 @end table
17290 @end deffn
17291
17292 @deffn {Data Type} httpd-module
17293 This data type represents a module for the httpd service.
17294
17295 @table @asis
17296 @item @code{name}
17297 The name of the module.
17298
17299 @item @code{file}
17300 The file for the module. This can be relative to the httpd package being
17301 used, the absolute location of a file, or a G-expression for a file
17302 within the store, for example @code{(file-append mod-wsgi
17303 "/modules/mod_wsgi.so")}.
17304
17305 @end table
17306 @end deffn
17307
17308 @defvr {Scheme Variable} %default-httpd-modules
17309 A default list of @code{httpd-module} objects.
17310 @end defvr
17311
17312 @deffn {Data Type} httpd-config-file
17313 This data type represents a configuration file for the httpd service.
17314
17315 @table @asis
17316 @item @code{modules} (default: @code{%default-httpd-modules})
17317 The modules to load. Additional modules can be added here, or loaded by
17318 additional configuration.
17319
17320 For example, in order to handle requests for PHP files, you can use Apache’s
17321 @code{mod_proxy_fcgi} module along with @code{php-fpm-service-type}:
17322
17323 @example
17324 (service httpd-service-type
17325 (httpd-configuration
17326 (config
17327 (httpd-config-file
17328 (modules (cons*
17329 (httpd-module
17330 (name "proxy_module")
17331 (file "modules/mod_proxy.so"))
17332 (httpd-module
17333 (name "proxy_fcgi_module")
17334 (file "modules/mod_proxy_fcgi.so"))
17335 %default-httpd-modules))
17336 (extra-config (list "\
17337 <FilesMatch \\.php$>
17338 SetHandler \"proxy:unix:/var/run/php-fpm.sock|fcgi://localhost/\"
17339 </FilesMatch>"))))))
17340 (service php-fpm-service-type
17341 (php-fpm-configuration
17342 (socket "/var/run/php-fpm.sock")
17343 (socket-group "httpd")))
17344 @end example
17345
17346 @item @code{server-root} (default: @code{httpd})
17347 The @code{ServerRoot} in the configuration file, defaults to the httpd
17348 package. Directives including @code{Include} and @code{LoadModule} are
17349 taken as relative to the server root.
17350
17351 @item @code{server-name} (default: @code{#f})
17352 The @code{ServerName} in the configuration file, used to specify the
17353 request scheme, hostname and port that the server uses to identify
17354 itself.
17355
17356 This doesn't need to be set in the server config, and can be specifyed
17357 in virtual hosts. The default is @code{#f} to not specify a
17358 @code{ServerName}.
17359
17360 @item @code{document-root} (default: @code{"/srv/http"})
17361 The @code{DocumentRoot} from which files will be served.
17362
17363 @item @code{listen} (default: @code{'("80")})
17364 The list of values for the @code{Listen} directives in the config
17365 file. The value should be a list of strings, when each string can
17366 specify the port number to listen on, and optionally the IP address and
17367 protocol to use.
17368
17369 @item @code{pid-file} (default: @code{"/var/run/httpd"})
17370 The @code{PidFile} to use. This should match the @code{pid-file} set in
17371 the @code{httpd-configuration} so that the Shepherd service is
17372 configured correctly.
17373
17374 @item @code{error-log} (default: @code{"/var/log/httpd/error_log"})
17375 The @code{ErrorLog} to which the server will log errors.
17376
17377 @item @code{user} (default: @code{"httpd"})
17378 The @code{User} which the server will answer requests as.
17379
17380 @item @code{group} (default: @code{"httpd"})
17381 The @code{Group} which the server will answer requests as.
17382
17383 @item @code{extra-config} (default: @code{(list "TypesConfig etc/httpd/mime.types")})
17384 A flat list of strings and G-expressions which will be added to the end
17385 of the configuration file.
17386
17387 Any values which the service is extended with will be appended to this
17388 list.
17389
17390 @end table
17391 @end deffn
17392
17393 @deffn {Data Type} httpd-virtualhost
17394 This data type represents a virtualhost configuration block for the httpd service.
17395
17396 These should be added to the extra-config for the httpd-service.
17397
17398 @example
17399 (simple-service 'my-extra-server httpd-service-type
17400 (list
17401 (httpd-virtualhost
17402 "*:80"
17403 (list (string-append
17404 "ServerName "www.example.com
17405 DocumentRoot \"/srv/http/www.example.com\"")))))
17406 @end example
17407
17408 @table @asis
17409 @item @code{addresses-and-ports}
17410 The addresses and ports for the @code{VirtualHost} directive.
17411
17412 @item @code{contents}
17413 The contents of the @code{VirtualHost} directive, this should be a list
17414 of strings and G-expressions.
17415
17416 @end table
17417 @end deffn
17418
17419 @subsubheading NGINX
17420
17421 @deffn {Scheme Variable} nginx-service-type
17422 Service type for the @uref{https://nginx.org/,NGinx} web server. The
17423 value for this service type is a @code{<nginx-configuration>} record.
17424
17425 A simple example configuration is given below.
17426
17427 @example
17428 (service nginx-service-type
17429 (nginx-configuration
17430 (server-blocks
17431 (list (nginx-server-configuration
17432 (server-name '("www.example.com"))
17433 (root "/srv/http/www.example.com"))))))
17434 @end example
17435
17436 In addition to adding server blocks to the service configuration
17437 directly, this service can be extended by other services to add server
17438 blocks, as in this example:
17439
17440 @example
17441 (simple-service 'my-extra-server nginx-service-type
17442 (list (nginx-server-configuration
17443 (root "/srv/http/extra-website")
17444 (try-files (list "$uri" "$uri/index.html")))))
17445 @end example
17446 @end deffn
17447
17448 At startup, @command{nginx} has not yet read its configuration file, so
17449 it uses a default file to log error messages. If it fails to load its
17450 configuration file, that is where error messages are logged. After the
17451 configuration file is loaded, the default error log file changes as per
17452 configuration. In our case, startup error messages can be found in
17453 @file{/var/run/nginx/logs/error.log}, and after configuration in
17454 @file{/var/log/nginx/error.log}. The second location can be changed
17455 with the @var{log-directory} configuration option.
17456
17457 @deffn {Data Type} nginx-configuration
17458 This data type represents the configuration for NGinx. Some
17459 configuration can be done through this and the other provided record
17460 types, or alternatively, a config file can be provided.
17461
17462 @table @asis
17463 @item @code{nginx} (default: @code{nginx})
17464 The nginx package to use.
17465
17466 @item @code{log-directory} (default: @code{"/var/log/nginx"})
17467 The directory to which NGinx will write log files.
17468
17469 @item @code{run-directory} (default: @code{"/var/run/nginx"})
17470 The directory in which NGinx will create a pid file, and write temporary
17471 files.
17472
17473 @item @code{server-blocks} (default: @code{'()})
17474 A list of @dfn{server blocks} to create in the generated configuration
17475 file, the elements should be of type
17476 @code{<nginx-server-configuration>}.
17477
17478 The following example would setup NGinx to serve @code{www.example.com}
17479 from the @code{/srv/http/www.example.com} directory, without using
17480 HTTPS.
17481 @example
17482 (service nginx-service-type
17483 (nginx-configuration
17484 (server-blocks
17485 (list (nginx-server-configuration
17486 (server-name '("www.example.com"))
17487 (root "/srv/http/www.example.com"))))))
17488 @end example
17489
17490 @item @code{upstream-blocks} (default: @code{'()})
17491 A list of @dfn{upstream blocks} to create in the generated configuration
17492 file, the elements should be of type
17493 @code{<nginx-upstream-configuration>}.
17494
17495 Configuring upstreams through the @code{upstream-blocks} can be useful
17496 when combined with @code{locations} in the
17497 @code{<nginx-server-configuration>} records. The following example
17498 creates a server configuration with one location configuration, that
17499 will proxy requests to a upstream configuration, which will handle
17500 requests with two servers.
17501
17502 @example
17503 (service
17504 nginx-service-type
17505 (nginx-configuration
17506 (server-blocks
17507 (list (nginx-server-configuration
17508 (server-name '("www.example.com"))
17509 (root "/srv/http/www.example.com")
17510 (locations
17511 (list
17512 (nginx-location-configuration
17513 (uri "/path1")
17514 (body '("proxy_pass http://server-proxy;"))))))))
17515 (upstream-blocks
17516 (list (nginx-upstream-configuration
17517 (name "server-proxy")
17518 (servers (list "server1.example.com"
17519 "server2.example.com")))))))
17520 @end example
17521
17522 @item @code{file} (default: @code{#f})
17523 If a configuration @var{file} is provided, this will be used, rather than
17524 generating a configuration file from the provided @code{log-directory},
17525 @code{run-directory}, @code{server-blocks} and @code{upstream-blocks}. For
17526 proper operation, these arguments should match what is in @var{file} to ensure
17527 that the directories are created when the service is activated.
17528
17529 This can be useful if you have an existing configuration file, or it's
17530 not possible to do what is required through the other parts of the
17531 nginx-configuration record.
17532
17533 @item @code{server-names-hash-bucket-size} (default: @code{#f})
17534 Bucket size for the server names hash tables, defaults to @code{#f} to
17535 use the size of the processors cache line.
17536
17537 @item @code{server-names-hash-bucket-max-size} (default: @code{#f})
17538 Maximum bucket size for the server names hash tables.
17539
17540 @item @code{extra-content} (default: @code{""})
17541 Extra content for the @code{http} block. Should be string or a string
17542 valued G-expression.
17543
17544 @end table
17545 @end deffn
17546
17547 @deftp {Data Type} nginx-server-configuration
17548 Data type representing the configuration of an nginx server block.
17549 This type has the following parameters:
17550
17551 @table @asis
17552 @item @code{listen} (default: @code{'("80" "443 ssl")})
17553 Each @code{listen} directive sets the address and port for IP, or the
17554 path for a UNIX-domain socket on which the server will accept requests.
17555 Both address and port, or only address or only port can be specified.
17556 An address may also be a hostname, for example:
17557
17558 @example
17559 '("127.0.0.1:8000" "127.0.0.1" "8000" "*:8000" "localhost:8000")
17560 @end example
17561
17562 @item @code{server-name} (default: @code{(list 'default)})
17563 A list of server names this server represents. @code{'default} represents the
17564 default server for connections matching no other server.
17565
17566 @item @code{root} (default: @code{"/srv/http"})
17567 Root of the website nginx will serve.
17568
17569 @item @code{locations} (default: @code{'()})
17570 A list of @dfn{nginx-location-configuration} or
17571 @dfn{nginx-named-location-configuration} records to use within this
17572 server block.
17573
17574 @item @code{index} (default: @code{(list "index.html")})
17575 Index files to look for when clients ask for a directory. If it cannot be found,
17576 Nginx will send the list of files in the directory.
17577
17578 @item @code{try-files} (default: @code{'()})
17579 A list of files whose existence is checked in the specified order.
17580 @code{nginx} will use the first file it finds to process the request.
17581
17582 @item @code{ssl-certificate} (default: @code{#f})
17583 Where to find the certificate for secure connections. Set it to @code{#f} if
17584 you don't have a certificate or you don't want to use HTTPS.
17585
17586 @item @code{ssl-certificate-key} (default: @code{#f})
17587 Where to find the private key for secure connections. Set it to @code{#f} if
17588 you don't have a key or you don't want to use HTTPS.
17589
17590 @item @code{server-tokens?} (default: @code{#f})
17591 Whether the server should add its configuration to response.
17592
17593 @item @code{raw-content} (default: @code{'()})
17594 A list of raw lines added to the server block.
17595
17596 @end table
17597 @end deftp
17598
17599 @deftp {Data Type} nginx-upstream-configuration
17600 Data type representing the configuration of an nginx @code{upstream}
17601 block. This type has the following parameters:
17602
17603 @table @asis
17604 @item @code{name}
17605 Name for this group of servers.
17606
17607 @item @code{servers}
17608 Specify the addresses of the servers in the group. The address can be
17609 specified as a IP address (e.g.@: @samp{127.0.0.1}), domain name
17610 (e.g.@: @samp{backend1.example.com}) or a path to a UNIX socket using the
17611 prefix @samp{unix:}. For addresses using an IP address or domain name,
17612 the default port is 80, and a different port can be specified
17613 explicitly.
17614
17615 @end table
17616 @end deftp
17617
17618 @deftp {Data Type} nginx-location-configuration
17619 Data type representing the configuration of an nginx @code{location}
17620 block. This type has the following parameters:
17621
17622 @table @asis
17623 @item @code{uri}
17624 URI which this location block matches.
17625
17626 @anchor{nginx-location-configuration body}
17627 @item @code{body}
17628 Body of the location block, specified as a list of strings. This can contain
17629 many
17630 configuration directives. For example, to pass requests to a upstream
17631 server group defined using an @code{nginx-upstream-configuration} block,
17632 the following directive would be specified in the body @samp{(list "proxy_pass
17633 http://upstream-name;")}.
17634
17635 @end table
17636 @end deftp
17637
17638 @deftp {Data Type} nginx-named-location-configuration
17639 Data type representing the configuration of an nginx named location
17640 block. Named location blocks are used for request redirection, and not
17641 used for regular request processing. This type has the following
17642 parameters:
17643
17644 @table @asis
17645 @item @code{name}
17646 Name to identify this location block.
17647
17648 @item @code{body}
17649 @xref{nginx-location-configuration body}, as the body for named location
17650 blocks can be used in a similar way to the
17651 @code{nginx-location-configuration body}. One restriction is that the
17652 body of a named location block cannot contain location blocks.
17653
17654 @end table
17655 @end deftp
17656
17657 @subsubheading Varnish Cache
17658 @cindex Varnish
17659 Varnish is a fast cache server that sits in between web applications
17660 and end users. It proxies requests from clients and caches the
17661 accessed URLs such that multiple requests for the same resource only
17662 creates one request to the back-end.
17663
17664 @defvr {Scheme Variable} varnish-service-type
17665 Service type for the Varnish daemon.
17666 @end defvr
17667
17668 @deftp {Data Type} varnish-configuration
17669 Data type representing the @code{varnish} service configuration.
17670 This type has the following parameters:
17671
17672 @table @asis
17673 @item @code{package} (default: @code{varnish})
17674 The Varnish package to use.
17675
17676 @item @code{name} (default: @code{"default"})
17677 A name for this Varnish instance. Varnish will create a directory in
17678 @file{/var/varnish/} with this name and keep temporary files there. If
17679 the name starts with a forward slash, it is interpreted as an absolute
17680 directory name.
17681
17682 Pass the @code{-n} argument to other Varnish programs to connect to the
17683 named instance, e.g.@: @command{varnishncsa -n default}.
17684
17685 @item @code{backend} (default: @code{"localhost:8080"})
17686 The backend to use. This option has no effect if @code{vcl} is set.
17687
17688 @item @code{vcl} (default: #f)
17689 The @dfn{VCL} (Varnish Configuration Language) program to run. If this
17690 is @code{#f}, Varnish will proxy @code{backend} using the default
17691 configuration. Otherwise this must be a file-like object with valid
17692 VCL syntax.
17693
17694 @c Varnish does not support HTTPS, so keep this URL to avoid confusion.
17695 For example, to mirror @url{http://www.gnu.org,www.gnu.org} with VCL you
17696 can do something along these lines:
17697
17698 @example
17699 (define %gnu-mirror
17700 (plain-file
17701 "gnu.vcl"
17702 "vcl 4.1;
17703 backend gnu @{ .host = "www.gnu.org"; @}"))
17704
17705 (operating-system
17706 ...
17707 (services (cons (service varnish-service-type
17708 (varnish-configuration
17709 (listen '(":80"))
17710 (vcl %gnu-mirror)))
17711 %base-services)))
17712 @end example
17713
17714 The configuration of an already running Varnish instance can be inspected
17715 and changed using the @command{varnishadm} program.
17716
17717 Consult the @url{https://varnish-cache.org/docs/,Varnish User Guide} and
17718 @url{https://book.varnish-software.com/4.0/,Varnish Book} for
17719 comprehensive documentation on Varnish and its configuration language.
17720
17721 @item @code{listen} (default: @code{'("localhost:80")})
17722 List of addresses Varnish will listen on.
17723
17724 @item @code{storage} (default: @code{'("malloc,128m")})
17725 List of storage backends that will be available in VCL.
17726
17727 @item @code{parameters} (default: @code{'()})
17728 List of run-time parameters in the form @code{'(("parameter" . "value"))}.
17729
17730 @item @code{extra-options} (default: @code{'()})
17731 Additional arguments to pass to the @command{varnishd} process.
17732
17733 @end table
17734 @end deftp
17735
17736 @subsubheading FastCGI
17737 @cindex fastcgi
17738 @cindex fcgiwrap
17739 FastCGI is an interface between the front-end and the back-end of a web
17740 service. It is a somewhat legacy facility; new web services should
17741 generally just talk HTTP between the front-end and the back-end.
17742 However there are a number of back-end services such as PHP or the
17743 optimized HTTP Git repository access that use FastCGI, so we have
17744 support for it in Guix.
17745
17746 To use FastCGI, you configure the front-end web server (e.g., nginx) to
17747 dispatch some subset of its requests to the fastcgi backend, which
17748 listens on a local TCP or UNIX socket. There is an intermediary
17749 @code{fcgiwrap} program that sits between the actual backend process and
17750 the web server. The front-end indicates which backend program to run,
17751 passing that information to the @code{fcgiwrap} process.
17752
17753 @defvr {Scheme Variable} fcgiwrap-service-type
17754 A service type for the @code{fcgiwrap} FastCGI proxy.
17755 @end defvr
17756
17757 @deftp {Data Type} fcgiwrap-configuration
17758 Data type representing the configuration of the @code{fcgiwrap} service.
17759 This type has the following parameters:
17760 @table @asis
17761 @item @code{package} (default: @code{fcgiwrap})
17762 The fcgiwrap package to use.
17763
17764 @item @code{socket} (default: @code{tcp:127.0.0.1:9000})
17765 The socket on which the @code{fcgiwrap} process should listen, as a
17766 string. Valid @var{socket} values include
17767 @code{unix:@var{/path/to/unix/socket}},
17768 @code{tcp:@var{dot.ted.qu.ad}:@var{port}} and
17769 @code{tcp6:[@var{ipv6_addr}]:port}.
17770
17771 @item @code{user} (default: @code{fcgiwrap})
17772 @itemx @code{group} (default: @code{fcgiwrap})
17773 The user and group names, as strings, under which to run the
17774 @code{fcgiwrap} process. The @code{fastcgi} service will ensure that if
17775 the user asks for the specific user or group names @code{fcgiwrap} that
17776 the corresponding user and/or group is present on the system.
17777
17778 It is possible to configure a FastCGI-backed web service to pass HTTP
17779 authentication information from the front-end to the back-end, and to
17780 allow @code{fcgiwrap} to run the back-end process as a corresponding
17781 local user. To enable this capability on the back-end., run
17782 @code{fcgiwrap} as the @code{root} user and group. Note that this
17783 capability also has to be configured on the front-end as well.
17784 @end table
17785 @end deftp
17786
17787 @cindex php-fpm
17788 PHP-FPM (FastCGI Process Manager) is an alternative PHP FastCGI implementation
17789 with some additional features useful for sites of any size.
17790
17791 These features include:
17792 @itemize @bullet
17793 @item Adaptive process spawning
17794 @item Basic statistics (similar to Apache's mod_status)
17795 @item Advanced process management with graceful stop/start
17796 @item Ability to start workers with different uid/gid/chroot/environment
17797 and different php.ini (replaces safe_mode)
17798 @item Stdout & stderr logging
17799 @item Emergency restart in case of accidental opcode cache destruction
17800 @item Accelerated upload support
17801 @item Support for a "slowlog"
17802 @item Enhancements to FastCGI, such as fastcgi_finish_request() -
17803 a special function to finish request & flush all data while continuing to do
17804 something time-consuming (video converting, stats processing, etc.)
17805 @end itemize
17806 ...@: and much more.
17807
17808 @defvr {Scheme Variable} php-fpm-service-type
17809 A Service type for @code{php-fpm}.
17810 @end defvr
17811
17812 @deftp {Data Type} php-fpm-configuration
17813 Data Type for php-fpm service configuration.
17814 @table @asis
17815 @item @code{php} (default: @code{php})
17816 The php package to use.
17817 @item @code{socket} (default: @code{(string-append "/var/run/php" (version-major (package-version php)) "-fpm.sock")})
17818 The address on which to accept FastCGI requests. Valid syntaxes are:
17819 @table @asis
17820 @item @code{"ip.add.re.ss:port"}
17821 Listen on a TCP socket to a specific address on a specific port.
17822 @item @code{"port"}
17823 Listen on a TCP socket to all addresses on a specific port.
17824 @item @code{"/path/to/unix/socket"}
17825 Listen on a unix socket.
17826 @end table
17827
17828 @item @code{user} (default: @code{php-fpm})
17829 User who will own the php worker processes.
17830 @item @code{group} (default: @code{php-fpm})
17831 Group of the worker processes.
17832 @item @code{socket-user} (default: @code{php-fpm})
17833 User who can speak to the php-fpm socket.
17834 @item @code{socket-group} (default: @code{php-fpm})
17835 Group that can speak to the php-fpm socket.
17836 @item @code{pid-file} (default: @code{(string-append "/var/run/php" (version-major (package-version php)) "-fpm.pid")})
17837 The process id of the php-fpm process is written to this file
17838 once the service has started.
17839 @item @code{log-file} (default: @code{(string-append "/var/log/php" (version-major (package-version php)) "-fpm.log")})
17840 Log for the php-fpm master process.
17841 @item @code{process-manager} (default: @code{(php-fpm-dynamic-process-manager-configuration)})
17842 Detailed settings for the php-fpm process manager.
17843 Must be either:
17844 @table @asis
17845 @item @code{<php-fpm-dynamic-process-manager-configuration>}
17846 @item @code{<php-fpm-static-process-manager-configuration>}
17847 @item @code{<php-fpm-on-demand-process-manager-configuration>}
17848 @end table
17849 @item @code{display-errors} (default @code{#f})
17850 Determines whether php errors and warning should be sent to clients
17851 and displayed in their browsers.
17852 This is useful for local php development, but a security risk for public sites,
17853 as error messages can reveal passwords and personal data.
17854 @item @code{timezone} (default @code{#f})
17855 Specifies @code{php_admin_value[date.timezone]} parameter.
17856 @item @code{workers-logfile} (default @code{(string-append "/var/log/php" (version-major (package-version php)) "-fpm.www.log")})
17857 This file will log the @code{stderr} outputs of php worker processes.
17858 Can be set to @code{#f} to disable logging.
17859 @item @code{file} (default @code{#f})
17860 An optional override of the whole configuration.
17861 You can use the @code{mixed-text-file} function or an absolute filepath for it.
17862 @end table
17863 @end deftp
17864
17865 @deftp {Data type} php-fpm-dynamic-process-manager-configuration
17866 Data Type for the @code{dynamic} php-fpm process manager. With the
17867 @code{dynamic} process manager, spare worker processes are kept around
17868 based on it's configured limits.
17869 @table @asis
17870 @item @code{max-children} (default: @code{5})
17871 Maximum of worker processes.
17872 @item @code{start-servers} (default: @code{2})
17873 How many worker processes should be started on start-up.
17874 @item @code{min-spare-servers} (default: @code{1})
17875 How many spare worker processes should be kept around at minimum.
17876 @item @code{max-spare-servers} (default: @code{3})
17877 How many spare worker processes should be kept around at maximum.
17878 @end table
17879 @end deftp
17880
17881 @deftp {Data type} php-fpm-static-process-manager-configuration
17882 Data Type for the @code{static} php-fpm process manager. With the
17883 @code{static} process manager, an unchanging number of worker processes
17884 are created.
17885 @table @asis
17886 @item @code{max-children} (default: @code{5})
17887 Maximum of worker processes.
17888 @end table
17889 @end deftp
17890
17891 @deftp {Data type} php-fpm-on-demand-process-manager-configuration
17892 Data Type for the @code{on-demand} php-fpm process manager. With the
17893 @code{on-demand} process manager, worker processes are only created as
17894 requests arrive.
17895 @table @asis
17896 @item @code{max-children} (default: @code{5})
17897 Maximum of worker processes.
17898 @item @code{process-idle-timeout} (default: @code{10})
17899 The time in seconds after which a process with no requests is killed.
17900 @end table
17901 @end deftp
17902
17903
17904 @deffn {Scheme Procedure} nginx-php-fpm-location @
17905 [#:nginx-package nginx] @
17906 [socket (string-append "/var/run/php" @
17907 (version-major (package-version php)) @
17908 "-fpm.sock")]
17909 A helper function to quickly add php to an @code{nginx-server-configuration}.
17910 @end deffn
17911
17912 A simple services setup for nginx with php can look like this:
17913 @example
17914 (services (cons* (service dhcp-client-service-type)
17915 (service php-fpm-service-type)
17916 (service nginx-service-type
17917 (nginx-server-configuration
17918 (server-name '("example.com"))
17919 (root "/srv/http/")
17920 (locations
17921 (list (nginx-php-location)))
17922 (listen '("80"))
17923 (ssl-certificate #f)
17924 (ssl-certificate-key #f)))
17925 %base-services))
17926 @end example
17927
17928 @cindex cat-avatar-generator
17929 The cat avatar generator is a simple service to demonstrate the use of php-fpm
17930 in @code{Nginx}. It is used to generate cat avatar from a seed, for instance
17931 the hash of a user's email address.
17932
17933 @deffn {Scheme Procedure} cat-avatar-generator-service @
17934 [#:cache-dir "/var/cache/cat-avatar-generator"] @
17935 [#:package cat-avatar-generator] @
17936 [#:configuration (nginx-server-configuration)]
17937 Returns an nginx-server-configuration that inherits @code{configuration}. It
17938 extends the nginx configuration to add a server block that serves @code{package},
17939 a version of cat-avatar-generator. During execution, cat-avatar-generator will
17940 be able to use @code{cache-dir} as its cache directory.
17941 @end deffn
17942
17943 A simple setup for cat-avatar-generator can look like this:
17944 @example
17945 (services (cons* (cat-avatar-generator-service
17946 #:configuration
17947 (nginx-server-configuration
17948 (server-name '("example.com"))))
17949 ...
17950 %base-services))
17951 @end example
17952
17953 @subsubheading Hpcguix-web
17954
17955 @cindex hpcguix-web
17956 The @uref{hpcguix-web, https://github.com/UMCUGenetics/hpcguix-web/}
17957 program is a customizable web interface to browse Guix packages,
17958 initially designed for users of high-performance computing (HPC)
17959 clusters.
17960
17961 @defvr {Scheme Variable} hpcguix-web-service-type
17962 The service type for @code{hpcguix-web}.
17963 @end defvr
17964
17965 @deftp {Data Type} hpcguix-web-configuration
17966 Data type for the hpcguix-web service configuration.
17967
17968 @table @asis
17969 @item @code{specs}
17970 A gexp (@pxref{G-Expressions}) specifying the hpcguix-web service
17971 configuration. The main items available in this spec are:
17972
17973 @table @asis
17974 @item @code{title-prefix} (default: @code{"hpcguix | "})
17975 The page title prefix.
17976
17977 @item @code{guix-command} (default: @code{"guix"})
17978 The @command{guix} command.
17979
17980 @item @code{package-filter-proc} (default: @code{(const #t)})
17981 A procedure specifying how to filter packages that are displayed.
17982
17983 @item @code{package-page-extension-proc} (default: @code{(const '())})
17984 Extension package for @code{hpcguix-web}.
17985
17986 @item @code{menu} (default: @code{'()})
17987 Additional entry in page @code{menu}.
17988
17989 @item @code{channels} (default: @code{%default-channels})
17990 List of channels from which the package list is built (@pxref{Channels}).
17991
17992 @item @code{package-list-expiration} (default: @code{(* 12 3600)})
17993 The expiration time, in seconds, after which the package list is rebuilt from
17994 the latest instances of the given channels.
17995 @end table
17996
17997 See the hpcguix-web repository for a
17998 @uref{https://github.com/UMCUGenetics/hpcguix-web/blob/master/hpcweb-configuration.scm,
17999 complete example}.
18000
18001 @item @code{package} (default: @code{hpcguix-web})
18002 The hpcguix-web package to use.
18003 @end table
18004 @end deftp
18005
18006 A typical hpcguix-web service declaration looks like this:
18007
18008 @example
18009 (service hpcguix-web-service-type
18010 (hpcguix-web-configuration
18011 (specs
18012 #~(define site-config
18013 (hpcweb-configuration
18014 (title-prefix "Guix-HPC - ")
18015 (menu '(("/about" "ABOUT"))))))))
18016 @end example
18017
18018 @quotation Note
18019 The hpcguix-web service periodically updates the package list it publishes by
18020 pulling channels from Git. To that end, it needs to access X.509 certificates
18021 so that it can authenticate Git servers when communicating over HTTPS, and it
18022 assumes that @file{/etc/ssl/certs} contains those certificates.
18023
18024 Thus, make sure to add @code{nss-certs} or another certificate package to the
18025 @code{packages} field of your configuration. @ref{X.509 Certificates}, for
18026 more information on X.509 certificates.
18027 @end quotation
18028
18029 @node Certificate Services
18030 @subsection Certificate Services
18031
18032 @cindex Web
18033 @cindex HTTP, HTTPS
18034 @cindex Let's Encrypt
18035 @cindex TLS certificates
18036 The @code{(gnu services certbot)} module provides a service to
18037 automatically obtain a valid TLS certificate from the Let's Encrypt
18038 certificate authority. These certificates can then be used to serve
18039 content securely over HTTPS or other TLS-based protocols, with the
18040 knowledge that the client will be able to verify the server's
18041 authenticity.
18042
18043 @url{https://letsencrypt.org/, Let's Encrypt} provides the
18044 @code{certbot} tool to automate the certification process. This tool
18045 first securely generates a key on the server. It then makes a request
18046 to the Let's Encrypt certificate authority (CA) to sign the key. The CA
18047 checks that the request originates from the host in question by using a
18048 challenge-response protocol, requiring the server to provide its
18049 response over HTTP. If that protocol completes successfully, the CA
18050 signs the key, resulting in a certificate. That certificate is valid
18051 for a limited period of time, and therefore to continue to provide TLS
18052 services, the server needs to periodically ask the CA to renew its
18053 signature.
18054
18055 The certbot service automates this process: the initial key
18056 generation, the initial certification request to the Let's Encrypt
18057 service, the web server challenge/response integration, writing the
18058 certificate to disk, the automated periodic renewals, and the deployment
18059 tasks associated with the renewal (e.g.@: reloading services, copying keys
18060 with different permissions).
18061
18062 Certbot is run twice a day, at a random minute within the hour. It
18063 won't do anything until your certificates are due for renewal or
18064 revoked, but running it regularly would give your service a chance of
18065 staying online in case a Let's Encrypt-initiated revocation happened for
18066 some reason.
18067
18068 By using this service, you agree to the ACME Subscriber Agreement, which
18069 can be found there:
18070 @url{https://acme-v01.api.letsencrypt.org/directory}.
18071
18072 @defvr {Scheme Variable} certbot-service-type
18073 A service type for the @code{certbot} Let's Encrypt client. Its value
18074 must be a @code{certbot-configuration} record as in this example:
18075
18076 @example
18077 (define %nginx-deploy-hook
18078 (program-file
18079 "nginx-deploy-hook"
18080 #~(let ((pid (call-with-input-file "/var/run/nginx/pid" read)))
18081 (kill pid SIGHUP))))
18082
18083 (service certbot-service-type
18084 (certbot-configuration
18085 (email "foo@@example.net")
18086 (certificates
18087 (list
18088 (certificate-configuration
18089 (domains '("example.net" "www.example.net"))
18090 (deploy-hook %nginx-deploy-hook))
18091 (certificate-configuration
18092 (domains '("bar.example.net")))))))
18093 @end example
18094
18095 See below for details about @code{certbot-configuration}.
18096 @end defvr
18097
18098 @deftp {Data Type} certbot-configuration
18099 Data type representing the configuration of the @code{certbot} service.
18100 This type has the following parameters:
18101
18102 @table @asis
18103 @item @code{package} (default: @code{certbot})
18104 The certbot package to use.
18105
18106 @item @code{webroot} (default: @code{/var/www})
18107 The directory from which to serve the Let's Encrypt challenge/response
18108 files.
18109
18110 @item @code{certificates} (default: @code{()})
18111 A list of @code{certificates-configuration}s for which to generate
18112 certificates and request signatures. Each certificate has a @code{name}
18113 and several @code{domains}.
18114
18115 @item @code{email}
18116 Mandatory email used for registration, recovery contact, and important
18117 account notifications.
18118
18119 @item @code{rsa-key-size} (default: @code{2048})
18120 Size of the RSA key.
18121
18122 @item @code{default-location} (default: @i{see below})
18123 The default @code{nginx-location-configuration}. Because @code{certbot}
18124 needs to be able to serve challenges and responses, it needs to be able
18125 to run a web server. It does so by extending the @code{nginx} web
18126 service with an @code{nginx-server-configuration} listening on the
18127 @var{domains} on port 80, and which has a
18128 @code{nginx-location-configuration} for the @code{/.well-known/} URI
18129 path subspace used by Let's Encrypt. @xref{Web Services}, for more on
18130 these nginx configuration data types.
18131
18132 Requests to other URL paths will be matched by the
18133 @code{default-location}, which if present is added to all
18134 @code{nginx-server-configuration}s.
18135
18136 By default, the @code{default-location} will issue a redirect from
18137 @code{http://@var{domain}/...} to @code{https://@var{domain}/...}, leaving
18138 you to define what to serve on your site via @code{https}.
18139
18140 Pass @code{#f} to not issue a default location.
18141 @end table
18142 @end deftp
18143
18144 @deftp {Data Type} certificate-configuration
18145 Data type representing the configuration of a certificate.
18146 This type has the following parameters:
18147
18148 @table @asis
18149 @item @code{name} (default: @i{see below})
18150 This name is used by Certbot for housekeeping and in file paths; it
18151 doesn't affect the content of the certificate itself. To see
18152 certificate names, run @code{certbot certificates}.
18153
18154 Its default is the first provided domain.
18155
18156 @item @code{domains} (default: @code{()})
18157 The first domain provided will be the subject CN of the certificate, and
18158 all domains will be Subject Alternative Names on the certificate.
18159
18160 @item @code{deploy-hook} (default: @code{#f})
18161 Command to be run in a shell once for each successfully issued
18162 certificate. For this command, the shell variable
18163 @code{$RENEWED_LINEAGE} will point to the config live subdirectory (for
18164 example, @samp{"/etc/letsencrypt/live/example.com"}) containing the new
18165 certificates and keys; the shell variable @code{$RENEWED_DOMAINS} will
18166 contain a space-delimited list of renewed certificate domains (for
18167 example, @samp{"example.com www.example.com"}.
18168
18169 @end table
18170 @end deftp
18171
18172 For each @code{certificate-configuration}, the certificate is saved to
18173 @code{/etc/letsencrypt/live/@var{name}/fullchain.pem} and the key is
18174 saved to @code{/etc/letsencrypt/live/@var{name}/privkey.pem}.
18175 @node DNS Services
18176 @subsection DNS Services
18177 @cindex DNS (domain name system)
18178 @cindex domain name system (DNS)
18179
18180 The @code{(gnu services dns)} module provides services related to the
18181 @dfn{domain name system} (DNS). It provides a server service for hosting
18182 an @emph{authoritative} DNS server for multiple zones, slave or master.
18183 This service uses @uref{https://www.knot-dns.cz/, Knot DNS}. And also a
18184 caching and forwarding DNS server for the LAN, which uses
18185 @uref{http://www.thekelleys.org.uk/dnsmasq/doc.html, dnsmasq}.
18186
18187 @subsubheading Knot Service
18188
18189 An example configuration of an authoritative server for two zones, one master
18190 and one slave, is:
18191
18192 @lisp
18193 (define-zone-entries example.org.zone
18194 ;; Name TTL Class Type Data
18195 ("@@" "" "IN" "A" "127.0.0.1")
18196 ("@@" "" "IN" "NS" "ns")
18197 ("ns" "" "IN" "A" "127.0.0.1"))
18198
18199 (define master-zone
18200 (knot-zone-configuration
18201 (domain "example.org")
18202 (zone (zone-file
18203 (origin "example.org")
18204 (entries example.org.zone)))))
18205
18206 (define slave-zone
18207 (knot-zone-configuration
18208 (domain "plop.org")
18209 (dnssec-policy "default")
18210 (master (list "plop-master"))))
18211
18212 (define plop-master
18213 (knot-remote-configuration
18214 (id "plop-master")
18215 (address (list "208.76.58.171"))))
18216
18217 (operating-system
18218 ;; ...
18219 (services (cons* (service knot-service-type
18220 (knot-configuration
18221 (remotes (list plop-master))
18222 (zones (list master-zone slave-zone))))
18223 ;; ...
18224 %base-services)))
18225 @end lisp
18226
18227 @deffn {Scheme Variable} knot-service-type
18228 This is the type for the Knot DNS server.
18229
18230 Knot DNS is an authoritative DNS server, meaning that it can serve multiple
18231 zones, that is to say domain names you would buy from a registrar. This server
18232 is not a resolver, meaning that it can only resolve names for which it is
18233 authoritative. This server can be configured to serve zones as a master server
18234 or a slave server as a per-zone basis. Slave zones will get their data from
18235 masters, and will serve it as an authoritative server. From the point of view
18236 of a resolver, there is no difference between master and slave.
18237
18238 The following data types are used to configure the Knot DNS server:
18239 @end deffn
18240
18241 @deftp {Data Type} knot-key-configuration
18242 Data type representing a key.
18243 This type has the following parameters:
18244
18245 @table @asis
18246 @item @code{id} (default: @code{""})
18247 An identifier for other configuration fields to refer to this key. IDs must
18248 be unique and must not be empty.
18249
18250 @item @code{algorithm} (default: @code{#f})
18251 The algorithm to use. Choose between @code{#f}, @code{'hmac-md5},
18252 @code{'hmac-sha1}, @code{'hmac-sha224}, @code{'hmac-sha256}, @code{'hmac-sha384}
18253 and @code{'hmac-sha512}.
18254
18255 @item @code{secret} (default: @code{""})
18256 The secret key itself.
18257
18258 @end table
18259 @end deftp
18260
18261 @deftp {Data Type} knot-acl-configuration
18262 Data type representing an Access Control List (ACL) configuration.
18263 This type has the following parameters:
18264
18265 @table @asis
18266 @item @code{id} (default: @code{""})
18267 An identifier for ether configuration fields to refer to this key. IDs must be
18268 unique and must not be empty.
18269
18270 @item @code{address} (default: @code{'()})
18271 An ordered list of IP addresses, network subnets, or network ranges represented
18272 with strings. The query must match one of them. Empty value means that
18273 address match is not required.
18274
18275 @item @code{key} (default: @code{'()})
18276 An ordered list of references to keys represented with strings. The string
18277 must match a key ID defined in a @code{knot-key-configuration}. No key means
18278 that a key is not require to match that ACL.
18279
18280 @item @code{action} (default: @code{'()})
18281 An ordered list of actions that are permitted or forbidden by this ACL. Possible
18282 values are lists of zero or more elements from @code{'transfer}, @code{'notify}
18283 and @code{'update}.
18284
18285 @item @code{deny?} (default: @code{#f})
18286 When true, the ACL defines restrictions. Listed actions are forbidden. When
18287 false, listed actions are allowed.
18288
18289 @end table
18290 @end deftp
18291
18292 @deftp {Data Type} zone-entry
18293 Data type represnting a record entry in a zone file.
18294 This type has the following parameters:
18295
18296 @table @asis
18297 @item @code{name} (default: @code{"@@"})
18298 The name of the record. @code{"@@"} refers to the origin of the zone. Names
18299 are relative to the origin of the zone. For example, in the @code{example.org}
18300 zone, @code{"ns.example.org"} actually refers to @code{ns.example.org.example.org}.
18301 Names ending with a dot are absolute, which means that @code{"ns.example.org."}
18302 refers to @code{ns.example.org}.
18303
18304 @item @code{ttl} (default: @code{""})
18305 The Time-To-Live (TTL) of this record. If not set, the default TTL is used.
18306
18307 @item @code{class} (default: @code{"IN"})
18308 The class of the record. Knot currently supports only @code{"IN"} and
18309 partially @code{"CH"}.
18310
18311 @item @code{type} (default: @code{"A"})
18312 The type of the record. Common types include A (IPv4 address), AAAA (IPv6
18313 address), NS (Name Server) and MX (Mail eXchange). Many other types are
18314 defined.
18315
18316 @item @code{data} (default: @code{""})
18317 The data contained in the record. For instance an IP address associated with
18318 an A record, or a domain name associated with an NS record. Remember that
18319 domain names are relative to the origin unless they end with a dot.
18320
18321 @end table
18322 @end deftp
18323
18324 @deftp {Data Type} zone-file
18325 Data type representing the content of a zone file.
18326 This type has the following parameters:
18327
18328 @table @asis
18329 @item @code{entries} (default: @code{'()})
18330 The list of entries. The SOA record is taken care of, so you don't need to
18331 put it in the list of entries. This list should probably contain an entry
18332 for your primary authoritative DNS server. Other than using a list of entries
18333 directly, you can use @code{define-zone-entries} to define a object containing
18334 the list of entries more easily, that you can later pass to the @code{entries}
18335 field of the @code{zone-file}.
18336
18337 @item @code{origin} (default: @code{""})
18338 The name of your zone. This parameter cannot be empty.
18339
18340 @item @code{ns} (default: @code{"ns"})
18341 The domain of your primary authoritative DNS server. The name is relative to
18342 the origin, unless it ends with a dot. It is mandatory that this primary
18343 DNS server corresponds to an NS record in the zone and that it is associated
18344 to an IP address in the list of entries.
18345
18346 @item @code{mail} (default: @code{"hostmaster"})
18347 An email address people can contact you at, as the owner of the zone. This
18348 is translated as @code{<mail>@@<origin>}.
18349
18350 @item @code{serial} (default: @code{1})
18351 The serial number of the zone. As this is used to keep track of changes by
18352 both slaves and resolvers, it is mandatory that it @emph{never} decreases.
18353 Always increment it when you make a change in your zone.
18354
18355 @item @code{refresh} (default: @code{(* 2 24 3600)})
18356 The frequency at which slaves will do a zone transfer. This value is a number
18357 of seconds. It can be computed by multiplications or with
18358 @code{(string->duration)}.
18359
18360 @item @code{retry} (default: @code{(* 15 60)})
18361 The period after which a slave will retry to contact its master when it fails
18362 to do so a first time.
18363
18364 @item @code{expiry} (default: @code{(* 14 24 3600)})
18365 Default TTL of records. Existing records are considered correct for at most
18366 this amount of time. After this period, resolvers will invalidate their cache
18367 and check again that it still exists.
18368
18369 @item @code{nx} (default: @code{3600})
18370 Default TTL of inexistant records. This delay is usually short because you want
18371 your new domains to reach everyone quickly.
18372
18373 @end table
18374 @end deftp
18375
18376 @deftp {Data Type} knot-remote-configuration
18377 Data type representing a remote configuration.
18378 This type has the following parameters:
18379
18380 @table @asis
18381 @item @code{id} (default: @code{""})
18382 An identifier for other configuration fields to refer to this remote. IDs must
18383 be unique and must not be empty.
18384
18385 @item @code{address} (default: @code{'()})
18386 An ordered list of destination IP addresses. Addresses are tried in sequence.
18387 An optional port can be given with the @@ separator. For instance:
18388 @code{(list "1.2.3.4" "2.3.4.5@@53")}. Default port is 53.
18389
18390 @item @code{via} (default: @code{'()})
18391 An ordered list of source IP addresses. An empty list will have Knot choose
18392 an appropriate source IP. An optional port can be given with the @@ separator.
18393 The default is to choose at random.
18394
18395 @item @code{key} (default: @code{#f})
18396 A reference to a key, that is a string containing the identifier of a key
18397 defined in a @code{knot-key-configuration} field.
18398
18399 @end table
18400 @end deftp
18401
18402 @deftp {Data Type} knot-keystore-configuration
18403 Data type representing a keystore to hold dnssec keys.
18404 This type has the following parameters:
18405
18406 @table @asis
18407 @item @code{id} (default: @code{""})
18408 The id of the keystore. It must not be empty.
18409
18410 @item @code{backend} (default: @code{'pem})
18411 The backend to store the keys in. Can be @code{'pem} or @code{'pkcs11}.
18412
18413 @item @code{config} (default: @code{"/var/lib/knot/keys/keys"})
18414 The configuration string of the backend. An example for the PKCS#11 is:
18415 @code{"pkcs11:token=knot;pin-value=1234 /gnu/store/.../lib/pkcs11/libsofthsm2.so"}.
18416 For the pem backend, the string reprensents a path in the file system.
18417
18418 @end table
18419 @end deftp
18420
18421 @deftp {Data Type} knot-policy-configuration
18422 Data type representing a dnssec policy. Knot DNS is able to automatically
18423 sign your zones. It can either generate and manage your keys automatically or
18424 use keys that you generate.
18425
18426 Dnssec is usually implemented using two keys: a Key Signing Key (KSK) that is
18427 used to sign the second, and a Zone Signing Key (ZSK) that is used to sign the
18428 zone. In order to be trusted, the KSK needs to be present in the parent zone
18429 (usually a top-level domain). If your registrar supports dnssec, you will
18430 have to send them your KSK's hash so they can add a DS record in their zone.
18431 This is not automated and need to be done each time you change your KSK.
18432
18433 The policy also defines the lifetime of keys. Usually, ZSK can be changed
18434 easily and use weaker cryptographic functions (they use lower parameters) in
18435 order to sign records quickly, so they are changed often. The KSK however
18436 requires manual interaction with the registrar, so they are changed less often
18437 and use stronger parameters because they sign only one record.
18438
18439 This type has the following parameters:
18440
18441 @table @asis
18442 @item @code{id} (default: @code{""})
18443 The id of the policy. It must not be empty.
18444
18445 @item @code{keystore} (default: @code{"default"})
18446 A reference to a keystore, that is a string containing the identifier of a
18447 keystore defined in a @code{knot-keystore-configuration} field. The
18448 @code{"default"} identifier means the default keystore (a kasp database that
18449 was setup by this service).
18450
18451 @item @code{manual?} (default: @code{#f})
18452 Whether the key management is manual or automatic.
18453
18454 @item @code{single-type-signing?} (default: @code{#f})
18455 When @code{#t}, use the Single-Type Signing Scheme.
18456
18457 @item @code{algorithm} (default: @code{"ecdsap256sha256"})
18458 An algorithm of signing keys and issued signatures.
18459
18460 @item @code{ksk-size} (default: @code{256})
18461 The length of the KSK. Note that this value is correct for the default
18462 algorithm, but would be unsecure for other algorithms.
18463
18464 @item @code{zsk-size} (default: @code{256})
18465 The length of the ZSK. Note that this value is correct for the default
18466 algorithm, but would be unsecure for other algorithms.
18467
18468 @item @code{dnskey-ttl} (default: @code{'default})
18469 The TTL value for DNSKEY records added into zone apex. The special
18470 @code{'default} value means same as the zone SOA TTL.
18471
18472 @item @code{zsk-lifetime} (default: @code{(* 30 24 3600)})
18473 The period between ZSK publication and the next rollover initiation.
18474
18475 @item @code{propagation-delay} (default: @code{(* 24 3600)})
18476 An extra delay added for each key rollover step. This value should be high
18477 enough to cover propagation of data from the master server to all slaves.
18478
18479 @item @code{rrsig-lifetime} (default: @code{(* 14 24 3600)})
18480 A validity period of newly issued signatures.
18481
18482 @item @code{rrsig-refresh} (default: @code{(* 7 24 3600)})
18483 A period how long before a signature expiration the signature will be refreshed.
18484
18485 @item @code{nsec3?} (default: @code{#f})
18486 When @code{#t}, NSEC3 will be used instead of NSEC.
18487
18488 @item @code{nsec3-iterations} (default: @code{5})
18489 The number of additional times the hashing is performed.
18490
18491 @item @code{nsec3-salt-length} (default: @code{8})
18492 The length of a salt field in octets, which is appended to the original owner
18493 name before hashing.
18494
18495 @item @code{nsec3-salt-lifetime} (default: @code{(* 30 24 3600)})
18496 The validity period of newly issued salt field.
18497
18498 @end table
18499 @end deftp
18500
18501 @deftp {Data Type} knot-zone-configuration
18502 Data type representing a zone served by Knot.
18503 This type has the following parameters:
18504
18505 @table @asis
18506 @item @code{domain} (default: @code{""})
18507 The domain served by this configuration. It must not be empty.
18508
18509 @item @code{file} (default: @code{""})
18510 The file where this zone is saved. This parameter is ignored by master zones.
18511 Empty means default location that depends on the domain name.
18512
18513 @item @code{zone} (default: @code{(zone-file)})
18514 The content of the zone file. This parameter is ignored by slave zones. It
18515 must contain a zone-file record.
18516
18517 @item @code{master} (default: @code{'()})
18518 A list of master remotes. When empty, this zone is a master. When set, this
18519 zone is a slave. This is a list of remotes identifiers.
18520
18521 @item @code{ddns-master} (default: @code{#f})
18522 The main master. When empty, it defaults to the first master in the list of
18523 masters.
18524
18525 @item @code{notify} (default: @code{'()})
18526 A list of slave remote identifiers.
18527
18528 @item @code{acl} (default: @code{'()})
18529 A list of acl identifiers.
18530
18531 @item @code{semantic-checks?} (default: @code{#f})
18532 When set, this adds more semantic checks to the zone.
18533
18534 @item @code{disable-any?} (default: @code{#f})
18535 When set, this forbids queries of the ANY type.
18536
18537 @item @code{zonefile-sync} (default: @code{0})
18538 The delay between a modification in memory and on disk. 0 means immediate
18539 synchronization.
18540
18541 @item @code{serial-policy} (default: @code{'increment})
18542 A policy between @code{'increment} and @code{'unixtime}.
18543
18544 @end table
18545 @end deftp
18546
18547 @deftp {Data Type} knot-configuration
18548 Data type representing the Knot configuration.
18549 This type has the following parameters:
18550
18551 @table @asis
18552 @item @code{knot} (default: @code{knot})
18553 The Knot package.
18554
18555 @item @code{run-directory} (default: @code{"/var/run/knot"})
18556 The run directory. This directory will be used for pid file and sockets.
18557
18558 @item @code{listen-v4} (default: @code{"0.0.0.0"})
18559 An ip address on which to listen.
18560
18561 @item @code{listen-v6} (default: @code{"::"})
18562 An ip address on which to listen.
18563
18564 @item @code{listen-port} (default: @code{53})
18565 A port on which to listen.
18566
18567 @item @code{keys} (default: @code{'()})
18568 The list of knot-key-configuration used by this configuration.
18569
18570 @item @code{acls} (default: @code{'()})
18571 The list of knot-acl-configuration used by this configuration.
18572
18573 @item @code{remotes} (default: @code{'()})
18574 The list of knot-remote-configuration used by this configuration.
18575
18576 @item @code{zones} (default: @code{'()})
18577 The list of knot-zone-configuration used by this configuration.
18578
18579 @end table
18580 @end deftp
18581
18582 @subsubheading Dnsmasq Service
18583
18584 @deffn {Scheme Variable} dnsmasq-service-type
18585 This is the type of the dnsmasq service, whose value should be an
18586 @code{dnsmasq-configuration} object as in this example:
18587
18588 @example
18589 (service dnsmasq-service-type
18590 (dnsmasq-configuration
18591 (no-resolv? #t)
18592 (servers '("192.168.1.1"))))
18593 @end example
18594 @end deffn
18595
18596 @deftp {Data Type} dnsmasq-configuration
18597 Data type representing the configuration of dnsmasq.
18598
18599 @table @asis
18600 @item @code{package} (default: @var{dnsmasq})
18601 Package object of the dnsmasq server.
18602
18603 @item @code{no-hosts?} (default: @code{#f})
18604 When true, don't read the hostnames in /etc/hosts.
18605
18606 @item @code{port} (default: @code{53})
18607 The port to listen on. Setting this to zero completely disables DNS
18608 responses, leaving only DHCP and/or TFTP functions.
18609
18610 @item @code{local-service?} (default: @code{#t})
18611 Accept DNS queries only from hosts whose address is on a local subnet,
18612 ie a subnet for which an interface exists on the server.
18613
18614 @item @code{listen-addresses} (default: @code{'()})
18615 Listen on the given IP addresses.
18616
18617 @item @code{resolv-file} (default: @code{"/etc/resolv.conf"})
18618 The file to read the IP address of the upstream nameservers from.
18619
18620 @item @code{no-resolv?} (default: @code{#f})
18621 When true, don't read @var{resolv-file}.
18622
18623 @item @code{servers} (default: @code{'()})
18624 Specify IP address of upstream servers directly.
18625
18626 @item @code{cache-size} (default: @code{150})
18627 Set the size of dnsmasq's cache. Setting the cache size to zero
18628 disables caching.
18629
18630 @item @code{negative-cache?} (default: @code{#t})
18631 When false, disable negative caching.
18632
18633 @end table
18634 @end deftp
18635
18636 @subsubheading ddclient Service
18637
18638 @cindex ddclient
18639 The ddclient service described below runs the ddclient daemon, which takes
18640 care of automatically updating DNS entries for service providers such as
18641 @uref{https://dyn.com/dns/, Dyn}.
18642
18643 The following example show instantiates the service with its default
18644 configuration:
18645
18646 @example
18647 (service ddclient-service-type)
18648 @end example
18649
18650 Note that ddclient needs to access credentials that are stored in a
18651 @dfn{secret file}, by default @file{/etc/ddclient/secrets} (see
18652 @code{secret-file} below.) You are expected to create this file manually, in
18653 an ``out-of-band'' fashion (you @emph{could} make this file part of the
18654 service configuration, for instance by using @code{plain-file}, but it will be
18655 world-readable @i{via} @file{/gnu/store}.) See the examples in the
18656 @file{share/ddclient} directory of the @code{ddclient} package.
18657
18658 @c %start of fragment
18659
18660 Available @code{ddclient-configuration} fields are:
18661
18662 @deftypevr {@code{ddclient-configuration} parameter} package ddclient
18663 The ddclient package.
18664
18665 @end deftypevr
18666
18667 @deftypevr {@code{ddclient-configuration} parameter} integer daemon
18668 The period after which ddclient will retry to check IP and domain name.
18669
18670 Defaults to @samp{300}.
18671
18672 @end deftypevr
18673
18674 @deftypevr {@code{ddclient-configuration} parameter} boolean syslog
18675 Use syslog for the output.
18676
18677 Defaults to @samp{#t}.
18678
18679 @end deftypevr
18680
18681 @deftypevr {@code{ddclient-configuration} parameter} string mail
18682 Mail to user.
18683
18684 Defaults to @samp{"root"}.
18685
18686 @end deftypevr
18687
18688 @deftypevr {@code{ddclient-configuration} parameter} string mail-failure
18689 Mail failed update to user.
18690
18691 Defaults to @samp{"root"}.
18692
18693 @end deftypevr
18694
18695 @deftypevr {@code{ddclient-configuration} parameter} string pid
18696 The ddclient PID file.
18697
18698 Defaults to @samp{"/var/run/ddclient/ddclient.pid"}.
18699
18700 @end deftypevr
18701
18702 @deftypevr {@code{ddclient-configuration} parameter} boolean ssl
18703 Enable SSL support.
18704
18705 Defaults to @samp{#t}.
18706
18707 @end deftypevr
18708
18709 @deftypevr {@code{ddclient-configuration} parameter} string user
18710 Specifies the user name or ID that is used when running ddclient
18711 program.
18712
18713 Defaults to @samp{"ddclient"}.
18714
18715 @end deftypevr
18716
18717 @deftypevr {@code{ddclient-configuration} parameter} string group
18718 Group of the user who will run the ddclient program.
18719
18720 Defaults to @samp{"ddclient"}.
18721
18722 @end deftypevr
18723
18724 @deftypevr {@code{ddclient-configuration} parameter} string secret-file
18725 Secret file which will be appended to @file{ddclient.conf} file. This
18726 file contains credentials for use by ddclient. You are expected to
18727 create it manually.
18728
18729 Defaults to @samp{"/etc/ddclient/secrets.conf"}.
18730
18731 @end deftypevr
18732
18733 @deftypevr {@code{ddclient-configuration} parameter} list extra-options
18734 Extra options will be appended to @file{ddclient.conf} file.
18735
18736 Defaults to @samp{()}.
18737
18738 @end deftypevr
18739
18740
18741 @c %end of fragment
18742
18743
18744 @node VPN Services
18745 @subsection VPN Services
18746 @cindex VPN (virtual private network)
18747 @cindex virtual private network (VPN)
18748
18749 The @code{(gnu services vpn)} module provides services related to
18750 @dfn{virtual private networks} (VPNs). It provides a @emph{client} service for
18751 your machine to connect to a VPN, and a @emph{servire} service for your machine
18752 to host a VPN. Both services use @uref{https://openvpn.net/, OpenVPN}.
18753
18754 @deffn {Scheme Procedure} openvpn-client-service @
18755 [#:config (openvpn-client-configuration)]
18756
18757 Return a service that runs @command{openvpn}, a VPN daemon, as a client.
18758 @end deffn
18759
18760 @deffn {Scheme Procedure} openvpn-server-service @
18761 [#:config (openvpn-server-configuration)]
18762
18763 Return a service that runs @command{openvpn}, a VPN daemon, as a server.
18764
18765 Both can be run simultaneously.
18766 @end deffn
18767
18768 @c %automatically generated documentation
18769
18770 Available @code{openvpn-client-configuration} fields are:
18771
18772 @deftypevr {@code{openvpn-client-configuration} parameter} package openvpn
18773 The OpenVPN package.
18774
18775 @end deftypevr
18776
18777 @deftypevr {@code{openvpn-client-configuration} parameter} string pid-file
18778 The OpenVPN pid file.
18779
18780 Defaults to @samp{"/var/run/openvpn/openvpn.pid"}.
18781
18782 @end deftypevr
18783
18784 @deftypevr {@code{openvpn-client-configuration} parameter} proto proto
18785 The protocol (UDP or TCP) used to open a channel between clients and
18786 servers.
18787
18788 Defaults to @samp{udp}.
18789
18790 @end deftypevr
18791
18792 @deftypevr {@code{openvpn-client-configuration} parameter} dev dev
18793 The device type used to represent the VPN connection.
18794
18795 Defaults to @samp{tun}.
18796
18797 @end deftypevr
18798
18799 @deftypevr {@code{openvpn-client-configuration} parameter} string ca
18800 The certificate authority to check connections against.
18801
18802 Defaults to @samp{"/etc/openvpn/ca.crt"}.
18803
18804 @end deftypevr
18805
18806 @deftypevr {@code{openvpn-client-configuration} parameter} string cert
18807 The certificate of the machine the daemon is running on. It should be
18808 signed by the authority given in @code{ca}.
18809
18810 Defaults to @samp{"/etc/openvpn/client.crt"}.
18811
18812 @end deftypevr
18813
18814 @deftypevr {@code{openvpn-client-configuration} parameter} string key
18815 The key of the machine the daemon is running on. It must be the key whose
18816 certificate is @code{cert}.
18817
18818 Defaults to @samp{"/etc/openvpn/client.key"}.
18819
18820 @end deftypevr
18821
18822 @deftypevr {@code{openvpn-client-configuration} parameter} boolean comp-lzo?
18823 Whether to use the lzo compression algorithm.
18824
18825 Defaults to @samp{#t}.
18826
18827 @end deftypevr
18828
18829 @deftypevr {@code{openvpn-client-configuration} parameter} boolean persist-key?
18830 Don't re-read key files across SIGUSR1 or --ping-restart.
18831
18832 Defaults to @samp{#t}.
18833
18834 @end deftypevr
18835
18836 @deftypevr {@code{openvpn-client-configuration} parameter} boolean persist-tun?
18837 Don't close and reopen TUN/TAP device or run up/down scripts across
18838 SIGUSR1 or --ping-restart restarts.
18839
18840 Defaults to @samp{#t}.
18841
18842 @end deftypevr
18843
18844 @deftypevr {@code{openvpn-client-configuration} parameter} number verbosity
18845 Verbosity level.
18846
18847 Defaults to @samp{3}.
18848
18849 @end deftypevr
18850
18851 @deftypevr {@code{openvpn-client-configuration} parameter} tls-auth-client tls-auth
18852 Add an additional layer of HMAC authentication on top of the TLS control
18853 channel to protect against DoS attacks.
18854
18855 Defaults to @samp{#f}.
18856
18857 @end deftypevr
18858
18859 @deftypevr {@code{openvpn-client-configuration} parameter} key-usage verify-key-usage?
18860 Whether to check the server certificate has server usage extension.
18861
18862 Defaults to @samp{#t}.
18863
18864 @end deftypevr
18865
18866 @deftypevr {@code{openvpn-client-configuration} parameter} bind bind?
18867 Bind to a specific local port number.
18868
18869 Defaults to @samp{#f}.
18870
18871 @end deftypevr
18872
18873 @deftypevr {@code{openvpn-client-configuration} parameter} resolv-retry resolv-retry?
18874 Retry resolving server address.
18875
18876 Defaults to @samp{#t}.
18877
18878 @end deftypevr
18879
18880 @deftypevr {@code{openvpn-client-configuration} parameter} openvpn-remote-list remote
18881 A list of remote servers to connect to.
18882
18883 Defaults to @samp{()}.
18884
18885 Available @code{openvpn-remote-configuration} fields are:
18886
18887 @deftypevr {@code{openvpn-remote-configuration} parameter} string name
18888 Server name.
18889
18890 Defaults to @samp{"my-server"}.
18891
18892 @end deftypevr
18893
18894 @deftypevr {@code{openvpn-remote-configuration} parameter} number port
18895 Port number the server listens to.
18896
18897 Defaults to @samp{1194}.
18898
18899 @end deftypevr
18900
18901 @end deftypevr
18902 @c %end of automatic openvpn-client documentation
18903
18904 @c %automatically generated documentation
18905
18906 Available @code{openvpn-server-configuration} fields are:
18907
18908 @deftypevr {@code{openvpn-server-configuration} parameter} package openvpn
18909 The OpenVPN package.
18910
18911 @end deftypevr
18912
18913 @deftypevr {@code{openvpn-server-configuration} parameter} string pid-file
18914 The OpenVPN pid file.
18915
18916 Defaults to @samp{"/var/run/openvpn/openvpn.pid"}.
18917
18918 @end deftypevr
18919
18920 @deftypevr {@code{openvpn-server-configuration} parameter} proto proto
18921 The protocol (UDP or TCP) used to open a channel between clients and
18922 servers.
18923
18924 Defaults to @samp{udp}.
18925
18926 @end deftypevr
18927
18928 @deftypevr {@code{openvpn-server-configuration} parameter} dev dev
18929 The device type used to represent the VPN connection.
18930
18931 Defaults to @samp{tun}.
18932
18933 @end deftypevr
18934
18935 @deftypevr {@code{openvpn-server-configuration} parameter} string ca
18936 The certificate authority to check connections against.
18937
18938 Defaults to @samp{"/etc/openvpn/ca.crt"}.
18939
18940 @end deftypevr
18941
18942 @deftypevr {@code{openvpn-server-configuration} parameter} string cert
18943 The certificate of the machine the daemon is running on. It should be
18944 signed by the authority given in @code{ca}.
18945
18946 Defaults to @samp{"/etc/openvpn/client.crt"}.
18947
18948 @end deftypevr
18949
18950 @deftypevr {@code{openvpn-server-configuration} parameter} string key
18951 The key of the machine the daemon is running on. It must be the key whose
18952 certificate is @code{cert}.
18953
18954 Defaults to @samp{"/etc/openvpn/client.key"}.
18955
18956 @end deftypevr
18957
18958 @deftypevr {@code{openvpn-server-configuration} parameter} boolean comp-lzo?
18959 Whether to use the lzo compression algorithm.
18960
18961 Defaults to @samp{#t}.
18962
18963 @end deftypevr
18964
18965 @deftypevr {@code{openvpn-server-configuration} parameter} boolean persist-key?
18966 Don't re-read key files across SIGUSR1 or --ping-restart.
18967
18968 Defaults to @samp{#t}.
18969
18970 @end deftypevr
18971
18972 @deftypevr {@code{openvpn-server-configuration} parameter} boolean persist-tun?
18973 Don't close and reopen TUN/TAP device or run up/down scripts across
18974 SIGUSR1 or --ping-restart restarts.
18975
18976 Defaults to @samp{#t}.
18977
18978 @end deftypevr
18979
18980 @deftypevr {@code{openvpn-server-configuration} parameter} number verbosity
18981 Verbosity level.
18982
18983 Defaults to @samp{3}.
18984
18985 @end deftypevr
18986
18987 @deftypevr {@code{openvpn-server-configuration} parameter} tls-auth-server tls-auth
18988 Add an additional layer of HMAC authentication on top of the TLS control
18989 channel to protect against DoS attacks.
18990
18991 Defaults to @samp{#f}.
18992
18993 @end deftypevr
18994
18995 @deftypevr {@code{openvpn-server-configuration} parameter} number port
18996 Specifies the port number on which the server listens.
18997
18998 Defaults to @samp{1194}.
18999
19000 @end deftypevr
19001
19002 @deftypevr {@code{openvpn-server-configuration} parameter} ip-mask server
19003 An ip and mask specifying the subnet inside the virtual network.
19004
19005 Defaults to @samp{"10.8.0.0 255.255.255.0"}.
19006
19007 @end deftypevr
19008
19009 @deftypevr {@code{openvpn-server-configuration} parameter} cidr6 server-ipv6
19010 A CIDR notation specifying the IPv6 subnet inside the virtual network.
19011
19012 Defaults to @samp{#f}.
19013
19014 @end deftypevr
19015
19016 @deftypevr {@code{openvpn-server-configuration} parameter} string dh
19017 The Diffie-Hellman parameters file.
19018
19019 Defaults to @samp{"/etc/openvpn/dh2048.pem"}.
19020
19021 @end deftypevr
19022
19023 @deftypevr {@code{openvpn-server-configuration} parameter} string ifconfig-pool-persist
19024 The file that records client IPs.
19025
19026 Defaults to @samp{"/etc/openvpn/ipp.txt"}.
19027
19028 @end deftypevr
19029
19030 @deftypevr {@code{openvpn-server-configuration} parameter} gateway redirect-gateway?
19031 When true, the server will act as a gateway for its clients.
19032
19033 Defaults to @samp{#f}.
19034
19035 @end deftypevr
19036
19037 @deftypevr {@code{openvpn-server-configuration} parameter} boolean client-to-client?
19038 When true, clients are allowed to talk to each other inside the VPN.
19039
19040 Defaults to @samp{#f}.
19041
19042 @end deftypevr
19043
19044 @deftypevr {@code{openvpn-server-configuration} parameter} keepalive keepalive
19045 Causes ping-like messages to be sent back and forth over the link so
19046 that each side knows when the other side has gone down. @code{keepalive}
19047 requires a pair. The first element is the period of the ping sending,
19048 and the second element is the timeout before considering the other side
19049 down.
19050
19051 @end deftypevr
19052
19053 @deftypevr {@code{openvpn-server-configuration} parameter} number max-clients
19054 The maximum number of clients.
19055
19056 Defaults to @samp{100}.
19057
19058 @end deftypevr
19059
19060 @deftypevr {@code{openvpn-server-configuration} parameter} string status
19061 The status file. This file shows a small report on current connection.
19062 It is truncated and rewritten every minute.
19063
19064 Defaults to @samp{"/var/run/openvpn/status"}.
19065
19066 @end deftypevr
19067
19068 @deftypevr {@code{openvpn-server-configuration} parameter} openvpn-ccd-list client-config-dir
19069 The list of configuration for some clients.
19070
19071 Defaults to @samp{()}.
19072
19073 Available @code{openvpn-ccd-configuration} fields are:
19074
19075 @deftypevr {@code{openvpn-ccd-configuration} parameter} string name
19076 Client name.
19077
19078 Defaults to @samp{"client"}.
19079
19080 @end deftypevr
19081
19082 @deftypevr {@code{openvpn-ccd-configuration} parameter} ip-mask iroute
19083 Client own network
19084
19085 Defaults to @samp{#f}.
19086
19087 @end deftypevr
19088
19089 @deftypevr {@code{openvpn-ccd-configuration} parameter} ip-mask ifconfig-push
19090 Client VPN IP.
19091
19092 Defaults to @samp{#f}.
19093
19094 @end deftypevr
19095
19096 @end deftypevr
19097
19098
19099 @c %end of automatic openvpn-server documentation
19100
19101
19102 @node Network File System
19103 @subsection Network File System
19104 @cindex NFS
19105
19106 The @code{(gnu services nfs)} module provides the following services,
19107 which are most commonly used in relation to mounting or exporting
19108 directory trees as @dfn{network file systems} (NFS).
19109
19110 @subsubheading RPC Bind Service
19111 @cindex rpcbind
19112
19113 The RPC Bind service provides a facility to map program numbers into
19114 universal addresses.
19115 Many NFS related services use this facility. Hence it is automatically
19116 started when a dependent service starts.
19117
19118 @defvr {Scheme Variable} rpcbind-service-type
19119 A service type for the RPC portmapper daemon.
19120 @end defvr
19121
19122
19123 @deftp {Data Type} rpcbind-configuration
19124 Data type representing the configuration of the RPC Bind Service.
19125 This type has the following parameters:
19126 @table @asis
19127 @item @code{rpcbind} (default: @code{rpcbind})
19128 The rpcbind package to use.
19129
19130 @item @code{warm-start?} (default: @code{#t})
19131 If this parameter is @code{#t}, then the daemon will read a
19132 state file on startup thus reloading state information saved by a previous
19133 instance.
19134 @end table
19135 @end deftp
19136
19137
19138 @subsubheading Pipefs Pseudo File System
19139 @cindex pipefs
19140 @cindex rpc_pipefs
19141
19142 The pipefs file system is used to transfer NFS related data
19143 between the kernel and user space programs.
19144
19145 @defvr {Scheme Variable} pipefs-service-type
19146 A service type for the pipefs pseudo file system.
19147 @end defvr
19148
19149 @deftp {Data Type} pipefs-configuration
19150 Data type representing the configuration of the pipefs pseudo file system service.
19151 This type has the following parameters:
19152 @table @asis
19153 @item @code{mount-point} (default: @code{"/var/lib/nfs/rpc_pipefs"})
19154 The directory to which the file system is to be attached.
19155 @end table
19156 @end deftp
19157
19158
19159 @subsubheading GSS Daemon Service
19160 @cindex GSSD
19161 @cindex GSS
19162 @cindex global security system
19163
19164 The @dfn{global security system} (GSS) daemon provides strong security for RPC
19165 based protocols.
19166 Before exchanging RPC requests an RPC client must establish a security
19167 context. Typically this is done using the Kerberos command @command{kinit}
19168 or automatically at login time using PAM services (@pxref{Kerberos Services}).
19169
19170 @defvr {Scheme Variable} gss-service-type
19171 A service type for the Global Security System (GSS) daemon.
19172 @end defvr
19173
19174 @deftp {Data Type} gss-configuration
19175 Data type representing the configuration of the GSS daemon service.
19176 This type has the following parameters:
19177 @table @asis
19178 @item @code{nfs-utils} (default: @code{nfs-utils})
19179 The package in which the @command{rpc.gssd} command is to be found.
19180
19181 @item @code{pipefs-directory} (default: @code{"/var/lib/nfs/rpc_pipefs"})
19182 The directory where the pipefs file system is mounted.
19183
19184 @end table
19185 @end deftp
19186
19187
19188 @subsubheading IDMAP Daemon Service
19189 @cindex idmapd
19190 @cindex name mapper
19191
19192 The idmap daemon service provides mapping between user IDs and user names.
19193 Typically it is required in order to access file systems mounted via NFSv4.
19194
19195 @defvr {Scheme Variable} idmap-service-type
19196 A service type for the Identity Mapper (IDMAP) daemon.
19197 @end defvr
19198
19199 @deftp {Data Type} idmap-configuration
19200 Data type representing the configuration of the IDMAP daemon service.
19201 This type has the following parameters:
19202 @table @asis
19203 @item @code{nfs-utils} (default: @code{nfs-utils})
19204 The package in which the @command{rpc.idmapd} command is to be found.
19205
19206 @item @code{pipefs-directory} (default: @code{"/var/lib/nfs/rpc_pipefs"})
19207 The directory where the pipefs file system is mounted.
19208
19209 @item @code{domain} (default: @code{#f})
19210 The local NFSv4 domain name.
19211 This must be a string or @code{#f}.
19212 If it is @code{#f} then the daemon will use the host's fully qualified domain name.
19213
19214 @end table
19215 @end deftp
19216
19217 @node Continuous Integration
19218 @subsection Continuous Integration
19219
19220 @cindex continuous integration
19221 @uref{https://git.savannah.gnu.org/cgit/guix/guix-cuirass.git, Cuirass} is a
19222 continuous integration tool for Guix. It can be used both for development and
19223 for providing substitutes to others (@pxref{Substitutes}).
19224
19225 The @code{(gnu services cuirass)} module provides the following service.
19226
19227 @defvr {Scheme Procedure} cuirass-service-type
19228 The type of the Cuirass service. Its value must be a
19229 @code{cuirass-configuration} object, as described below.
19230 @end defvr
19231
19232 To add build jobs, you have to set the @code{specifications} field of the
19233 configuration. Here is an example of a service that polls the Guix repository
19234 and builds the packages from a manifest. Some of the packages are defined in
19235 the @code{"custom-packages"} input, which is the equivalent of
19236 @code{GUIX_PACKAGE_PATH}.
19237
19238 @example
19239 (define %cuirass-specs
19240 #~(list
19241 '((#:name . "my-manifest")
19242 (#:load-path-inputs . ("guix"))
19243 (#:package-path-inputs . ("custom-packages"))
19244 (#:proc-input . "guix")
19245 (#:proc-file . "build-aux/cuirass/gnu-system.scm")
19246 (#:proc . cuirass-jobs)
19247 (#:proc-args . ((subset . "manifests")
19248 (systems . ("x86_64-linux"))
19249 (manifests . (("config" . "guix/manifest.scm")))))
19250 (#:inputs . (((#:name . "guix")
19251 (#:url . "git://git.savannah.gnu.org/guix.git")
19252 (#:load-path . ".")
19253 (#:branch . "master")
19254 (#:no-compile? . #t))
19255 ((#:name . "config")
19256 (#:url . "git://git.example.org/config.git")
19257 (#:load-path . ".")
19258 (#:branch . "master")
19259 (#:no-compile? . #t))
19260 ((#:name . "custom-packages")
19261 (#:url . "git://git.example.org/custom-packages.git")
19262 (#:load-path . ".")
19263 (#:branch . "master")
19264 (#:no-compile? . #t)))))))
19265
19266 (service cuirass-service-type
19267 (cuirass-configuration
19268 (specifications %cuirass-specs)))
19269 @end example
19270
19271 While information related to build jobs is located directly in the
19272 specifications, global settings for the @command{cuirass} process are
19273 accessible in other @code{cuirass-configuration} fields.
19274
19275 @deftp {Data Type} cuirass-configuration
19276 Data type representing the configuration of Cuirass.
19277
19278 @table @asis
19279 @item @code{log-file} (default: @code{"/var/log/cuirass.log"})
19280 Location of the log file.
19281
19282 @item @code{cache-directory} (default: @code{"/var/cache/cuirass"})
19283 Location of the repository cache.
19284
19285 @item @code{user} (default: @code{"cuirass"})
19286 Owner of the @code{cuirass} process.
19287
19288 @item @code{group} (default: @code{"cuirass"})
19289 Owner's group of the @code{cuirass} process.
19290
19291 @item @code{interval} (default: @code{60})
19292 Number of seconds between the poll of the repositories followed by the
19293 Cuirass jobs.
19294
19295 @item @code{database} (default: @code{"/var/lib/cuirass/cuirass.db"})
19296 Location of sqlite database which contains the build results and previously
19297 added specifications.
19298
19299 @item @code{ttl} (default: @code{(* 30 24 3600)})
19300 Specifies the time-to-live (TTL) in seconds of garbage collector roots that
19301 are registered for build results. This means that build results are protected
19302 from garbage collection for at least @var{ttl} seconds.
19303
19304 @item @code{port} (default: @code{8081})
19305 Port number used by the HTTP server.
19306
19307 @item --listen=@var{host}
19308 Listen on the network interface for @var{host}. The default is to
19309 accept connections from localhost.
19310
19311 @item @code{specifications} (default: @code{#~'()})
19312 A gexp (@pxref{G-Expressions}) that evaluates to a list of specifications,
19313 where a specification is an association list
19314 (@pxref{Associations Lists,,, guile, GNU Guile Reference Manual}) whose
19315 keys are keywords (@code{#:keyword-example}) as shown in the example
19316 above.
19317
19318 @item @code{use-substitutes?} (default: @code{#f})
19319 This allows using substitutes to avoid building every dependencies of a job
19320 from source.
19321
19322 @item @code{one-shot?} (default: @code{#f})
19323 Only evaluate specifications and build derivations once.
19324
19325 @item @code{fallback?} (default: @code{#f})
19326 When substituting a pre-built binary fails, fall back to building
19327 packages locally.
19328
19329 @item @code{cuirass} (default: @code{cuirass})
19330 The Cuirass package to use.
19331 @end table
19332 @end deftp
19333
19334 @node Power Management Services
19335 @subsection Power Management Services
19336
19337 @cindex tlp
19338 @cindex power management with TLP
19339 @subsubheading TLP daemon
19340
19341 The @code{(gnu services pm)} module provides a Guix service definition
19342 for the Linux power management tool TLP.
19343
19344 TLP enables various powersaving modes in userspace and kernel.
19345 Contrary to @code{upower-service}, it is not a passive,
19346 monitoring tool, as it will apply custom settings each time a new power
19347 source is detected. More information can be found at
19348 @uref{http://linrunner.de/en/tlp/tlp.html, TLP home page}.
19349
19350 @deffn {Scheme Variable} tlp-service-type
19351 The service type for the TLP tool. Its value should be a valid
19352 TLP configuration (see below). To use the default settings, simply
19353 write:
19354 @example
19355 (service tlp-service-type)
19356 @end example
19357 @end deffn
19358
19359 By default TLP does not need much configuration but most TLP parameters
19360 can be tweaked using @code{tlp-configuration}.
19361
19362 Each parameter definition is preceded by its type; for example,
19363 @samp{boolean foo} indicates that the @code{foo} parameter
19364 should be specified as a boolean. Types starting with
19365 @code{maybe-} denote parameters that won't show up in TLP config file
19366 when their value is @code{'disabled}.
19367
19368 @c The following documentation was initially generated by
19369 @c (generate-tlp-documentation) in (gnu services pm). Manually maintained
19370 @c documentation is better, so we shouldn't hesitate to edit below as
19371 @c needed. However if the change you want to make to this documentation
19372 @c can be done in an automated way, it's probably easier to change
19373 @c (generate-documentation) than to make it below and have to deal with
19374 @c the churn as TLP updates.
19375
19376 Available @code{tlp-configuration} fields are:
19377
19378 @deftypevr {@code{tlp-configuration} parameter} package tlp
19379 The TLP package.
19380
19381 @end deftypevr
19382
19383 @deftypevr {@code{tlp-configuration} parameter} boolean tlp-enable?
19384 Set to true if you wish to enable TLP.
19385
19386 Defaults to @samp{#t}.
19387
19388 @end deftypevr
19389
19390 @deftypevr {@code{tlp-configuration} parameter} string tlp-default-mode
19391 Default mode when no power supply can be detected. Alternatives are AC
19392 and BAT.
19393
19394 Defaults to @samp{"AC"}.
19395
19396 @end deftypevr
19397
19398 @deftypevr {@code{tlp-configuration} parameter} non-negative-integer disk-idle-secs-on-ac
19399 Number of seconds Linux kernel has to wait after the disk goes idle,
19400 before syncing on AC.
19401
19402 Defaults to @samp{0}.
19403
19404 @end deftypevr
19405
19406 @deftypevr {@code{tlp-configuration} parameter} non-negative-integer disk-idle-secs-on-bat
19407 Same as @code{disk-idle-ac} but on BAT mode.
19408
19409 Defaults to @samp{2}.
19410
19411 @end deftypevr
19412
19413 @deftypevr {@code{tlp-configuration} parameter} non-negative-integer max-lost-work-secs-on-ac
19414 Dirty pages flushing periodicity, expressed in seconds.
19415
19416 Defaults to @samp{15}.
19417
19418 @end deftypevr
19419
19420 @deftypevr {@code{tlp-configuration} parameter} non-negative-integer max-lost-work-secs-on-bat
19421 Same as @code{max-lost-work-secs-on-ac} but on BAT mode.
19422
19423 Defaults to @samp{60}.
19424
19425 @end deftypevr
19426
19427 @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list cpu-scaling-governor-on-ac
19428 CPU frequency scaling governor on AC mode. With intel_pstate driver,
19429 alternatives are powersave and performance. With acpi-cpufreq driver,
19430 alternatives are ondemand, powersave, performance and conservative.
19431
19432 Defaults to @samp{disabled}.
19433
19434 @end deftypevr
19435
19436 @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list cpu-scaling-governor-on-bat
19437 Same as @code{cpu-scaling-governor-on-ac} but on BAT mode.
19438
19439 Defaults to @samp{disabled}.
19440
19441 @end deftypevr
19442
19443 @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-scaling-min-freq-on-ac
19444 Set the min available frequency for the scaling governor on AC.
19445
19446 Defaults to @samp{disabled}.
19447
19448 @end deftypevr
19449
19450 @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-scaling-max-freq-on-ac
19451 Set the max available frequency for the scaling governor on AC.
19452
19453 Defaults to @samp{disabled}.
19454
19455 @end deftypevr
19456
19457 @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-scaling-min-freq-on-bat
19458 Set the min available frequency for the scaling governor on BAT.
19459
19460 Defaults to @samp{disabled}.
19461
19462 @end deftypevr
19463
19464 @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-scaling-max-freq-on-bat
19465 Set the max available frequency for the scaling governor on BAT.
19466
19467 Defaults to @samp{disabled}.
19468
19469 @end deftypevr
19470
19471 @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-min-perf-on-ac
19472 Limit the min P-state to control the power dissipation of the CPU, in AC
19473 mode. Values are stated as a percentage of the available performance.
19474
19475 Defaults to @samp{disabled}.
19476
19477 @end deftypevr
19478
19479 @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-max-perf-on-ac
19480 Limit the max P-state to control the power dissipation of the CPU, in AC
19481 mode. Values are stated as a percentage of the available performance.
19482
19483 Defaults to @samp{disabled}.
19484
19485 @end deftypevr
19486
19487 @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-min-perf-on-bat
19488 Same as @code{cpu-min-perf-on-ac} on BAT mode.
19489
19490 Defaults to @samp{disabled}.
19491
19492 @end deftypevr
19493
19494 @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-max-perf-on-bat
19495 Same as @code{cpu-max-perf-on-ac} on BAT mode.
19496
19497 Defaults to @samp{disabled}.
19498
19499 @end deftypevr
19500
19501 @deftypevr {@code{tlp-configuration} parameter} maybe-boolean cpu-boost-on-ac?
19502 Enable CPU turbo boost feature on AC mode.
19503
19504 Defaults to @samp{disabled}.
19505
19506 @end deftypevr
19507
19508 @deftypevr {@code{tlp-configuration} parameter} maybe-boolean cpu-boost-on-bat?
19509 Same as @code{cpu-boost-on-ac?} on BAT mode.
19510
19511 Defaults to @samp{disabled}.
19512
19513 @end deftypevr
19514
19515 @deftypevr {@code{tlp-configuration} parameter} boolean sched-powersave-on-ac?
19516 Allow Linux kernel to minimize the number of CPU cores/hyper-threads
19517 used under light load conditions.
19518
19519 Defaults to @samp{#f}.
19520
19521 @end deftypevr
19522
19523 @deftypevr {@code{tlp-configuration} parameter} boolean sched-powersave-on-bat?
19524 Same as @code{sched-powersave-on-ac?} but on BAT mode.
19525
19526 Defaults to @samp{#t}.
19527
19528 @end deftypevr
19529
19530 @deftypevr {@code{tlp-configuration} parameter} boolean nmi-watchdog?
19531 Enable Linux kernel NMI watchdog.
19532
19533 Defaults to @samp{#f}.
19534
19535 @end deftypevr
19536
19537 @deftypevr {@code{tlp-configuration} parameter} maybe-string phc-controls
19538 For Linux kernels with PHC patch applied, change CPU voltages. An
19539 example value would be @samp{"F:V F:V F:V F:V"}.
19540
19541 Defaults to @samp{disabled}.
19542
19543 @end deftypevr
19544
19545 @deftypevr {@code{tlp-configuration} parameter} string energy-perf-policy-on-ac
19546 Set CPU performance versus energy saving policy on AC. Alternatives are
19547 performance, normal, powersave.
19548
19549 Defaults to @samp{"performance"}.
19550
19551 @end deftypevr
19552
19553 @deftypevr {@code{tlp-configuration} parameter} string energy-perf-policy-on-bat
19554 Same as @code{energy-perf-policy-ac} but on BAT mode.
19555
19556 Defaults to @samp{"powersave"}.
19557
19558 @end deftypevr
19559
19560 @deftypevr {@code{tlp-configuration} parameter} space-separated-string-list disks-devices
19561 Hard disk devices.
19562
19563 @end deftypevr
19564
19565 @deftypevr {@code{tlp-configuration} parameter} space-separated-string-list disk-apm-level-on-ac
19566 Hard disk advanced power management level.
19567
19568 @end deftypevr
19569
19570 @deftypevr {@code{tlp-configuration} parameter} space-separated-string-list disk-apm-level-on-bat
19571 Same as @code{disk-apm-bat} but on BAT mode.
19572
19573 @end deftypevr
19574
19575 @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list disk-spindown-timeout-on-ac
19576 Hard disk spin down timeout. One value has to be specified for each
19577 declared hard disk.
19578
19579 Defaults to @samp{disabled}.
19580
19581 @end deftypevr
19582
19583 @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list disk-spindown-timeout-on-bat
19584 Same as @code{disk-spindown-timeout-on-ac} but on BAT mode.
19585
19586 Defaults to @samp{disabled}.
19587
19588 @end deftypevr
19589
19590 @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list disk-iosched
19591 Select IO scheduler for disk devices. One value has to be specified for
19592 each declared hard disk. Example alternatives are cfq, deadline and
19593 noop.
19594
19595 Defaults to @samp{disabled}.
19596
19597 @end deftypevr
19598
19599 @deftypevr {@code{tlp-configuration} parameter} string sata-linkpwr-on-ac
19600 SATA aggressive link power management (ALPM) level. Alternatives are
19601 min_power, medium_power, max_performance.
19602
19603 Defaults to @samp{"max_performance"}.
19604
19605 @end deftypevr
19606
19607 @deftypevr {@code{tlp-configuration} parameter} string sata-linkpwr-on-bat
19608 Same as @code{sata-linkpwr-ac} but on BAT mode.
19609
19610 Defaults to @samp{"min_power"}.
19611
19612 @end deftypevr
19613
19614 @deftypevr {@code{tlp-configuration} parameter} maybe-string sata-linkpwr-blacklist
19615 Exclude specified SATA host devices for link power management.
19616
19617 Defaults to @samp{disabled}.
19618
19619 @end deftypevr
19620
19621 @deftypevr {@code{tlp-configuration} parameter} maybe-on-off-boolean ahci-runtime-pm-on-ac?
19622 Enable Runtime Power Management for AHCI controller and disks on AC
19623 mode.
19624
19625 Defaults to @samp{disabled}.
19626
19627 @end deftypevr
19628
19629 @deftypevr {@code{tlp-configuration} parameter} maybe-on-off-boolean ahci-runtime-pm-on-bat?
19630 Same as @code{ahci-runtime-pm-on-ac} on BAT mode.
19631
19632 Defaults to @samp{disabled}.
19633
19634 @end deftypevr
19635
19636 @deftypevr {@code{tlp-configuration} parameter} non-negative-integer ahci-runtime-pm-timeout
19637 Seconds of inactivity before disk is suspended.
19638
19639 Defaults to @samp{15}.
19640
19641 @end deftypevr
19642
19643 @deftypevr {@code{tlp-configuration} parameter} string pcie-aspm-on-ac
19644 PCI Express Active State Power Management level. Alternatives are
19645 default, performance, powersave.
19646
19647 Defaults to @samp{"performance"}.
19648
19649 @end deftypevr
19650
19651 @deftypevr {@code{tlp-configuration} parameter} string pcie-aspm-on-bat
19652 Same as @code{pcie-aspm-ac} but on BAT mode.
19653
19654 Defaults to @samp{"powersave"}.
19655
19656 @end deftypevr
19657
19658 @deftypevr {@code{tlp-configuration} parameter} string radeon-power-profile-on-ac
19659 Radeon graphics clock speed level. Alternatives are low, mid, high,
19660 auto, default.
19661
19662 Defaults to @samp{"high"}.
19663
19664 @end deftypevr
19665
19666 @deftypevr {@code{tlp-configuration} parameter} string radeon-power-profile-on-bat
19667 Same as @code{radeon-power-ac} but on BAT mode.
19668
19669 Defaults to @samp{"low"}.
19670
19671 @end deftypevr
19672
19673 @deftypevr {@code{tlp-configuration} parameter} string radeon-dpm-state-on-ac
19674 Radeon dynamic power management method (DPM). Alternatives are battery,
19675 performance.
19676
19677 Defaults to @samp{"performance"}.
19678
19679 @end deftypevr
19680
19681 @deftypevr {@code{tlp-configuration} parameter} string radeon-dpm-state-on-bat
19682 Same as @code{radeon-dpm-state-ac} but on BAT mode.
19683
19684 Defaults to @samp{"battery"}.
19685
19686 @end deftypevr
19687
19688 @deftypevr {@code{tlp-configuration} parameter} string radeon-dpm-perf-level-on-ac
19689 Radeon DPM performance level. Alternatives are auto, low, high.
19690
19691 Defaults to @samp{"auto"}.
19692
19693 @end deftypevr
19694
19695 @deftypevr {@code{tlp-configuration} parameter} string radeon-dpm-perf-level-on-bat
19696 Same as @code{radeon-dpm-perf-ac} but on BAT mode.
19697
19698 Defaults to @samp{"auto"}.
19699
19700 @end deftypevr
19701
19702 @deftypevr {@code{tlp-configuration} parameter} on-off-boolean wifi-pwr-on-ac?
19703 Wifi power saving mode.
19704
19705 Defaults to @samp{#f}.
19706
19707 @end deftypevr
19708
19709 @deftypevr {@code{tlp-configuration} parameter} on-off-boolean wifi-pwr-on-bat?
19710 Same as @code{wifi-power-ac?} but on BAT mode.
19711
19712 Defaults to @samp{#t}.
19713
19714 @end deftypevr
19715
19716 @deftypevr {@code{tlp-configuration} parameter} y-n-boolean wol-disable?
19717 Disable wake on LAN.
19718
19719 Defaults to @samp{#t}.
19720
19721 @end deftypevr
19722
19723 @deftypevr {@code{tlp-configuration} parameter} non-negative-integer sound-power-save-on-ac
19724 Timeout duration in seconds before activating audio power saving on
19725 Intel HDA and AC97 devices. A value of 0 disables power saving.
19726
19727 Defaults to @samp{0}.
19728
19729 @end deftypevr
19730
19731 @deftypevr {@code{tlp-configuration} parameter} non-negative-integer sound-power-save-on-bat
19732 Same as @code{sound-powersave-ac} but on BAT mode.
19733
19734 Defaults to @samp{1}.
19735
19736 @end deftypevr
19737
19738 @deftypevr {@code{tlp-configuration} parameter} y-n-boolean sound-power-save-controller?
19739 Disable controller in powersaving mode on Intel HDA devices.
19740
19741 Defaults to @samp{#t}.
19742
19743 @end deftypevr
19744
19745 @deftypevr {@code{tlp-configuration} parameter} boolean bay-poweroff-on-bat?
19746 Enable optical drive in UltraBay/MediaBay on BAT mode. Drive can be
19747 powered on again by releasing (and reinserting) the eject lever or by
19748 pressing the disc eject button on newer models.
19749
19750 Defaults to @samp{#f}.
19751
19752 @end deftypevr
19753
19754 @deftypevr {@code{tlp-configuration} parameter} string bay-device
19755 Name of the optical drive device to power off.
19756
19757 Defaults to @samp{"sr0"}.
19758
19759 @end deftypevr
19760
19761 @deftypevr {@code{tlp-configuration} parameter} string runtime-pm-on-ac
19762 Runtime Power Management for PCI(e) bus devices. Alternatives are on
19763 and auto.
19764
19765 Defaults to @samp{"on"}.
19766
19767 @end deftypevr
19768
19769 @deftypevr {@code{tlp-configuration} parameter} string runtime-pm-on-bat
19770 Same as @code{runtime-pm-ac} but on BAT mode.
19771
19772 Defaults to @samp{"auto"}.
19773
19774 @end deftypevr
19775
19776 @deftypevr {@code{tlp-configuration} parameter} boolean runtime-pm-all?
19777 Runtime Power Management for all PCI(e) bus devices, except blacklisted
19778 ones.
19779
19780 Defaults to @samp{#t}.
19781
19782 @end deftypevr
19783
19784 @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list runtime-pm-blacklist
19785 Exclude specified PCI(e) device addresses from Runtime Power Management.
19786
19787 Defaults to @samp{disabled}.
19788
19789 @end deftypevr
19790
19791 @deftypevr {@code{tlp-configuration} parameter} space-separated-string-list runtime-pm-driver-blacklist
19792 Exclude PCI(e) devices assigned to the specified drivers from Runtime
19793 Power Management.
19794
19795 @end deftypevr
19796
19797 @deftypevr {@code{tlp-configuration} parameter} boolean usb-autosuspend?
19798 Enable USB autosuspend feature.
19799
19800 Defaults to @samp{#t}.
19801
19802 @end deftypevr
19803
19804 @deftypevr {@code{tlp-configuration} parameter} maybe-string usb-blacklist
19805 Exclude specified devices from USB autosuspend.
19806
19807 Defaults to @samp{disabled}.
19808
19809 @end deftypevr
19810
19811 @deftypevr {@code{tlp-configuration} parameter} boolean usb-blacklist-wwan?
19812 Exclude WWAN devices from USB autosuspend.
19813
19814 Defaults to @samp{#t}.
19815
19816 @end deftypevr
19817
19818 @deftypevr {@code{tlp-configuration} parameter} maybe-string usb-whitelist
19819 Include specified devices into USB autosuspend, even if they are already
19820 excluded by the driver or via @code{usb-blacklist-wwan?}.
19821
19822 Defaults to @samp{disabled}.
19823
19824 @end deftypevr
19825
19826 @deftypevr {@code{tlp-configuration} parameter} maybe-boolean usb-autosuspend-disable-on-shutdown?
19827 Enable USB autosuspend before shutdown.
19828
19829 Defaults to @samp{disabled}.
19830
19831 @end deftypevr
19832
19833 @deftypevr {@code{tlp-configuration} parameter} boolean restore-device-state-on-startup?
19834 Restore radio device state (bluetooth, wifi, wwan) from previous
19835 shutdown on system startup.
19836
19837 Defaults to @samp{#f}.
19838
19839 @end deftypevr
19840
19841 @cindex thermald
19842 @cindex CPU frequency scaling with thermald
19843 @subsubheading Thermald daemon
19844
19845 The @code{(gnu services pm)} module provides an interface to
19846 thermald, a CPU frequency scaling service which helps prevent overheating.
19847
19848 @defvr {Scheme Variable} thermald-service-type
19849 This is the service type for
19850 @uref{https://01.org/linux-thermal-daemon/, thermald}, the Linux
19851 Thermal Daemon, which is responsible for controlling the thermal state
19852 of processors and preventing overheating.
19853 @end defvr
19854
19855 @deftp {Data Type} thermald-configuration
19856 Data type representing the configuration of @code{thermald-service-type}.
19857
19858 @table @asis
19859 @item @code{ignore-cpuid-check?} (default: @code{#f})
19860 Ignore cpuid check for supported CPU models.
19861
19862 @item @code{thermald} (default: @var{thermald})
19863 Package object of thermald.
19864
19865 @end table
19866 @end deftp
19867
19868 @node Audio Services
19869 @subsection Audio Services
19870
19871 The @code{(gnu services audio)} module provides a service to start MPD
19872 (the Music Player Daemon).
19873
19874 @cindex mpd
19875 @subsubheading Music Player Daemon
19876
19877 The Music Player Daemon (MPD) is a service that can play music while
19878 being controlled from the local machine or over the network by a variety
19879 of clients.
19880
19881 The following example shows how one might run @code{mpd} as user
19882 @code{"bob"} on port @code{6666}. It uses pulseaudio for output.
19883
19884 @example
19885 (service mpd-service-type
19886 (mpd-configuration
19887 (user "bob")
19888 (port "6666")))
19889 @end example
19890
19891 @defvr {Scheme Variable} mpd-service-type
19892 The service type for @command{mpd}
19893 @end defvr
19894
19895 @deftp {Data Type} mpd-configuration
19896 Data type representing the configuration of @command{mpd}.
19897
19898 @table @asis
19899 @item @code{user} (default: @code{"mpd"})
19900 The user to run mpd as.
19901
19902 @item @code{music-dir} (default: @code{"~/Music"})
19903 The directory to scan for music files.
19904
19905 @item @code{playlist-dir} (default: @code{"~/.mpd/playlists"})
19906 The directory to store playlists.
19907
19908 @item @code{port} (default: @code{"6600"})
19909 The port to run mpd on.
19910
19911 @item @code{address} (default: @code{"any"})
19912 The address that mpd will bind to. To use a Unix domain socket,
19913 an absolute path can be specified here.
19914
19915 @end table
19916 @end deftp
19917
19918 @node Virtualization Services
19919 @subsection Virtualization services
19920
19921 The @code{(gnu services virtualization)} module provides services for
19922 the libvirt and virtlog daemons, as well as other virtualization-related
19923 services.
19924
19925 @subsubheading Libvirt daemon
19926 @code{libvirtd} is the server side daemon component of the libvirt
19927 virtualization management system. This daemon runs on host servers
19928 and performs required management tasks for virtualized guests.
19929
19930 @deffn {Scheme Variable} libvirt-service-type
19931 This is the type of the @uref{https://libvirt.org, libvirt daemon}.
19932 Its value must be a @code{libvirt-configuration}.
19933
19934 @example
19935 (service libvirt-service-type
19936 (libvirt-configuration
19937 (unix-sock-group "libvirt")
19938 (tls-port "16555")))
19939 @end example
19940 @end deffn
19941
19942 @c Auto-generated with (generate-libvirt-documentation)
19943 Available @code{libvirt-configuration} fields are:
19944
19945 @deftypevr {@code{libvirt-configuration} parameter} package libvirt
19946 Libvirt package.
19947
19948 @end deftypevr
19949
19950 @deftypevr {@code{libvirt-configuration} parameter} boolean listen-tls?
19951 Flag listening for secure TLS connections on the public TCP/IP port.
19952 must set @code{listen} for this to have any effect.
19953
19954 It is necessary to setup a CA and issue server certificates before using
19955 this capability.
19956
19957 Defaults to @samp{#t}.
19958
19959 @end deftypevr
19960
19961 @deftypevr {@code{libvirt-configuration} parameter} boolean listen-tcp?
19962 Listen for unencrypted TCP connections on the public TCP/IP port. must
19963 set @code{listen} for this to have any effect.
19964
19965 Using the TCP socket requires SASL authentication by default. Only SASL
19966 mechanisms which support data encryption are allowed. This is
19967 DIGEST_MD5 and GSSAPI (Kerberos5)
19968
19969 Defaults to @samp{#f}.
19970
19971 @end deftypevr
19972
19973 @deftypevr {@code{libvirt-configuration} parameter} string tls-port
19974 Port for accepting secure TLS connections This can be a port number, or
19975 service name
19976
19977 Defaults to @samp{"16514"}.
19978
19979 @end deftypevr
19980
19981 @deftypevr {@code{libvirt-configuration} parameter} string tcp-port
19982 Port for accepting insecure TCP connections This can be a port number,
19983 or service name
19984
19985 Defaults to @samp{"16509"}.
19986
19987 @end deftypevr
19988
19989 @deftypevr {@code{libvirt-configuration} parameter} string listen-addr
19990 IP address or hostname used for client connections.
19991
19992 Defaults to @samp{"0.0.0.0"}.
19993
19994 @end deftypevr
19995
19996 @deftypevr {@code{libvirt-configuration} parameter} boolean mdns-adv?
19997 Flag toggling mDNS advertisement of the libvirt service.
19998
19999 Alternatively can disable for all services on a host by stopping the
20000 Avahi daemon.
20001
20002 Defaults to @samp{#f}.
20003
20004 @end deftypevr
20005
20006 @deftypevr {@code{libvirt-configuration} parameter} string mdns-name
20007 Default mDNS advertisement name. This must be unique on the immediate
20008 broadcast network.
20009
20010 Defaults to @samp{"Virtualization Host <hostname>"}.
20011
20012 @end deftypevr
20013
20014 @deftypevr {@code{libvirt-configuration} parameter} string unix-sock-group
20015 UNIX domain socket group ownership. This can be used to allow a
20016 'trusted' set of users access to management capabilities without
20017 becoming root.
20018
20019 Defaults to @samp{"root"}.
20020
20021 @end deftypevr
20022
20023 @deftypevr {@code{libvirt-configuration} parameter} string unix-sock-ro-perms
20024 UNIX socket permissions for the R/O socket. This is used for monitoring
20025 VM status only.
20026
20027 Defaults to @samp{"0777"}.
20028
20029 @end deftypevr
20030
20031 @deftypevr {@code{libvirt-configuration} parameter} string unix-sock-rw-perms
20032 UNIX socket permissions for the R/W socket. Default allows only root.
20033 If PolicyKit is enabled on the socket, the default will change to allow
20034 everyone (eg, 0777)
20035
20036 Defaults to @samp{"0770"}.
20037
20038 @end deftypevr
20039
20040 @deftypevr {@code{libvirt-configuration} parameter} string unix-sock-admin-perms
20041 UNIX socket permissions for the admin socket. Default allows only owner
20042 (root), do not change it unless you are sure to whom you are exposing
20043 the access to.
20044
20045 Defaults to @samp{"0777"}.
20046
20047 @end deftypevr
20048
20049 @deftypevr {@code{libvirt-configuration} parameter} string unix-sock-dir
20050 The directory in which sockets will be found/created.
20051
20052 Defaults to @samp{"/var/run/libvirt"}.
20053
20054 @end deftypevr
20055
20056 @deftypevr {@code{libvirt-configuration} parameter} string auth-unix-ro
20057 Authentication scheme for UNIX read-only sockets. By default socket
20058 permissions allow anyone to connect
20059
20060 Defaults to @samp{"polkit"}.
20061
20062 @end deftypevr
20063
20064 @deftypevr {@code{libvirt-configuration} parameter} string auth-unix-rw
20065 Authentication scheme for UNIX read-write sockets. By default socket
20066 permissions only allow root. If PolicyKit support was compiled into
20067 libvirt, the default will be to use 'polkit' auth.
20068
20069 Defaults to @samp{"polkit"}.
20070
20071 @end deftypevr
20072
20073 @deftypevr {@code{libvirt-configuration} parameter} string auth-tcp
20074 Authentication scheme for TCP sockets. If you don't enable SASL, then
20075 all TCP traffic is cleartext. Don't do this outside of a dev/test
20076 scenario.
20077
20078 Defaults to @samp{"sasl"}.
20079
20080 @end deftypevr
20081
20082 @deftypevr {@code{libvirt-configuration} parameter} string auth-tls
20083 Authentication scheme for TLS sockets. TLS sockets already have
20084 encryption provided by the TLS layer, and limited authentication is done
20085 by certificates.
20086
20087 It is possible to make use of any SASL authentication mechanism as well,
20088 by using 'sasl' for this option
20089
20090 Defaults to @samp{"none"}.
20091
20092 @end deftypevr
20093
20094 @deftypevr {@code{libvirt-configuration} parameter} optional-list access-drivers
20095 API access control scheme.
20096
20097 By default an authenticated user is allowed access to all APIs. Access
20098 drivers can place restrictions on this.
20099
20100 Defaults to @samp{()}.
20101
20102 @end deftypevr
20103
20104 @deftypevr {@code{libvirt-configuration} parameter} string key-file
20105 Server key file path. If set to an empty string, then no private key is
20106 loaded.
20107
20108 Defaults to @samp{""}.
20109
20110 @end deftypevr
20111
20112 @deftypevr {@code{libvirt-configuration} parameter} string cert-file
20113 Server key file path. If set to an empty string, then no certificate is
20114 loaded.
20115
20116 Defaults to @samp{""}.
20117
20118 @end deftypevr
20119
20120 @deftypevr {@code{libvirt-configuration} parameter} string ca-file
20121 Server key file path. If set to an empty string, then no CA certificate
20122 is loaded.
20123
20124 Defaults to @samp{""}.
20125
20126 @end deftypevr
20127
20128 @deftypevr {@code{libvirt-configuration} parameter} string crl-file
20129 Certificate revocation list path. If set to an empty string, then no
20130 CRL is loaded.
20131
20132 Defaults to @samp{""}.
20133
20134 @end deftypevr
20135
20136 @deftypevr {@code{libvirt-configuration} parameter} boolean tls-no-sanity-cert
20137 Disable verification of our own server certificates.
20138
20139 When libvirtd starts it performs some sanity checks against its own
20140 certificates.
20141
20142 Defaults to @samp{#f}.
20143
20144 @end deftypevr
20145
20146 @deftypevr {@code{libvirt-configuration} parameter} boolean tls-no-verify-cert
20147 Disable verification of client certificates.
20148
20149 Client certificate verification is the primary authentication mechanism.
20150 Any client which does not present a certificate signed by the CA will be
20151 rejected.
20152
20153 Defaults to @samp{#f}.
20154
20155 @end deftypevr
20156
20157 @deftypevr {@code{libvirt-configuration} parameter} optional-list tls-allowed-dn-list
20158 Whitelist of allowed x509 Distinguished Name.
20159
20160 Defaults to @samp{()}.
20161
20162 @end deftypevr
20163
20164 @deftypevr {@code{libvirt-configuration} parameter} optional-list sasl-allowed-usernames
20165 Whitelist of allowed SASL usernames. The format for username depends on
20166 the SASL authentication mechanism.
20167
20168 Defaults to @samp{()}.
20169
20170 @end deftypevr
20171
20172 @deftypevr {@code{libvirt-configuration} parameter} string tls-priority
20173 Override the compile time default TLS priority string. The default is
20174 usually "NORMAL" unless overridden at build time. Only set this is it
20175 is desired for libvirt to deviate from the global default settings.
20176
20177 Defaults to @samp{"NORMAL"}.
20178
20179 @end deftypevr
20180
20181 @deftypevr {@code{libvirt-configuration} parameter} integer max-clients
20182 Maximum number of concurrent client connections to allow over all
20183 sockets combined.
20184
20185 Defaults to @samp{5000}.
20186
20187 @end deftypevr
20188
20189 @deftypevr {@code{libvirt-configuration} parameter} integer max-queued-clients
20190 Maximum length of queue of connections waiting to be accepted by the
20191 daemon. Note, that some protocols supporting retransmission may obey
20192 this so that a later reattempt at connection succeeds.
20193
20194 Defaults to @samp{1000}.
20195
20196 @end deftypevr
20197
20198 @deftypevr {@code{libvirt-configuration} parameter} integer max-anonymous-clients
20199 Maximum length of queue of accepted but not yet authenticated clients.
20200 Set this to zero to turn this feature off
20201
20202 Defaults to @samp{20}.
20203
20204 @end deftypevr
20205
20206 @deftypevr {@code{libvirt-configuration} parameter} integer min-workers
20207 Number of workers to start up initially.
20208
20209 Defaults to @samp{5}.
20210
20211 @end deftypevr
20212
20213 @deftypevr {@code{libvirt-configuration} parameter} integer max-workers
20214 Maximum number of worker threads.
20215
20216 If the number of active clients exceeds @code{min-workers}, then more
20217 threads are spawned, up to max_workers limit. Typically you'd want
20218 max_workers to equal maximum number of clients allowed.
20219
20220 Defaults to @samp{20}.
20221
20222 @end deftypevr
20223
20224 @deftypevr {@code{libvirt-configuration} parameter} integer prio-workers
20225 Number of priority workers. If all workers from above pool are stuck,
20226 some calls marked as high priority (notably domainDestroy) can be
20227 executed in this pool.
20228
20229 Defaults to @samp{5}.
20230
20231 @end deftypevr
20232
20233 @deftypevr {@code{libvirt-configuration} parameter} integer max-requests
20234 Total global limit on concurrent RPC calls.
20235
20236 Defaults to @samp{20}.
20237
20238 @end deftypevr
20239
20240 @deftypevr {@code{libvirt-configuration} parameter} integer max-client-requests
20241 Limit on concurrent requests from a single client connection. To avoid
20242 one client monopolizing the server this should be a small fraction of
20243 the global max_requests and max_workers parameter.
20244
20245 Defaults to @samp{5}.
20246
20247 @end deftypevr
20248
20249 @deftypevr {@code{libvirt-configuration} parameter} integer admin-min-workers
20250 Same as @code{min-workers} but for the admin interface.
20251
20252 Defaults to @samp{1}.
20253
20254 @end deftypevr
20255
20256 @deftypevr {@code{libvirt-configuration} parameter} integer admin-max-workers
20257 Same as @code{max-workers} but for the admin interface.
20258
20259 Defaults to @samp{5}.
20260
20261 @end deftypevr
20262
20263 @deftypevr {@code{libvirt-configuration} parameter} integer admin-max-clients
20264 Same as @code{max-clients} but for the admin interface.
20265
20266 Defaults to @samp{5}.
20267
20268 @end deftypevr
20269
20270 @deftypevr {@code{libvirt-configuration} parameter} integer admin-max-queued-clients
20271 Same as @code{max-queued-clients} but for the admin interface.
20272
20273 Defaults to @samp{5}.
20274
20275 @end deftypevr
20276
20277 @deftypevr {@code{libvirt-configuration} parameter} integer admin-max-client-requests
20278 Same as @code{max-client-requests} but for the admin interface.
20279
20280 Defaults to @samp{5}.
20281
20282 @end deftypevr
20283
20284 @deftypevr {@code{libvirt-configuration} parameter} integer log-level
20285 Logging level. 4 errors, 3 warnings, 2 information, 1 debug.
20286
20287 Defaults to @samp{3}.
20288
20289 @end deftypevr
20290
20291 @deftypevr {@code{libvirt-configuration} parameter} string log-filters
20292 Logging filters.
20293
20294 A filter allows to select a different logging level for a given category
20295 of logs The format for a filter is one of:
20296
20297 @itemize @bullet
20298 @item
20299 x:name
20300
20301 @item
20302 x:+name
20303
20304 @end itemize
20305
20306 where @code{name} is a string which is matched against the category
20307 given in the @code{VIR_LOG_INIT()} at the top of each libvirt source
20308 file, e.g., "remote", "qemu", or "util.json" (the name in the filter can
20309 be a substring of the full category name, in order to match multiple
20310 similar categories), the optional "+" prefix tells libvirt to log stack
20311 trace for each message matching name, and @code{x} is the minimal level
20312 where matching messages should be logged:
20313
20314 @itemize @bullet
20315 @item
20316 1: DEBUG
20317
20318 @item
20319 2: INFO
20320
20321 @item
20322 3: WARNING
20323
20324 @item
20325 4: ERROR
20326
20327 @end itemize
20328
20329 Multiple filters can be defined in a single filters statement, they just
20330 need to be separated by spaces.
20331
20332 Defaults to @samp{"3:remote 4:event"}.
20333
20334 @end deftypevr
20335
20336 @deftypevr {@code{libvirt-configuration} parameter} string log-outputs
20337 Logging outputs.
20338
20339 An output is one of the places to save logging information The format
20340 for an output can be:
20341
20342 @table @code
20343 @item x:stderr
20344 output goes to stderr
20345
20346 @item x:syslog:name
20347 use syslog for the output and use the given name as the ident
20348
20349 @item x:file:file_path
20350 output to a file, with the given filepath
20351
20352 @item x:journald
20353 output to journald logging system
20354
20355 @end table
20356
20357 In all case the x prefix is the minimal level, acting as a filter
20358
20359 @itemize @bullet
20360 @item
20361 1: DEBUG
20362
20363 @item
20364 2: INFO
20365
20366 @item
20367 3: WARNING
20368
20369 @item
20370 4: ERROR
20371
20372 @end itemize
20373
20374 Multiple outputs can be defined, they just need to be separated by
20375 spaces.
20376
20377 Defaults to @samp{"3:stderr"}.
20378
20379 @end deftypevr
20380
20381 @deftypevr {@code{libvirt-configuration} parameter} integer audit-level
20382 Allows usage of the auditing subsystem to be altered
20383
20384 @itemize @bullet
20385 @item
20386 0: disable all auditing
20387
20388 @item
20389 1: enable auditing, only if enabled on host
20390
20391 @item
20392 2: enable auditing, and exit if disabled on host.
20393
20394 @end itemize
20395
20396 Defaults to @samp{1}.
20397
20398 @end deftypevr
20399
20400 @deftypevr {@code{libvirt-configuration} parameter} boolean audit-logging
20401 Send audit messages via libvirt logging infrastructure.
20402
20403 Defaults to @samp{#f}.
20404
20405 @end deftypevr
20406
20407 @deftypevr {@code{libvirt-configuration} parameter} optional-string host-uuid
20408 Host UUID. UUID must not have all digits be the same.
20409
20410 Defaults to @samp{""}.
20411
20412 @end deftypevr
20413
20414 @deftypevr {@code{libvirt-configuration} parameter} string host-uuid-source
20415 Source to read host UUID.
20416
20417 @itemize @bullet
20418 @item
20419 @code{smbios}: fetch the UUID from @code{dmidecode -s system-uuid}
20420
20421 @item
20422 @code{machine-id}: fetch the UUID from @code{/etc/machine-id}
20423
20424 @end itemize
20425
20426 If @code{dmidecode} does not provide a valid UUID a temporary UUID will
20427 be generated.
20428
20429 Defaults to @samp{"smbios"}.
20430
20431 @end deftypevr
20432
20433 @deftypevr {@code{libvirt-configuration} parameter} integer keepalive-interval
20434 A keepalive message is sent to a client after @code{keepalive_interval}
20435 seconds of inactivity to check if the client is still responding. If
20436 set to -1, libvirtd will never send keepalive requests; however clients
20437 can still send them and the daemon will send responses.
20438
20439 Defaults to @samp{5}.
20440
20441 @end deftypevr
20442
20443 @deftypevr {@code{libvirt-configuration} parameter} integer keepalive-count
20444 Maximum number of keepalive messages that are allowed to be sent to the
20445 client without getting any response before the connection is considered
20446 broken.
20447
20448 In other words, the connection is automatically closed approximately
20449 after @code{keepalive_interval * (keepalive_count + 1)} seconds since
20450 the last message received from the client. When @code{keepalive-count}
20451 is set to 0, connections will be automatically closed after
20452 @code{keepalive-interval} seconds of inactivity without sending any
20453 keepalive messages.
20454
20455 Defaults to @samp{5}.
20456
20457 @end deftypevr
20458
20459 @deftypevr {@code{libvirt-configuration} parameter} integer admin-keepalive-interval
20460 Same as above but for admin interface.
20461
20462 Defaults to @samp{5}.
20463
20464 @end deftypevr
20465
20466 @deftypevr {@code{libvirt-configuration} parameter} integer admin-keepalive-count
20467 Same as above but for admin interface.
20468
20469 Defaults to @samp{5}.
20470
20471 @end deftypevr
20472
20473 @deftypevr {@code{libvirt-configuration} parameter} integer ovs-timeout
20474 Timeout for Open vSwitch calls.
20475
20476 The @code{ovs-vsctl} utility is used for the configuration and its
20477 timeout option is set by default to 5 seconds to avoid potential
20478 infinite waits blocking libvirt.
20479
20480 Defaults to @samp{5}.
20481
20482 @end deftypevr
20483
20484 @c %end of autogenerated docs
20485
20486 @subsubheading Virtlog daemon
20487 The virtlogd service is a server side daemon component of libvirt that is
20488 used to manage logs from virtual machine consoles.
20489
20490 This daemon is not used directly by libvirt client applications, rather it
20491 is called on their behalf by @code{libvirtd}. By maintaining the logs in a
20492 standalone daemon, the main @code{libvirtd} daemon can be restarted without
20493 risk of losing logs. The @code{virtlogd} daemon has the ability to re-exec()
20494 itself upon receiving @code{SIGUSR1}, to allow live upgrades without downtime.
20495
20496 @deffn {Scheme Variable} virtlog-service-type
20497 This is the type of the virtlog daemon.
20498 Its value must be a @code{virtlog-configuration}.
20499
20500 @example
20501 (service virtlog-service-type
20502 (virtlog-configuration
20503 (max-clients 1000)))
20504 @end example
20505 @end deffn
20506
20507 @deftypevr {@code{virtlog-configuration} parameter} integer log-level
20508 Logging level. 4 errors, 3 warnings, 2 information, 1 debug.
20509
20510 Defaults to @samp{3}.
20511
20512 @end deftypevr
20513
20514 @deftypevr {@code{virtlog-configuration} parameter} string log-filters
20515 Logging filters.
20516
20517 A filter allows to select a different logging level for a given category
20518 of logs The format for a filter is one of:
20519
20520 @itemize @bullet
20521 @item
20522 x:name
20523
20524 @item
20525 x:+name
20526
20527 @end itemize
20528
20529 where @code{name} is a string which is matched against the category
20530 given in the @code{VIR_LOG_INIT()} at the top of each libvirt source
20531 file, e.g., "remote", "qemu", or "util.json" (the name in the filter can
20532 be a substring of the full category name, in order to match multiple
20533 similar categories), the optional "+" prefix tells libvirt to log stack
20534 trace for each message matching name, and @code{x} is the minimal level
20535 where matching messages should be logged:
20536
20537 @itemize @bullet
20538 @item
20539 1: DEBUG
20540
20541 @item
20542 2: INFO
20543
20544 @item
20545 3: WARNING
20546
20547 @item
20548 4: ERROR
20549
20550 @end itemize
20551
20552 Multiple filters can be defined in a single filters statement, they just
20553 need to be separated by spaces.
20554
20555 Defaults to @samp{"3:remote 4:event"}.
20556
20557 @end deftypevr
20558
20559 @deftypevr {@code{virtlog-configuration} parameter} string log-outputs
20560 Logging outputs.
20561
20562 An output is one of the places to save logging information The format
20563 for an output can be:
20564
20565 @table @code
20566 @item x:stderr
20567 output goes to stderr
20568
20569 @item x:syslog:name
20570 use syslog for the output and use the given name as the ident
20571
20572 @item x:file:file_path
20573 output to a file, with the given filepath
20574
20575 @item x:journald
20576 output to journald logging system
20577
20578 @end table
20579
20580 In all case the x prefix is the minimal level, acting as a filter
20581
20582 @itemize @bullet
20583 @item
20584 1: DEBUG
20585
20586 @item
20587 2: INFO
20588
20589 @item
20590 3: WARNING
20591
20592 @item
20593 4: ERROR
20594
20595 @end itemize
20596
20597 Multiple outputs can be defined, they just need to be separated by
20598 spaces.
20599
20600 Defaults to @samp{"3:stderr"}.
20601
20602 @end deftypevr
20603
20604 @deftypevr {@code{virtlog-configuration} parameter} integer max-clients
20605 Maximum number of concurrent client connections to allow over all
20606 sockets combined.
20607
20608 Defaults to @samp{1024}.
20609
20610 @end deftypevr
20611
20612 @deftypevr {@code{virtlog-configuration} parameter} integer max-size
20613 Maximum file size before rolling over.
20614
20615 Defaults to @samp{2MB}
20616
20617 @end deftypevr
20618
20619 @deftypevr {@code{virtlog-configuration} parameter} integer max-backups
20620 Maximum number of backup files to keep.
20621
20622 Defaults to @samp{3}
20623
20624 @end deftypevr
20625
20626 @subsubheading Transparent Emulation with QEMU
20627
20628 @cindex emulation
20629 @cindex @code{binfmt_misc}
20630 @code{qemu-binfmt-service-type} provides support for transparent
20631 emulation of program binaries built for different architectures---e.g.,
20632 it allows you to transparently execute an ARMv7 program on an x86_64
20633 machine. It achieves this by combining the @uref{https://www.qemu.org,
20634 QEMU} emulator and the @code{binfmt_misc} feature of the kernel Linux.
20635
20636 @defvr {Scheme Variable} qemu-binfmt-service-type
20637 This is the type of the QEMU/binfmt service for transparent emulation.
20638 Its value must be a @code{qemu-binfmt-configuration} object, which
20639 specifies the QEMU package to use as well as the architecture we want to
20640 emulated:
20641
20642 @example
20643 (service qemu-binfmt-service-type
20644 (qemu-binfmt-configuration
20645 (platforms (lookup-qemu-platforms "arm" "aarch64" "ppc"))))
20646 @end example
20647
20648 In this example, we enable transparent emulation for the ARM and aarch64
20649 platforms. Running @code{herd stop qemu-binfmt} turns it off, and
20650 running @code{herd start qemu-binfmt} turns it back on (@pxref{Invoking
20651 herd, the @command{herd} command,, shepherd, The GNU Shepherd Manual}).
20652 @end defvr
20653
20654 @deftp {Data Type} qemu-binfmt-configuration
20655 This is the configuration for the @code{qemu-binfmt} service.
20656
20657 @table @asis
20658 @item @code{platforms} (default: @code{'()})
20659 The list of emulated QEMU platforms. Each item must be a @dfn{platform
20660 object} as returned by @code{lookup-qemu-platforms} (see below).
20661
20662 @item @code{guix-support?} (default: @code{#f})
20663 When it is true, QEMU and all its dependencies are added to the build
20664 environment of @command{guix-daemon} (@pxref{Invoking guix-daemon,
20665 @code{--chroot-directory} option}). This allows the @code{binfmt_misc}
20666 handlers to be used within the build environment, which in turn means
20667 that you can transparently build programs for another architecture.
20668
20669 For example, let's suppose you're on an x86_64 machine and you have this
20670 service:
20671
20672 @example
20673 (service qemu-binfmt-service-type
20674 (qemu-binfmt-configuration
20675 (platforms (lookup-qemu-platforms "arm"))
20676 (guix-support? #t)))
20677 @end example
20678
20679 You can run:
20680
20681 @example
20682 guix build -s armhf-linux inkscape
20683 @end example
20684
20685 @noindent
20686 and it will build Inkscape for ARMv7 @emph{as if it were a native
20687 build}, transparently using QEMU to emulate the ARMv7 CPU. Pretty handy
20688 if you'd like to test a package build for an architecture you don't have
20689 access to!
20690
20691 @item @code{qemu} (default: @code{qemu})
20692 The QEMU package to use.
20693 @end table
20694 @end deftp
20695
20696 @deffn {Scheme Procedure} lookup-qemu-platforms @var{platforms}@dots{}
20697 Return the list of QEMU platform objects corresponding to
20698 @var{platforms}@dots{}. @var{platforms} must be a list of strings
20699 corresponding to platform names, such as @code{"arm"}, @code{"sparc"},
20700 @code{"mips64el"}, and so on.
20701 @end deffn
20702
20703 @deffn {Scheme Procedure} qemu-platform? @var{obj}
20704 Return true if @var{obj} is a platform object.
20705 @end deffn
20706
20707 @deffn {Scheme Procedure} qemu-platform-name @var{platform}
20708 Return the name of @var{platform}---a string such as @code{"arm"}.
20709 @end deffn
20710
20711 @node Version Control Services
20712 @subsection Version Control Services
20713
20714 The @code{(gnu services version-control)} module provides a service to
20715 allow remote access to local Git repositories. There are three options:
20716 the @code{git-daemon-service}, which provides access to repositories via
20717 the @code{git://} unsecured TCP-based protocol, extending the
20718 @code{nginx} web server to proxy some requests to
20719 @code{git-http-backend}, or providing a web interface with
20720 @code{cgit-service-type}.
20721
20722 @deffn {Scheme Procedure} git-daemon-service [#:config (git-daemon-configuration)]
20723
20724 Return a service that runs @command{git daemon}, a simple TCP server to
20725 expose repositories over the Git protocol for anonymous access.
20726
20727 The optional @var{config} argument should be a
20728 @code{<git-daemon-configuration>} object, by default it allows read-only
20729 access to exported@footnote{By creating the magic file
20730 "git-daemon-export-ok" in the repository directory.} repositories under
20731 @file{/srv/git}.
20732
20733 @end deffn
20734
20735 @deftp {Data Type} git-daemon-configuration
20736 Data type representing the configuration for @code{git-daemon-service}.
20737
20738 @table @asis
20739 @item @code{package} (default: @var{git})
20740 Package object of the Git distributed version control system.
20741
20742 @item @code{export-all?} (default: @var{#f})
20743 Whether to allow access for all Git repositories, even if they do not
20744 have the @file{git-daemon-export-ok} file.
20745
20746 @item @code{base-path} (default: @file{/srv/git})
20747 Whether to remap all the path requests as relative to the given path.
20748 If you run git daemon with @var{(base-path "/srv/git")} on example.com,
20749 then if you later try to pull @code{git://example.com/hello.git}, git
20750 daemon will interpret the path as @code{/srv/git/hello.git}.
20751
20752 @item @code{user-path} (default: @var{#f})
20753 Whether to allow @code{~user} notation to be used in requests. When
20754 specified with empty string, requests to @code{git://host/~alice/foo} is
20755 taken as a request to access @code{foo} repository in the home directory
20756 of user @code{alice}. If @var{(user-path "path")} is specified, the
20757 same request is taken as a request to access @code{path/foo} repository
20758 in the home directory of user @code{alice}.
20759
20760 @item @code{listen} (default: @var{'()})
20761 Whether to listen on specific IP addresses or hostnames, defaults to
20762 all.
20763
20764 @item @code{port} (default: @var{#f})
20765 Whether to listen on an alternative port, which defaults to 9418.
20766
20767 @item @code{whitelist} (default: @var{'()})
20768 If not empty, only allow access to this list of directories.
20769
20770 @item @code{extra-options} (default: @var{'()})
20771 Extra options will be passed to @code{git daemon}, please run
20772 @command{man git-daemon} for more information.
20773
20774 @end table
20775 @end deftp
20776
20777 The @code{git://} protocol lacks authentication. When you pull from a
20778 repository fetched via @code{git://}, you don't know that the data you
20779 receive was modified is really coming from the specified host, and you
20780 have your connection is subject to eavesdropping. It's better to use an
20781 authenticated and encrypted transport, such as @code{https}. Although Git allows you
20782 to serve repositories using unsophisticated file-based web servers,
20783 there is a faster protocol implemented by the @code{git-http-backend}
20784 program. This program is the back-end of a proper Git web service. It
20785 is designed to sit behind a FastCGI proxy. @xref{Web Services}, for more
20786 on running the necessary @code{fcgiwrap} daemon.
20787
20788 Guix has a separate configuration data type for serving Git repositories
20789 over HTTP.
20790
20791 @deftp {Data Type} git-http-configuration
20792 Data type representing the configuration for @code{git-http-service}.
20793
20794 @table @asis
20795 @item @code{package} (default: @var{git})
20796 Package object of the Git distributed version control system.
20797
20798 @item @code{git-root} (default: @file{/srv/git})
20799 Directory containing the Git repositories to expose to the world.
20800
20801 @item @code{export-all?} (default: @var{#f})
20802 Whether to expose access for all Git repositories in @var{git-root},
20803 even if they do not have the @file{git-daemon-export-ok} file.
20804
20805 @item @code{uri-path} (default: @file{/git/})
20806 Path prefix for Git access. With the default @code{/git/} prefix, this
20807 will map @code{http://@var{server}/git/@var{repo}.git} to
20808 @code{/srv/git/@var{repo}.git}. Requests whose URI paths do not begin
20809 with this prefix are not passed on to this Git instance.
20810
20811 @item @code{fcgiwrap-socket} (default: @code{127.0.0.1:9000})
20812 The socket on which the @code{fcgiwrap} daemon is listening. @xref{Web
20813 Services}.
20814 @end table
20815 @end deftp
20816
20817 There is no @code{git-http-service-type}, currently; instead you can
20818 create an @code{nginx-location-configuration} from a
20819 @code{git-http-configuration} and then add that location to a web
20820 server.
20821
20822 @deffn {Scheme Procedure} git-http-nginx-location-configuration @
20823 [config=(git-http-configuration)]
20824 Compute an @code{nginx-location-configuration} that corresponds to the
20825 given Git http configuration. An example nginx service definition to
20826 serve the default @file{/srv/git} over HTTPS might be:
20827
20828 @example
20829 (service nginx-service-type
20830 (nginx-configuration
20831 (server-blocks
20832 (list
20833 (nginx-server-configuration
20834 (listen '("443 ssl"))
20835 (server-name "git.my-host.org")
20836 (ssl-certificate
20837 "/etc/letsencrypt/live/git.my-host.org/fullchain.pem")
20838 (ssl-certificate-key
20839 "/etc/letsencrypt/live/git.my-host.org/privkey.pem")
20840 (locations
20841 (list
20842 (git-http-nginx-location-configuration
20843 (git-http-configuration (uri-path "/"))))))))))
20844 @end example
20845
20846 This example assumes that you are using Let's Encrypt to get your TLS
20847 certificate. @xref{Certificate Services}. The default @code{certbot}
20848 service will redirect all HTTP traffic on @code{git.my-host.org} to
20849 HTTPS. You will also need to add an @code{fcgiwrap} proxy to your
20850 system services. @xref{Web Services}.
20851 @end deffn
20852
20853 @subsubheading Cgit Service
20854
20855 @cindex Cgit service
20856 @cindex Git, web interface
20857 @uref{https://git.zx2c4.com/cgit/, Cgit} is a web frontend for Git
20858 repositories written in C.
20859
20860 The following example will configure the service with default values.
20861 By default, Cgit can be accessed on port 80 (@code{http://localhost:80}).
20862
20863 @example
20864 (service cgit-service-type)
20865 @end example
20866
20867 The @code{file-object} type designates either a file-like object
20868 (@pxref{G-Expressions, file-like objects}) or a string.
20869
20870 @c %start of fragment
20871
20872 Available @code{cgit-configuration} fields are:
20873
20874 @deftypevr {@code{cgit-configuration} parameter} package package
20875 The CGIT package.
20876
20877 @end deftypevr
20878
20879 @deftypevr {@code{cgit-configuration} parameter} nginx-server-configuration-list nginx
20880 NGINX configuration.
20881
20882 @end deftypevr
20883
20884 @deftypevr {@code{cgit-configuration} parameter} file-object about-filter
20885 Specifies a command which will be invoked to format the content of about
20886 pages (both top-level and for each repository).
20887
20888 Defaults to @samp{""}.
20889
20890 @end deftypevr
20891
20892 @deftypevr {@code{cgit-configuration} parameter} string agefile
20893 Specifies a path, relative to each repository path, which can be used to
20894 specify the date and time of the youngest commit in the repository.
20895
20896 Defaults to @samp{""}.
20897
20898 @end deftypevr
20899
20900 @deftypevr {@code{cgit-configuration} parameter} file-object auth-filter
20901 Specifies a command that will be invoked for authenticating repository
20902 access.
20903
20904 Defaults to @samp{""}.
20905
20906 @end deftypevr
20907
20908 @deftypevr {@code{cgit-configuration} parameter} string branch-sort
20909 Flag which, when set to @samp{age}, enables date ordering in the branch
20910 ref list, and when set @samp{name} enables ordering by branch name.
20911
20912 Defaults to @samp{"name"}.
20913
20914 @end deftypevr
20915
20916 @deftypevr {@code{cgit-configuration} parameter} string cache-root
20917 Path used to store the cgit cache entries.
20918
20919 Defaults to @samp{"/var/cache/cgit"}.
20920
20921 @end deftypevr
20922
20923 @deftypevr {@code{cgit-configuration} parameter} integer cache-static-ttl
20924 Number which specifies the time-to-live, in minutes, for the cached
20925 version of repository pages accessed with a fixed SHA1.
20926
20927 Defaults to @samp{-1}.
20928
20929 @end deftypevr
20930
20931 @deftypevr {@code{cgit-configuration} parameter} integer cache-dynamic-ttl
20932 Number which specifies the time-to-live, in minutes, for the cached
20933 version of repository pages accessed without a fixed SHA1.
20934
20935 Defaults to @samp{5}.
20936
20937 @end deftypevr
20938
20939 @deftypevr {@code{cgit-configuration} parameter} integer cache-repo-ttl
20940 Number which specifies the time-to-live, in minutes, for the cached
20941 version of the repository summary page.
20942
20943 Defaults to @samp{5}.
20944
20945 @end deftypevr
20946
20947 @deftypevr {@code{cgit-configuration} parameter} integer cache-root-ttl
20948 Number which specifies the time-to-live, in minutes, for the cached
20949 version of the repository index page.
20950
20951 Defaults to @samp{5}.
20952
20953 @end deftypevr
20954
20955 @deftypevr {@code{cgit-configuration} parameter} integer cache-scanrc-ttl
20956 Number which specifies the time-to-live, in minutes, for the result of
20957 scanning a path for Git repositories.
20958
20959 Defaults to @samp{15}.
20960
20961 @end deftypevr
20962
20963 @deftypevr {@code{cgit-configuration} parameter} integer cache-about-ttl
20964 Number which specifies the time-to-live, in minutes, for the cached
20965 version of the repository about page.
20966
20967 Defaults to @samp{15}.
20968
20969 @end deftypevr
20970
20971 @deftypevr {@code{cgit-configuration} parameter} integer cache-snapshot-ttl
20972 Number which specifies the time-to-live, in minutes, for the cached
20973 version of snapshots.
20974
20975 Defaults to @samp{5}.
20976
20977 @end deftypevr
20978
20979 @deftypevr {@code{cgit-configuration} parameter} integer cache-size
20980 The maximum number of entries in the cgit cache. When set to @samp{0},
20981 caching is disabled.
20982
20983 Defaults to @samp{0}.
20984
20985 @end deftypevr
20986
20987 @deftypevr {@code{cgit-configuration} parameter} boolean case-sensitive-sort?
20988 Sort items in the repo list case sensitively.
20989
20990 Defaults to @samp{#t}.
20991
20992 @end deftypevr
20993
20994 @deftypevr {@code{cgit-configuration} parameter} list clone-prefix
20995 List of common prefixes which, when combined with a repository URL,
20996 generates valid clone URLs for the repository.
20997
20998 Defaults to @samp{()}.
20999
21000 @end deftypevr
21001
21002 @deftypevr {@code{cgit-configuration} parameter} list clone-url
21003 List of @code{clone-url} templates.
21004
21005 Defaults to @samp{()}.
21006
21007 @end deftypevr
21008
21009 @deftypevr {@code{cgit-configuration} parameter} file-object commit-filter
21010 Command which will be invoked to format commit messages.
21011
21012 Defaults to @samp{""}.
21013
21014 @end deftypevr
21015
21016 @deftypevr {@code{cgit-configuration} parameter} string commit-sort
21017 Flag which, when set to @samp{date}, enables strict date ordering in the
21018 commit log, and when set to @samp{topo} enables strict topological
21019 ordering.
21020
21021 Defaults to @samp{"git log"}.
21022
21023 @end deftypevr
21024
21025 @deftypevr {@code{cgit-configuration} parameter} file-object css
21026 URL which specifies the css document to include in all cgit pages.
21027
21028 Defaults to @samp{"/share/cgit/cgit.css"}.
21029
21030 @end deftypevr
21031
21032 @deftypevr {@code{cgit-configuration} parameter} file-object email-filter
21033 Specifies a command which will be invoked to format names and email
21034 address of committers, authors, and taggers, as represented in various
21035 places throughout the cgit interface.
21036
21037 Defaults to @samp{""}.
21038
21039 @end deftypevr
21040
21041 @deftypevr {@code{cgit-configuration} parameter} boolean embedded?
21042 Flag which, when set to @samp{#t}, will make cgit generate a HTML
21043 fragment suitable for embedding in other HTML pages.
21044
21045 Defaults to @samp{#f}.
21046
21047 @end deftypevr
21048
21049 @deftypevr {@code{cgit-configuration} parameter} boolean enable-commit-graph?
21050 Flag which, when set to @samp{#t}, will make cgit print an ASCII-art
21051 commit history graph to the left of the commit messages in the
21052 repository log page.
21053
21054 Defaults to @samp{#f}.
21055
21056 @end deftypevr
21057
21058 @deftypevr {@code{cgit-configuration} parameter} boolean enable-filter-overrides?
21059 Flag which, when set to @samp{#t}, allows all filter settings to be
21060 overridden in repository-specific cgitrc files.
21061
21062 Defaults to @samp{#f}.
21063
21064 @end deftypevr
21065
21066 @deftypevr {@code{cgit-configuration} parameter} boolean enable-follow-links?
21067 Flag which, when set to @samp{#t}, allows users to follow a file in the
21068 log view.
21069
21070 Defaults to @samp{#f}.
21071
21072 @end deftypevr
21073
21074 @deftypevr {@code{cgit-configuration} parameter} boolean enable-http-clone?
21075 If set to @samp{#t}, cgit will act as an dumb HTTP endpoint for Git
21076 clones.
21077
21078 Defaults to @samp{#t}.
21079
21080 @end deftypevr
21081
21082 @deftypevr {@code{cgit-configuration} parameter} boolean enable-index-links?
21083 Flag which, when set to @samp{#t}, will make cgit generate extra links
21084 "summary", "commit", "tree" for each repo in the repository index.
21085
21086 Defaults to @samp{#f}.
21087
21088 @end deftypevr
21089
21090 @deftypevr {@code{cgit-configuration} parameter} boolean enable-index-owner?
21091 Flag which, when set to @samp{#t}, will make cgit display the owner of
21092 each repo in the repository index.
21093
21094 Defaults to @samp{#t}.
21095
21096 @end deftypevr
21097
21098 @deftypevr {@code{cgit-configuration} parameter} boolean enable-log-filecount?
21099 Flag which, when set to @samp{#t}, will make cgit print the number of
21100 modified files for each commit on the repository log page.
21101
21102 Defaults to @samp{#f}.
21103
21104 @end deftypevr
21105
21106 @deftypevr {@code{cgit-configuration} parameter} boolean enable-log-linecount?
21107 Flag which, when set to @samp{#t}, will make cgit print the number of
21108 added and removed lines for each commit on the repository log page.
21109
21110 Defaults to @samp{#f}.
21111
21112 @end deftypevr
21113
21114 @deftypevr {@code{cgit-configuration} parameter} boolean enable-remote-branches?
21115 Flag which, when set to @code{#t}, will make cgit display remote
21116 branches in the summary and refs views.
21117
21118 Defaults to @samp{#f}.
21119
21120 @end deftypevr
21121
21122 @deftypevr {@code{cgit-configuration} parameter} boolean enable-subject-links?
21123 Flag which, when set to @code{1}, will make cgit use the subject of the
21124 parent commit as link text when generating links to parent commits in
21125 commit view.
21126
21127 Defaults to @samp{#f}.
21128
21129 @end deftypevr
21130
21131 @deftypevr {@code{cgit-configuration} parameter} boolean enable-html-serving?
21132 Flag which, when set to @samp{#t}, will make cgit use the subject of the
21133 parent commit as link text when generating links to parent commits in
21134 commit view.
21135
21136 Defaults to @samp{#f}.
21137
21138 @end deftypevr
21139
21140 @deftypevr {@code{cgit-configuration} parameter} boolean enable-tree-linenumbers?
21141 Flag which, when set to @samp{#t}, will make cgit generate linenumber
21142 links for plaintext blobs printed in the tree view.
21143
21144 Defaults to @samp{#t}.
21145
21146 @end deftypevr
21147
21148 @deftypevr {@code{cgit-configuration} parameter} boolean enable-git-config?
21149 Flag which, when set to @samp{#f}, will allow cgit to use Git config to
21150 set any repo specific settings.
21151
21152 Defaults to @samp{#f}.
21153
21154 @end deftypevr
21155
21156 @deftypevr {@code{cgit-configuration} parameter} file-object favicon
21157 URL used as link to a shortcut icon for cgit.
21158
21159 Defaults to @samp{"/favicon.ico"}.
21160
21161 @end deftypevr
21162
21163 @deftypevr {@code{cgit-configuration} parameter} string footer
21164 The content of the file specified with this option will be included
21165 verbatim at the bottom of all pages (i.e.@: it replaces the standard
21166 "generated by..."@: message).
21167
21168 Defaults to @samp{""}.
21169
21170 @end deftypevr
21171
21172 @deftypevr {@code{cgit-configuration} parameter} string head-include
21173 The content of the file specified with this option will be included
21174 verbatim in the HTML HEAD section on all pages.
21175
21176 Defaults to @samp{""}.
21177
21178 @end deftypevr
21179
21180 @deftypevr {@code{cgit-configuration} parameter} string header
21181 The content of the file specified with this option will be included
21182 verbatim at the top of all pages.
21183
21184 Defaults to @samp{""}.
21185
21186 @end deftypevr
21187
21188 @deftypevr {@code{cgit-configuration} parameter} file-object include
21189 Name of a configfile to include before the rest of the current config-
21190 file is parsed.
21191
21192 Defaults to @samp{""}.
21193
21194 @end deftypevr
21195
21196 @deftypevr {@code{cgit-configuration} parameter} string index-header
21197 The content of the file specified with this option will be included
21198 verbatim above the repository index.
21199
21200 Defaults to @samp{""}.
21201
21202 @end deftypevr
21203
21204 @deftypevr {@code{cgit-configuration} parameter} string index-info
21205 The content of the file specified with this option will be included
21206 verbatim below the heading on the repository index page.
21207
21208 Defaults to @samp{""}.
21209
21210 @end deftypevr
21211
21212 @deftypevr {@code{cgit-configuration} parameter} boolean local-time?
21213 Flag which, if set to @samp{#t}, makes cgit print commit and tag times
21214 in the servers timezone.
21215
21216 Defaults to @samp{#f}.
21217
21218 @end deftypevr
21219
21220 @deftypevr {@code{cgit-configuration} parameter} file-object logo
21221 URL which specifies the source of an image which will be used as a logo
21222 on all cgit pages.
21223
21224 Defaults to @samp{"/share/cgit/cgit.png"}.
21225
21226 @end deftypevr
21227
21228 @deftypevr {@code{cgit-configuration} parameter} string logo-link
21229 URL loaded when clicking on the cgit logo image.
21230
21231 Defaults to @samp{""}.
21232
21233 @end deftypevr
21234
21235 @deftypevr {@code{cgit-configuration} parameter} file-object owner-filter
21236 Command which will be invoked to format the Owner column of the main
21237 page.
21238
21239 Defaults to @samp{""}.
21240
21241 @end deftypevr
21242
21243 @deftypevr {@code{cgit-configuration} parameter} integer max-atom-items
21244 Number of items to display in atom feeds view.
21245
21246 Defaults to @samp{10}.
21247
21248 @end deftypevr
21249
21250 @deftypevr {@code{cgit-configuration} parameter} integer max-commit-count
21251 Number of entries to list per page in "log" view.
21252
21253 Defaults to @samp{50}.
21254
21255 @end deftypevr
21256
21257 @deftypevr {@code{cgit-configuration} parameter} integer max-message-length
21258 Number of commit message characters to display in "log" view.
21259
21260 Defaults to @samp{80}.
21261
21262 @end deftypevr
21263
21264 @deftypevr {@code{cgit-configuration} parameter} integer max-repo-count
21265 Specifies the number of entries to list per page on the repository index
21266 page.
21267
21268 Defaults to @samp{50}.
21269
21270 @end deftypevr
21271
21272 @deftypevr {@code{cgit-configuration} parameter} integer max-repodesc-length
21273 Specifies the maximum number of repo description characters to display
21274 on the repository index page.
21275
21276 Defaults to @samp{80}.
21277
21278 @end deftypevr
21279
21280 @deftypevr {@code{cgit-configuration} parameter} integer max-blob-size
21281 Specifies the maximum size of a blob to display HTML for in KBytes.
21282
21283 Defaults to @samp{0}.
21284
21285 @end deftypevr
21286
21287 @deftypevr {@code{cgit-configuration} parameter} string max-stats
21288 Maximum statistics period. Valid values are @samp{week},@samp{month},
21289 @samp{quarter} and @samp{year}.
21290
21291 Defaults to @samp{""}.
21292
21293 @end deftypevr
21294
21295 @deftypevr {@code{cgit-configuration} parameter} mimetype-alist mimetype
21296 Mimetype for the specified filename extension.
21297
21298 Defaults to @samp{((gif "image/gif") (html "text/html") (jpg
21299 "image/jpeg") (jpeg "image/jpeg") (pdf "application/pdf") (png
21300 "image/png") (svg "image/svg+xml"))}.
21301
21302 @end deftypevr
21303
21304 @deftypevr {@code{cgit-configuration} parameter} file-object mimetype-file
21305 Specifies the file to use for automatic mimetype lookup.
21306
21307 Defaults to @samp{""}.
21308
21309 @end deftypevr
21310
21311 @deftypevr {@code{cgit-configuration} parameter} string module-link
21312 Text which will be used as the formatstring for a hyperlink when a
21313 submodule is printed in a directory listing.
21314
21315 Defaults to @samp{""}.
21316
21317 @end deftypevr
21318
21319 @deftypevr {@code{cgit-configuration} parameter} boolean nocache?
21320 If set to the value @samp{#t} caching will be disabled.
21321
21322 Defaults to @samp{#f}.
21323
21324 @end deftypevr
21325
21326 @deftypevr {@code{cgit-configuration} parameter} boolean noplainemail?
21327 If set to @samp{#t} showing full author email addresses will be
21328 disabled.
21329
21330 Defaults to @samp{#f}.
21331
21332 @end deftypevr
21333
21334 @deftypevr {@code{cgit-configuration} parameter} boolean noheader?
21335 Flag which, when set to @samp{#t}, will make cgit omit the standard
21336 header on all pages.
21337
21338 Defaults to @samp{#f}.
21339
21340 @end deftypevr
21341
21342 @deftypevr {@code{cgit-configuration} parameter} project-list project-list
21343 A list of subdirectories inside of @code{repository-directory}, relative
21344 to it, that should loaded as Git repositories. An empty list means that
21345 all subdirectories will be loaded.
21346
21347 Defaults to @samp{()}.
21348
21349 @end deftypevr
21350
21351 @deftypevr {@code{cgit-configuration} parameter} file-object readme
21352 Text which will be used as default value for @code{cgit-repo-readme}.
21353
21354 Defaults to @samp{""}.
21355
21356 @end deftypevr
21357
21358 @deftypevr {@code{cgit-configuration} parameter} boolean remove-suffix?
21359 If set to @code{#t} and @code{repository-directory} is enabled, if any
21360 repositories are found with a suffix of @code{.git}, this suffix will be
21361 removed for the URL and name.
21362
21363 Defaults to @samp{#f}.
21364
21365 @end deftypevr
21366
21367 @deftypevr {@code{cgit-configuration} parameter} integer renamelimit
21368 Maximum number of files to consider when detecting renames.
21369
21370 Defaults to @samp{-1}.
21371
21372 @end deftypevr
21373
21374 @deftypevr {@code{cgit-configuration} parameter} string repository-sort
21375 The way in which repositories in each section are sorted.
21376
21377 Defaults to @samp{""}.
21378
21379 @end deftypevr
21380
21381 @deftypevr {@code{cgit-configuration} parameter} robots-list robots
21382 Text used as content for the @code{robots} meta-tag.
21383
21384 Defaults to @samp{("noindex" "nofollow")}.
21385
21386 @end deftypevr
21387
21388 @deftypevr {@code{cgit-configuration} parameter} string root-desc
21389 Text printed below the heading on the repository index page.
21390
21391 Defaults to @samp{"a fast webinterface for the git dscm"}.
21392
21393 @end deftypevr
21394
21395 @deftypevr {@code{cgit-configuration} parameter} string root-readme
21396 The content of the file specified with this option will be included
21397 verbatim below thef "about" link on the repository index page.
21398
21399 Defaults to @samp{""}.
21400
21401 @end deftypevr
21402
21403 @deftypevr {@code{cgit-configuration} parameter} string root-title
21404 Text printed as heading on the repository index page.
21405
21406 Defaults to @samp{""}.
21407
21408 @end deftypevr
21409
21410 @deftypevr {@code{cgit-configuration} parameter} boolean scan-hidden-path
21411 If set to @samp{#t} and repository-directory is enabled,
21412 repository-directory will recurse into directories whose name starts
21413 with a period. Otherwise, repository-directory will stay away from such
21414 directories, considered as "hidden". Note that this does not apply to
21415 the ".git" directory in non-bare repos.
21416
21417 Defaults to @samp{#f}.
21418
21419 @end deftypevr
21420
21421 @deftypevr {@code{cgit-configuration} parameter} list snapshots
21422 Text which specifies the default set of snapshot formats that cgit
21423 generates links for.
21424
21425 Defaults to @samp{()}.
21426
21427 @end deftypevr
21428
21429 @deftypevr {@code{cgit-configuration} parameter} repository-directory repository-directory
21430 Name of the directory to scan for repositories (represents
21431 @code{scan-path}).
21432
21433 Defaults to @samp{"/srv/git"}.
21434
21435 @end deftypevr
21436
21437 @deftypevr {@code{cgit-configuration} parameter} string section
21438 The name of the current repository section - all repositories defined
21439 after this option will inherit the current section name.
21440
21441 Defaults to @samp{""}.
21442
21443 @end deftypevr
21444
21445 @deftypevr {@code{cgit-configuration} parameter} string section-sort
21446 Flag which, when set to @samp{1}, will sort the sections on the
21447 repository listing by name.
21448
21449 Defaults to @samp{""}.
21450
21451 @end deftypevr
21452
21453 @deftypevr {@code{cgit-configuration} parameter} integer section-from-path
21454 A number which, if defined prior to repository-directory, specifies how
21455 many path elements from each repo path to use as a default section name.
21456
21457 Defaults to @samp{0}.
21458
21459 @end deftypevr
21460
21461 @deftypevr {@code{cgit-configuration} parameter} boolean side-by-side-diffs?
21462 If set to @samp{#t} shows side-by-side diffs instead of unidiffs per
21463 default.
21464
21465 Defaults to @samp{#f}.
21466
21467 @end deftypevr
21468
21469 @deftypevr {@code{cgit-configuration} parameter} file-object source-filter
21470 Specifies a command which will be invoked to format plaintext blobs in
21471 the tree view.
21472
21473 Defaults to @samp{""}.
21474
21475 @end deftypevr
21476
21477 @deftypevr {@code{cgit-configuration} parameter} integer summary-branches
21478 Specifies the number of branches to display in the repository "summary"
21479 view.
21480
21481 Defaults to @samp{10}.
21482
21483 @end deftypevr
21484
21485 @deftypevr {@code{cgit-configuration} parameter} integer summary-log
21486 Specifies the number of log entries to display in the repository
21487 "summary" view.
21488
21489 Defaults to @samp{10}.
21490
21491 @end deftypevr
21492
21493 @deftypevr {@code{cgit-configuration} parameter} integer summary-tags
21494 Specifies the number of tags to display in the repository "summary"
21495 view.
21496
21497 Defaults to @samp{10}.
21498
21499 @end deftypevr
21500
21501 @deftypevr {@code{cgit-configuration} parameter} string strict-export
21502 Filename which, if specified, needs to be present within the repository
21503 for cgit to allow access to that repository.
21504
21505 Defaults to @samp{""}.
21506
21507 @end deftypevr
21508
21509 @deftypevr {@code{cgit-configuration} parameter} string virtual-root
21510 URL which, if specified, will be used as root for all cgit links.
21511
21512 Defaults to @samp{"/"}.
21513
21514 @end deftypevr
21515
21516 @deftypevr {@code{cgit-configuration} parameter} repository-cgit-configuration-list repositories
21517 A list of @dfn{cgit-repo} records to use with config.
21518
21519 Defaults to @samp{()}.
21520
21521 Available @code{repository-cgit-configuration} fields are:
21522
21523 @deftypevr {@code{repository-cgit-configuration} parameter} repo-list snapshots
21524 A mask of snapshot formats for this repo that cgit generates links for,
21525 restricted by the global @code{snapshots} setting.
21526
21527 Defaults to @samp{()}.
21528
21529 @end deftypevr
21530
21531 @deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object source-filter
21532 Override the default @code{source-filter}.
21533
21534 Defaults to @samp{""}.
21535
21536 @end deftypevr
21537
21538 @deftypevr {@code{repository-cgit-configuration} parameter} repo-string url
21539 The relative URL used to access the repository.
21540
21541 Defaults to @samp{""}.
21542
21543 @end deftypevr
21544
21545 @deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object about-filter
21546 Override the default @code{about-filter}.
21547
21548 Defaults to @samp{""}.
21549
21550 @end deftypevr
21551
21552 @deftypevr {@code{repository-cgit-configuration} parameter} repo-string branch-sort
21553 Flag which, when set to @samp{age}, enables date ordering in the branch
21554 ref list, and when set to @samp{name} enables ordering by branch name.
21555
21556 Defaults to @samp{""}.
21557
21558 @end deftypevr
21559
21560 @deftypevr {@code{repository-cgit-configuration} parameter} repo-list clone-url
21561 A list of URLs which can be used to clone repo.
21562
21563 Defaults to @samp{()}.
21564
21565 @end deftypevr
21566
21567 @deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object commit-filter
21568 Override the default @code{commit-filter}.
21569
21570 Defaults to @samp{""}.
21571
21572 @end deftypevr
21573
21574 @deftypevr {@code{repository-cgit-configuration} parameter} repo-string commit-sort
21575 Flag which, when set to @samp{date}, enables strict date ordering in the
21576 commit log, and when set to @samp{topo} enables strict topological
21577 ordering.
21578
21579 Defaults to @samp{""}.
21580
21581 @end deftypevr
21582
21583 @deftypevr {@code{repository-cgit-configuration} parameter} repo-string defbranch
21584 The name of the default branch for this repository. If no such branch
21585 exists in the repository, the first branch name (when sorted) is used as
21586 default instead. By default branch pointed to by HEAD, or "master" if
21587 there is no suitable HEAD.
21588
21589 Defaults to @samp{""}.
21590
21591 @end deftypevr
21592
21593 @deftypevr {@code{repository-cgit-configuration} parameter} repo-string desc
21594 The value to show as repository description.
21595
21596 Defaults to @samp{""}.
21597
21598 @end deftypevr
21599
21600 @deftypevr {@code{repository-cgit-configuration} parameter} repo-string homepage
21601 The value to show as repository homepage.
21602
21603 Defaults to @samp{""}.
21604
21605 @end deftypevr
21606
21607 @deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object email-filter
21608 Override the default @code{email-filter}.
21609
21610 Defaults to @samp{""}.
21611
21612 @end deftypevr
21613
21614 @deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-commit-graph?
21615 A flag which can be used to disable the global setting
21616 @code{enable-commit-graph?}.
21617
21618 Defaults to @samp{disabled}.
21619
21620 @end deftypevr
21621
21622 @deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-log-filecount?
21623 A flag which can be used to disable the global setting
21624 @code{enable-log-filecount?}.
21625
21626 Defaults to @samp{disabled}.
21627
21628 @end deftypevr
21629
21630 @deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-log-linecount?
21631 A flag which can be used to disable the global setting
21632 @code{enable-log-linecount?}.
21633
21634 Defaults to @samp{disabled}.
21635
21636 @end deftypevr
21637
21638 @deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-remote-branches?
21639 Flag which, when set to @code{#t}, will make cgit display remote
21640 branches in the summary and refs views.
21641
21642 Defaults to @samp{disabled}.
21643
21644 @end deftypevr
21645
21646 @deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-subject-links?
21647 A flag which can be used to override the global setting
21648 @code{enable-subject-links?}.
21649
21650 Defaults to @samp{disabled}.
21651
21652 @end deftypevr
21653
21654 @deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-html-serving?
21655 A flag which can be used to override the global setting
21656 @code{enable-html-serving?}.
21657
21658 Defaults to @samp{disabled}.
21659
21660 @end deftypevr
21661
21662 @deftypevr {@code{repository-cgit-configuration} parameter} repo-boolean hide?
21663 Flag which, when set to @code{#t}, hides the repository from the
21664 repository index.
21665
21666 Defaults to @samp{#f}.
21667
21668 @end deftypevr
21669
21670 @deftypevr {@code{repository-cgit-configuration} parameter} repo-boolean ignore?
21671 Flag which, when set to @samp{#t}, ignores the repository.
21672
21673 Defaults to @samp{#f}.
21674
21675 @end deftypevr
21676
21677 @deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object logo
21678 URL which specifies the source of an image which will be used as a logo
21679 on this repo’s pages.
21680
21681 Defaults to @samp{""}.
21682
21683 @end deftypevr
21684
21685 @deftypevr {@code{repository-cgit-configuration} parameter} repo-string logo-link
21686 URL loaded when clicking on the cgit logo image.
21687
21688 Defaults to @samp{""}.
21689
21690 @end deftypevr
21691
21692 @deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object owner-filter
21693 Override the default @code{owner-filter}.
21694
21695 Defaults to @samp{""}.
21696
21697 @end deftypevr
21698
21699 @deftypevr {@code{repository-cgit-configuration} parameter} repo-string module-link
21700 Text which will be used as the formatstring for a hyperlink when a
21701 submodule is printed in a directory listing. The arguments for the
21702 formatstring are the path and SHA1 of the submodule commit.
21703
21704 Defaults to @samp{""}.
21705
21706 @end deftypevr
21707
21708 @deftypevr {@code{repository-cgit-configuration} parameter} module-link-path module-link-path
21709 Text which will be used as the formatstring for a hyperlink when a
21710 submodule with the specified subdirectory path is printed in a directory
21711 listing.
21712
21713 Defaults to @samp{()}.
21714
21715 @end deftypevr
21716
21717 @deftypevr {@code{repository-cgit-configuration} parameter} repo-string max-stats
21718 Override the default maximum statistics period.
21719
21720 Defaults to @samp{""}.
21721
21722 @end deftypevr
21723
21724 @deftypevr {@code{repository-cgit-configuration} parameter} repo-string name
21725 The value to show as repository name.
21726
21727 Defaults to @samp{""}.
21728
21729 @end deftypevr
21730
21731 @deftypevr {@code{repository-cgit-configuration} parameter} repo-string owner
21732 A value used to identify the owner of the repository.
21733
21734 Defaults to @samp{""}.
21735
21736 @end deftypevr
21737
21738 @deftypevr {@code{repository-cgit-configuration} parameter} repo-string path
21739 An absolute path to the repository directory.
21740
21741 Defaults to @samp{""}.
21742
21743 @end deftypevr
21744
21745 @deftypevr {@code{repository-cgit-configuration} parameter} repo-string readme
21746 A path (relative to repo) which specifies a file to include verbatim as
21747 the "About" page for this repo.
21748
21749 Defaults to @samp{""}.
21750
21751 @end deftypevr
21752
21753 @deftypevr {@code{repository-cgit-configuration} parameter} repo-string section
21754 The name of the current repository section - all repositories defined
21755 after this option will inherit the current section name.
21756
21757 Defaults to @samp{""}.
21758
21759 @end deftypevr
21760
21761 @deftypevr {@code{repository-cgit-configuration} parameter} repo-list extra-options
21762 Extra options will be appended to cgitrc file.
21763
21764 Defaults to @samp{()}.
21765
21766 @end deftypevr
21767
21768 @end deftypevr
21769
21770 @deftypevr {@code{cgit-configuration} parameter} list extra-options
21771 Extra options will be appended to cgitrc file.
21772
21773 Defaults to @samp{()}.
21774
21775 @end deftypevr
21776
21777
21778 @c %end of fragment
21779
21780 However, it could be that you just want to get a @code{cgitrc} up and
21781 running. In that case, you can pass an @code{opaque-cgit-configuration}
21782 as a record to @code{cgit-service-type}. As its name indicates, an
21783 opaque configuration does not have easy reflective capabilities.
21784
21785 Available @code{opaque-cgit-configuration} fields are:
21786
21787 @deftypevr {@code{opaque-cgit-configuration} parameter} package cgit
21788 The cgit package.
21789 @end deftypevr
21790
21791 @deftypevr {@code{opaque-cgit-configuration} parameter} string string
21792 The contents of the @code{cgitrc}, as a string.
21793 @end deftypevr
21794
21795 For example, if your @code{cgitrc} is just the empty string, you
21796 could instantiate a cgit service like this:
21797
21798 @example
21799 (service cgit-service-type
21800 (opaque-cgit-configuration
21801 (cgitrc "")))
21802 @end example
21803
21804 @subsubheading Gitolite Service
21805
21806 @cindex Gitolite service
21807 @cindex Git, hosting
21808 @uref{http://gitolite.com/gitolite/, Gitolite} is a tool for hosting Git
21809 repositories on a central server.
21810
21811 Gitolite can handle multiple repositories and users, and supports flexible
21812 configuration of the permissions for the users on the repositories.
21813
21814 The following example will configure Gitolite using the default @code{git}
21815 user, and the provided SSH public key.
21816
21817 @example
21818 (service gitolite-service-type
21819 (gitolite-configuration
21820 (admin-pubkey (plain-file
21821 "yourname.pub"
21822 "ssh-rsa AAAA... guix@@example.com"))))
21823 @end example
21824
21825 Gitolite is configured through a special admin repository which you can clone,
21826 for example, if you setup Gitolite on @code{example.com}, you would run the
21827 following command to clone the admin repository.
21828
21829 @example
21830 git clone git@@example.com:gitolite-admin
21831 @end example
21832
21833 When the Gitolite service is activated, the provided @code{admin-pubkey} will
21834 be inserted in to the @file{keydir} directory in the gitolite-admin
21835 repository. If this results in a change in the repository, it will be
21836 committed using the message ``gitolite setup by GNU Guix''.
21837
21838 @deftp {Data Type} gitolite-configuration
21839 Data type representing the configuration for @code{gitolite-service-type}.
21840
21841 @table @asis
21842 @item @code{package} (default: @var{gitolite})
21843 Gitolite package to use.
21844
21845 @item @code{user} (default: @var{git})
21846 User to use for Gitolite. This will be user that you use when accessing
21847 Gitolite over SSH.
21848
21849 @item @code{group} (default: @var{git})
21850 Group to use for Gitolite.
21851
21852 @item @code{home-directory} (default: @var{"/var/lib/gitolite"})
21853 Directory in which to store the Gitolite configuration and repositories.
21854
21855 @item @code{rc-file} (default: @var{(gitolite-rc-file)})
21856 A ``file-like'' object (@pxref{G-Expressions, file-like objects}),
21857 representing the configuration for Gitolite.
21858
21859 @item @code{admin-pubkey} (default: @var{#f})
21860 A ``file-like'' object (@pxref{G-Expressions, file-like objects}) used to
21861 setup Gitolite. This will be inserted in to the @file{keydir} directory
21862 within the gitolite-admin repository.
21863
21864 To specify the SSH key as a string, use the @code{plain-file} function.
21865
21866 @example
21867 (plain-file "yourname.pub" "ssh-rsa AAAA... guix@@example.com")
21868 @end example
21869
21870 @end table
21871 @end deftp
21872
21873 @deftp {Data Type} gitolite-rc-file
21874 Data type representing the Gitolite RC file.
21875
21876 @table @asis
21877 @item @code{umask} (default: @code{#o0077})
21878 This controls the permissions Gitolite sets on the repositories and their
21879 contents.
21880
21881 A value like @code{#o0027} will give read access to the group used by Gitolite
21882 (by default: @code{git}). This is necessary when using Gitolite with software
21883 like cgit or gitweb.
21884
21885 @item @code{git-config-keys} (default: @code{""})
21886 Gitolite allows you to set git config values using the "config" keyword. This
21887 setting allows control over the config keys to accept.
21888
21889 @item @code{roles} (default: @code{'(("READERS" . 1) ("WRITERS" . ))})
21890 Set the role names allowed to be used by users running the perms command.
21891
21892 @item @code{enable} (default: @code{'("help" "desc" "info" "perms" "writable" "ssh-authkeys" "git-config" "daemon" "gitweb")})
21893 This setting controls the commands and features to enable within Gitolite.
21894
21895 @end table
21896 @end deftp
21897
21898
21899 @node Game Services
21900 @subsection Game Services
21901
21902 @subsubheading The Battle for Wesnoth Service
21903 @cindex wesnothd
21904 @uref{https://wesnoth.org, The Battle for Wesnoth} is a fantasy, turn
21905 based tactical strategy game, with several single player campaigns, and
21906 multiplayer games (both networked and local).
21907
21908 @defvar {Scheme Variable} wesnothd-service-type
21909 Service type for the wesnothd service. Its value must be a
21910 @code{wesnothd-configuration} object. To run wesnothd in the default
21911 configuration, instantiate it as:
21912
21913 @example
21914 (service wesnothd-service-type)
21915 @end example
21916 @end defvar
21917
21918 @deftp {Data Type} wesnothd-configuration
21919 Data type representing the configuration of @command{wesnothd}.
21920
21921 @table @asis
21922 @item @code{package} (default: @code{wesnoth-server})
21923 The wesnoth server package to use.
21924
21925 @item @code{port} (default: @code{15000})
21926 The port to bind the server to.
21927 @end table
21928 @end deftp
21929
21930 @node Miscellaneous Services
21931 @subsection Miscellaneous Services
21932
21933 @cindex fingerprint
21934 @subsubheading Fingerprint Service
21935
21936 The @code{(gnu services fingerprint)} module provides a DBus service to
21937 read and identify fingerprints via a fingerprint sensor.
21938
21939 @defvr {Scheme Variable} fprintd-service-type
21940 The service type for @command{fprintd}, which provides the fingerprint
21941 reading capability.
21942
21943 @example
21944 (service fprintd-service-type)
21945 @end example
21946 @end defvr
21947
21948 @cindex sysctl
21949 @subsubheading System Control Service
21950
21951 The @code{(gnu services sysctl)} provides a service to configure kernel
21952 parameters at boot.
21953
21954 @defvr {Scheme Variable} sysctl-service-type
21955 The service type for @command{sysctl}, which modifies kernel parameters
21956 under @file{/proc/sys/}. To enable IPv4 forwarding, it can be
21957 instantiated as:
21958
21959 @example
21960 (service sysctl-service-type
21961 (sysctl-configuration
21962 (settings '(("net.ipv4.ip_forward" . "1")))))
21963 @end example
21964 @end defvr
21965
21966 @deftp {Data Type} sysctl-configuration
21967 The data type representing the configuration of @command{sysctl}.
21968
21969 @table @asis
21970 @item @code{sysctl} (default: @code{(file-append procps "/sbin/sysctl"})
21971 The @command{sysctl} executable to use.
21972
21973 @item @code{settings} (default: @code{'()})
21974 An association list specifies kernel parameters and their values.
21975 @end table
21976 @end deftp
21977
21978 @cindex pcscd
21979 @subsubheading PC/SC Smart Card Daemon Service
21980
21981 The @code{(gnu services security-token)} module provides the following service
21982 to run @command{pcscd}, the PC/SC Smart Card Daemon. @command{pcscd} is the
21983 daemon program for pcsc-lite and the MuscleCard framework. It is a resource
21984 manager that coordinates communications with smart card readers, smart cards
21985 and cryptographic tokens that are connected to the system.
21986
21987 @defvr {Scheme Variable} pcscd-service-type
21988 Service type for the @command{pcscd} service. Its value must be a
21989 @code{pcscd-configuration} object. To run pcscd in the default
21990 configuration, instantiate it as:
21991
21992 @example
21993 (service pcscd-service-type)
21994 @end example
21995 @end defvr
21996
21997 @deftp {Data Type} pcscd-configuration
21998 The data type representing the configuration of @command{pcscd}.
21999
22000 @table @asis
22001 @item @code{pcsc-lite} (default: @code{pcsc-lite})
22002 The pcsc-lite package that provides pcscd.
22003 @item @code{usb-drivers} (default: @code{(list ccid)})
22004 List of packages that provide USB drivers to pcscd. Drivers are expected to be
22005 under @file{pcsc/drivers} in the store directory of the package.
22006 @end table
22007 @end deftp
22008
22009 @cindex lirc
22010 @subsubheading Lirc Service
22011
22012 The @code{(gnu services lirc)} module provides the following service.
22013
22014 @deffn {Scheme Procedure} lirc-service [#:lirc lirc] @
22015 [#:device #f] [#:driver #f] [#:config-file #f] @
22016 [#:extra-options '()]
22017 Return a service that runs @url{http://www.lirc.org,LIRC}, a daemon that
22018 decodes infrared signals from remote controls.
22019
22020 Optionally, @var{device}, @var{driver} and @var{config-file}
22021 (configuration file name) may be specified. See @command{lircd} manual
22022 for details.
22023
22024 Finally, @var{extra-options} is a list of additional command-line options
22025 passed to @command{lircd}.
22026 @end deffn
22027
22028 @cindex spice
22029 @subsubheading Spice Service
22030
22031 The @code{(gnu services spice)} module provides the following service.
22032
22033 @deffn {Scheme Procedure} spice-vdagent-service [#:spice-vdagent]
22034 Returns a service that runs @url{http://www.spice-space.org,VDAGENT}, a daemon
22035 that enables sharing the clipboard with a vm and setting the guest display
22036 resolution when the graphical console window resizes.
22037 @end deffn
22038
22039 @subsection Dictionary Services
22040 @cindex dictionary
22041 The @code{(gnu services dict)} module provides the following service:
22042
22043 @deffn {Scheme Procedure} dicod-service [#:config (dicod-configuration)]
22044 Return a service that runs the @command{dicod} daemon, an implementation
22045 of DICT server (@pxref{Dicod,,, dico, GNU Dico Manual}).
22046
22047 The optional @var{config} argument specifies the configuration for
22048 @command{dicod}, which should be a @code{<dicod-configuration>} object, by
22049 default it serves the GNU Collaborative International Dictonary of English.
22050
22051 You can add @command{open localhost} to your @file{~/.dico} file to make
22052 @code{localhost} the default server for @command{dico} client
22053 (@pxref{Initialization File,,, dico, GNU Dico Manual}).
22054 @end deffn
22055
22056 @deftp {Data Type} dicod-configuration
22057 Data type representing the configuration of dicod.
22058
22059 @table @asis
22060 @item @code{dico} (default: @var{dico})
22061 Package object of the GNU Dico dictionary server.
22062
22063 @item @code{interfaces} (default: @var{'("localhost")})
22064 This is the list of IP addresses and ports and possibly socket file
22065 names to listen to (@pxref{Server Settings, @code{listen} directive,,
22066 dico, GNU Dico Manual}).
22067
22068 @item @code{handlers} (default: @var{'()})
22069 List of @code{<dicod-handler>} objects denoting handlers (module instances).
22070
22071 @item @code{databases} (default: @var{(list %dicod-database:gcide)})
22072 List of @code{<dicod-database>} objects denoting dictionaries to be served.
22073 @end table
22074 @end deftp
22075
22076 @deftp {Data Type} dicod-handler
22077 Data type representing a dictionary handler (module instance).
22078
22079 @table @asis
22080 @item @code{name}
22081 Name of the handler (module instance).
22082
22083 @item @code{module} (default: @var{#f})
22084 Name of the dicod module of the handler (instance). If it is @code{#f},
22085 the module has the same name as the handler.
22086 (@pxref{Modules,,, dico, GNU Dico Manual}).
22087
22088 @item @code{options}
22089 List of strings or gexps representing the arguments for the module handler
22090 @end table
22091 @end deftp
22092
22093 @deftp {Data Type} dicod-database
22094 Data type representing a dictionary database.
22095
22096 @table @asis
22097 @item @code{name}
22098 Name of the database, will be used in DICT commands.
22099
22100 @item @code{handler}
22101 Name of the dicod handler (module instance) used by this database
22102 (@pxref{Handlers,,, dico, GNU Dico Manual}).
22103
22104 @item @code{complex?} (default: @var{#f})
22105 Whether the database configuration complex. The complex configuration
22106 will need a corresponding @code{<dicod-handler>} object, otherwise not.
22107
22108 @item @code{options}
22109 List of strings or gexps representing the arguments for the database
22110 (@pxref{Databases,,, dico, GNU Dico Manual}).
22111 @end table
22112 @end deftp
22113
22114 @defvr {Scheme Variable} %dicod-database:gcide
22115 A @code{<dicod-database>} object serving the GNU Collaborative International
22116 Dictionary of English using the @code{gcide} package.
22117 @end defvr
22118
22119 The following is an example @code{dicod-service} configuration.
22120
22121 @example
22122 (dicod-service #:config
22123 (dicod-configuration
22124 (handlers (list (dicod-handler
22125 (name "wordnet")
22126 (module "dictorg")
22127 (options
22128 (list #~(string-append "dbdir=" #$wordnet))))))
22129 (databases (list (dicod-database
22130 (name "wordnet")
22131 (complex? #t)
22132 (handler "wordnet")
22133 (options '("database=wn")))
22134 %dicod-database:gcide))))
22135 @end example
22136
22137 @cindex Docker
22138 @subsubheading Docker Service
22139
22140 The @code{(gnu services docker)} module provides the following service.
22141
22142 @defvr {Scheme Variable} docker-service-type
22143
22144 This is the type of the service that runs @url{http://www.docker.com,Docker},
22145 a daemon that can execute application bundles (sometimes referred to as
22146 ``containers'') in isolated environments.
22147
22148 @end defvr
22149
22150 @deftp {Data Type} docker-configuration
22151 This is the data type representing the configuration of Docker and Containerd.
22152
22153 @table @asis
22154
22155 @item @code{package} (default: @code{docker})
22156 The Docker package to use.
22157
22158 @item @code{containerd} (default: @var{containerd})
22159 The Containerd package to use.
22160
22161 @end table
22162 @end deftp
22163
22164 @node Setuid Programs
22165 @section Setuid Programs
22166
22167 @cindex setuid programs
22168 Some programs need to run with ``root'' privileges, even when they are
22169 launched by unprivileged users. A notorious example is the
22170 @command{passwd} program, which users can run to change their
22171 password, and which needs to access the @file{/etc/passwd} and
22172 @file{/etc/shadow} files---something normally restricted to root, for
22173 obvious security reasons. To address that, these executables are
22174 @dfn{setuid-root}, meaning that they always run with root privileges
22175 (@pxref{How Change Persona,,, libc, The GNU C Library Reference Manual},
22176 for more info about the setuid mechanism.)
22177
22178 The store itself @emph{cannot} contain setuid programs: that would be a
22179 security issue since any user on the system can write derivations that
22180 populate the store (@pxref{The Store}). Thus, a different mechanism is
22181 used: instead of changing the setuid bit directly on files that are in
22182 the store, we let the system administrator @emph{declare} which programs
22183 should be setuid root.
22184
22185 The @code{setuid-programs} field of an @code{operating-system}
22186 declaration contains a list of G-expressions denoting the names of
22187 programs to be setuid-root (@pxref{Using the Configuration System}).
22188 For instance, the @command{passwd} program, which is part of the Shadow
22189 package, can be designated by this G-expression (@pxref{G-Expressions}):
22190
22191 @example
22192 #~(string-append #$shadow "/bin/passwd")
22193 @end example
22194
22195 A default set of setuid programs is defined by the
22196 @code{%setuid-programs} variable of the @code{(gnu system)} module.
22197
22198 @defvr {Scheme Variable} %setuid-programs
22199 A list of G-expressions denoting common programs that are setuid-root.
22200
22201 The list includes commands such as @command{passwd}, @command{ping},
22202 @command{su}, and @command{sudo}.
22203 @end defvr
22204
22205 Under the hood, the actual setuid programs are created in the
22206 @file{/run/setuid-programs} directory at system activation time. The
22207 files in this directory refer to the ``real'' binaries, which are in the
22208 store.
22209
22210 @node X.509 Certificates
22211 @section X.509 Certificates
22212
22213 @cindex HTTPS, certificates
22214 @cindex X.509 certificates
22215 @cindex TLS
22216 Web servers available over HTTPS (that is, HTTP over the transport-layer
22217 security mechanism, TLS) send client programs an @dfn{X.509 certificate}
22218 that the client can then use to @emph{authenticate} the server. To do
22219 that, clients verify that the server's certificate is signed by a
22220 so-called @dfn{certificate authority} (CA). But to verify the CA's
22221 signature, clients must have first acquired the CA's certificate.
22222
22223 Web browsers such as GNU@tie{}IceCat include their own set of CA
22224 certificates, such that they are able to verify CA signatures
22225 out-of-the-box.
22226
22227 However, most other programs that can talk HTTPS---@command{wget},
22228 @command{git}, @command{w3m}, etc.---need to be told where CA
22229 certificates can be found.
22230
22231 @cindex @code{nss-certs}
22232 In GuixSD, this is done by adding a package that provides certificates
22233 to the @code{packages} field of the @code{operating-system} declaration
22234 (@pxref{operating-system Reference}). GuixSD includes one such package,
22235 @code{nss-certs}, which is a set of CA certificates provided as part of
22236 Mozilla's Network Security Services.
22237
22238 Note that it is @emph{not} part of @var{%base-packages}, so you need to
22239 explicitly add it. The @file{/etc/ssl/certs} directory, which is where
22240 most applications and libraries look for certificates by default, points
22241 to the certificates installed globally.
22242
22243 Unprivileged users, including users of Guix on a foreign distro,
22244 can also install their own certificate package in
22245 their profile. A number of environment variables need to be defined so
22246 that applications and libraries know where to find them. Namely, the
22247 OpenSSL library honors the @code{SSL_CERT_DIR} and @code{SSL_CERT_FILE}
22248 variables. Some applications add their own environment variables; for
22249 instance, the Git version control system honors the certificate bundle
22250 pointed to by the @code{GIT_SSL_CAINFO} environment variable. Thus, you
22251 would typically run something like:
22252
22253 @example
22254 $ guix package -i nss-certs
22255 $ export SSL_CERT_DIR="$HOME/.guix-profile/etc/ssl/certs"
22256 $ export SSL_CERT_FILE="$HOME/.guix-profile/etc/ssl/certs/ca-certificates.crt"
22257 $ export GIT_SSL_CAINFO="$SSL_CERT_FILE"
22258 @end example
22259
22260 As another example, R requires the @code{CURL_CA_BUNDLE} environment
22261 variable to point to a certificate bundle, so you would have to run
22262 something like this:
22263
22264 @example
22265 $ guix package -i nss-certs
22266 $ export CURL_CA_BUNDLE="$HOME/.guix-profile/etc/ssl/certs/ca-certificates.crt"
22267 @end example
22268
22269 For other applications you may want to look up the required environment
22270 variable in the relevant documentation.
22271
22272
22273 @node Name Service Switch
22274 @section Name Service Switch
22275
22276 @cindex name service switch
22277 @cindex NSS
22278 The @code{(gnu system nss)} module provides bindings to the
22279 configuration file of the libc @dfn{name service switch} or @dfn{NSS}
22280 (@pxref{NSS Configuration File,,, libc, The GNU C Library Reference
22281 Manual}). In a nutshell, the NSS is a mechanism that allows libc to be
22282 extended with new ``name'' lookup methods for system databases, which
22283 includes host names, service names, user accounts, and more (@pxref{Name
22284 Service Switch, System Databases and Name Service Switch,, libc, The GNU
22285 C Library Reference Manual}).
22286
22287 The NSS configuration specifies, for each system database, which lookup
22288 method is to be used, and how the various methods are chained
22289 together---for instance, under which circumstances NSS should try the
22290 next method in the list. The NSS configuration is given in the
22291 @code{name-service-switch} field of @code{operating-system} declarations
22292 (@pxref{operating-system Reference, @code{name-service-switch}}).
22293
22294 @cindex nss-mdns
22295 @cindex .local, host name lookup
22296 As an example, the declaration below configures the NSS to use the
22297 @uref{http://0pointer.de/lennart/projects/nss-mdns/, @code{nss-mdns}
22298 back-end}, which supports host name lookups over multicast DNS (mDNS)
22299 for host names ending in @code{.local}:
22300
22301 @example
22302 (name-service-switch
22303 (hosts (list %files ;first, check /etc/hosts
22304
22305 ;; If the above did not succeed, try
22306 ;; with 'mdns_minimal'.
22307 (name-service
22308 (name "mdns_minimal")
22309
22310 ;; 'mdns_minimal' is authoritative for
22311 ;; '.local'. When it returns "not found",
22312 ;; no need to try the next methods.
22313 (reaction (lookup-specification
22314 (not-found => return))))
22315
22316 ;; Then fall back to DNS.
22317 (name-service
22318 (name "dns"))
22319
22320 ;; Finally, try with the "full" 'mdns'.
22321 (name-service
22322 (name "mdns")))))
22323 @end example
22324
22325 Do not worry: the @code{%mdns-host-lookup-nss} variable (see below)
22326 contains this configuration, so you will not have to type it if all you
22327 want is to have @code{.local} host lookup working.
22328
22329 Note that, in this case, in addition to setting the
22330 @code{name-service-switch} of the @code{operating-system} declaration,
22331 you also need to use @code{avahi-service-type} (@pxref{Networking Services,
22332 @code{avahi-service-type}}), or @var{%desktop-services}, which includes it
22333 (@pxref{Desktop Services}). Doing this makes @code{nss-mdns} accessible
22334 to the name service cache daemon (@pxref{Base Services,
22335 @code{nscd-service}}).
22336
22337 For convenience, the following variables provide typical NSS
22338 configurations.
22339
22340 @defvr {Scheme Variable} %default-nss
22341 This is the default name service switch configuration, a
22342 @code{name-service-switch} object.
22343 @end defvr
22344
22345 @defvr {Scheme Variable} %mdns-host-lookup-nss
22346 This is the name service switch configuration with support for host name
22347 lookup over multicast DNS (mDNS) for host names ending in @code{.local}.
22348 @end defvr
22349
22350 The reference for name service switch configuration is given below. It
22351 is a direct mapping of the configuration file format of the C library , so
22352 please refer to the C library manual for more information (@pxref{NSS
22353 Configuration File,,, libc, The GNU C Library Reference Manual}).
22354 Compared to the configuration file format of libc NSS, it has the advantage
22355 not only of adding this warm parenthetic feel that we like, but also
22356 static checks: you will know about syntax errors and typos as soon as you
22357 run @command{guix system}.
22358
22359 @deftp {Data Type} name-service-switch
22360
22361 This is the data type representation the configuration of libc's name
22362 service switch (NSS). Each field below represents one of the supported
22363 system databases.
22364
22365 @table @code
22366 @item aliases
22367 @itemx ethers
22368 @itemx group
22369 @itemx gshadow
22370 @itemx hosts
22371 @itemx initgroups
22372 @itemx netgroup
22373 @itemx networks
22374 @itemx password
22375 @itemx public-key
22376 @itemx rpc
22377 @itemx services
22378 @itemx shadow
22379 The system databases handled by the NSS. Each of these fields must be a
22380 list of @code{<name-service>} objects (see below).
22381 @end table
22382 @end deftp
22383
22384 @deftp {Data Type} name-service
22385
22386 This is the data type representing an actual name service and the
22387 associated lookup action.
22388
22389 @table @code
22390 @item name
22391 A string denoting the name service (@pxref{Services in the NSS
22392 configuration,,, libc, The GNU C Library Reference Manual}).
22393
22394 Note that name services listed here must be visible to nscd. This is
22395 achieved by passing the @code{#:name-services} argument to
22396 @code{nscd-service} the list of packages providing the needed name
22397 services (@pxref{Base Services, @code{nscd-service}}).
22398
22399 @item reaction
22400 An action specified using the @code{lookup-specification} macro
22401 (@pxref{Actions in the NSS configuration,,, libc, The GNU C Library
22402 Reference Manual}). For example:
22403
22404 @example
22405 (lookup-specification (unavailable => continue)
22406 (success => return))
22407 @end example
22408 @end table
22409 @end deftp
22410
22411 @node Initial RAM Disk
22412 @section Initial RAM Disk
22413
22414 @cindex initrd
22415 @cindex initial RAM disk
22416 For bootstrapping purposes, the Linux-Libre kernel is passed an
22417 @dfn{initial RAM disk}, or @dfn{initrd}. An initrd contains a temporary
22418 root file system as well as an initialization script. The latter is
22419 responsible for mounting the real root file system, and for loading any
22420 kernel modules that may be needed to achieve that.
22421
22422 The @code{initrd-modules} field of an @code{operating-system}
22423 declaration allows you to specify Linux-libre kernel modules that must
22424 be available in the initrd. In particular, this is where you would list
22425 modules needed to actually drive the hard disk where your root partition
22426 is---although the default value of @code{initrd-modules} should cover
22427 most use cases. For example, assuming you need the @code{megaraid_sas}
22428 module in addition to the default modules to be able to access your root
22429 file system, you would write:
22430
22431 @example
22432 (operating-system
22433 ;; @dots{}
22434 (initrd-modules (cons "megaraid_sas" %base-initrd-modules)))
22435 @end example
22436
22437 @defvr {Scheme Variable} %base-initrd-modules
22438 This is the list of kernel modules included in the initrd by default.
22439 @end defvr
22440
22441 Furthermore, if you need lower-level customization, the @code{initrd}
22442 field of an @code{operating-system} declaration allows
22443 you to specify which initrd you would like to use. The @code{(gnu
22444 system linux-initrd)} module provides three ways to build an initrd: the
22445 high-level @code{base-initrd} procedure and the low-level
22446 @code{raw-initrd} and @code{expression->initrd} procedures.
22447
22448 The @code{base-initrd} procedure is intended to cover most common uses.
22449 For example, if you want to add a bunch of kernel modules to be loaded
22450 at boot time, you can define the @code{initrd} field of the operating
22451 system declaration like this:
22452
22453 @example
22454 (initrd (lambda (file-systems . rest)
22455 ;; Create a standard initrd but set up networking
22456 ;; with the parameters QEMU expects by default.
22457 (apply base-initrd file-systems
22458 #:qemu-networking? #t
22459 rest)))
22460 @end example
22461
22462 The @code{base-initrd} procedure also handles common use cases that
22463 involves using the system as a QEMU guest, or as a ``live'' system with
22464 volatile root file system.
22465
22466 The @code{base-initrd} procedure is built from @code{raw-initrd} procedure.
22467 Unlike @code{base-initrd}, @code{raw-initrd} doesn't do anything high-level,
22468 such as trying to guess which kernel modules and packages should be included
22469 to the initrd. An example use of @code{raw-initrd} is when a user has
22470 a custom Linux kernel configuration and default kernel modules included by
22471 @code{base-initrd} are not available.
22472
22473 The initial RAM disk produced by @code{base-initrd} or @code{raw-initrd}
22474 honors several options passed on the Linux kernel command line
22475 (that is, arguments passed @i{via} the @code{linux} command of GRUB, or the
22476 @code{-append} option of QEMU), notably:
22477
22478 @table @code
22479 @item --load=@var{boot}
22480 Tell the initial RAM disk to load @var{boot}, a file containing a Scheme
22481 program, once it has mounted the root file system.
22482
22483 GuixSD uses this option to yield control to a boot program that runs the
22484 service activation programs and then spawns the GNU@tie{}Shepherd, the
22485 initialization system.
22486
22487 @item --root=@var{root}
22488 Mount @var{root} as the root file system. @var{root} can be a
22489 device name like @code{/dev/sda1}, a file system label, or a file system
22490 UUID.
22491
22492 @item --system=@var{system}
22493 Have @file{/run/booted-system} and @file{/run/current-system} point to
22494 @var{system}.
22495
22496 @item modprobe.blacklist=@var{modules}@dots{}
22497 @cindex module, black-listing
22498 @cindex black list, of kernel modules
22499 Instruct the initial RAM disk as well as the @command{modprobe} command
22500 (from the kmod package) to refuse to load @var{modules}. @var{modules}
22501 must be a comma-separated list of module names---e.g.,
22502 @code{usbkbd,9pnet}.
22503
22504 @item --repl
22505 Start a read-eval-print loop (REPL) from the initial RAM disk before it
22506 tries to load kernel modules and to mount the root file system. Our
22507 marketing team calls it @dfn{boot-to-Guile}. The Schemer in you will
22508 love it. @xref{Using Guile Interactively,,, guile, GNU Guile Reference
22509 Manual}, for more information on Guile's REPL.
22510
22511 @end table
22512
22513 Now that you know all the features that initial RAM disks produced by
22514 @code{base-initrd} and @code{raw-initrd} provide,
22515 here is how to use it and customize it further.
22516
22517 @cindex initrd
22518 @cindex initial RAM disk
22519 @deffn {Scheme Procedure} raw-initrd @var{file-systems} @
22520 [#:linux-modules '()] [#:mapped-devices '()] @
22521 [#:helper-packages '()] [#:qemu-networking? #f] [#:volatile-root? #f]
22522 Return a derivation that builds a raw initrd. @var{file-systems} is
22523 a list of file systems to be mounted by the initrd, possibly in addition to
22524 the root file system specified on the kernel command line via @code{--root}.
22525 @var{linux-modules} is a list of kernel modules to be loaded at boot time.
22526 @var{mapped-devices} is a list of device mappings to realize before
22527 @var{file-systems} are mounted (@pxref{Mapped Devices}).
22528 @var{helper-packages} is a list of packages to be copied in the initrd. It may
22529 include @code{e2fsck/static} or other packages needed by the initrd to check
22530 the root file system.
22531
22532 When @var{qemu-networking?} is true, set up networking with the standard QEMU
22533 parameters. When @var{virtio?} is true, load additional modules so that the
22534 initrd can be used as a QEMU guest with para-virtualized I/O drivers.
22535
22536 When @var{volatile-root?} is true, the root file system is writable but any changes
22537 to it are lost.
22538 @end deffn
22539
22540 @deffn {Scheme Procedure} base-initrd @var{file-systems} @
22541 [#:mapped-devices '()] [#:qemu-networking? #f] [#:volatile-root? #f]@
22542 [#:linux-modules '()]
22543 Return as a file-like object a generic initrd, with kernel
22544 modules taken from @var{linux}. @var{file-systems} is a list of file-systems to be
22545 mounted by the initrd, possibly in addition to the root file system specified
22546 on the kernel command line via @code{--root}. @var{mapped-devices} is a list of device
22547 mappings to realize before @var{file-systems} are mounted.
22548
22549 @var{qemu-networking?} and @var{volatile-root?} behaves as in @code{raw-initrd}.
22550
22551 The initrd is automatically populated with all the kernel modules necessary
22552 for @var{file-systems} and for the given options. Additional kernel
22553 modules can be listed in @var{linux-modules}. They will be added to the initrd, and
22554 loaded at boot time in the order in which they appear.
22555 @end deffn
22556
22557 Needless to say, the initrds we produce and use embed a
22558 statically-linked Guile, and the initialization program is a Guile
22559 program. That gives a lot of flexibility. The
22560 @code{expression->initrd} procedure builds such an initrd, given the
22561 program to run in that initrd.
22562
22563 @deffn {Scheme Procedure} expression->initrd @var{exp} @
22564 [#:guile %guile-static-stripped] [#:name "guile-initrd"]
22565 Return as a file-like object a Linux initrd (a gzipped cpio archive)
22566 containing @var{guile} and that evaluates @var{exp}, a G-expression,
22567 upon booting. All the derivations referenced by @var{exp} are
22568 automatically copied to the initrd.
22569 @end deffn
22570
22571 @node Bootloader Configuration
22572 @section Bootloader Configuration
22573
22574 @cindex bootloader
22575 @cindex boot loader
22576
22577 The operating system supports multiple bootloaders. The bootloader is
22578 configured using @code{bootloader-configuration} declaration. All the
22579 fields of this structure are bootloader agnostic except for one field,
22580 @code{bootloader} that indicates the bootloader to be configured and
22581 installed.
22582
22583 Some of the bootloaders do not honor every field of
22584 @code{bootloader-configuration}. For instance, the extlinux
22585 bootloader does not support themes and thus ignores the @code{theme}
22586 field.
22587
22588 @deftp {Data Type} bootloader-configuration
22589 The type of a bootloader configuration declaration.
22590
22591 @table @asis
22592
22593 @item @code{bootloader}
22594 @cindex EFI, bootloader
22595 @cindex UEFI, bootloader
22596 @cindex BIOS, bootloader
22597 The bootloader to use, as a @code{bootloader} object. For now
22598 @code{grub-bootloader}, @code{grub-efi-bootloader},
22599 @code{extlinux-bootloader} and @code{u-boot-bootloader} are supported.
22600
22601 @vindex grub-efi-bootloader
22602 @code{grub-efi-bootloader} allows to boot on modern systems using the
22603 @dfn{Unified Extensible Firmware Interface} (UEFI). This is what you should
22604 use if the installation image contains a @file{/sys/firmware/efi} directory
22605 when you boot it on your system.
22606
22607 @vindex grub-bootloader
22608 @code{grub-bootloader} allows you to boot in particular Intel-based machines
22609 in ``legacy'' BIOS mode.
22610
22611 @cindex ARM, bootloaders
22612 @cindex AArch64, bootloaders
22613 Available bootloaders are described in @code{(gnu bootloader @dots{})}
22614 modules. In particular, @code{(gnu bootloader u-boot)} contains definitions
22615 of bootloaders for a wide range of ARM and AArch64 systems, using the
22616 @uref{http://www.denx.de/wiki/U-Boot/, U-Boot bootloader}.
22617
22618 @item @code{target}
22619 This is a string denoting the target onto which to install the
22620 bootloader.
22621
22622 The interpretation depends on the bootloader in question. For
22623 @code{grub-bootloader}, for example, it should be a device name understood by
22624 the bootloader @command{installer} command, such as @code{/dev/sda} or
22625 @code{(hd0)} (@pxref{Invoking grub-install,,, grub, GNU GRUB Manual}). For
22626 @code{grub-efi-bootloader}, it should be the mount point of the EFI file
22627 system, usually @file{/boot/efi}.
22628
22629 @item @code{menu-entries} (default: @code{()})
22630 A possibly empty list of @code{menu-entry} objects (see below), denoting
22631 entries to appear in the bootloader menu, in addition to the current
22632 system entry and the entry pointing to previous system generations.
22633
22634 @item @code{default-entry} (default: @code{0})
22635 The index of the default boot menu entry. Index 0 is for the entry of the
22636 current system.
22637
22638 @item @code{timeout} (default: @code{5})
22639 The number of seconds to wait for keyboard input before booting. Set to
22640 0 to boot immediately, and to -1 to wait indefinitely.
22641
22642 @item @code{theme} (default: @var{#f})
22643 The bootloader theme object describing the theme to use. If no theme
22644 is provided, some bootloaders might use a default theme, that's true
22645 for GRUB.
22646
22647 @item @code{terminal-outputs} (default: @code{'gfxterm})
22648 The output terminals used for the bootloader boot menu, as a list of
22649 symbols. GRUB accepts the values: @code{console}, @code{serial},
22650 @code{serial_@{0-3@}}, @code{gfxterm}, @code{vga_text},
22651 @code{mda_text}, @code{morse}, and @code{pkmodem}. This field
22652 corresponds to the GRUB variable @code{GRUB_TERMINAL_OUTPUT} (@pxref{Simple
22653 configuration,,, grub,GNU GRUB manual}).
22654
22655 @item @code{terminal-inputs} (default: @code{'()})
22656 The input terminals used for the bootloader boot menu, as a list of
22657 symbols. For GRUB, the default is the native platform terminal as
22658 determined at run-time. GRUB accepts the values: @code{console},
22659 @code{serial}, @code{serial_@{0-3@}}, @code{at_keyboard}, and
22660 @code{usb_keyboard}. This field corresponds to the GRUB variable
22661 @code{GRUB_TERMINAL_INPUT} (@pxref{Simple configuration,,, grub,GNU GRUB
22662 manual}).
22663
22664 @item @code{serial-unit} (default: @code{#f})
22665 The serial unit used by the bootloader, as an integer from 0 to 3.
22666 For GRUB, it is chosen at run-time; currently GRUB chooses 0, which
22667 corresponds to COM1 (@pxref{Serial terminal,,, grub,GNU GRUB manual}).
22668
22669 @item @code{serial-speed} (default: @code{#f})
22670 The speed of the serial interface, as an integer. For GRUB, the
22671 default value is chosen at run-time; currently GRUB chooses
22672 9600@tie{}bps (@pxref{Serial terminal,,, grub,GNU GRUB manual}).
22673 @end table
22674
22675 @end deftp
22676
22677 @cindex dual boot
22678 @cindex boot menu
22679 Should you want to list additional boot menu entries @i{via} the
22680 @code{menu-entries} field above, you will need to create them with the
22681 @code{menu-entry} form. For example, imagine you want to be able to
22682 boot another distro (hard to imagine!), you can define a menu entry
22683 along these lines:
22684
22685 @example
22686 (menu-entry
22687 (label "The Other Distro")
22688 (linux "/boot/old/vmlinux-2.6.32")
22689 (linux-arguments '("root=/dev/sda2"))
22690 (initrd "/boot/old/initrd"))
22691 @end example
22692
22693 Details below.
22694
22695 @deftp {Data Type} menu-entry
22696 The type of an entry in the bootloader menu.
22697
22698 @table @asis
22699
22700 @item @code{label}
22701 The label to show in the menu---e.g., @code{"GNU"}.
22702
22703 @item @code{linux}
22704 The Linux kernel image to boot, for example:
22705
22706 @example
22707 (file-append linux-libre "/bzImage")
22708 @end example
22709
22710 For GRUB, it is also possible to specify a device explicitly in the
22711 file path using GRUB's device naming convention (@pxref{Naming
22712 convention,,, grub, GNU GRUB manual}), for example:
22713
22714 @example
22715 "(hd0,msdos1)/boot/vmlinuz"
22716 @end example
22717
22718 If the device is specified explicitly as above, then the @code{device}
22719 field is ignored entirely.
22720
22721 @item @code{linux-arguments} (default: @code{()})
22722 The list of extra Linux kernel command-line arguments---e.g.,
22723 @code{("console=ttyS0")}.
22724
22725 @item @code{initrd}
22726 A G-Expression or string denoting the file name of the initial RAM disk
22727 to use (@pxref{G-Expressions}).
22728 @item @code{device} (default: @code{#f})
22729 The device where the kernel and initrd are to be found---i.e., for GRUB,
22730 @dfn{root} for this menu entry (@pxref{root,,, grub, GNU GRUB manual}).
22731
22732 This may be a file system label (a string), a file system UUID (a
22733 bytevector, @pxref{File Systems}), or @code{#f}, in which case
22734 the bootloader will search the device containing the file specified by
22735 the @code{linux} field (@pxref{search,,, grub, GNU GRUB manual}). It
22736 must @emph{not} be an OS device name such as @file{/dev/sda1}.
22737
22738 @end table
22739 @end deftp
22740
22741 @c FIXME: Write documentation once it's stable.
22742 Fow now only GRUB has theme support. GRUB themes are created using
22743 the @code{grub-theme} form, which is not documented yet.
22744
22745 @defvr {Scheme Variable} %default-theme
22746 This is the default GRUB theme used by the operating system if no
22747 @code{theme} field is specified in @code{bootloader-configuration}
22748 record.
22749
22750 It comes with a fancy background image displaying the GNU and Guix
22751 logos.
22752 @end defvr
22753
22754
22755 @node Invoking guix system
22756 @section Invoking @code{guix system}
22757
22758 Once you have written an operating system declaration as seen in the
22759 previous section, it can be @dfn{instantiated} using the @command{guix
22760 system} command. The synopsis is:
22761
22762 @example
22763 guix system @var{options}@dots{} @var{action} @var{file}
22764 @end example
22765
22766 @var{file} must be the name of a file containing an
22767 @code{operating-system} declaration. @var{action} specifies how the
22768 operating system is instantiated. Currently the following values are
22769 supported:
22770
22771 @table @code
22772 @item search
22773 Display available service type definitions that match the given regular
22774 expressions, sorted by relevance:
22775
22776 @example
22777 $ guix system search console font
22778 name: console-fonts
22779 location: gnu/services/base.scm:729:2
22780 extends: shepherd-root
22781 description: Install the given fonts on the specified ttys (fonts are
22782 + per virtual console on GNU/Linux). The value of this service is a list
22783 + of tty/font pairs like:
22784 +
22785 + '(("tty1" . "LatGrkCyr-8x16"))
22786 relevance: 20
22787
22788 name: mingetty
22789 location: gnu/services/base.scm:1048:2
22790 extends: shepherd-root
22791 description: Provide console login using the `mingetty' program.
22792 relevance: 2
22793
22794 name: login
22795 location: gnu/services/base.scm:775:2
22796 extends: pam
22797 description: Provide a console log-in service as specified by its
22798 + configuration value, a `login-configuration' object.
22799 relevance: 2
22800
22801 @dots{}
22802 @end example
22803
22804 As for @command{guix package --search}, the result is written in
22805 @code{recutils} format, which makes it easy to filter the output
22806 (@pxref{Top, GNU recutils databases,, recutils, GNU recutils manual}).
22807
22808 @item reconfigure
22809 Build the operating system described in @var{file}, activate it, and
22810 switch to it@footnote{This action (and the related actions
22811 @code{switch-generation} and @code{roll-back}) are usable only on
22812 systems already running GuixSD.}.
22813
22814 This effects all the configuration specified in @var{file}: user
22815 accounts, system services, global package list, setuid programs, etc.
22816 The command starts system services specified in @var{file} that are not
22817 currently running; if a service is currently running this command will
22818 arrange for it to be upgraded the next time it is stopped (e.g.@: by
22819 @code{herd stop X} or @code{herd restart X}).
22820
22821 This command creates a new generation whose number is one greater than
22822 the current generation (as reported by @command{guix system
22823 list-generations}). If that generation already exists, it will be
22824 overwritten. This behavior mirrors that of @command{guix package}
22825 (@pxref{Invoking guix package}).
22826
22827 It also adds a bootloader menu entry for the new OS configuration,
22828 ---unless @option{--no-bootloader} is passed. For GRUB, it moves
22829 entries for older configurations to a submenu, allowing you to choose
22830 an older system generation at boot time should you need it.
22831
22832 @quotation Note
22833 @c The paragraph below refers to the problem discussed at
22834 @c <http://lists.gnu.org/archive/html/guix-devel/2014-08/msg00057.html>.
22835 It is highly recommended to run @command{guix pull} once before you run
22836 @command{guix system reconfigure} for the first time (@pxref{Invoking
22837 guix pull}). Failing to do that you would see an older version of Guix
22838 once @command{reconfigure} has completed.
22839 @end quotation
22840
22841 @item switch-generation
22842 @cindex generations
22843 Switch to an existing system generation. This action atomically
22844 switches the system profile to the specified system generation. It
22845 also rearranges the system's existing bootloader menu entries. It
22846 makes the menu entry for the specified system generation the default,
22847 and it moves the entries for the other generatiors to a submenu, if
22848 supported by the bootloader being used. The next time the system
22849 boots, it will use the specified system generation.
22850
22851 The bootloader itself is not being reinstalled when using this
22852 command. Thus, the installed bootloader is used with an updated
22853 configuration file.
22854
22855 The target generation can be specified explicitly by its generation
22856 number. For example, the following invocation would switch to system
22857 generation 7:
22858
22859 @example
22860 guix system switch-generation 7
22861 @end example
22862
22863 The target generation can also be specified relative to the current
22864 generation with the form @code{+N} or @code{-N}, where @code{+3} means
22865 ``3 generations ahead of the current generation,'' and @code{-1} means
22866 ``1 generation prior to the current generation.'' When specifying a
22867 negative value such as @code{-1}, you must precede it with @code{--} to
22868 prevent it from being parsed as an option. For example:
22869
22870 @example
22871 guix system switch-generation -- -1
22872 @end example
22873
22874 Currently, the effect of invoking this action is @emph{only} to switch
22875 the system profile to an existing generation and rearrange the
22876 bootloader menu entries. To actually start using the target system
22877 generation, you must reboot after running this action. In the future,
22878 it will be updated to do the same things as @command{reconfigure},
22879 like activating and deactivating services.
22880
22881 This action will fail if the specified generation does not exist.
22882
22883 @item roll-back
22884 @cindex rolling back
22885 Switch to the preceding system generation. The next time the system
22886 boots, it will use the preceding system generation. This is the inverse
22887 of @command{reconfigure}, and it is exactly the same as invoking
22888 @command{switch-generation} with an argument of @code{-1}.
22889
22890 Currently, as with @command{switch-generation}, you must reboot after
22891 running this action to actually start using the preceding system
22892 generation.
22893
22894 @item build
22895 Build the derivation of the operating system, which includes all the
22896 configuration files and programs needed to boot and run the system.
22897 This action does not actually install anything.
22898
22899 @item init
22900 Populate the given directory with all the files necessary to run the
22901 operating system specified in @var{file}. This is useful for first-time
22902 installations of GuixSD. For instance:
22903
22904 @example
22905 guix system init my-os-config.scm /mnt
22906 @end example
22907
22908 copies to @file{/mnt} all the store items required by the configuration
22909 specified in @file{my-os-config.scm}. This includes configuration
22910 files, packages, and so on. It also creates other essential files
22911 needed for the system to operate correctly---e.g., the @file{/etc},
22912 @file{/var}, and @file{/run} directories, and the @file{/bin/sh} file.
22913
22914 This command also installs bootloader on the target specified in
22915 @file{my-os-config}, unless the @option{--no-bootloader} option was
22916 passed.
22917
22918 @item vm
22919 @cindex virtual machine
22920 @cindex VM
22921 @anchor{guix system vm}
22922 Build a virtual machine that contains the operating system declared in
22923 @var{file}, and return a script to run that virtual machine (VM).
22924 Arguments given to the script are passed to QEMU as in the example
22925 below, which enables networking and requests 1@tie{}GiB of RAM for the
22926 emulated machine:
22927
22928 @example
22929 $ /gnu/store/@dots{}-run-vm.sh -m 1024 -net user
22930 @end example
22931
22932 The VM shares its store with the host system.
22933
22934 Additional file systems can be shared between the host and the VM using
22935 the @code{--share} and @code{--expose} command-line options: the former
22936 specifies a directory to be shared with write access, while the latter
22937 provides read-only access to the shared directory.
22938
22939 The example below creates a VM in which the user's home directory is
22940 accessible read-only, and where the @file{/exchange} directory is a
22941 read-write mapping of @file{$HOME/tmp} on the host:
22942
22943 @example
22944 guix system vm my-config.scm \
22945 --expose=$HOME --share=$HOME/tmp=/exchange
22946 @end example
22947
22948 On GNU/Linux, the default is to boot directly to the kernel; this has
22949 the advantage of requiring only a very tiny root disk image since the
22950 store of the host can then be mounted.
22951
22952 The @code{--full-boot} option forces a complete boot sequence, starting
22953 with the bootloader. This requires more disk space since a root image
22954 containing at least the kernel, initrd, and bootloader data files must
22955 be created. The @code{--image-size} option can be used to specify the
22956 size of the image.
22957
22958 @cindex System images, creation in various formats
22959 @cindex Creating system images in various formats
22960 @item vm-image
22961 @itemx disk-image
22962 @itemx docker-image
22963 Return a virtual machine, disk image, or Docker image of the operating
22964 system declared in @var{file} that stands alone. By default,
22965 @command{guix system} estimates the size of the image needed to store
22966 the system, but you can use the @option{--image-size} option to specify
22967 a value. Docker images are built to contain exactly what they need, so
22968 the @option{--image-size} option is ignored in the case of
22969 @code{docker-image}.
22970
22971 You can specify the root file system type by using the
22972 @option{--file-system-type} option. It defaults to @code{ext4}.
22973
22974 When using @code{vm-image}, the returned image is in qcow2 format, which
22975 the QEMU emulator can efficiently use. @xref{Running GuixSD in a VM},
22976 for more information on how to run the image in a virtual machine.
22977
22978 When using @code{disk-image}, a raw disk image is produced; it can be
22979 copied as is to a USB stick, for instance. Assuming @code{/dev/sdc} is
22980 the device corresponding to a USB stick, one can copy the image to it
22981 using the following command:
22982
22983 @example
22984 # dd if=$(guix system disk-image my-os.scm) of=/dev/sdc
22985 @end example
22986
22987 When using @code{docker-image}, a Docker image is produced. Guix builds
22988 the image from scratch, not from a pre-existing Docker base image. As a
22989 result, it contains @emph{exactly} what you define in the operating
22990 system configuration file. You can then load the image and launch a
22991 Docker container using commands like the following:
22992
22993 @example
22994 image_id="$(docker load < guixsd-docker-image.tar.gz)"
22995 docker run -e GUIX_NEW_SYSTEM=/var/guix/profiles/system \\
22996 --entrypoint /var/guix/profiles/system/profile/bin/guile \\
22997 $image_id /var/guix/profiles/system/boot
22998 @end example
22999
23000 This command starts a new Docker container from the specified image. It
23001 will boot the GuixSD system in the usual manner, which means it will
23002 start any services you have defined in the operating system
23003 configuration. Depending on what you run in the Docker container, it
23004 may be necessary to give the container additional permissions. For
23005 example, if you intend to build software using Guix inside of the Docker
23006 container, you may need to pass the @option{--privileged} option to
23007 @code{docker run}.
23008
23009 @item container
23010 Return a script to run the operating system declared in @var{file}
23011 within a container. Containers are a set of lightweight isolation
23012 mechanisms provided by the kernel Linux-libre. Containers are
23013 substantially less resource-demanding than full virtual machines since
23014 the kernel, shared objects, and other resources can be shared with the
23015 host system; this also means they provide thinner isolation.
23016
23017 Currently, the script must be run as root in order to support more than
23018 a single user and group. The container shares its store with the host
23019 system.
23020
23021 As with the @code{vm} action (@pxref{guix system vm}), additional file
23022 systems to be shared between the host and container can be specified
23023 using the @option{--share} and @option{--expose} options:
23024
23025 @example
23026 guix system container my-config.scm \
23027 --expose=$HOME --share=$HOME/tmp=/exchange
23028 @end example
23029
23030 @quotation Note
23031 This option requires Linux-libre 3.19 or newer.
23032 @end quotation
23033
23034 @end table
23035
23036 @var{options} can contain any of the common build options (@pxref{Common
23037 Build Options}). In addition, @var{options} can contain one of the
23038 following:
23039
23040 @table @option
23041 @item --expression=@var{expr}
23042 @itemx -e @var{expr}
23043 Consider the operating-system @var{expr} evaluates to.
23044 This is an alternative to specifying a file which evaluates to an
23045 operating system.
23046 This is used to generate the GuixSD installer @pxref{Building the
23047 Installation Image}).
23048
23049 @item --system=@var{system}
23050 @itemx -s @var{system}
23051 Attempt to build for @var{system} instead of the host system type.
23052 This works as per @command{guix build} (@pxref{Invoking guix build}).
23053
23054 @item --derivation
23055 @itemx -d
23056 Return the derivation file name of the given operating system without
23057 building anything.
23058
23059 @item --file-system-type=@var{type}
23060 @itemx -t @var{type}
23061 For the @code{disk-image} action, create a file system of the given
23062 @var{type} on the image.
23063
23064 When this option is omitted, @command{guix system} uses @code{ext4}.
23065
23066 @cindex ISO-9660 format
23067 @cindex CD image format
23068 @cindex DVD image format
23069 @code{--file-system-type=iso9660} produces an ISO-9660 image, suitable
23070 for burning on CDs and DVDs.
23071
23072 @item --image-size=@var{size}
23073 For the @code{vm-image} and @code{disk-image} actions, create an image
23074 of the given @var{size}. @var{size} may be a number of bytes, or it may
23075 include a unit as a suffix (@pxref{Block size, size specifications,,
23076 coreutils, GNU Coreutils}).
23077
23078 When this option is omitted, @command{guix system} computes an estimate
23079 of the image size as a function of the size of the system declared in
23080 @var{file}.
23081
23082 @item --root=@var{file}
23083 @itemx -r @var{file}
23084 Make @var{file} a symlink to the result, and register it as a garbage
23085 collector root.
23086
23087 @item --skip-checks
23088 Skip pre-installation safety checks.
23089
23090 By default, @command{guix system init} and @command{guix system
23091 reconfigure} perform safety checks: they make sure the file systems that
23092 appear in the @code{operating-system} declaration actually exist
23093 (@pxref{File Systems}), and that any Linux kernel modules that may be
23094 needed at boot time are listed in @code{initrd-modules} (@pxref{Initial
23095 RAM Disk}). Passing this option skips these tests altogether.
23096
23097 @cindex on-error
23098 @cindex on-error strategy
23099 @cindex error strategy
23100 @item --on-error=@var{strategy}
23101 Apply @var{strategy} when an error occurs when reading @var{file}.
23102 @var{strategy} may be one of the following:
23103
23104 @table @code
23105 @item nothing-special
23106 Report the error concisely and exit. This is the default strategy.
23107
23108 @item backtrace
23109 Likewise, but also display a backtrace.
23110
23111 @item debug
23112 Report the error and enter Guile's debugger. From there, you can run
23113 commands such as @code{,bt} to get a backtrace, @code{,locals} to
23114 display local variable values, and more generally inspect the state of the
23115 program. @xref{Debug Commands,,, guile, GNU Guile Reference Manual}, for
23116 a list of available debugging commands.
23117 @end table
23118 @end table
23119
23120 @quotation Note
23121 All the actions above, except @code{build} and @code{init},
23122 can use KVM support in the Linux-libre kernel. Specifically, if the
23123 machine has hardware virtualization support, the corresponding
23124 KVM kernel module should be loaded, and the @file{/dev/kvm} device node
23125 must exist and be readable and writable by the user and by the
23126 build users of the daemon (@pxref{Build Environment Setup}).
23127 @end quotation
23128
23129 Once you have built, configured, re-configured, and re-re-configured
23130 your GuixSD installation, you may find it useful to list the operating
23131 system generations available on disk---and that you can choose from the
23132 bootloader boot menu:
23133
23134 @table @code
23135
23136 @item list-generations
23137 List a summary of each generation of the operating system available on
23138 disk, in a human-readable way. This is similar to the
23139 @option{--list-generations} option of @command{guix package}
23140 (@pxref{Invoking guix package}).
23141
23142 Optionally, one can specify a pattern, with the same syntax that is used
23143 in @command{guix package --list-generations}, to restrict the list of
23144 generations displayed. For instance, the following command displays
23145 generations that are up to 10 days old:
23146
23147 @example
23148 $ guix system list-generations 10d
23149 @end example
23150
23151 @end table
23152
23153 The @command{guix system} command has even more to offer! The following
23154 sub-commands allow you to visualize how your system services relate to
23155 each other:
23156
23157 @anchor{system-extension-graph}
23158 @table @code
23159
23160 @item extension-graph
23161 Emit in Dot/Graphviz format to standard output the @dfn{service
23162 extension graph} of the operating system defined in @var{file}
23163 (@pxref{Service Composition}, for more information on service
23164 extensions.)
23165
23166 The command:
23167
23168 @example
23169 $ guix system extension-graph @var{file} | dot -Tpdf > services.pdf
23170 @end example
23171
23172 produces a PDF file showing the extension relations among services.
23173
23174 @anchor{system-shepherd-graph}
23175 @item shepherd-graph
23176 Emit in Dot/Graphviz format to standard output the @dfn{dependency
23177 graph} of shepherd services of the operating system defined in
23178 @var{file}. @xref{Shepherd Services}, for more information and for an
23179 example graph.
23180
23181 @end table
23182
23183 @node Running GuixSD in a VM
23184 @section Running GuixSD in a Virtual Machine
23185
23186 @cindex virtual machine
23187 To run GuixSD in a virtual machine (VM), one can either use the
23188 pre-built GuixSD VM image distributed at
23189 @indicateurl{https://alpha.gnu.org/gnu/guix/guixsd-vm-image-@value{VERSION}.@var{system}.xz}
23190 , or build their own virtual machine image using @command{guix system
23191 vm-image} (@pxref{Invoking guix system}). The returned image is in
23192 qcow2 format, which the @uref{http://qemu.org/, QEMU emulator} can
23193 efficiently use.
23194
23195 @cindex QEMU
23196 If you built your own image, you must copy it out of the store
23197 (@pxref{The Store}) and give yourself permission to write to the copy
23198 before you can use it. When invoking QEMU, you must choose a system
23199 emulator that is suitable for your hardware platform. Here is a minimal
23200 QEMU invocation that will boot the result of @command{guix system
23201 vm-image} on x86_64 hardware:
23202
23203 @example
23204 $ qemu-system-x86_64 \
23205 -net user -net nic,model=virtio \
23206 -enable-kvm -m 256 /tmp/qemu-image
23207 @end example
23208
23209 Here is what each of these options means:
23210
23211 @table @code
23212 @item qemu-system-x86_64
23213 This specifies the hardware platform to emulate. This should match the
23214 host.
23215
23216 @item -net user
23217 Enable the unprivileged user-mode network stack. The guest OS can
23218 access the host but not vice versa. This is the simplest way to get the
23219 guest OS online.
23220
23221 @item -net nic,model=virtio
23222 You must create a network interface of a given model. If you do not
23223 create a NIC, the boot will fail. Assuming your hardware platform is
23224 x86_64, you can get a list of available NIC models by running
23225 @command{qemu-system-x86_64 -net nic,model=help}.
23226
23227 @item -enable-kvm
23228 If your system has hardware virtualization extensions, enabling the
23229 virtual machine support (KVM) of the Linux kernel will make things run
23230 faster.
23231
23232 @item -m 256
23233 RAM available to the guest OS, in mebibytes. Defaults to 128@tie{}MiB,
23234 which may be insufficient for some operations.
23235
23236 @item /tmp/qemu-image
23237 The file name of the qcow2 image.
23238 @end table
23239
23240 The default @command{run-vm.sh} script that is returned by an invocation of
23241 @command{guix system vm} does not add a @command{-net user} flag by default.
23242 To get network access from within the vm add the @code{(dhcp-client-service)}
23243 to your system definition and start the VM using
23244 @command{`guix system vm config.scm` -net user}. An important caveat of using
23245 @command{-net user} for networking is that @command{ping} will not work, because
23246 it uses the ICMP protocol. You'll have to use a different command to check for
23247 network connectivity, for example @command{guix download}.
23248
23249 @subsection Connecting Through SSH
23250
23251 @cindex SSH
23252 @cindex SSH server
23253 To enable SSH inside a VM you need to add a SSH server like @code{(dropbear-service)}
23254 or @code{(lsh-service)} to your VM. The @code{(lsh-service}) doesn't currently
23255 boot unsupervised. It requires you to type some characters to initialize the
23256 randomness generator. In addition you need to forward the SSH port, 22 by
23257 default, to the host. You can do this with
23258
23259 @example
23260 `guix system vm config.scm` -net user,hostfwd=tcp::10022-:22
23261 @end example
23262
23263 To connect to the VM you can run
23264
23265 @example
23266 ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 10022
23267 @end example
23268
23269 The @command{-p} tells @command{ssh} the port you want to connect to.
23270 @command{-o UserKnownHostsFile=/dev/null} prevents @command{ssh} from complaining
23271 every time you modify your @command{config.scm} file and the
23272 @command{-o StrictHostKeyChecking=no} prevents you from having to allow a
23273 connection to an unknown host every time you connect.
23274
23275 @subsection Using @command{virt-viewer} with Spice
23276
23277 As an alternative to the default @command{qemu} graphical client you can
23278 use the @command{remote-viewer} from the @command{virt-viewer} package. To
23279 connect pass the @command{-spice port=5930,disable-ticketing} flag to
23280 @command{qemu}. See previous section for further information on how to do this.
23281
23282 Spice also allows you to do some nice stuff like share your clipboard with your
23283 VM. To enable that you'll also have to pass the following flags to @command{qemu}:
23284
23285 @example
23286 -device virtio-serial-pci,id=virtio-serial0,max_ports=16,bus=pci.0,addr=0x5
23287 -chardev spicevmc,name=vdagent,id=vdagent
23288 -device virtserialport,nr=1,bus=virtio-serial0.0,chardev=vdagent,
23289 name=com.redhat.spice.0
23290 @end example
23291
23292 You'll also need to add the @pxref{Miscellaneous Services, Spice service}.
23293
23294 @node Defining Services
23295 @section Defining Services
23296
23297 The previous sections show the available services and how one can combine
23298 them in an @code{operating-system} declaration. But how do we define
23299 them in the first place? And what is a service anyway?
23300
23301 @menu
23302 * Service Composition:: The model for composing services.
23303 * Service Types and Services:: Types and services.
23304 * Service Reference:: API reference.
23305 * Shepherd Services:: A particular type of service.
23306 @end menu
23307
23308 @node Service Composition
23309 @subsection Service Composition
23310
23311 @cindex services
23312 @cindex daemons
23313 Here we define a @dfn{service} as, broadly, something that extends the
23314 functionality of the operating system. Often a service is a process---a
23315 @dfn{daemon}---started when the system boots: a secure shell server, a
23316 Web server, the Guix build daemon, etc. Sometimes a service is a daemon
23317 whose execution can be triggered by another daemon---e.g., an FTP server
23318 started by @command{inetd} or a D-Bus service activated by
23319 @command{dbus-daemon}. Occasionally, a service does not map to a
23320 daemon. For instance, the ``account'' service collects user accounts
23321 and makes sure they exist when the system runs; the ``udev'' service
23322 collects device management rules and makes them available to the eudev
23323 daemon; the @file{/etc} service populates the @file{/etc} directory
23324 of the system.
23325
23326 @cindex service extensions
23327 GuixSD services are connected by @dfn{extensions}. For instance, the
23328 secure shell service @emph{extends} the Shepherd---the GuixSD
23329 initialization system, running as PID@tie{}1---by giving it the command
23330 lines to start and stop the secure shell daemon (@pxref{Networking
23331 Services, @code{lsh-service}}); the UPower service extends the D-Bus
23332 service by passing it its @file{.service} specification, and extends the
23333 udev service by passing it device management rules (@pxref{Desktop
23334 Services, @code{upower-service}}); the Guix daemon service extends the
23335 Shepherd by passing it the command lines to start and stop the daemon,
23336 and extends the account service by passing it a list of required build
23337 user accounts (@pxref{Base Services}).
23338
23339 All in all, services and their ``extends'' relations form a directed
23340 acyclic graph (DAG). If we represent services as boxes and extensions
23341 as arrows, a typical system might provide something like this:
23342
23343 @image{images/service-graph,,5in,Typical service extension graph.}
23344
23345 @cindex system service
23346 At the bottom, we see the @dfn{system service}, which produces the
23347 directory containing everything to run and boot the system, as returned
23348 by the @command{guix system build} command. @xref{Service Reference},
23349 to learn about the other service types shown here.
23350 @xref{system-extension-graph, the @command{guix system extension-graph}
23351 command}, for information on how to generate this representation for a
23352 particular operating system definition.
23353
23354 @cindex service types
23355 Technically, developers can define @dfn{service types} to express these
23356 relations. There can be any number of services of a given type on the
23357 system---for instance, a system running two instances of the GNU secure
23358 shell server (lsh) has two instances of @var{lsh-service-type}, with
23359 different parameters.
23360
23361 The following section describes the programming interface for service
23362 types and services.
23363
23364 @node Service Types and Services
23365 @subsection Service Types and Services
23366
23367 A @dfn{service type} is a node in the DAG described above. Let us start
23368 with a simple example, the service type for the Guix build daemon
23369 (@pxref{Invoking guix-daemon}):
23370
23371 @example
23372 (define guix-service-type
23373 (service-type
23374 (name 'guix)
23375 (extensions
23376 (list (service-extension shepherd-root-service-type guix-shepherd-service)
23377 (service-extension account-service-type guix-accounts)
23378 (service-extension activation-service-type guix-activation)))
23379 (default-value (guix-configuration))))
23380 @end example
23381
23382 @noindent
23383 It defines three things:
23384
23385 @enumerate
23386 @item
23387 A name, whose sole purpose is to make inspection and debugging easier.
23388
23389 @item
23390 A list of @dfn{service extensions}, where each extension designates the
23391 target service type and a procedure that, given the parameters of the
23392 service, returns a list of objects to extend the service of that type.
23393
23394 Every service type has at least one service extension. The only
23395 exception is the @dfn{boot service type}, which is the ultimate service.
23396
23397 @item
23398 Optionally, a default value for instances of this type.
23399 @end enumerate
23400
23401 In this example, @var{guix-service-type} extends three services:
23402
23403 @table @var
23404 @item shepherd-root-service-type
23405 The @var{guix-shepherd-service} procedure defines how the Shepherd
23406 service is extended. Namely, it returns a @code{<shepherd-service>}
23407 object that defines how @command{guix-daemon} is started and stopped
23408 (@pxref{Shepherd Services}).
23409
23410 @item account-service-type
23411 This extension for this service is computed by @var{guix-accounts},
23412 which returns a list of @code{user-group} and @code{user-account}
23413 objects representing the build user accounts (@pxref{Invoking
23414 guix-daemon}).
23415
23416 @item activation-service-type
23417 Here @var{guix-activation} is a procedure that returns a gexp, which is
23418 a code snippet to run at ``activation time''---e.g., when the service is
23419 booted.
23420 @end table
23421
23422 A service of this type is instantiated like this:
23423
23424 @example
23425 (service guix-service-type
23426 (guix-configuration
23427 (build-accounts 5)
23428 (use-substitutes? #f)))
23429 @end example
23430
23431 The second argument to the @code{service} form is a value representing
23432 the parameters of this specific service instance.
23433 @xref{guix-configuration-type, @code{guix-configuration}}, for
23434 information about the @code{guix-configuration} data type. When the
23435 value is omitted, the default value specified by
23436 @code{guix-service-type} is used:
23437
23438 @example
23439 (service guix-service-type)
23440 @end example
23441
23442 @var{guix-service-type} is quite simple because it extends other
23443 services but is not extensible itself.
23444
23445 @c @subsubsubsection Extensible Service Types
23446
23447 The service type for an @emph{extensible} service looks like this:
23448
23449 @example
23450 (define udev-service-type
23451 (service-type (name 'udev)
23452 (extensions
23453 (list (service-extension shepherd-root-service-type
23454 udev-shepherd-service)))
23455
23456 (compose concatenate) ;concatenate the list of rules
23457 (extend (lambda (config rules)
23458 (match config
23459 (($ <udev-configuration> udev initial-rules)
23460 (udev-configuration
23461 (udev udev) ;the udev package to use
23462 (rules (append initial-rules rules)))))))))
23463 @end example
23464
23465 This is the service type for the
23466 @uref{https://wiki.gentoo.org/wiki/Project:Eudev, eudev device
23467 management daemon}. Compared to the previous example, in addition to an
23468 extension of @var{shepherd-root-service-type}, we see two new fields:
23469
23470 @table @code
23471 @item compose
23472 This is the procedure to @dfn{compose} the list of extensions to
23473 services of this type.
23474
23475 Services can extend the udev service by passing it lists of rules; we
23476 compose those extensions simply by concatenating them.
23477
23478 @item extend
23479 This procedure defines how the value of the service is @dfn{extended} with
23480 the composition of the extensions.
23481
23482 Udev extensions are composed into a list of rules, but the udev service
23483 value is itself a @code{<udev-configuration>} record. So here, we
23484 extend that record by appending the list of rules it contains to the
23485 list of contributed rules.
23486
23487 @item description
23488 This is a string giving an overview of the service type. The string can
23489 contain Texinfo markup (@pxref{Overview,,, texinfo, GNU Texinfo}). The
23490 @command{guix system search} command searches these strings and displays
23491 them (@pxref{Invoking guix system}).
23492 @end table
23493
23494 There can be only one instance of an extensible service type such as
23495 @var{udev-service-type}. If there were more, the
23496 @code{service-extension} specifications would be ambiguous.
23497
23498 Still here? The next section provides a reference of the programming
23499 interface for services.
23500
23501 @node Service Reference
23502 @subsection Service Reference
23503
23504 We have seen an overview of service types (@pxref{Service Types and
23505 Services}). This section provides a reference on how to manipulate
23506 services and service types. This interface is provided by the
23507 @code{(gnu services)} module.
23508
23509 @deffn {Scheme Procedure} service @var{type} [@var{value}]
23510 Return a new service of @var{type}, a @code{<service-type>} object (see
23511 below.) @var{value} can be any object; it represents the parameters of
23512 this particular service instance.
23513
23514 When @var{value} is omitted, the default value specified by @var{type}
23515 is used; if @var{type} does not specify a default value, an error is
23516 raised.
23517
23518 For instance, this:
23519
23520 @example
23521 (service openssh-service-type)
23522 @end example
23523
23524 @noindent
23525 is equivalent to this:
23526
23527 @example
23528 (service openssh-service-type
23529 (openssh-configuration))
23530 @end example
23531
23532 In both cases the result is an instance of @code{openssh-service-type}
23533 with the default configuration.
23534 @end deffn
23535
23536 @deffn {Scheme Procedure} service? @var{obj}
23537 Return true if @var{obj} is a service.
23538 @end deffn
23539
23540 @deffn {Scheme Procedure} service-kind @var{service}
23541 Return the type of @var{service}---i.e., a @code{<service-type>} object.
23542 @end deffn
23543
23544 @deffn {Scheme Procedure} service-value @var{service}
23545 Return the value associated with @var{service}. It represents its
23546 parameters.
23547 @end deffn
23548
23549 Here is an example of how a service is created and manipulated:
23550
23551 @example
23552 (define s
23553 (service nginx-service-type
23554 (nginx-configuration
23555 (nginx nginx)
23556 (log-directory log-directory)
23557 (run-directory run-directory)
23558 (file config-file))))
23559
23560 (service? s)
23561 @result{} #t
23562
23563 (eq? (service-kind s) nginx-service-type)
23564 @result{} #t
23565 @end example
23566
23567 The @code{modify-services} form provides a handy way to change the
23568 parameters of some of the services of a list such as
23569 @var{%base-services} (@pxref{Base Services, @code{%base-services}}). It
23570 evaluates to a list of services. Of course, you could always use
23571 standard list combinators such as @code{map} and @code{fold} to do that
23572 (@pxref{SRFI-1, List Library,, guile, GNU Guile Reference Manual});
23573 @code{modify-services} simply provides a more concise form for this
23574 common pattern.
23575
23576 @deffn {Scheme Syntax} modify-services @var{services} @
23577 (@var{type} @var{variable} => @var{body}) @dots{}
23578
23579 Modify the services listed in @var{services} according to the given
23580 clauses. Each clause has the form:
23581
23582 @example
23583 (@var{type} @var{variable} => @var{body})
23584 @end example
23585
23586 where @var{type} is a service type---e.g.,
23587 @code{guix-service-type}---and @var{variable} is an identifier that is
23588 bound within the @var{body} to the service parameters---e.g., a
23589 @code{guix-configuration} instance---of the original service of that
23590 @var{type}.
23591
23592 The @var{body} should evaluate to the new service parameters, which will
23593 be used to configure the new service. This new service will replace the
23594 original in the resulting list. Because a service's service parameters
23595 are created using @code{define-record-type*}, you can write a succinct
23596 @var{body} that evaluates to the new service parameters by using the
23597 @code{inherit} feature that @code{define-record-type*} provides.
23598
23599 @xref{Using the Configuration System}, for example usage.
23600
23601 @end deffn
23602
23603 Next comes the programming interface for service types. This is
23604 something you want to know when writing new service definitions, but not
23605 necessarily when simply looking for ways to customize your
23606 @code{operating-system} declaration.
23607
23608 @deftp {Data Type} service-type
23609 @cindex service type
23610 This is the representation of a @dfn{service type} (@pxref{Service Types
23611 and Services}).
23612
23613 @table @asis
23614 @item @code{name}
23615 This is a symbol, used only to simplify inspection and debugging.
23616
23617 @item @code{extensions}
23618 A non-empty list of @code{<service-extension>} objects (see below).
23619
23620 @item @code{compose} (default: @code{#f})
23621 If this is @code{#f}, then the service type denotes services that cannot
23622 be extended---i.e., services that do not receive ``values'' from other
23623 services.
23624
23625 Otherwise, it must be a one-argument procedure. The procedure is called
23626 by @code{fold-services} and is passed a list of values collected from
23627 extensions. It may return any single value.
23628
23629 @item @code{extend} (default: @code{#f})
23630 If this is @code{#f}, services of this type cannot be extended.
23631
23632 Otherwise, it must be a two-argument procedure: @code{fold-services}
23633 calls it, passing it the initial value of the service as the first
23634 argument and the result of applying @code{compose} to the extension
23635 values as the second argument. It must return a value that is a valid
23636 parameter value for the service instance.
23637 @end table
23638
23639 @xref{Service Types and Services}, for examples.
23640 @end deftp
23641
23642 @deffn {Scheme Procedure} service-extension @var{target-type} @
23643 @var{compute}
23644 Return a new extension for services of type @var{target-type}.
23645 @var{compute} must be a one-argument procedure: @code{fold-services}
23646 calls it, passing it the value associated with the service that provides
23647 the extension; it must return a valid value for the target service.
23648 @end deffn
23649
23650 @deffn {Scheme Procedure} service-extension? @var{obj}
23651 Return true if @var{obj} is a service extension.
23652 @end deffn
23653
23654 Occasionally, you might want to simply extend an existing service. This
23655 involves creating a new service type and specifying the extension of
23656 interest, which can be verbose; the @code{simple-service} procedure
23657 provides a shorthand for this.
23658
23659 @deffn {Scheme Procedure} simple-service @var{name} @var{target} @var{value}
23660 Return a service that extends @var{target} with @var{value}. This works
23661 by creating a singleton service type @var{name}, of which the returned
23662 service is an instance.
23663
23664 For example, this extends mcron (@pxref{Scheduled Job Execution}) with
23665 an additional job:
23666
23667 @example
23668 (simple-service 'my-mcron-job mcron-service-type
23669 #~(job '(next-hour (3)) "guix gc -F 2G"))
23670 @end example
23671 @end deffn
23672
23673 At the core of the service abstraction lies the @code{fold-services}
23674 procedure, which is responsible for ``compiling'' a list of services
23675 down to a single directory that contains everything needed to boot and
23676 run the system---the directory shown by the @command{guix system build}
23677 command (@pxref{Invoking guix system}). In essence, it propagates
23678 service extensions down the service graph, updating each node parameters
23679 on the way, until it reaches the root node.
23680
23681 @deffn {Scheme Procedure} fold-services @var{services} @
23682 [#:target-type @var{system-service-type}]
23683 Fold @var{services} by propagating their extensions down to the root of
23684 type @var{target-type}; return the root service adjusted accordingly.
23685 @end deffn
23686
23687 Lastly, the @code{(gnu services)} module also defines several essential
23688 service types, some of which are listed below.
23689
23690 @defvr {Scheme Variable} system-service-type
23691 This is the root of the service graph. It produces the system directory
23692 as returned by the @command{guix system build} command.
23693 @end defvr
23694
23695 @defvr {Scheme Variable} boot-service-type
23696 The type of the ``boot service'', which produces the @dfn{boot script}.
23697 The boot script is what the initial RAM disk runs when booting.
23698 @end defvr
23699
23700 @defvr {Scheme Variable} etc-service-type
23701 The type of the @file{/etc} service. This service is used to create
23702 files under @file{/etc} and can be extended by
23703 passing it name/file tuples such as:
23704
23705 @example
23706 (list `("issue" ,(plain-file "issue" "Welcome!\n")))
23707 @end example
23708
23709 In this example, the effect would be to add an @file{/etc/issue} file
23710 pointing to the given file.
23711 @end defvr
23712
23713 @defvr {Scheme Variable} setuid-program-service-type
23714 Type for the ``setuid-program service''. This service collects lists of
23715 executable file names, passed as gexps, and adds them to the set of
23716 setuid-root programs on the system (@pxref{Setuid Programs}).
23717 @end defvr
23718
23719 @defvr {Scheme Variable} profile-service-type
23720 Type of the service that populates the @dfn{system profile}---i.e., the
23721 programs under @file{/run/current-system/profile}. Other services can
23722 extend it by passing it lists of packages to add to the system profile.
23723 @end defvr
23724
23725
23726 @node Shepherd Services
23727 @subsection Shepherd Services
23728
23729 @cindex shepherd services
23730 @cindex PID 1
23731 @cindex init system
23732 The @code{(gnu services shepherd)} module provides a way to define
23733 services managed by the GNU@tie{}Shepherd, which is the GuixSD
23734 initialization system---the first process that is started when the
23735 system boots, also known as PID@tie{}1
23736 (@pxref{Introduction,,, shepherd, The GNU Shepherd Manual}).
23737
23738 Services in the Shepherd can depend on each other. For instance, the
23739 SSH daemon may need to be started after the syslog daemon has been
23740 started, which in turn can only happen once all the file systems have
23741 been mounted. The simple operating system defined earlier (@pxref{Using
23742 the Configuration System}) results in a service graph like this:
23743
23744 @image{images/shepherd-graph,,5in,Typical shepherd service graph.}
23745
23746 You can actually generate such a graph for any operating system
23747 definition using the @command{guix system shepherd-graph} command
23748 (@pxref{system-shepherd-graph, @command{guix system shepherd-graph}}).
23749
23750 The @var{%shepherd-root-service} is a service object representing
23751 PID@tie{}1, of type @var{shepherd-root-service-type}; it can be extended
23752 by passing it lists of @code{<shepherd-service>} objects.
23753
23754 @deftp {Data Type} shepherd-service
23755 The data type representing a service managed by the Shepherd.
23756
23757 @table @asis
23758 @item @code{provision}
23759 This is a list of symbols denoting what the service provides.
23760
23761 These are the names that may be passed to @command{herd start},
23762 @command{herd status}, and similar commands (@pxref{Invoking herd,,,
23763 shepherd, The GNU Shepherd Manual}). @xref{Slots of services, the
23764 @code{provides} slot,, shepherd, The GNU Shepherd Manual}, for details.
23765
23766 @item @code{requirements} (default: @code{'()})
23767 List of symbols denoting the Shepherd services this one depends on.
23768
23769 @item @code{respawn?} (default: @code{#t})
23770 Whether to restart the service when it stops, for instance when the
23771 underlying process dies.
23772
23773 @item @code{start}
23774 @itemx @code{stop} (default: @code{#~(const #f)})
23775 The @code{start} and @code{stop} fields refer to the Shepherd's
23776 facilities to start and stop processes (@pxref{Service De- and
23777 Constructors,,, shepherd, The GNU Shepherd Manual}). They are given as
23778 G-expressions that get expanded in the Shepherd configuration file
23779 (@pxref{G-Expressions}).
23780
23781 @item @code{actions} (default: @code{'()})
23782 @cindex actions, of Shepherd services
23783 This is a list of @code{shepherd-action} objects (see below) defining
23784 @dfn{actions} supported by the service, in addition to the standard
23785 @code{start} and @code{stop} actions. Actions listed here become available as
23786 @command{herd} sub-commands:
23787
23788 @example
23789 herd @var{action} @var{service} [@var{arguments}@dots{}]
23790 @end example
23791
23792 @item @code{documentation}
23793 A documentation string, as shown when running:
23794
23795 @example
23796 herd doc @var{service-name}
23797 @end example
23798
23799 where @var{service-name} is one of the symbols in @var{provision}
23800 (@pxref{Invoking herd,,, shepherd, The GNU Shepherd Manual}).
23801
23802 @item @code{modules} (default: @var{%default-modules})
23803 This is the list of modules that must be in scope when @code{start} and
23804 @code{stop} are evaluated.
23805
23806 @end table
23807 @end deftp
23808
23809 @deftp {Data Type} shepherd-action
23810 This is the data type that defines additional actions implemented by a
23811 Shepherd service (see above).
23812
23813 @table @code
23814 @item name
23815 Symbol naming the action.
23816
23817 @item documentation
23818 This is a documentation string for the action. It can be viewed by running:
23819
23820 @example
23821 herd doc @var{service} action @var{action}
23822 @end example
23823
23824 @item procedure
23825 This should be a gexp that evaluates to a procedure of at least one argument,
23826 which is the ``running value'' of the service (@pxref{Slots of services,,,
23827 shepherd, The GNU Shepherd Manual}).
23828 @end table
23829
23830 The following example defines an action called @code{say-hello} that kindly
23831 greets the user:
23832
23833 @example
23834 (shepherd-action
23835 (name 'say-hello)
23836 (documentation "Say hi!")
23837 (procedure #~(lambda (running . args)
23838 (format #t "Hello, friend! arguments: ~s\n"
23839 args)
23840 #t)))
23841 @end example
23842
23843 Assuming this action is added to the @code{example} service, then you can do:
23844
23845 @example
23846 # herd say-hello example
23847 Hello, friend! arguments: ()
23848 # herd say-hello example a b c
23849 Hello, friend! arguments: ("a" "b" "c")
23850 @end example
23851
23852 This, as you can see, is a fairly sophisticated way to say hello.
23853 @xref{Service Convenience,,, shepherd, The GNU Shepherd Manual}, for more
23854 info on actions.
23855 @end deftp
23856
23857 @defvr {Scheme Variable} shepherd-root-service-type
23858 The service type for the Shepherd ``root service''---i.e., PID@tie{}1.
23859
23860 This is the service type that extensions target when they want to create
23861 shepherd services (@pxref{Service Types and Services}, for an example).
23862 Each extension must pass a list of @code{<shepherd-service>}.
23863 @end defvr
23864
23865 @defvr {Scheme Variable} %shepherd-root-service
23866 This service represents PID@tie{}1.
23867 @end defvr
23868
23869
23870 @node Documentation
23871 @chapter Documentation
23872
23873 @cindex documentation, searching for
23874 @cindex searching for documentation
23875 @cindex Info, documentation format
23876 @cindex man pages
23877 @cindex manual pages
23878 In most cases packages installed with Guix come with documentation.
23879 There are two main documentation formats: ``Info'', a browseable
23880 hypertext format used for GNU software, and ``manual pages'' (or ``man
23881 pages''), the linear documentation format traditionally found on Unix.
23882 Info manuals are accessed with the @command{info} command or with Emacs,
23883 and man pages are accessed using @command{man}.
23884
23885 You can look for documentation of software installed on your system by
23886 keyword. For example, the following command searches for information
23887 about ``TLS'' in Info manuals:
23888
23889 @example
23890 $ info -k TLS
23891 "(emacs)Network Security" -- STARTTLS
23892 "(emacs)Network Security" -- TLS
23893 "(gnutls)Core TLS API" -- gnutls_certificate_set_verify_flags
23894 "(gnutls)Core TLS API" -- gnutls_certificate_set_verify_function
23895 @dots{}
23896 @end example
23897
23898 @noindent
23899 The command below searches for the same keyword in man pages:
23900
23901 @example
23902 $ man -k TLS
23903 SSL (7) - OpenSSL SSL/TLS library
23904 certtool (1) - GnuTLS certificate tool
23905 @dots {}
23906 @end example
23907
23908 These searches are purely local to your computer so you have the
23909 guarantee that documentation you find corresponds to what you have
23910 actually installed, you can access it off-line, and your privacy is
23911 respected.
23912
23913 Once you have these results, you can view the relevant documentation by
23914 running, say:
23915
23916 @example
23917 $ info "(gnutls)Core TLS API"
23918 @end example
23919
23920 @noindent
23921 or:
23922
23923 @example
23924 $ man certtool
23925 @end example
23926
23927 Info manuals contain sections and indices as well as hyperlinks like
23928 those found in Web pages. The @command{info} reader (@pxref{Top, Info
23929 reader,, info-stnd, Stand-alone GNU Info}) and its Emacs counterpart
23930 (@pxref{Misc Help,,, emacs, The GNU Emacs Manual}) provide intuitive key
23931 bindings to navigate manuals. @xref{Getting Started,,, info, Info: An
23932 Introduction}, for an introduction to Info navigation.
23933
23934 @node Installing Debugging Files
23935 @chapter Installing Debugging Files
23936
23937 @cindex debugging files
23938 Program binaries, as produced by the GCC compilers for instance, are
23939 typically written in the ELF format, with a section containing
23940 @dfn{debugging information}. Debugging information is what allows the
23941 debugger, GDB, to map binary code to source code; it is required to
23942 debug a compiled program in good conditions.
23943
23944 The problem with debugging information is that is takes up a fair amount
23945 of disk space. For example, debugging information for the GNU C Library
23946 weighs in at more than 60 MiB. Thus, as a user, keeping all the
23947 debugging info of all the installed programs is usually not an option.
23948 Yet, space savings should not come at the cost of an impediment to
23949 debugging---especially in the GNU system, which should make it easier
23950 for users to exert their computing freedom (@pxref{GNU Distribution}).
23951
23952 Thankfully, the GNU Binary Utilities (Binutils) and GDB provide a
23953 mechanism that allows users to get the best of both worlds: debugging
23954 information can be stripped from the binaries and stored in separate
23955 files. GDB is then able to load debugging information from those files,
23956 when they are available (@pxref{Separate Debug Files,,, gdb, Debugging
23957 with GDB}).
23958
23959 The GNU distribution takes advantage of this by storing debugging
23960 information in the @code{lib/debug} sub-directory of a separate package
23961 output unimaginatively called @code{debug} (@pxref{Packages with
23962 Multiple Outputs}). Users can choose to install the @code{debug} output
23963 of a package when they need it. For instance, the following command
23964 installs the debugging information for the GNU C Library and for GNU
23965 Guile:
23966
23967 @example
23968 guix package -i glibc:debug guile:debug
23969 @end example
23970
23971 GDB must then be told to look for debug files in the user's profile, by
23972 setting the @code{debug-file-directory} variable (consider setting it
23973 from the @file{~/.gdbinit} file, @pxref{Startup,,, gdb, Debugging with
23974 GDB}):
23975
23976 @example
23977 (gdb) set debug-file-directory ~/.guix-profile/lib/debug
23978 @end example
23979
23980 From there on, GDB will pick up debugging information from the
23981 @code{.debug} files under @file{~/.guix-profile/lib/debug}.
23982
23983 In addition, you will most likely want GDB to be able to show the source
23984 code being debugged. To do that, you will have to unpack the source
23985 code of the package of interest (obtained with @code{guix build
23986 --source}, @pxref{Invoking guix build}), and to point GDB to that source
23987 directory using the @code{directory} command (@pxref{Source Path,
23988 @code{directory},, gdb, Debugging with GDB}).
23989
23990 @c XXX: keep me up-to-date
23991 The @code{debug} output mechanism in Guix is implemented by the
23992 @code{gnu-build-system} (@pxref{Build Systems}). Currently, it is
23993 opt-in---debugging information is available only for the packages
23994 with definitions explicitly declaring a @code{debug} output. This may be
23995 changed to opt-out in the future if our build farm servers can handle
23996 the load. To check whether a package has a @code{debug} output, use
23997 @command{guix package --list-available} (@pxref{Invoking guix package}).
23998
23999
24000 @node Security Updates
24001 @chapter Security Updates
24002
24003 @cindex security updates
24004 @cindex security vulnerabilities
24005 Occasionally, important security vulnerabilities are discovered in software
24006 packages and must be patched. Guix developers try hard to keep track of
24007 known vulnerabilities and to apply fixes as soon as possible in the
24008 @code{master} branch of Guix (we do not yet provide a ``stable'' branch
24009 containing only security updates.) The @command{guix lint} tool helps
24010 developers find out about vulnerable versions of software packages in the
24011 distribution:
24012
24013 @smallexample
24014 $ guix lint -c cve
24015 gnu/packages/base.scm:652:2: glibc@@2.21: probably vulnerable to CVE-2015-1781, CVE-2015-7547
24016 gnu/packages/gcc.scm:334:2: gcc@@4.9.3: probably vulnerable to CVE-2015-5276
24017 gnu/packages/image.scm:312:2: openjpeg@@2.1.0: probably vulnerable to CVE-2016-1923, CVE-2016-1924
24018 @dots{}
24019 @end smallexample
24020
24021 @xref{Invoking guix lint}, for more information.
24022
24023 @quotation Note
24024 As of version @value{VERSION}, the feature described below is considered
24025 ``beta''.
24026 @end quotation
24027
24028 Guix follows a functional
24029 package management discipline (@pxref{Introduction}), which implies
24030 that, when a package is changed, @emph{every package that depends on it}
24031 must be rebuilt. This can significantly slow down the deployment of
24032 fixes in core packages such as libc or Bash, since basically the whole
24033 distribution would need to be rebuilt. Using pre-built binaries helps
24034 (@pxref{Substitutes}), but deployment may still take more time than
24035 desired.
24036
24037 @cindex grafts
24038 To address this, Guix implements @dfn{grafts}, a mechanism that allows
24039 for fast deployment of critical updates without the costs associated
24040 with a whole-distribution rebuild. The idea is to rebuild only the
24041 package that needs to be patched, and then to ``graft'' it onto packages
24042 explicitly installed by the user and that were previously referring to
24043 the original package. The cost of grafting is typically very low, and
24044 order of magnitudes lower than a full rebuild of the dependency chain.
24045
24046 @cindex replacements of packages, for grafts
24047 For instance, suppose a security update needs to be applied to Bash.
24048 Guix developers will provide a package definition for the ``fixed''
24049 Bash, say @var{bash-fixed}, in the usual way (@pxref{Defining
24050 Packages}). Then, the original package definition is augmented with a
24051 @code{replacement} field pointing to the package containing the bug fix:
24052
24053 @example
24054 (define bash
24055 (package
24056 (name "bash")
24057 ;; @dots{}
24058 (replacement bash-fixed)))
24059 @end example
24060
24061 From there on, any package depending directly or indirectly on Bash---as
24062 reported by @command{guix gc --requisites} (@pxref{Invoking guix
24063 gc})---that is installed is automatically ``rewritten'' to refer to
24064 @var{bash-fixed} instead of @var{bash}. This grafting process takes
24065 time proportional to the size of the package, usually less than a
24066 minute for an ``average'' package on a recent machine. Grafting is
24067 recursive: when an indirect dependency requires grafting, then grafting
24068 ``propagates'' up to the package that the user is installing.
24069
24070 Currently, the length of the name and version of the graft and that of
24071 the package it replaces (@var{bash-fixed} and @var{bash} in the example
24072 above) must be equal. This restriction mostly comes from the fact that
24073 grafting works by patching files, including binary files, directly.
24074 Other restrictions may apply: for instance, when adding a graft to a
24075 package providing a shared library, the original shared library and its
24076 replacement must have the same @code{SONAME} and be binary-compatible.
24077
24078 The @option{--no-grafts} command-line option allows you to forcefully
24079 avoid grafting (@pxref{Common Build Options, @option{--no-grafts}}).
24080 Thus, the command:
24081
24082 @example
24083 guix build bash --no-grafts
24084 @end example
24085
24086 @noindent
24087 returns the store file name of the original Bash, whereas:
24088
24089 @example
24090 guix build bash
24091 @end example
24092
24093 @noindent
24094 returns the store file name of the ``fixed'', replacement Bash. This
24095 allows you to distinguish between the two variants of Bash.
24096
24097 To verify which Bash your whole profile refers to, you can run
24098 (@pxref{Invoking guix gc}):
24099
24100 @example
24101 guix gc -R `readlink -f ~/.guix-profile` | grep bash
24102 @end example
24103
24104 @noindent
24105 @dots{} and compare the store file names that you get with those above.
24106 Likewise for a complete GuixSD system generation:
24107
24108 @example
24109 guix gc -R `guix system build my-config.scm` | grep bash
24110 @end example
24111
24112 Lastly, to check which Bash running processes are using, you can use the
24113 @command{lsof} command:
24114
24115 @example
24116 lsof | grep /gnu/store/.*bash
24117 @end example
24118
24119
24120 @node Package Modules
24121 @chapter Package Modules
24122
24123 From a programming viewpoint, the package definitions of the
24124 GNU distribution are provided by Guile modules in the @code{(gnu packages
24125 @dots{})} name space@footnote{Note that packages under the @code{(gnu
24126 packages @dots{})} module name space are not necessarily ``GNU
24127 packages''. This module naming scheme follows the usual Guile module
24128 naming convention: @code{gnu} means that these modules are distributed
24129 as part of the GNU system, and @code{packages} identifies modules that
24130 define packages.} (@pxref{Modules, Guile modules,, guile, GNU Guile
24131 Reference Manual}). For instance, the @code{(gnu packages emacs)}
24132 module exports a variable named @code{emacs}, which is bound to a
24133 @code{<package>} object (@pxref{Defining Packages}).
24134
24135 The @code{(gnu packages @dots{})} module name space is
24136 automatically scanned for packages by the command-line tools. For
24137 instance, when running @code{guix package -i emacs}, all the @code{(gnu
24138 packages @dots{})} modules are scanned until one that exports a package
24139 object whose name is @code{emacs} is found. This package search
24140 facility is implemented in the @code{(gnu packages)} module.
24141
24142 @cindex customization, of packages
24143 @cindex package module search path
24144 Users can store package definitions in modules with different
24145 names---e.g., @code{(my-packages emacs)}@footnote{Note that the file
24146 name and module name must match. For instance, the @code{(my-packages
24147 emacs)} module must be stored in a @file{my-packages/emacs.scm} file
24148 relative to the load path specified with @option{--load-path} or
24149 @code{GUIX_PACKAGE_PATH}. @xref{Modules and the File System,,,
24150 guile, GNU Guile Reference Manual}, for details.}. There are two ways to make
24151 these package definitions visible to the user interfaces:
24152
24153 @enumerate
24154 @item
24155 By adding the directory containing your package modules to the search path
24156 with the @code{-L} flag of @command{guix package} and other commands
24157 (@pxref{Common Build Options}), or by setting the @code{GUIX_PACKAGE_PATH}
24158 environment variable described below.
24159
24160 @item
24161 By defining a @dfn{channel} and configuring @command{guix pull} so that it
24162 pulls from it. A channel is essentially a Git repository containing package
24163 modules. @xref{Channels}, for more information on how to define and use
24164 channels.
24165 @end enumerate
24166
24167 @code{GUIX_PACKAGE_PATH} works similarly to other search path variables:
24168
24169 @defvr {Environment Variable} GUIX_PACKAGE_PATH
24170 This is a colon-separated list of directories to search for additional
24171 package modules. Directories listed in this variable take precedence
24172 over the own modules of the distribution.
24173 @end defvr
24174
24175 The distribution is fully @dfn{bootstrapped} and @dfn{self-contained}:
24176 each package is built based solely on other packages in the
24177 distribution. The root of this dependency graph is a small set of
24178 @dfn{bootstrap binaries}, provided by the @code{(gnu packages
24179 bootstrap)} module. For more information on bootstrapping,
24180 @pxref{Bootstrapping}.
24181
24182 @node Packaging Guidelines
24183 @chapter Packaging Guidelines
24184
24185 @cindex packages, creating
24186 The GNU distribution is nascent and may well lack some of your favorite
24187 packages. This section describes how you can help make the distribution
24188 grow. @xref{Contributing}, for additional information on how you can
24189 help.
24190
24191 Free software packages are usually distributed in the form of
24192 @dfn{source code tarballs}---typically @file{tar.gz} files that contain
24193 all the source files. Adding a package to the distribution means
24194 essentially two things: adding a @dfn{recipe} that describes how to
24195 build the package, including a list of other packages required to build
24196 it, and adding @dfn{package metadata} along with that recipe, such as a
24197 description and licensing information.
24198
24199 In Guix all this information is embodied in @dfn{package definitions}.
24200 Package definitions provide a high-level view of the package. They are
24201 written using the syntax of the Scheme programming language; in fact,
24202 for each package we define a variable bound to the package definition,
24203 and export that variable from a module (@pxref{Package Modules}).
24204 However, in-depth Scheme knowledge is @emph{not} a prerequisite for
24205 creating packages. For more information on package definitions,
24206 @pxref{Defining Packages}.
24207
24208 Once a package definition is in place, stored in a file in the Guix
24209 source tree, it can be tested using the @command{guix build} command
24210 (@pxref{Invoking guix build}). For example, assuming the new package is
24211 called @code{gnew}, you may run this command from the Guix build tree
24212 (@pxref{Running Guix Before It Is Installed}):
24213
24214 @example
24215 ./pre-inst-env guix build gnew --keep-failed
24216 @end example
24217
24218 Using @code{--keep-failed} makes it easier to debug build failures since
24219 it provides access to the failed build tree. Another useful
24220 command-line option when debugging is @code{--log-file}, to access the
24221 build log.
24222
24223 If the package is unknown to the @command{guix} command, it may be that
24224 the source file contains a syntax error, or lacks a @code{define-public}
24225 clause to export the package variable. To figure it out, you may load
24226 the module from Guile to get more information about the actual error:
24227
24228 @example
24229 ./pre-inst-env guile -c '(use-modules (gnu packages gnew))'
24230 @end example
24231
24232 Once your package builds correctly, please send us a patch
24233 (@pxref{Contributing}). Well, if you need help, we will be happy to
24234 help you too. Once the patch is committed in the Guix repository, the
24235 new package automatically gets built on the supported platforms by
24236 @url{http://hydra.gnu.org/jobset/gnu/master, our continuous integration
24237 system}.
24238
24239 @cindex substituter
24240 Users can obtain the new package definition simply by running
24241 @command{guix pull} (@pxref{Invoking guix pull}). When
24242 @code{@value{SUBSTITUTE-SERVER}} is done building the package, installing the
24243 package automatically downloads binaries from there
24244 (@pxref{Substitutes}). The only place where human intervention is
24245 needed is to review and apply the patch.
24246
24247
24248 @menu
24249 * Software Freedom:: What may go into the distribution.
24250 * Package Naming:: What's in a name?
24251 * Version Numbers:: When the name is not enough.
24252 * Synopses and Descriptions:: Helping users find the right package.
24253 * Python Modules:: A touch of British comedy.
24254 * Perl Modules:: Little pearls.
24255 * Java Packages:: Coffee break.
24256 * Fonts:: Fond of fonts.
24257 @end menu
24258
24259 @node Software Freedom
24260 @section Software Freedom
24261
24262 @c Adapted from http://www.gnu.org/philosophy/philosophy.html.
24263 @cindex free software
24264 The GNU operating system has been developed so that users can have
24265 freedom in their computing. GNU is @dfn{free software}, meaning that
24266 users have the @url{http://www.gnu.org/philosophy/free-sw.html,four
24267 essential freedoms}: to run the program, to study and change the program
24268 in source code form, to redistribute exact copies, and to distribute
24269 modified versions. Packages found in the GNU distribution provide only
24270 software that conveys these four freedoms.
24271
24272 In addition, the GNU distribution follow the
24273 @url{http://www.gnu.org/distros/free-system-distribution-guidelines.html,free
24274 software distribution guidelines}. Among other things, these guidelines
24275 reject non-free firmware, recommendations of non-free software, and
24276 discuss ways to deal with trademarks and patents.
24277
24278 Some otherwise free upstream package sources contain a small and optional
24279 subset that violates the above guidelines, for instance because this subset
24280 is itself non-free code. When that happens, the offending items are removed
24281 with appropriate patches or code snippets in the @code{origin} form of the
24282 package (@pxref{Defining Packages}). This way, @code{guix
24283 build --source} returns the ``freed'' source rather than the unmodified
24284 upstream source.
24285
24286
24287 @node Package Naming
24288 @section Package Naming
24289
24290 @cindex package name
24291 A package has actually two names associated with it:
24292 First, there is the name of the @emph{Scheme variable}, the one following
24293 @code{define-public}. By this name, the package can be made known in the
24294 Scheme code, for instance as input to another package. Second, there is
24295 the string in the @code{name} field of a package definition. This name
24296 is used by package management commands such as
24297 @command{guix package} and @command{guix build}.
24298
24299 Both are usually the same and correspond to the lowercase conversion of
24300 the project name chosen upstream, with underscores replaced with
24301 hyphens. For instance, GNUnet is available as @code{gnunet}, and
24302 SDL_net as @code{sdl-net}.
24303
24304 We do not add @code{lib} prefixes for library packages, unless these are
24305 already part of the official project name. But @pxref{Python
24306 Modules} and @ref{Perl Modules} for special rules concerning modules for
24307 the Python and Perl languages.
24308
24309 Font package names are handled differently, @pxref{Fonts}.
24310
24311
24312 @node Version Numbers
24313 @section Version Numbers
24314
24315 @cindex package version
24316 We usually package only the latest version of a given free software
24317 project. But sometimes, for instance for incompatible library versions,
24318 two (or more) versions of the same package are needed. These require
24319 different Scheme variable names. We use the name as defined
24320 in @ref{Package Naming}
24321 for the most recent version; previous versions use the same name, suffixed
24322 by @code{-} and the smallest prefix of the version number that may
24323 distinguish the two versions.
24324
24325 The name inside the package definition is the same for all versions of a
24326 package and does not contain any version number.
24327
24328 For instance, the versions 2.24.20 and 3.9.12 of GTK+ may be packaged as follows:
24329
24330 @example
24331 (define-public gtk+
24332 (package
24333 (name "gtk+")
24334 (version "3.9.12")
24335 ...))
24336 (define-public gtk+-2
24337 (package
24338 (name "gtk+")
24339 (version "2.24.20")
24340 ...))
24341 @end example
24342 If we also wanted GTK+ 3.8.2, this would be packaged as
24343 @example
24344 (define-public gtk+-3.8
24345 (package
24346 (name "gtk+")
24347 (version "3.8.2")
24348 ...))
24349 @end example
24350
24351 @c See <https://lists.gnu.org/archive/html/guix-devel/2016-01/msg00425.html>,
24352 @c for a discussion of what follows.
24353 @cindex version number, for VCS snapshots
24354 Occasionally, we package snapshots of upstream's version control system
24355 (VCS) instead of formal releases. This should remain exceptional,
24356 because it is up to upstream developers to clarify what the stable
24357 release is. Yet, it is sometimes necessary. So, what should we put in
24358 the @code{version} field?
24359
24360 Clearly, we need to make the commit identifier of the VCS snapshot
24361 visible in the version string, but we also need to make sure that the
24362 version string is monotonically increasing so that @command{guix package
24363 --upgrade} can determine which version is newer. Since commit
24364 identifiers, notably with Git, are not monotonically increasing, we add
24365 a revision number that we increase each time we upgrade to a newer
24366 snapshot. The resulting version string looks like this:
24367
24368 @example
24369 2.0.11-3.cabba9e
24370 ^ ^ ^
24371 | | `-- upstream commit ID
24372 | |
24373 | `--- Guix package revision
24374 |
24375 latest upstream version
24376 @end example
24377
24378 It is a good idea to strip commit identifiers in the @code{version}
24379 field to, say, 7 digits. It avoids an aesthetic annoyance (assuming
24380 aesthetics have a role to play here) as well as problems related to OS
24381 limits such as the maximum shebang length (127 bytes for the Linux
24382 kernel.) It is best to use the full commit identifiers in
24383 @code{origin}s, though, to avoid ambiguities. A typical package
24384 definition may look like this:
24385
24386 @example
24387 (define my-package
24388 (let ((commit "c3f29bc928d5900971f65965feaae59e1272a3f7")
24389 (revision "1")) ;Guix package revision
24390 (package
24391 (version (git-version "0.9" revision commit))
24392 (source (origin
24393 (method git-fetch)
24394 (uri (git-reference
24395 (url "git://example.org/my-package.git")
24396 (commit commit)))
24397 (sha256 (base32 "1mbikn@dots{}"))
24398 (file-name (git-file-name name version))))
24399 ;; @dots{}
24400 )))
24401 @end example
24402
24403 @node Synopses and Descriptions
24404 @section Synopses and Descriptions
24405
24406 @cindex package description
24407 @cindex package synopsis
24408 As we have seen before, each package in GNU@tie{}Guix includes a
24409 synopsis and a description (@pxref{Defining Packages}). Synopses and
24410 descriptions are important: They are what @command{guix package
24411 --search} searches, and a crucial piece of information to help users
24412 determine whether a given package suits their needs. Consequently,
24413 packagers should pay attention to what goes into them.
24414
24415 Synopses must start with a capital letter and must not end with a
24416 period. They must not start with ``a'' or ``the'', which usually does
24417 not bring anything; for instance, prefer ``File-frobbing tool'' over ``A
24418 tool that frobs files''. The synopsis should say what the package
24419 is---e.g., ``Core GNU utilities (file, text, shell)''---or what it is
24420 used for---e.g., the synopsis for GNU@tie{}grep is ``Print lines
24421 matching a pattern''.
24422
24423 Keep in mind that the synopsis must be meaningful for a very wide
24424 audience. For example, ``Manipulate alignments in the SAM format''
24425 might make sense for a seasoned bioinformatics researcher, but might be
24426 fairly unhelpful or even misleading to a non-specialized audience. It
24427 is a good idea to come up with a synopsis that gives an idea of the
24428 application domain of the package. In this example, this might give
24429 something like ``Manipulate nucleotide sequence alignments'', which
24430 hopefully gives the user a better idea of whether this is what they are
24431 looking for.
24432
24433 Descriptions should take between five and ten lines. Use full
24434 sentences, and avoid using acronyms without first introducing them.
24435 Please avoid marketing phrases such as ``world-leading'',
24436 ``industrial-strength'', and ``next-generation'', and avoid superlatives
24437 like ``the most advanced''---they are not helpful to users looking for a
24438 package and may even sound suspicious. Instead, try to be factual,
24439 mentioning use cases and features.
24440
24441 @cindex Texinfo markup, in package descriptions
24442 Descriptions can include Texinfo markup, which is useful to introduce
24443 ornaments such as @code{@@code} or @code{@@dfn}, bullet lists, or
24444 hyperlinks (@pxref{Overview,,, texinfo, GNU Texinfo}). However you
24445 should be careful when using some characters for example @samp{@@} and
24446 curly braces which are the basic special characters in Texinfo
24447 (@pxref{Special Characters,,, texinfo, GNU Texinfo}). User interfaces
24448 such as @command{guix package --show} take care of rendering it
24449 appropriately.
24450
24451 Synopses and descriptions are translated by volunteers
24452 @uref{http://translationproject.org/domain/guix-packages.html, at the
24453 Translation Project} so that as many users as possible can read them in
24454 their native language. User interfaces search them and display them in
24455 the language specified by the current locale.
24456
24457 To allow @command{xgettext} to extract them as translatable strings,
24458 synopses and descriptions @emph{must be literal strings}. This means
24459 that you cannot use @code{string-append} or @code{format} to construct
24460 these strings:
24461
24462 @lisp
24463 (package
24464 ;; @dots{}
24465 (synopsis "This is translatable")
24466 (description (string-append "This is " "*not*" " translatable.")))
24467 @end lisp
24468
24469 Translation is a lot of work so, as a packager, please pay even more
24470 attention to your synopses and descriptions as every change may entail
24471 additional work for translators. In order to help them, it is possible
24472 to make recommendations or instructions visible to them by inserting
24473 special comments like this (@pxref{xgettext Invocation,,, gettext, GNU
24474 Gettext}):
24475
24476 @example
24477 ;; TRANSLATORS: "X11 resize-and-rotate" should not be translated.
24478 (description "ARandR is designed to provide a simple visual front end
24479 for the X11 resize-and-rotate (RandR) extension. @dots{}")
24480 @end example
24481
24482
24483 @node Python Modules
24484 @section Python Modules
24485
24486 @cindex python
24487 We currently package Python 2 and Python 3, under the Scheme variable names
24488 @code{python-2} and @code{python} as explained in @ref{Version Numbers}.
24489 To avoid confusion and naming clashes with other programming languages, it
24490 seems desirable that the name of a package for a Python module contains
24491 the word @code{python}.
24492
24493 Some modules are compatible with only one version of Python, others with both.
24494 If the package Foo compiles only with Python 3, we name it
24495 @code{python-foo}; if it compiles only with Python 2, we name it
24496 @code{python2-foo}. If it is compatible with both versions, we create two
24497 packages with the corresponding names.
24498
24499 If a project already contains the word @code{python}, we drop this;
24500 for instance, the module python-dateutil is packaged under the names
24501 @code{python-dateutil} and @code{python2-dateutil}. If the project name
24502 starts with @code{py} (e.g.@: @code{pytz}), we keep it and prefix it as
24503 described above.
24504
24505 @subsection Specifying Dependencies
24506 @cindex inputs, for Python packages
24507
24508 Dependency information for Python packages is usually available in the
24509 package source tree, with varying degrees of accuracy: in the
24510 @file{setup.py} file, in @file{requirements.txt}, or in @file{tox.ini}.
24511
24512 Your mission, when writing a recipe for a Python package, is to map
24513 these dependencies to the appropriate type of ``input'' (@pxref{package
24514 Reference, inputs}). Although the @code{pypi} importer normally does a
24515 good job (@pxref{Invoking guix import}), you may want to check the
24516 following check list to determine which dependency goes where.
24517
24518 @itemize
24519
24520 @item
24521 We currently package Python 2 with @code{setuptools} and @code{pip}
24522 installed like Python 3.4 has per default. Thus you don't need to
24523 specify either of these as an input. @command{guix lint} will warn you
24524 if you do.
24525
24526 @item
24527 Python dependencies required at run time go into
24528 @code{propagated-inputs}. They are typically defined with the
24529 @code{install_requires} keyword in @file{setup.py}, or in the
24530 @file{requirements.txt} file.
24531
24532 @item
24533 Python packages required only at build time---e.g., those listed with
24534 the @code{setup_requires} keyword in @file{setup.py}---or only for
24535 testing---e.g., those in @code{tests_require}---go into
24536 @code{native-inputs}. The rationale is that (1) they do not need to be
24537 propagated because they are not needed at run time, and (2) in a
24538 cross-compilation context, it's the ``native'' input that we'd want.
24539
24540 Examples are the @code{pytest}, @code{mock}, and @code{nose} test
24541 frameworks. Of course if any of these packages is also required at
24542 run-time, it needs to go to @code{propagated-inputs}.
24543
24544 @item
24545 Anything that does not fall in the previous categories goes to
24546 @code{inputs}, for example programs or C libraries required for building
24547 Python packages containing C extensions.
24548
24549 @item
24550 If a Python package has optional dependencies (@code{extras_require}),
24551 it is up to you to decide whether to add them or not, based on their
24552 usefulness/overhead ratio (@pxref{Submitting Patches, @command{guix
24553 size}}).
24554
24555 @end itemize
24556
24557
24558 @node Perl Modules
24559 @section Perl Modules
24560
24561 @cindex perl
24562 Perl programs standing for themselves are named as any other package,
24563 using the lowercase upstream name.
24564 For Perl packages containing a single class, we use the lowercase class name,
24565 replace all occurrences of @code{::} by dashes and prepend the prefix
24566 @code{perl-}.
24567 So the class @code{XML::Parser} becomes @code{perl-xml-parser}.
24568 Modules containing several classes keep their lowercase upstream name and
24569 are also prepended by @code{perl-}. Such modules tend to have the word
24570 @code{perl} somewhere in their name, which gets dropped in favor of the
24571 prefix. For instance, @code{libwww-perl} becomes @code{perl-libwww}.
24572
24573
24574 @node Java Packages
24575 @section Java Packages
24576
24577 @cindex java
24578 Java programs standing for themselves are named as any other package,
24579 using the lowercase upstream name.
24580
24581 To avoid confusion and naming clashes with other programming languages,
24582 it is desirable that the name of a package for a Java package is
24583 prefixed with @code{java-}. If a project already contains the word
24584 @code{java}, we drop this; for instance, the package @code{ngsjava} is
24585 packaged under the name @code{java-ngs}.
24586
24587 For Java packages containing a single class or a small class hierarchy,
24588 we use the lowercase class name, replace all occurrences of @code{.} by
24589 dashes and prepend the prefix @code{java-}. So the class
24590 @code{apache.commons.cli} becomes package
24591 @code{java-apache-commons-cli}.
24592
24593
24594 @node Fonts
24595 @section Fonts
24596
24597 @cindex fonts
24598 For fonts that are in general not installed by a user for typesetting
24599 purposes, or that are distributed as part of a larger software package,
24600 we rely on the general packaging rules for software; for instance, this
24601 applies to the fonts delivered as part of the X.Org system or fonts that
24602 are part of TeX Live.
24603
24604 To make it easier for a user to search for fonts, names for other packages
24605 containing only fonts are constructed as follows, independently of the
24606 upstream package name.
24607
24608 The name of a package containing only one font family starts with
24609 @code{font-}; it is followed by the foundry name and a dash @code{-}
24610 if the foundry is known, and the font family name, in which spaces are
24611 replaced by dashes (and as usual, all upper case letters are transformed
24612 to lower case).
24613 For example, the Gentium font family by SIL is packaged under the name
24614 @code{font-sil-gentium}.
24615
24616 For a package containing several font families, the name of the collection
24617 is used in the place of the font family name.
24618 For instance, the Liberation fonts consist of three families,
24619 Liberation Sans, Liberation Serif and Liberation Mono.
24620 These could be packaged separately under the names
24621 @code{font-liberation-sans} and so on; but as they are distributed together
24622 under a common name, we prefer to package them together as
24623 @code{font-liberation}.
24624
24625 In the case where several formats of the same font family or font collection
24626 are packaged separately, a short form of the format, prepended by a dash,
24627 is added to the package name. We use @code{-ttf} for TrueType fonts,
24628 @code{-otf} for OpenType fonts and @code{-type1} for PostScript Type 1
24629 fonts.
24630
24631
24632
24633 @node Bootstrapping
24634 @chapter Bootstrapping
24635
24636 @c Adapted from the ELS 2013 paper.
24637
24638 @cindex bootstrapping
24639
24640 Bootstrapping in our context refers to how the distribution gets built
24641 ``from nothing''. Remember that the build environment of a derivation
24642 contains nothing but its declared inputs (@pxref{Introduction}). So
24643 there's an obvious chicken-and-egg problem: how does the first package
24644 get built? How does the first compiler get compiled? Note that this is
24645 a question of interest only to the curious hacker, not to the regular
24646 user, so you can shamelessly skip this section if you consider yourself
24647 a ``regular user''.
24648
24649 @cindex bootstrap binaries
24650 The GNU system is primarily made of C code, with libc at its core. The
24651 GNU build system itself assumes the availability of a Bourne shell and
24652 command-line tools provided by GNU Coreutils, Awk, Findutils, `sed', and
24653 `grep'. Furthermore, build programs---programs that run
24654 @code{./configure}, @code{make}, etc.---are written in Guile Scheme
24655 (@pxref{Derivations}). Consequently, to be able to build anything at
24656 all, from scratch, Guix relies on pre-built binaries of Guile, GCC,
24657 Binutils, libc, and the other packages mentioned above---the
24658 @dfn{bootstrap binaries}.
24659
24660 These bootstrap binaries are ``taken for granted'', though we can also
24661 re-create them if needed (more on that later).
24662
24663 @unnumberedsec Preparing to Use the Bootstrap Binaries
24664
24665 @c As of Emacs 24.3, Info-mode displays the image, but since it's a
24666 @c large image, it's hard to scroll. Oh well.
24667 @image{images/bootstrap-graph,6in,,Dependency graph of the early bootstrap derivations}
24668
24669 The figure above shows the very beginning of the dependency graph of the
24670 distribution, corresponding to the package definitions of the @code{(gnu
24671 packages bootstrap)} module. A similar figure can be generated with
24672 @command{guix graph} (@pxref{Invoking guix graph}), along the lines of:
24673
24674 @example
24675 guix graph -t derivation \
24676 -e '(@@@@ (gnu packages bootstrap) %bootstrap-gcc)' \
24677 | dot -Tps > t.ps
24678 @end example
24679
24680 At this level of detail, things are
24681 slightly complex. First, Guile itself consists of an ELF executable,
24682 along with many source and compiled Scheme files that are dynamically
24683 loaded when it runs. This gets stored in the @file{guile-2.0.7.tar.xz}
24684 tarball shown in this graph. This tarball is part of Guix's ``source''
24685 distribution, and gets inserted into the store with @code{add-to-store}
24686 (@pxref{The Store}).
24687
24688 But how do we write a derivation that unpacks this tarball and adds it
24689 to the store? To solve this problem, the @code{guile-bootstrap-2.0.drv}
24690 derivation---the first one that gets built---uses @code{bash} as its
24691 builder, which runs @code{build-bootstrap-guile.sh}, which in turn calls
24692 @code{tar} to unpack the tarball. Thus, @file{bash}, @file{tar},
24693 @file{xz}, and @file{mkdir} are statically-linked binaries, also part of
24694 the Guix source distribution, whose sole purpose is to allow the Guile
24695 tarball to be unpacked.
24696
24697 Once @code{guile-bootstrap-2.0.drv} is built, we have a functioning
24698 Guile that can be used to run subsequent build programs. Its first task
24699 is to download tarballs containing the other pre-built binaries---this
24700 is what the @code{.tar.xz.drv} derivations do. Guix modules such as
24701 @code{ftp-client.scm} are used for this purpose. The
24702 @code{module-import.drv} derivations import those modules in a directory
24703 in the store, using the original layout. The
24704 @code{module-import-compiled.drv} derivations compile those modules, and
24705 write them in an output directory with the right layout. This
24706 corresponds to the @code{#:modules} argument of
24707 @code{build-expression->derivation} (@pxref{Derivations}).
24708
24709 Finally, the various tarballs are unpacked by the
24710 derivations @code{gcc-bootstrap-0.drv}, @code{glibc-bootstrap-0.drv},
24711 etc., at which point we have a working C tool chain.
24712
24713
24714 @unnumberedsec Building the Build Tools
24715
24716 Bootstrapping is complete when we have a full tool chain that does not
24717 depend on the pre-built bootstrap tools discussed above. This
24718 no-dependency requirement is verified by checking whether the files of
24719 the final tool chain contain references to the @file{/gnu/store}
24720 directories of the bootstrap inputs. The process that leads to this
24721 ``final'' tool chain is described by the package definitions found in
24722 the @code{(gnu packages commencement)} module.
24723
24724 The @command{guix graph} command allows us to ``zoom out'' compared to
24725 the graph above, by looking at the level of package objects instead of
24726 individual derivations---remember that a package may translate to
24727 several derivations, typically one derivation to download its source,
24728 one to build the Guile modules it needs, and one to actually build the
24729 package from source. The command:
24730
24731 @example
24732 guix graph -t bag \
24733 -e '(@@@@ (gnu packages commencement)
24734 glibc-final-with-bootstrap-bash)' | dot -Tps > t.ps
24735 @end example
24736
24737 @noindent
24738 produces the dependency graph leading to the ``final'' C
24739 library@footnote{You may notice the @code{glibc-intermediate} label,
24740 suggesting that it is not @emph{quite} final, but as a good
24741 approximation, we will consider it final.}, depicted below.
24742
24743 @image{images/bootstrap-packages,6in,,Dependency graph of the early packages}
24744
24745 @c See <http://lists.gnu.org/archive/html/gnu-system-discuss/2012-10/msg00000.html>.
24746 The first tool that gets built with the bootstrap binaries is
24747 GNU@tie{}Make---noted @code{make-boot0} above---which is a prerequisite
24748 for all the following packages. From there Findutils and Diffutils get
24749 built.
24750
24751 Then come the first-stage Binutils and GCC, built as pseudo cross
24752 tools---i.e., with @code{--target} equal to @code{--host}. They are
24753 used to build libc. Thanks to this cross-build trick, this libc is
24754 guaranteed not to hold any reference to the initial tool chain.
24755
24756 From there the final Binutils and GCC (not shown above) are built.
24757 GCC uses @code{ld}
24758 from the final Binutils, and links programs against the just-built libc.
24759 This tool chain is used to build the other packages used by Guix and by
24760 the GNU Build System: Guile, Bash, Coreutils, etc.
24761
24762 And voilà! At this point we have the complete set of build tools that
24763 the GNU Build System expects. These are in the @code{%final-inputs}
24764 variable of the @code{(gnu packages commencement)} module, and are
24765 implicitly used by any package that uses @code{gnu-build-system}
24766 (@pxref{Build Systems, @code{gnu-build-system}}).
24767
24768
24769 @unnumberedsec Building the Bootstrap Binaries
24770
24771 @cindex bootstrap binaries
24772 Because the final tool chain does not depend on the bootstrap binaries,
24773 those rarely need to be updated. Nevertheless, it is useful to have an
24774 automated way to produce them, should an update occur, and this is what
24775 the @code{(gnu packages make-bootstrap)} module provides.
24776
24777 The following command builds the tarballs containing the bootstrap
24778 binaries (Guile, Binutils, GCC, libc, and a tarball containing a mixture
24779 of Coreutils and other basic command-line tools):
24780
24781 @example
24782 guix build bootstrap-tarballs
24783 @end example
24784
24785 The generated tarballs are those that should be referred to in the
24786 @code{(gnu packages bootstrap)} module mentioned at the beginning of
24787 this section.
24788
24789 Still here? Then perhaps by now you've started to wonder: when do we
24790 reach a fixed point? That is an interesting question! The answer is
24791 unknown, but if you would like to investigate further (and have
24792 significant computational and storage resources to do so), then let us
24793 know.
24794
24795 @unnumberedsec Reducing the Set of Bootstrap Binaries
24796
24797 Our bootstrap binaries currently include GCC, Guile, etc. That's a lot
24798 of binary code! Why is that a problem? It's a problem because these
24799 big chunks of binary code are practically non-auditable, which makes it
24800 hard to establish what source code produced them. Every unauditable
24801 binary also leaves us vulnerable to compiler backdoors as described by
24802 Ken Thompson in the 1984 paper @emph{Reflections on Trusting Trust}.
24803
24804 This is mitigated by the fact that our bootstrap binaries were generated
24805 from an earlier Guix revision. Nevertheless it lacks the level of
24806 transparency that we get in the rest of the package dependency graph,
24807 where Guix always gives us a source-to-binary mapping. Thus, our goal
24808 is to reduce the set of bootstrap binaries to the bare minimum.
24809
24810 The @uref{http://bootstrappable.org, Bootstrappable.org web site} lists
24811 on-going projects to do that. One of these is about replacing the
24812 bootstrap GCC with a sequence of assemblers, interpreters, and compilers
24813 of increasing complexity, which could be built from source starting from
24814 a simple and auditable assembler. Your help is welcome!
24815
24816
24817 @node Porting
24818 @chapter Porting to a New Platform
24819
24820 As discussed above, the GNU distribution is self-contained, and
24821 self-containment is achieved by relying on pre-built ``bootstrap
24822 binaries'' (@pxref{Bootstrapping}). These binaries are specific to an
24823 operating system kernel, CPU architecture, and application binary
24824 interface (ABI). Thus, to port the distribution to a platform that is
24825 not yet supported, one must build those bootstrap binaries, and update
24826 the @code{(gnu packages bootstrap)} module to use them on that platform.
24827
24828 Fortunately, Guix can @emph{cross compile} those bootstrap binaries.
24829 When everything goes well, and assuming the GNU tool chain supports the
24830 target platform, this can be as simple as running a command like this
24831 one:
24832
24833 @example
24834 guix build --target=armv5tel-linux-gnueabi bootstrap-tarballs
24835 @end example
24836
24837 For this to work, the @code{glibc-dynamic-linker} procedure in
24838 @code{(gnu packages bootstrap)} must be augmented to return the right
24839 file name for libc's dynamic linker on that platform; likewise,
24840 @code{system->linux-architecture} in @code{(gnu packages linux)} must be
24841 taught about the new platform.
24842
24843 Once these are built, the @code{(gnu packages bootstrap)} module needs
24844 to be updated to refer to these binaries on the target platform. That
24845 is, the hashes and URLs of the bootstrap tarballs for the new platform
24846 must be added alongside those of the currently supported platforms. The
24847 bootstrap Guile tarball is treated specially: it is expected to be
24848 available locally, and @file{gnu/local.mk} has rules to download it for
24849 the supported architectures; a rule for the new platform must be added
24850 as well.
24851
24852 In practice, there may be some complications. First, it may be that the
24853 extended GNU triplet that specifies an ABI (like the @code{eabi} suffix
24854 above) is not recognized by all the GNU tools. Typically, glibc
24855 recognizes some of these, whereas GCC uses an extra @code{--with-abi}
24856 configure flag (see @code{gcc.scm} for examples of how to handle this).
24857 Second, some of the required packages could fail to build for that
24858 platform. Lastly, the generated binaries could be broken for some
24859 reason.
24860
24861 @c *********************************************************************
24862 @include contributing.texi
24863
24864 @c *********************************************************************
24865 @node Acknowledgments
24866 @chapter Acknowledgments
24867
24868 Guix is based on the @uref{http://nixos.org/nix/, Nix package manager},
24869 which was designed and
24870 implemented by Eelco Dolstra, with contributions from other people (see
24871 the @file{nix/AUTHORS} file in Guix.) Nix pioneered functional package
24872 management, and promoted unprecedented features, such as transactional
24873 package upgrades and rollbacks, per-user profiles, and referentially
24874 transparent build processes. Without this work, Guix would not exist.
24875
24876 The Nix-based software distributions, Nixpkgs and NixOS, have also been
24877 an inspiration for Guix.
24878
24879 GNU@tie{}Guix itself is a collective work with contributions from a
24880 number of people. See the @file{AUTHORS} file in Guix for more
24881 information on these fine people. The @file{THANKS} file lists people
24882 who have helped by reporting bugs, taking care of the infrastructure,
24883 providing artwork and themes, making suggestions, and more---thank you!
24884
24885
24886 @c *********************************************************************
24887 @node GNU Free Documentation License
24888 @appendix GNU Free Documentation License
24889 @cindex license, GNU Free Documentation License
24890 @include fdl-1.3.texi
24891
24892 @c *********************************************************************
24893 @node Concept Index
24894 @unnumbered Concept Index
24895 @printindex cp
24896
24897 @node Programming Index
24898 @unnumbered Programming Index
24899 @syncodeindex tp fn
24900 @syncodeindex vr fn
24901 @printindex fn
24902
24903 @bye
24904
24905 @c Local Variables:
24906 @c ispell-local-dictionary: "american";
24907 @c End: