gnu: postgresql: Add extension-packages.
[jackhill/guix/guix.git] / doc / guix.texi
CommitLineData
568717fd
LC
1\input texinfo
2@c -*-texinfo-*-
3
4@c %**start of header
5@setfilename guix.info
6@documentencoding UTF-8
f8348b91 7@settitle GNU Guix Reference Manual
568717fd
LC
8@c %**end of header
9
10@include version.texi
7df7a74e 11
debc6360 12@c Identifier of the OpenPGP key used to sign tarballs and such.
df671177 13@set OPENPGP-SIGNING-KEY-ID 3CE464558A84FDC69DB40CFB090B11993D9AEBB5
debc6360 14
7df7a74e 15@copying
29a68668 16Copyright @copyright{} 2012, 2013, 2014, 2015, 2016, 2017, 2018 Ludovic Courtès@*
f97c9175 17Copyright @copyright{} 2013, 2014, 2016 Andreas Enge@*
87eafdbd 18Copyright @copyright{} 2013 Nikita Karetnikov@*
1a3e6b15 19Copyright @copyright{} 2014, 2015, 2016 Alex Kost@*
1b846da8 20Copyright @copyright{} 2015, 2016 Mathieu Lirzin@*
8c01b9d0 21Copyright @copyright{} 2014 Pierre-Antoine Rault@*
97d76250 22Copyright @copyright{} 2015 Taylan Ulrich Bayırlı/Kammer@*
8a9cffb2 23Copyright @copyright{} 2015, 2016, 2017 Leo Famulari@*
b617a9fe 24Copyright @copyright{} 2015, 2016, 2017, 2018 Ricardo Wurmus@*
4d343a14 25Copyright @copyright{} 2016 Ben Woodcroft@*
272c0709 26Copyright @copyright{} 2016, 2017, 2018 Chris Marusich@*
16718b67 27Copyright @copyright{} 2016, 2017, 2018 Efraim Flashner@*
d6a07ee6 28Copyright @copyright{} 2016 John Darrington@*
4a78fd46 29Copyright @copyright{} 2016, 2017 Nils Gillmann@*
f3a42251 30Copyright @copyright{} 2016, 2017, 2018 Jan Nieuwenhuizen@*
9747d189 31Copyright @copyright{} 2016 Julien Lepiller@*
78cef99b 32Copyright @copyright{} 2016 Alex ter Weele@*
7ab04c17 33Copyright @copyright{} 2017, 2018 Clément Lassieur@*
bc5844d1 34Copyright @copyright{} 2017 Mathieu Othacehe@*
82ccc499 35Copyright @copyright{} 2017 Federico Beffa@*
9260b9d1 36Copyright @copyright{} 2017 Carlo Zancanaro@*
fc06b15e 37Copyright @copyright{} 2017 Thomas Danckaert@*
d7fa39cc 38Copyright @copyright{} 2017 humanitiesNerd@*
c80cd4df 39Copyright @copyright{} 2017 Christopher Allan Webber@*
38ab778f 40Copyright @copyright{} 2017, 2018 Marius Bakke@*
4695472f 41Copyright @copyright{} 2017 Hartmut Goebel@*
352a5b63 42Copyright @copyright{} 2017 Maxim Cournoyer@*
782c94fe 43Copyright @copyright{} 2017, 2018 Tobias Geerinckx-Rice@*
1115f140 44Copyright @copyright{} 2017 George Clemmer@*
3d0aa7f7 45Copyright @copyright{} 2017 Andy Wingo@*
a76acfd3 46Copyright @copyright{} 2017, 2018 Arun Isaac@*
3853f86f 47Copyright @copyright{} 2017 nee@*
e1cf4fd2 48Copyright @copyright{} 2018 Rutger Helling@*
07ec3492 49Copyright @copyright{} 2018 Oleg Pykhalov@*
93b83eb3 50Copyright @copyright{} 2018 Mike Gerwitz@*
a33652ee
GB
51Copyright @copyright{} 2018 Pierre-Antoine Rouby@*
52Copyright @copyright{} 2018 Gábor Boskovits@*
7df7a74e
NK
53
54Permission is granted to copy, distribute and/or modify this document
55under the terms of the GNU Free Documentation License, Version 1.3 or
56any later version published by the Free Software Foundation; with no
57Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A
58copy of the license is included in the section entitled ``GNU Free
59Documentation License''.
60@end copying
568717fd 61
abd67856 62@dircategory System administration
568717fd 63@direntry
abd67856
LC
64* Guix: (guix). Manage installed software and system configuration.
65* guix package: (guix)Invoking guix package. Installing, removing, and upgrading packages.
abd67856
LC
66* guix gc: (guix)Invoking guix gc. Reclaiming unused disk space.
67* guix pull: (guix)Invoking guix pull. Update the list of available packages.
68* guix system: (guix)Invoking guix system. Manage the operating system configuration.
568717fd 69@end direntry
568717fd 70
372c4bbc
DT
71@dircategory Software development
72@direntry
abd67856 73* guix environment: (guix)Invoking guix environment. Building development environments with Guix.
ad172c4a
LC
74* guix build: (guix)Invoking guix build. Building packages.
75* guix pack: (guix)Invoking guix pack. Creating binary bundles.
372c4bbc
DT
76@end direntry
77
568717fd 78@titlepage
7730d112
LC
79@title GNU Guix Reference Manual
80@subtitle Using the GNU Guix Functional Package Manager
2cbed07e 81@author The GNU Guix Developers
568717fd
LC
82
83@page
84@vskip 0pt plus 1filll
85Edition @value{EDITION} @*
86@value{UPDATED} @*
87
7df7a74e 88@insertcopying
568717fd
LC
89@end titlepage
90
568717fd
LC
91@contents
92
93@c *********************************************************************
94@node Top
f8348b91 95@top GNU Guix
568717fd 96
f8348b91
LC
97This document describes GNU Guix version @value{VERSION}, a functional
98package management tool written for the GNU system.
568717fd 99
56b4dabc
LC
100@c TRANSLATORS: You can replace the following paragraph with information on
101@c how to join your own translation team and how to report issues with the
102@c translation.
103This manual is also available in French (@pxref{Top,,, guix.fr, Manuel de
104référence de GNU Guix}). If you would like to translate it in your native
105language, consider joining the
106@uref{https://translationproject.org/domain/guix-manual.html, Translation
107Project}.
108
568717fd
LC
109@menu
110* Introduction:: What is Guix about?
bd5e766b 111* Installation:: Installing Guix.
eeaf4427 112* Package Management:: Package installation, upgrade, etc.
568717fd
LC
113* Programming Interface:: Using Guix in Scheme.
114* Utilities:: Package management commands.
a1ba8475 115* GNU Distribution:: Software for your friendly GNU system.
9bf3c1a7 116* Contributing:: Your help needed!
568717fd
LC
117
118* Acknowledgments:: Thanks!
119* GNU Free Documentation License:: The license of this manual.
120* Concept Index:: Concepts.
a85b83d2 121* Programming Index:: Data types, functions, and variables.
aaa3eaa9
LC
122
123@detailmenu
124 --- The Detailed Node Listing ---
125
126Installation
127
1b2b8177 128* Binary Installation:: Getting Guix running in no time!
aaa3eaa9 129* Requirements:: Software needed to build and run Guix.
ec0339cd 130* Running the Test Suite:: Testing Guix.
aaa3eaa9
LC
131* Setting Up the Daemon:: Preparing the build daemon's environment.
132* Invoking guix-daemon:: Running the build daemon.
0e2d0213 133* Application Setup:: Application-specific setup.
aaa3eaa9
LC
134
135Setting Up the Daemon
136
137* Build Environment Setup:: Preparing the isolated build environment.
138* Daemon Offload Setup:: Offloading builds to remote machines.
b617a9fe 139* SELinux Support:: Using an SELinux policy for the daemon.
aaa3eaa9
LC
140
141Package Management
142
143* Features:: How Guix will make your life brighter.
144* Invoking guix package:: Package installation, removal, etc.
aaa3eaa9
LC
145* Substitutes:: Downloading pre-built binaries.
146* Packages with Multiple Outputs:: Single source package, multiple outputs.
147* Invoking guix gc:: Running the garbage collector.
148* Invoking guix pull:: Fetching the latest Guix and distribution.
239c2266 149* Invoking guix pack:: Creating software bundles.
aaa3eaa9
LC
150* Invoking guix archive:: Exporting and importing store files.
151
77f92158
CM
152Substitutes
153
154* Official Substitute Server:: One particular source of substitutes.
155* Substitute Server Authorization:: How to enable or disable substitutes.
156* Substitute Authentication:: How Guix verifies substitutes.
157* Proxy Settings:: How to get substitutes via proxy.
158* Substitution Failure:: What happens when substitution fails.
159* On Trusting Binaries:: How can you trust that binary blob?
160
aaa3eaa9
LC
161Programming Interface
162
163* Defining Packages:: Defining new packages.
164* Build Systems:: Specifying how packages are built.
165* The Store:: Manipulating the package store.
166* Derivations:: Low-level interface to package derivations.
167* The Store Monad:: Purely functional interface to the store.
168* G-Expressions:: Manipulating build expressions.
2ca299ca 169* Invoking guix repl:: Fiddling with Guix interactively.
aaa3eaa9 170
92492b23
LC
171Defining Packages
172
fa4ebd2f 173* package Reference:: The package data type.
92492b23
LC
174* origin Reference:: The origin data type.
175
aaa3eaa9
LC
176Utilities
177
178* Invoking guix build:: Building packages from the command line.
fcc58db6 179* Invoking guix edit:: Editing package definitions.
aaa3eaa9
LC
180* Invoking guix download:: Downloading a file and printing its hash.
181* Invoking guix hash:: Computing the cryptographic hash of a file.
182* Invoking guix import:: Importing package definitions.
183* Invoking guix refresh:: Updating package definitions.
184* Invoking guix lint:: Finding errors in package definitions.
fcc58db6 185* Invoking guix size:: Profiling disk usage.
88856916 186* Invoking guix graph:: Visualizing the graph of packages.
aaa3eaa9 187* Invoking guix environment:: Setting up development environments.
aff8ce7c 188* Invoking guix publish:: Sharing substitutes.
d23c20f1 189* Invoking guix challenge:: Challenging substitute servers.
f11c444d 190* Invoking guix copy:: Copying to and from a remote store.
32efa254 191* Invoking guix container:: Process isolation.
585347d7 192* Invoking guix weather:: Assessing substitute availability.
aaa3eaa9 193
e3009f60
LC
194Invoking @command{guix build}
195
196* Common Build Options:: Build options for most commands.
f11c444d 197* Package Transformation Options:: Creating variants of packages.
e3009f60 198* Additional Build Options:: Options specific to 'guix build'.
10f4353d 199* Debugging Build Failures:: Real life packaging experience.
e3009f60 200
aaa3eaa9
LC
201GNU Distribution
202
203* System Installation:: Installing the whole operating system.
35ed9306 204* System Configuration:: Configuring the operating system.
31f1f593 205* Documentation:: Browsing software user manuals.
aaa3eaa9
LC
206* Installing Debugging Files:: Feeding the debugger.
207* Security Updates:: Deploying security fixes quickly.
208* Package Modules:: Packages from the programmer's viewpoint.
209* Packaging Guidelines:: Growing the distribution.
210* Bootstrapping:: GNU/Linux built from scratch.
211* Porting:: Targeting another platform or kernel.
212
e3009f60
LC
213System Installation
214
215* Limitations:: What you can expect.
216* Hardware Considerations:: Supported hardware.
2626062b 217* USB Stick and DVD Installation:: Preparing the installation medium.
e3009f60
LC
218* Preparing for Installation:: Networking, partitioning, etc.
219* Proceeding with the Installation:: The real thing.
c8b54374 220* Installing GuixSD in a VM:: GuixSD playground.
e3009f60
LC
221* Building the Installation Image:: How this comes to be.
222
aaa3eaa9
LC
223System Configuration
224
225* Using the Configuration System:: Customizing your GNU system.
226* operating-system Reference:: Detail of operating-system declarations.
227* File Systems:: Configuring file system mounts.
228* Mapped Devices:: Block device extra processing.
229* User Accounts:: Specifying user accounts.
598e19dc 230* Locales:: Language and cultural convention settings.
aaa3eaa9
LC
231* Services:: Specifying system services.
232* Setuid Programs:: Programs running with root privileges.
1b2b8177 233* X.509 Certificates:: Authenticating HTTPS servers.
996ed739 234* Name Service Switch:: Configuring libc's name service switch.
aaa3eaa9 235* Initial RAM Disk:: Linux-Libre bootstrapping.
74e64724 236* Bootloader Configuration:: Configuring the boot loader.
aaa3eaa9 237* Invoking guix system:: Instantiating a system configuration.
97d76250 238* Running GuixSD in a VM:: How to run GuixSD in a virtual machine.
aaa3eaa9
LC
239* Defining Services:: Adding new service definitions.
240
241Services
242
243* Base Services:: Essential system services.
c311089b 244* Scheduled Job Execution:: The mcron service.
92c03a87 245* Log Rotation:: The rottlog service.
aaa3eaa9
LC
246* Networking Services:: Network setup, SSH daemon, etc.
247* X Window:: Graphical display.
f11c444d 248* Printing Services:: Local and remote printer support.
1b2b8177 249* Desktop Services:: D-Bus and desktop services.
8cd1e8e8 250* Sound Services:: ALSA and Pulseaudio services.
29059262 251* Database Services:: SQL databases, key-value stores, etc.
d8c18af8 252* Mail Services:: IMAP, POP3, SMTP, and all that.
78cef99b 253* Messaging Services:: Messaging services.
b6d2930d 254* Telephony Services:: Telephony services.
730ed6ec 255* Monitoring Services:: Monitoring services.
859e367d 256* Kerberos Services:: Kerberos services.
cbd02397 257* Web Services:: Web servers.
1115f140 258* Certificate Services:: TLS certificates via Let's Encrypt.
ba69e8f7 259* DNS Services:: DNS daemons.
2be1b471 260* VPN Services:: VPN daemons.
eb419bc9 261* Network File System:: NFS related services.
f11c444d 262* Continuous Integration:: The Cuirass service.
69390e29 263* Power Management Services:: Extending battery life.
06465d2b 264* Audio Services:: The MPD.
e6051057 265* Virtualization Services:: Virtualization services.
05f1cb3c 266* Version Control Services:: Providing remote access to Git repositories.
a76acfd3 267* Game Services:: Game servers.
dbc6d370 268* Miscellaneous Services:: Other services.
aaa3eaa9 269
0adfe95a
LC
270Defining Services
271
272* Service Composition:: The model for composing services.
273* Service Types and Services:: Types and services.
274* Service Reference:: API reference.
dd17bc38 275* Shepherd Services:: A particular type of service.
0adfe95a 276
aaa3eaa9
LC
277Packaging Guidelines
278
ec0339cd
LC
279* Software Freedom:: What may go into the distribution.
280* Package Naming:: What's in a name?
281* Version Numbers:: When the name is not enough.
cbd02397 282* Synopses and Descriptions:: Helping users find the right package.
fb4d6f6c 283* Python Modules:: A touch of British comedy.
ec0339cd 284* Perl Modules:: Little pearls.
e1c963bf 285* Java Packages:: Coffee break.
ec0339cd 286* Fonts:: Fond of fonts.
aaa3eaa9 287
8c01b9d0
ML
288Contributing
289
290* Building from Git:: The latest and greatest.
291* Running Guix Before It Is Installed:: Hacker tricks.
292* The Perfect Setup:: The right tools.
293* Coding Style:: Hygiene of the contributor.
294* Submitting Patches:: Share your work.
295
296Coding Style
297
298* Programming Paradigm:: How to compose your elements.
299* Modules:: Where to store your code?
300* Data Types and Pattern Matching:: Implementing data structures.
301* Formatting Code:: Writing conventions.
302
aaa3eaa9 303@end detailmenu
568717fd
LC
304@end menu
305
306@c *********************************************************************
307@node Introduction
308@chapter Introduction
309
6f773606 310@cindex purpose
c80e7e55 311GNU Guix@footnote{``Guix'' is pronounced like ``geeks'', or ``ɡiːks''
6f773606
LC
312using the international phonetic alphabet (IPA).} is a package
313management tool for the GNU system. Guix makes it easy for unprivileged
314users to install, upgrade, or remove packages, to roll back to a
315previous package set, to build packages from source, and generally
316assists with the creation and maintenance of software environments.
317
318@cindex user interfaces
319Guix provides a command-line package management interface
320(@pxref{Invoking guix package}), a set of command-line utilities
deb6276d 321(@pxref{Utilities}), as well as Scheme programming interfaces
6f773606
LC
322(@pxref{Programming Interface}).
323@cindex build daemon
324Its @dfn{build daemon} is responsible for building packages on behalf of
325users (@pxref{Setting Up the Daemon}) and for downloading pre-built
326binaries from authorized sources (@pxref{Substitutes}).
327
328@cindex extensibility of the distribution
e32171ee 329@cindex customization, of packages
6f773606
LC
330Guix includes package definitions for many GNU and non-GNU packages, all
331of which @uref{https://www.gnu.org/philosophy/free-sw.html, respect the
332user's computing freedom}. It is @emph{extensible}: users can write
333their own package definitions (@pxref{Defining Packages}) and make them
334available as independent package modules (@pxref{Package Modules}). It
335is also @emph{customizable}: users can @emph{derive} specialized package
336definitions from existing ones, including from the command line
337(@pxref{Package Transformation Options}).
338
339@cindex Guix System Distribution
340@cindex GuixSD
341You can install GNU@tie{}Guix on top of an existing GNU/Linux system
342where it complements the available tools without interference
343(@pxref{Installation}), or you can use it as part of the standalone
344@dfn{Guix System Distribution} or GuixSD (@pxref{GNU Distribution}).
345With GNU@tie{}GuixSD, you @emph{declare} all aspects of the operating
346system configuration and Guix takes care of instantiating the
347configuration in a transactional, reproducible, and stateless fashion
348(@pxref{System Configuration}).
568717fd
LC
349
350@cindex functional package management
6f773606 351Under the hood, Guix implements the @dfn{functional package management}
136787cb
LC
352discipline pioneered by Nix (@pxref{Acknowledgments}).
353In Guix, the package build and installation process is seen
6f773606 354as a @emph{function}, in the mathematical sense. That function takes inputs,
4bfc4ea3
NK
355such as build scripts, a compiler, and libraries, and
356returns an installed package. As a pure function, its result depends
568717fd
LC
357solely on its inputs---for instance, it cannot refer to software or
358scripts that were not explicitly passed as inputs. A build function
4bfc4ea3 359always produces the same result when passed a given set of inputs. It
f97c9175 360cannot alter the environment of the running system in
568717fd
LC
361any way; for instance, it cannot create, modify, or delete files outside
362of its build and installation directories. This is achieved by running
e900c503 363build processes in isolated environments (or @dfn{containers}), where only their
4bfc4ea3 364explicit inputs are visible.
568717fd 365
e531ac2a 366@cindex store
568717fd 367The result of package build functions is @dfn{cached} in the file
e531ac2a 368system, in a special directory called @dfn{the store} (@pxref{The
f97c9175 369Store}). Each package is installed in a directory of its own in the
834129e0 370store---by default under @file{/gnu/store}. The directory name contains
568717fd
LC
371a hash of all the inputs used to build that package; thus, changing an
372input yields a different directory name.
373
f97c9175
AE
374This approach is the foundation for the salient features of Guix: support
375for transactional package upgrade and rollback, per-user installation, and
eeaf4427 376garbage collection of packages (@pxref{Features}).
568717fd 377
a1ba8475 378
bd5e766b
LC
379@c *********************************************************************
380@node Installation
381@chapter Installation
382
e32171ee 383@cindex installing Guix
48febeb8
LC
384GNU Guix is available for download from its website at
385@url{http://www.gnu.org/software/guix/}. This section describes the
386software requirements of Guix, as well as how to install it and get
387ready to use it.
bd5e766b 388
5af6de3e
LC
389Note that this section is concerned with the installation of the package
390manager, which can be done on top of a running GNU/Linux system. If,
391instead, you want to install the complete GNU operating system,
6621cdb6 392@pxref{System Installation}.
5af6de3e 393
d23ef788
LC
394@cindex foreign distro
395When installed on a running GNU/Linux system---thereafter called a
396@dfn{foreign distro}---GNU@tie{}Guix complements the available tools
397without interference. Its data lives exclusively in two directories,
398usually @file{/gnu/store} and @file{/var/guix}; other files on your
399system, such as @file{/etc}, are left untouched.
400
7fcf2a0b
LC
401Once installed, Guix can be updated by running @command{guix pull}
402(@pxref{Invoking guix pull}).
403
bd5e766b 404@menu
09722b11 405* Binary Installation:: Getting Guix running in no time!
bd5e766b 406* Requirements:: Software needed to build and run Guix.
ec0339cd 407* Running the Test Suite:: Testing Guix.
bd5e766b
LC
408* Setting Up the Daemon:: Preparing the build daemon's environment.
409* Invoking guix-daemon:: Running the build daemon.
0e2d0213 410* Application Setup:: Application-specific setup.
bd5e766b
LC
411@end menu
412
09722b11
LC
413@node Binary Installation
414@section Binary Installation
415
e32171ee 416@cindex installing Guix from binaries
09722b11
LC
417This section describes how to install Guix on an arbitrary system from a
418self-contained tarball providing binaries for Guix and for all its
419dependencies. This is often quicker than installing from source, which
420is described in the next sections. The only requirement is to have
421GNU@tie{}tar and Xz.
422
6f4e8693
RW
423We provide a
424@uref{https://git.savannah.gnu.org/cgit/guix.git/plain/etc/guix-install.sh,
425shell installer script}, which automates the download, installation, and
426initial configuration of Guix. It should be run as the root user.
427
09722b11
LC
428Installing goes along these lines:
429
430@enumerate
431@item
e32171ee 432@cindex downloading Guix binary
09722b11 433Download the binary tarball from
af7914a1 434@indicateurl{https://alpha.gnu.org/gnu/guix/guix-binary-@value{VERSION}.@var{system}.tar.xz},
daa8922a
LC
435where @var{system} is @code{x86_64-linux} for an @code{x86_64} machine
436already running the kernel Linux, and so on.
437
debc6360 438@c The following is somewhat duplicated in ``System Installation''.
daa8922a
LC
439Make sure to download the associated @file{.sig} file and to verify the
440authenticity of the tarball against it, along these lines:
441
442@example
af7914a1 443$ wget https://alpha.gnu.org/gnu/guix/guix-binary-@value{VERSION}.@var{system}.tar.xz.sig
daa8922a
LC
444$ gpg --verify guix-binary-@value{VERSION}.@var{system}.tar.xz.sig
445@end example
446
f97c9175 447If that command fails because you do not have the required public key,
daa8922a
LC
448then run this command to import it:
449
450@example
debc6360 451$ gpg --keyserver pgp.mit.edu --recv-keys @value{OPENPGP-SIGNING-KEY-ID}
daa8922a
LC
452@end example
453
454@noindent
455and rerun the @code{gpg --verify} command.
debc6360 456@c end authentication part
09722b11
LC
457
458@item
1f3921e1
JL
459Now, you need to become the @code{root} user. Depending on your distribution,
460you may have to run @code{su -} or @code{sudo -i}. As @code{root}, run:
09722b11
LC
461
462@example
5dc42964 463# cd /tmp
254b1c2e
LC
464# tar --warning=no-timestamp -xf \
465 guix-binary-@value{VERSION}.@var{system}.tar.xz
5dc42964 466# mv var/guix /var/ && mv gnu /
09722b11
LC
467@end example
468
7acd3439
LC
469This creates @file{/gnu/store} (@pxref{The Store}) and @file{/var/guix}.
470The latter contains a ready-to-use profile for @code{root} (see next
471step.)
09722b11 472
5dc3ce5f
LC
473Do @emph{not} unpack the tarball on a working Guix system since that
474would overwrite its own essential files.
475
254b1c2e 476The @code{--warning=no-timestamp} option makes sure GNU@tie{}tar does
e9ba6357
LC
477not emit warnings about ``implausibly old time stamps'' (such
478warnings were triggered by GNU@tie{}tar 1.26 and older; recent
479versions are fine.)
480They stem from the fact that all the
254b1c2e
LC
481files in the archive have their modification time set to zero (which
482means January 1st, 1970.) This is done on purpose to make sure the
483archive content is independent of its creation time, thus making it
484reproducible.
485
7acd3439 486@item
3cd4447f 487Make @code{root}'s profile available under @file{~root/.guix-profile}:
7acd3439
LC
488
489@example
490# ln -sf /var/guix/profiles/per-user/root/guix-profile \
491 ~root/.guix-profile
492@end example
493
1165b08f
LC
494Source @file{etc/profile} to augment @code{PATH} and other relevant
495environment variables:
496
497@example
3cd4447f 498# GUIX_PROFILE="`echo ~root`/.guix-profile" ; \
1165b08f
LC
499 source $GUIX_PROFILE/etc/profile
500@end example
501
43c33047
LC
502@item
503Create the group and user accounts for build users as explained below
504(@pxref{Build Environment Setup}).
505
09722b11 506@item
bf98aea9 507Run the daemon, and set it to automatically start on boot.
c8e26887 508
bf98aea9
LC
509If your host distro uses the systemd init system, this can be achieved
510with these commands:
c8e26887 511
b812da70
LF
512@c Versions of systemd that supported symlinked service files are not
513@c yet widely deployed, so we should suggest that users copy the service
514@c files into place.
515@c
516@c See this thread for more information:
517@c http://lists.gnu.org/archive/html/guix-devel/2017-01/msg01199.html
518
c8e26887 519@example
b812da70 520# cp ~root/.guix-profile/lib/systemd/system/guix-daemon.service \
c8e26887
GC
521 /etc/systemd/system/
522# systemctl start guix-daemon && systemctl enable guix-daemon
523@end example
524
525If your host distro uses the Upstart init system:
09722b11
LC
526
527@example
4a780bdf 528# initctl reload-configuration
b812da70 529# cp ~root/.guix-profile/lib/upstart/system/guix-daemon.conf /etc/init/
bf98aea9 530# start guix-daemon
09722b11
LC
531@end example
532
c8e26887
GC
533Otherwise, you can still start the daemon manually with:
534
535@example
536# ~root/.guix-profile/bin/guix-daemon --build-users-group=guixbuild
537@end example
d2825c96 538
09722b11
LC
539@item
540Make the @command{guix} command available to other users on the machine,
541for instance with:
542
543@example
544# mkdir -p /usr/local/bin
545# cd /usr/local/bin
d72d05f9 546# ln -s /var/guix/profiles/per-user/root/guix-profile/bin/guix
09722b11 547@end example
39f8ed14 548
aca738f3
LC
549It is also a good idea to make the Info version of this manual available
550there:
551
552@example
553# mkdir -p /usr/local/share/info
554# cd /usr/local/share/info
555# for i in /var/guix/profiles/per-user/root/guix-profile/share/info/* ;
556 do ln -s $i ; done
557@end example
558
559That way, assuming @file{/usr/local/share/info} is in the search path,
560running @command{info guix} will open this manual (@pxref{Other Info
561Directories,,, texinfo, GNU Texinfo}, for more details on changing the
562Info search path.)
563
39f8ed14 564@item
e32171ee 565@cindex substitutes, authorization thereof
df061d07
LC
566To use substitutes from @code{hydra.gnu.org} or one of its mirrors
567(@pxref{Substitutes}), authorize them:
39f8ed14
LC
568
569@example
7acd3439 570# guix archive --authorize < ~root/.guix-profile/share/guix/hydra.gnu.org.pub
39f8ed14 571@end example
7f608a9b
LC
572
573@item
574Each user may need to perform a few additional steps to make their Guix
575environment ready for use, @pxref{Application Setup}.
09722b11
LC
576@end enumerate
577
7f608a9b 578Voilà, the installation is complete!
09722b11 579
c8e26887
GC
580You can confirm that Guix is working by installing a sample package into
581the root profile:
09722b11
LC
582
583@example
c8e26887 584# guix package -i hello
09722b11
LC
585@end example
586
c8e26887
GC
587The @code{guix} package must remain available in @code{root}'s profile,
588or it would become subject to garbage collection---in which case you
589would find yourself badly handicapped by the lack of the @command{guix}
bf98aea9
LC
590command. In other words, do not remove @code{guix} by running
591@code{guix package -r guix}.
592
593The binary installation tarball can be (re)produced and verified simply
594by running the following command in the Guix source tree:
595
596@example
597make guix-binary.@var{system}.tar.xz
598@end example
c8e26887 599
239c2266
LC
600@noindent
601... which, in turn, runs:
602
603@example
6b63c43e 604guix pack -s @var{system} --localstatedir guix
239c2266
LC
605@end example
606
607@xref{Invoking guix pack}, for more info on this handy tool.
09722b11 608
bd5e766b
LC
609@node Requirements
610@section Requirements
611
09722b11
LC
612This section lists requirements when building Guix from source. The
613build procedure for Guix is the same as for other GNU software, and is
614not covered here. Please see the files @file{README} and @file{INSTALL}
615in the Guix source tree for additional details.
616
bd5e766b
LC
617GNU Guix depends on the following packages:
618
619@itemize
1d84d7bf 620@item @url{http://gnu.org/software/guile/, GNU Guile}, version 2.0.13 or
608e42e7 621later, including 2.2.x;
288dca55 622@item @url{http://gnupg.org/, GNU libgcrypt};
1dbe3a8d
LC
623@item
624@uref{http://gnutls.org/, GnuTLS}, specifically its Guile bindings
625(@pxref{Guile Preparations, how to install the GnuTLS bindings for
626Guile,, gnutls-guile, GnuTLS-Guile});
7441f1db 627@item
fc6cbb31
LC
628@uref{https://notabug.org/civodul/guile-sqlite3, Guile-SQLite3}, version 0.1.0
629or later;
c5a2e1ff
LC
630@item
631@c FIXME: Specify a version number once a release has been made.
7441f1db
LC
632@uref{https://gitlab.com/guile-git/guile-git, Guile-Git}, from August
6332017 or later;
06e3a518 634@item @url{http://zlib.net, zlib};
f0b98b84 635@item @url{http://www.gnu.org/software/make/, GNU Make}.
8a96bd4b
ID
636@end itemize
637
638The following dependencies are optional:
639
640@itemize
288dca55 641@item
8a96bd4b 642Installing
288dca55 643@url{http://savannah.nongnu.org/projects/guile-json/, Guile-JSON} will
2f7d2d91
LC
644allow you to use the @command{guix import pypi} command (@pxref{Invoking
645guix import}). It is of
288dca55 646interest primarily for developers and not for casual users.
4591c02e 647
21531add
LC
648@item
649@c Note: We need at least 0.10.2 for 'channel-send-eof'.
f11c444d
LC
650Support for build offloading (@pxref{Daemon Offload Setup}) and
651@command{guix copy} (@pxref{Invoking guix copy}) depends on
21531add
LC
652@uref{https://github.com/artyom-poptsov/guile-ssh, Guile-SSH},
653version 0.10.2 or later.
654
4591c02e 655@item
06e3a518
LC
656When @url{http://www.bzip.org, libbz2} is available,
657@command{guix-daemon} can use it to compress build logs.
bd5e766b
LC
658@end itemize
659
660Unless @code{--disable-daemon} was passed to @command{configure}, the
661following packages are also needed:
662
663@itemize
368d08f7 664@item @url{http://sqlite.org, SQLite 3};
368d08f7
LC
665@item @url{http://gcc.gnu.org, GCC's g++}, with support for the
666C++11 standard.
bd5e766b
LC
667@end itemize
668
e32171ee 669@cindex state directory
ef5f5c86
LC
670When configuring Guix on a system that already has a Guix installation,
671be sure to specify the same state directory as the existing installation
672using the @code{--localstatedir} option of the @command{configure}
673script (@pxref{Directory Variables, @code{localstatedir},, standards,
674GNU Coding Standards}). The @command{configure} script protects against
675unintended misconfiguration of @var{localstatedir} so you do not
676inadvertently corrupt your store (@pxref{The Store}).
677
e32171ee 678@cindex Nix, compatibility
4bfc4ea3
NK
679When a working installation of @url{http://nixos.org/nix/, the Nix package
680manager} is available, you
bd5e766b 681can instead configure Guix with @code{--disable-daemon}. In that case,
4bfc4ea3 682Nix replaces the three dependencies above.
bd5e766b 683
b22a12fd
LC
684Guix is compatible with Nix, so it is possible to share the same store
685between both. To do so, you must pass @command{configure} not only the
686same @code{--with-store-dir} value, but also the same
4bfc4ea3
NK
687@code{--localstatedir} value. The latter is essential because it
688specifies where the database that stores metadata about the store is
834129e0 689located, among other things. The default values for Nix are
b22a12fd 690@code{--with-store-dir=/nix/store} and @code{--localstatedir=/nix/var}.
4bfc4ea3
NK
691Note that @code{--disable-daemon} is not required if
692your goal is to share the store with Nix.
b22a12fd 693
ec0339cd
LC
694@node Running the Test Suite
695@section Running the Test Suite
696
e32171ee 697@cindex test suite
ec0339cd
LC
698After a successful @command{configure} and @code{make} run, it is a good
699idea to run the test suite. It can help catch issues with the setup or
700environment, or bugs in Guix itself---and really, reporting test
701failures is a good way to help improve the software. To run the test
702suite, type:
703
704@example
705make check
706@end example
707
708Test cases can run in parallel: you can use the @code{-j} option of
709GNU@tie{}make to speed things up. The first run may take a few minutes
710on a recent machine; subsequent runs will be faster because the store
711that is created for test purposes will already have various things in
712cache.
713
a887fd8d
LC
714It is also possible to run a subset of the tests by defining the
715@code{TESTS} makefile variable as in this example:
716
717@example
718make check TESTS="tests/store.scm tests/cpio.scm"
719@end example
720
a9edb211
ML
721By default, tests results are displayed at a file level. In order to
722see the details of every individual test cases, it is possible to define
723the @code{SCM_LOG_DRIVER_FLAGS} makefile variable as in this example:
724
725@example
726make check TESTS="tests/base64.scm" SCM_LOG_DRIVER_FLAGS="--brief=no"
727@end example
728
ec0339cd 729Upon failure, please email @email{bug-guix@@gnu.org} and attach the
a9edb211
ML
730@file{test-suite.log} file. Please specify the Guix version being used
731as well as version numbers of the dependencies (@pxref{Requirements}) in
732your message.
ec0339cd 733
0a2f2848
LC
734Guix also comes with a whole-system test suite that tests complete
735GuixSD operating system instances. It can only run on systems where
736Guix is already installed, using:
737
738@example
739make check-system
740@end example
741
742@noindent
743or, again, by defining @code{TESTS} to select a subset of tests to run:
744
745@example
746make check-system TESTS="basic mcron"
747@end example
748
749These system tests are defined in the @code{(gnu tests @dots{})}
750modules. They work by running the operating systems under test with
751lightweight instrumentation in a virtual machine (VM). They can be
752computationally intensive or rather cheap, depending on whether
753substitutes are available for their dependencies (@pxref{Substitutes}).
754Some of them require a lot of storage space to hold VM images.
755
756Again in case of test failures, please send @email{bug-guix@@gnu.org}
757all the details.
758
bd5e766b
LC
759@node Setting Up the Daemon
760@section Setting Up the Daemon
761
762@cindex daemon
763Operations such as building a package or running the garbage collector
49e6291a 764are all performed by a specialized process, the @dfn{build daemon}, on
bd5e766b
LC
765behalf of clients. Only the daemon may access the store and its
766associated database. Thus, any operation that manipulates the store
767goes through the daemon. For instance, command-line tools such as
e49951eb 768@command{guix package} and @command{guix build} communicate with the
bd5e766b
LC
769daemon (@i{via} remote procedure calls) to instruct it what to do.
770
49e6291a 771The following sections explain how to prepare the build daemon's
f97c9175 772environment. See also @ref{Substitutes}, for information on how to allow
225dafde 773the daemon to download pre-built binaries.
49e6291a
LC
774
775@menu
776* Build Environment Setup:: Preparing the isolated build environment.
777* Daemon Offload Setup:: Offloading builds to remote machines.
b617a9fe 778* SELinux Support:: Using an SELinux policy for the daemon.
49e6291a
LC
779@end menu
780
781@node Build Environment Setup
782@subsection Build Environment Setup
783
e32171ee 784@cindex build environment
bd5e766b
LC
785In a standard multi-user setup, Guix and its daemon---the
786@command{guix-daemon} program---are installed by the system
834129e0 787administrator; @file{/gnu/store} is owned by @code{root} and
bd5e766b
LC
788@command{guix-daemon} runs as @code{root}. Unprivileged users may use
789Guix tools to build packages or otherwise access the store, and the
790daemon will do it on their behalf, ensuring that the store is kept in a
791consistent state, and allowing built packages to be shared among users.
792
793@cindex build users
794When @command{guix-daemon} runs as @code{root}, you may not want package
795build processes themselves to run as @code{root} too, for obvious
796security reasons. To avoid that, a special pool of @dfn{build users}
797should be created for use by build processes started by the daemon.
798These build users need not have a shell and a home directory: they will
799just be used when the daemon drops @code{root} privileges in build
800processes. Having several such users allows the daemon to launch
801distinct build processes under separate UIDs, which guarantees that they
802do not interfere with each other---an essential feature since builds are
803regarded as pure functions (@pxref{Introduction}).
804
805On a GNU/Linux system, a build user pool may be created like this (using
806Bash syntax and the @code{shadow} commands):
807
091196b3
LC
808@c See http://lists.gnu.org/archive/html/bug-guix/2013-01/msg00239.html
809@c for why `-G' is needed.
bd5e766b 810@example
cfc149dc
LC
811# groupadd --system guixbuild
812# for i in `seq -w 1 10`;
bd5e766b 813 do
cfc149dc
LC
814 useradd -g guixbuild -G guixbuild \
815 -d /var/empty -s `which nologin` \
816 -c "Guix build user $i" --system \
817 guixbuilder$i;
bd5e766b
LC
818 done
819@end example
820
821@noindent
54eb03ab
LC
822The number of build users determines how many build jobs may run in
823parallel, as specified by the @option{--max-jobs} option
eca69fc0
LC
824(@pxref{Invoking guix-daemon, @option{--max-jobs}}). To use
825@command{guix system vm} and related commands, you may need to add the
826build users to the @code{kvm} group so they can access @file{/dev/kvm},
827using @code{-G guixbuild,kvm} instead of @code{-G guixbuild}
828(@pxref{Invoking guix system}).
829
830The @code{guix-daemon} program may then be run as @code{root} with the
d2825c96
LC
831following command@footnote{If your machine uses the systemd init system,
832dropping the @file{@var{prefix}/lib/systemd/system/guix-daemon.service}
833file in @file{/etc/systemd/system} will ensure that
ad227484
MDRS
834@command{guix-daemon} is automatically started. Similarly, if your
835machine uses the Upstart init system, drop the
836@file{@var{prefix}/lib/upstart/system/guix-daemon.conf}
837file in @file{/etc/init}.}:
bd5e766b
LC
838
839@example
cfc149dc 840# guix-daemon --build-users-group=guixbuild
bd5e766b
LC
841@end example
842
e900c503 843@cindex chroot
b095792f
LC
844@noindent
845This way, the daemon starts build processes in a chroot, under one of
cfc149dc 846the @code{guixbuilder} users. On GNU/Linux, by default, the chroot
6dc99317
LC
847environment contains nothing but:
848
849@c Keep this list in sync with libstore/build.cc! -----------------------
850@itemize
851@item
4743a4da
LC
852a minimal @code{/dev} directory, created mostly independently from the
853host @code{/dev}@footnote{``Mostly'', because while the set of files
854that appear in the chroot's @code{/dev} is fixed, most of these files
855can only be created if the host has them.};
856
857@item
f97c9175 858the @code{/proc} directory; it only shows the processes of the container
4743a4da 859since a separate PID name space is used;
6dc99317
LC
860
861@item
862@file{/etc/passwd} with an entry for the current user and an entry for
863user @file{nobody};
864
865@item
866@file{/etc/group} with an entry for the user's group;
867
868@item
869@file{/etc/hosts} with an entry that maps @code{localhost} to
870@code{127.0.0.1};
871
872@item
873a writable @file{/tmp} directory.
874@end itemize
b095792f 875
cb960102
ED
876You can influence the directory where the daemon stores build trees
877@i{via} the @code{TMPDIR} environment variable. However, the build tree
f97c9175 878within the chroot is always called @file{/tmp/guix-build-@var{name}.drv-0},
cb960102
ED
879where @var{name} is the derivation name---e.g., @code{coreutils-8.24}.
880This way, the value of @code{TMPDIR} does not leak inside build
881environments, which avoids discrepancies in cases where build processes
882capture the name of their build tree.
883
e0c941fe
LC
884@vindex http_proxy
885The daemon also honors the @code{http_proxy} environment variable for
886HTTP downloads it performs, be it for fixed-output derivations
887(@pxref{Derivations}) or for substitutes (@pxref{Substitutes}).
888
1e2644bb
LC
889If you are installing Guix as an unprivileged user, it is still possible
890to run @command{guix-daemon} provided you pass @code{--disable-chroot}.
891However, build processes will not be isolated from one another, and not
892from the rest of the system. Thus, build processes may interfere with
893each other, and may access programs, libraries, and other files
894available on the system---making it much harder to view them as
895@emph{pure} functions.
bd5e766b 896
49e6291a
LC
897
898@node Daemon Offload Setup
899@subsection Using the Offload Facility
900
901@cindex offloading
4ec2e92d 902@cindex build hook
21531add
LC
903When desired, the build daemon can @dfn{offload} derivation builds to
904other machines running Guix, using the @code{offload} @dfn{build
905hook}@footnote{This feature is available only when
906@uref{https://github.com/artyom-poptsov/guile-ssh, Guile-SSH} is
907present.}. When that
49e6291a 908feature is enabled, a list of user-specified build machines is read from
f97c9175 909@file{/etc/guix/machines.scm}; every time a build is requested, for
49e6291a 910instance via @code{guix build}, the daemon attempts to offload it to one
f97c9175 911of the machines that satisfy the constraints of the derivation, in
49e6291a
LC
912particular its system type---e.g., @file{x86_64-linux}. Missing
913prerequisites for the build are copied over SSH to the target machine,
914which then proceeds with the build; upon success the output(s) of the
915build are copied back to the initial machine.
916
4ec2e92d 917The @file{/etc/guix/machines.scm} file typically looks like this:
49e6291a
LC
918
919@example
920(list (build-machine
921 (name "eightysix.example.org")
922 (system "x86_64-linux")
21531add 923 (host-key "ssh-ed25519 AAAAC3Nza@dots{}")
49e6291a 924 (user "bob")
21531add 925 (speed 2.)) ;incredibly fast!
49e6291a
LC
926
927 (build-machine
928 (name "meeps.example.org")
929 (system "mips64el-linux")
21531add 930 (host-key "ssh-rsa AAAAB3Nza@dots{}")
49e6291a
LC
931 (user "alice")
932 (private-key
933 (string-append (getenv "HOME")
21531add 934 "/.ssh/identity-for-guix"))))
49e6291a
LC
935@end example
936
937@noindent
938In the example above we specify a list of two build machines, one for
939the @code{x86_64} architecture and one for the @code{mips64el}
4ec2e92d
LC
940architecture.
941
942In fact, this file is---not surprisingly!---a Scheme file that is
943evaluated when the @code{offload} hook is started. Its return value
944must be a list of @code{build-machine} objects. While this example
945shows a fixed list of build machines, one could imagine, say, using
946DNS-SD to return a list of potential build machines discovered in the
947local network (@pxref{Introduction, Guile-Avahi,, guile-avahi, Using
c678a4ee
LC
948Avahi in Guile Scheme Programs}). The @code{build-machine} data type is
949detailed below.
4ec2e92d 950
c678a4ee 951@deftp {Data Type} build-machine
f97c9175
AE
952This data type represents build machines to which the daemon may offload
953builds. The important fields are:
49e6291a
LC
954
955@table @code
956
957@item name
f97c9175 958The host name of the remote machine.
49e6291a
LC
959
960@item system
f97c9175 961The system type of the remote machine---e.g., @code{"x86_64-linux"}.
49e6291a
LC
962
963@item user
964The user account to use when connecting to the remote machine over SSH.
965Note that the SSH key pair must @emph{not} be passphrase-protected, to
966allow non-interactive logins.
967
21531add
LC
968@item host-key
969This must be the machine's SSH @dfn{public host key} in OpenSSH format.
970This is used to authenticate the machine when we connect to it. It is a
971long string that looks like this:
972
973@example
974ssh-ed25519 AAAAC3NzaC@dots{}mde+UhL hint@@example.org
975@end example
976
977If the machine is running the OpenSSH daemon, @command{sshd}, the host
978key can be found in a file such as
979@file{/etc/ssh/ssh_host_ed25519_key.pub}.
980
981If the machine is running the SSH daemon of GNU@tie{}lsh,
982@command{lshd}, the host key is in @file{/etc/lsh/host-key.pub} or a
983similar file. It can be converted to the OpenSSH format using
984@command{lsh-export-key} (@pxref{Converting keys,,, lsh, LSH Manual}):
985
986@example
987$ lsh-export-key --openssh < /etc/lsh/host-key.pub
988ssh-rsa AAAAB3NzaC1yc2EAAAAEOp8FoQAAAQEAs1eB46LV@dots{}
989@end example
990
49e6291a
LC
991@end table
992
4ec2e92d 993A number of optional fields may be specified:
49e6291a 994
21531add 995@table @asis
49e6291a 996
21531add
LC
997@item @code{port} (default: @code{22})
998Port number of SSH server on the machine.
cecd72d5 999
dde1e152 1000@item @code{private-key} (default: @file{~root/.ssh/id_rsa})
21531add 1001The SSH private key file to use when connecting to the machine, in
a15e4b16 1002OpenSSH format. This key must not be protected with a passphrase.
49e6291a 1003
dde1e152
OP
1004Note that the default value is the private key @emph{of the root
1005account}. Make sure it exists if you use the default.
1006
1d48cf94
LC
1007@item @code{compression} (default: @code{"zlib@@openssh.com,zlib"})
1008@itemx @code{compression-level} (default: @code{3})
1009The SSH-level compression methods and compression level requested.
1010
1011Note that offloading relies on SSH compression to reduce bandwidth usage
1012when transferring files to and from build machines.
1013
cf283dd9
LC
1014@item @code{daemon-socket} (default: @code{"/var/guix/daemon-socket/socket"})
1015File name of the Unix-domain socket @command{guix-daemon} is listening
1016to on that machine.
c4fdfd6f 1017
21531add
LC
1018@item @code{parallel-builds} (default: @code{1})
1019The number of builds that may run in parallel on the machine.
49e6291a 1020
21531add 1021@item @code{speed} (default: @code{1.0})
49e6291a
LC
1022A ``relative speed factor''. The offload scheduler will tend to prefer
1023machines with a higher speed factor.
1024
21531add 1025@item @code{features} (default: @code{'()})
49e6291a
LC
1026A list of strings denoting specific features supported by the machine.
1027An example is @code{"kvm"} for machines that have the KVM Linux modules
1028and corresponding hardware support. Derivations can request features by
1029name, and they will be scheduled on matching build machines.
1030
1031@end table
c678a4ee 1032@end deftp
49e6291a 1033
aebaee95
LC
1034The @code{guile} command must be in the search path on the build
1035machines. In addition, the Guix modules must be in
c4fdfd6f
LC
1036@code{$GUILE_LOAD_PATH} on the build machine---you can check whether
1037this is the case by running:
1038
1039@example
21531add 1040ssh build-machine guile -c "'(use-modules (guix config))'"
c4fdfd6f 1041@end example
49e6291a 1042
f97c9175 1043There is one last thing to do once @file{machines.scm} is in place. As
49e6291a 1044explained above, when offloading, files are transferred back and forth
c4fdfd6f
LC
1045between the machine stores. For this to work, you first need to
1046generate a key pair on each machine to allow the daemon to export signed
1047archives of files from the store (@pxref{Invoking guix archive}):
49e6291a
LC
1048
1049@example
1050# guix archive --generate-key
1051@end example
1052
1053@noindent
c4fdfd6f
LC
1054Each build machine must authorize the key of the master machine so that
1055it accepts store items it receives from the master:
1056
1057@example
1058# guix archive --authorize < master-public-key.txt
1059@end example
1060
1061@noindent
1062Likewise, the master machine must authorize the key of each build machine.
1063
1064All the fuss with keys is here to express pairwise mutual trust
1065relations between the master and the build machines. Concretely, when
1066the master receives files from a build machine (and @i{vice versa}), its
1067build daemon can make sure they are genuine, have not been tampered
1068with, and that they are signed by an authorized key.
49e6291a 1069
aebaee95
LC
1070@cindex offload test
1071To test whether your setup is operational, run this command on the
1072master node:
1073
1074@example
1075# guix offload test
1076@end example
1077
1078This will attempt to connect to each of the build machines specified in
1079@file{/etc/guix/machines.scm}, make sure Guile and the Guix modules are
1080available on each machine, attempt to export to the machine and import
1081from it, and report any error in the process.
1082
1083If you want to test a different machine file, just specify it on the
1084command line:
1085
1086@example
1087# guix offload test machines-qualif.scm
1088@end example
1089
27991c97
LC
1090Last, you can test the subset of the machines whose name matches a
1091regular expression like this:
1092
1093@example
1094# guix offload test machines.scm '\.gnu\.org$'
1095@end example
49e6291a 1096
dafc3daf
RW
1097@cindex offload status
1098To display the current load of all build hosts, run this command on the
1099main node:
1100
1101@example
1102# guix offload status
1103@end example
1104
1105
b617a9fe
RW
1106@node SELinux Support
1107@subsection SELinux Support
1108
1109@cindex SELinux, daemon policy
1110@cindex mandatory access control, SELinux
1111@cindex security, guix-daemon
1112Guix includes an SELinux policy file at @file{etc/guix-daemon.cil} that
1113can be installed on a system where SELinux is enabled, in order to label
1114Guix files and to specify the expected behavior of the daemon. Since
1115GuixSD does not provide an SELinux base policy, the daemon policy cannot
1116be used on GuixSD.
1117
1118@subsubsection Installing the SELinux policy
1119@cindex SELinux, policy installation
1120To install the policy run this command as root:
1121
1122@example
1123semodule -i etc/guix-daemon.cil
1124@end example
1125
1126Then relabel the file system with @code{restorecon} or by a different
1127mechanism provided by your system.
1128
1129Once the policy is installed, the file system has been relabeled, and
1130the daemon has been restarted, it should be running in the
1131@code{guix_daemon_t} context. You can confirm this with the following
1132command:
1133
1134@example
1135ps -Zax | grep guix-daemon
1136@end example
1137
1138Monitor the SELinux log files as you run a command like @code{guix build
1139hello} to convince yourself that SELinux permits all necessary
1140operations.
1141
1142@subsubsection Limitations
1143@cindex SELinux, limitations
1144
1145This policy is not perfect. Here is a list of limitations or quirks
1146that should be considered when deploying the provided SELinux policy for
1147the Guix daemon.
1148
1149@enumerate
1150@item
1151@code{guix_daemon_socket_t} isn’t actually used. None of the socket
1152operations involve contexts that have anything to do with
1153@code{guix_daemon_socket_t}. It doesn’t hurt to have this unused label,
1154but it would be preferrable to define socket rules for only this label.
1155
1156@item
1157@code{guix gc} cannot access arbitrary links to profiles. By design,
1158the file label of the destination of a symlink is independent of the
1159file label of the link itself. Although all profiles under
1160$localstatedir are labelled, the links to these profiles inherit the
1161label of the directory they are in. For links in the user’s home
1162directory this will be @code{user_home_t}. But for links from the root
1163user’s home directory, or @file{/tmp}, or the HTTP server’s working
1164directory, etc, this won’t work. @code{guix gc} would be prevented from
1165reading and following these links.
1166
1167@item
1168The daemon’s feature to listen for TCP connections might no longer work.
1169This might require extra rules, because SELinux treats network sockets
1170differently from files.
1171
1172@item
1173Currently all files with a name matching the regular expression
1174@code{/gnu/store/.+-(guix-.+|profile)/bin/guix-daemon} are assigned the
1175label @code{guix_daemon_exec_t}; this means that @emph{any} file with
1176that name in any profile would be permitted to run in the
1177@code{guix_daemon_t} domain. This is not ideal. An attacker could
1178build a package that provides this executable and convince a user to
1179install and run it, which lifts it into the @code{guix_daemon_t} domain.
1180At that point SELinux could not prevent it from accessing files that are
1181allowed for processes in that domain.
1182
1183We could generate a much more restrictive policy at installation time,
1184so that only the @emph{exact} file name of the currently installed
1185@code{guix-daemon} executable would be labelled with
1186@code{guix_daemon_exec_t}, instead of using a broad regular expression.
1187The downside is that root would have to install or upgrade the policy at
1188installation time whenever the Guix package that provides the
1189effectively running @code{guix-daemon} executable is upgraded.
1190@end enumerate
1191
bd5e766b
LC
1192@node Invoking guix-daemon
1193@section Invoking @command{guix-daemon}
1194
1195The @command{guix-daemon} program implements all the functionality to
1196access the store. This includes launching build processes, running the
1197garbage collector, querying the availability of a build result, etc. It
1198is normally run as @code{root} like this:
1199
1200@example
cfc149dc 1201# guix-daemon --build-users-group=guixbuild
bd5e766b
LC
1202@end example
1203
1204@noindent
081145cf 1205For details on how to set it up, @pxref{Setting Up the Daemon}.
bd5e766b 1206
e900c503
LC
1207@cindex chroot
1208@cindex container, build environment
1209@cindex build environment
1210@cindex reproducible builds
bd5e766b
LC
1211By default, @command{guix-daemon} launches build processes under
1212different UIDs, taken from the build group specified with
1213@code{--build-users-group}. In addition, each build process is run in a
1214chroot environment that only contains the subset of the store that the
1215build process depends on, as specified by its derivation
1216(@pxref{Programming Interface, derivation}), plus a set of specific
1217system directories. By default, the latter contains @file{/dev} and
e900c503
LC
1218@file{/dev/pts}. Furthermore, on GNU/Linux, the build environment is a
1219@dfn{container}: in addition to having its own file system tree, it has
1220a separate mount name space, its own PID name space, network name space,
1221etc. This helps achieve reproducible builds (@pxref{Features}).
bd5e766b 1222
cbc538fe
LC
1223When the daemon performs a build on behalf of the user, it creates a
1224build directory under @file{/tmp} or under the directory specified by
1225its @code{TMPDIR} environment variable; this directory is shared with
1226the container for the duration of the build. Be aware that using a
1227directory other than @file{/tmp} can affect build results---for example,
1228with a longer directory name, a build process that uses Unix-domain
1229sockets might hit the name length limitation for @code{sun_path}, which
1230it would otherwise not hit.
1231
1232The build directory is automatically deleted upon completion, unless the
1233build failed and the client specified @option{--keep-failed}
1234(@pxref{Invoking guix build, @option{--keep-failed}}).
1235
bd5e766b
LC
1236The following command-line options are supported:
1237
1238@table @code
1239@item --build-users-group=@var{group}
1240Take users from @var{group} to run build processes (@pxref{Setting Up
1241the Daemon, build users}).
1242
6858f9d1 1243@item --no-substitutes
b5385b52 1244@cindex substitutes
6858f9d1 1245Do not use substitutes for build products. That is, always build things
c4202d60
LC
1246locally instead of allowing downloads of pre-built binaries
1247(@pxref{Substitutes}).
6858f9d1 1248
b5385b52
LC
1249When the daemon runs with @code{--no-substitutes}, clients can still
1250explicitly enable substitution @i{via} the @code{set-build-options}
1251remote procedure call (@pxref{The Store}).
1252
9176607e 1253@item --substitute-urls=@var{urls}
f8a8e0fe 1254@anchor{daemon-substitute-urls}
9176607e 1255Consider @var{urls} the default whitespace-separated list of substitute
df061d07
LC
1256source URLs. When this option is omitted,
1257@indicateurl{https://mirror.hydra.gnu.org https://hydra.gnu.org} is used
1258(@code{mirror.hydra.gnu.org} is a mirror of @code{hydra.gnu.org}).
9176607e
LC
1259
1260This means that substitutes may be downloaded from @var{urls}, as long
1261as they are signed by a trusted signature (@pxref{Substitutes}).
1262
4ec2e92d
LC
1263@cindex build hook
1264@item --no-build-hook
1265Do not use the @dfn{build hook}.
1266
1267The build hook is a helper program that the daemon can start and to
1268which it submits build requests. This mechanism is used to offload
1269builds to other machines (@pxref{Daemon Offload Setup}).
1270
bd5e766b
LC
1271@item --cache-failures
1272Cache build failures. By default, only successful builds are cached.
1273
30d9aa54
LC
1274When this option is used, @command{guix gc --list-failures} can be used
1275to query the set of store items marked as failed; @command{guix gc
1276--clear-failures} removes store items from the set of cached failures.
1277@xref{Invoking guix gc}.
1278
bd5e766b
LC
1279@item --cores=@var{n}
1280@itemx -c @var{n}
1281Use @var{n} CPU cores to build each derivation; @code{0} means as many
1282as available.
1283
6efc160e 1284The default value is @code{0}, but it may be overridden by clients, such
e49951eb
MW
1285as the @code{--cores} option of @command{guix build} (@pxref{Invoking
1286guix build}).
bd5e766b
LC
1287
1288The effect is to define the @code{NIX_BUILD_CORES} environment variable
1289in the build process, which can then use it to exploit internal
1290parallelism---for instance, by running @code{make -j$NIX_BUILD_CORES}.
1291
1292@item --max-jobs=@var{n}
1293@itemx -M @var{n}
1294Allow at most @var{n} build jobs in parallel. The default value is
f6526eb3
LC
1295@code{1}. Setting it to @code{0} means that no builds will be performed
1296locally; instead, the daemon will offload builds (@pxref{Daemon Offload
1297Setup}), or simply fail.
bd5e766b 1298
2ca9f51e
LC
1299@item --max-silent-time=@var{seconds}
1300When the build or substitution process remains silent for more than
1301@var{seconds}, terminate it and report a build failure.
1302
1303The default value is @code{0}, which disables the timeout.
1304
1305The value specified here can be overridden by clients (@pxref{Common
1306Build Options, @code{--max-silent-time}}).
1307
1308@item --timeout=@var{seconds}
1309Likewise, when the build or substitution process lasts for more than
1310@var{seconds}, terminate it and report a build failure.
1311
1312The default value is @code{0}, which disables the timeout.
1313
1314The value specified here can be overridden by clients (@pxref{Common
1315Build Options, @code{--timeout}}).
1316
ecf84b7c
LC
1317@item --rounds=@var{N}
1318Build each derivation @var{n} times in a row, and raise an error if
1319consecutive build results are not bit-for-bit identical. Note that this
1320setting can be overridden by clients such as @command{guix build}
1321(@pxref{Invoking guix build}).
1322
b4528110
ED
1323When used in conjunction with @option{--keep-failed}, the differing
1324output is kept in the store, under @file{/gnu/store/@dots{}-check}.
1325This makes it easy to look for differences between the two results.
1326
bd5e766b
LC
1327@item --debug
1328Produce debugging output.
1329
1330This is useful to debug daemon start-up issues, but then it may be
1331overridden by clients, for example the @code{--verbosity} option of
e49951eb 1332@command{guix build} (@pxref{Invoking guix build}).
bd5e766b
LC
1333
1334@item --chroot-directory=@var{dir}
1335Add @var{dir} to the build chroot.
1336
1337Doing this may change the result of build processes---for instance if
1338they use optional dependencies found in @var{dir} when it is available,
1339and not otherwise. For that reason, it is not recommended to do so.
1340Instead, make sure that each derivation declares all the inputs that it
1341needs.
1342
1343@item --disable-chroot
1344Disable chroot builds.
1345
1346Using this option is not recommended since, again, it would allow build
1e2644bb
LC
1347processes to gain access to undeclared dependencies. It is necessary,
1348though, when @command{guix-daemon} is running under an unprivileged user
1349account.
bd5e766b 1350
29a68668
LC
1351@item --log-compression=@var{type}
1352Compress build logs according to @var{type}, one of @code{gzip},
1353@code{bzip2}, or @code{none}.
bd5e766b 1354
1da983b9
LC
1355Unless @code{--lose-logs} is used, all the build logs are kept in the
1356@var{localstatedir}. To save space, the daemon automatically compresses
29a68668 1357them with bzip2 by default.
1da983b9 1358
ab3893d7
LC
1359@item --disable-deduplication
1360@cindex deduplication
bd5e766b
LC
1361Disable automatic file ``deduplication'' in the store.
1362
1da983b9 1363By default, files added to the store are automatically ``deduplicated'':
ab3893d7
LC
1364if a newly added file is identical to another one found in the store,
1365the daemon makes the new file a hard link to the other file. This can
4988dd40 1366noticeably reduce disk usage, at the expense of slightly increased
ab3893d7
LC
1367input/output load at the end of a build process. This option disables
1368this optimization.
1da983b9 1369
6e37066e
LC
1370@item --gc-keep-outputs[=yes|no]
1371Tell whether the garbage collector (GC) must keep outputs of live
1372derivations.
1373
6a98b9f3
LC
1374@cindex GC roots
1375@cindex garbage collector roots
6e37066e
LC
1376When set to ``yes'', the GC will keep the outputs of any live derivation
1377available in the store---the @code{.drv} files. The default is ``no'',
346a6321
CM
1378meaning that derivation outputs are kept only if they are reachable from a GC
1379root. @xref{Invoking guix gc}, for more on GC roots.
6e37066e
LC
1380
1381@item --gc-keep-derivations[=yes|no]
1382Tell whether the garbage collector (GC) must keep derivations
1383corresponding to live outputs.
1384
1385When set to ``yes'', as is the case by default, the GC keeps
1386derivations---i.e., @code{.drv} files---as long as at least one of their
1387outputs is live. This allows users to keep track of the origins of
1388items in their store. Setting it to ``no'' saves a bit of disk space.
1389
346a6321
CM
1390In this way, setting @code{--gc-keep-derivations} to ``yes'' causes liveness
1391to flow from outputs to derivations, and setting @code{--gc-keep-outputs} to
1392``yes'' causes liveness to flow from derivations to outputs. When both are
1393set to ``yes'', the effect is to keep all the build prerequisites (the
1394sources, compiler, libraries, and other build-time tools) of live objects in
1395the store, regardless of whether these prerequisites are reachable from a GC
1396root. This is convenient for developers since it saves rebuilds or downloads.
6e37066e 1397
bd5e766b
LC
1398@item --impersonate-linux-2.6
1399On Linux-based systems, impersonate Linux 2.6. This means that the
1400kernel's @code{uname} system call will report 2.6 as the release number.
1401
1402This might be helpful to build programs that (usually wrongfully) depend
1403on the kernel version number.
1404
1405@item --lose-logs
1406Do not keep build logs. By default they are kept under
ce33631f 1407@code{@var{localstatedir}/guix/log}.
bd5e766b
LC
1408
1409@item --system=@var{system}
1410Assume @var{system} as the current system type. By default it is the
1411architecture/kernel pair found at configure time, such as
1412@code{x86_64-linux}.
b8d2aa26 1413
1071f781
LC
1414@item --listen=@var{endpoint}
1415Listen for connections on @var{endpoint}. @var{endpoint} is interpreted
1416as the file name of a Unix-domain socket if it starts with
1417@code{/} (slash sign). Otherwise, @var{endpoint} is interpreted as a
1418host name or host name and port to listen to. Here are a few examples:
1419
1420@table @code
1421@item --listen=/gnu/var/daemon
1422Listen for connections on the @file{/gnu/var/daemon} Unix-domain socket,
1423creating it if needed.
1424
1425@item --listen=localhost
1426@cindex daemon, remote access
1427@cindex remote access to the daemon
1428@cindex daemon, cluster setup
1429@cindex clusters, daemon setup
1430Listen for TCP connections on the network interface corresponding to
1431@code{localhost}, on port 44146.
1432
1433@item --listen=128.0.0.42:1234
1434Listen for TCP connections on the network interface corresponding to
1435@code{128.0.0.42}, on port 1234.
1436@end table
1437
1438This option can be repeated multiple times, in which case
1439@command{guix-daemon} accepts connections on all the specified
1440endpoints. Users can tell client commands what endpoint to connect to
1441by setting the @code{GUIX_DAEMON_SOCKET} environment variable
1442(@pxref{The Store, @code{GUIX_DAEMON_SOCKET}}).
1443
1444@quotation Note
1445The daemon protocol is @emph{unauthenticated and unencrypted}. Using
1446@code{--listen=@var{host}} is suitable on local networks, such as
1447clusters, where only trusted nodes may connect to the build daemon. In
1448other cases where remote access to the daemon is needed, we recommend
1449using Unix-domain sockets along with SSH.
1450@end quotation
1451
1452When @code{--listen} is omitted, @command{guix-daemon} listens for
1453connections on the Unix-domain socket located at
fae7973e 1454@file{@var{localstatedir}/guix/daemon-socket/socket}.
bd5e766b
LC
1455@end table
1456
1457
0e2d0213
LC
1458@node Application Setup
1459@section Application Setup
1460
d23ef788 1461@cindex foreign distro
85e57214
LC
1462When using Guix on top of GNU/Linux distribution other than GuixSD---a
1463so-called @dfn{foreign distro}---a few additional steps are needed to
1464get everything in place. Here are some of them.
0e2d0213
LC
1465
1466@subsection Locales
1467
5c3c1427 1468@anchor{locales-and-locpath}
0e2d0213 1469@cindex locales, when not on GuixSD
5c3c1427 1470@vindex LOCPATH
85e57214 1471@vindex GUIX_LOCPATH
f97c9175
AE
1472Packages installed @i{via} Guix will not use the locale data of the
1473host system. Instead, you must first install one of the locale packages
85e57214
LC
1474available with Guix and then define the @code{GUIX_LOCPATH} environment
1475variable:
0e2d0213
LC
1476
1477@example
1478$ guix package -i glibc-locales
85e57214 1479$ export GUIX_LOCPATH=$HOME/.guix-profile/lib/locale
0e2d0213
LC
1480@end example
1481
1482Note that the @code{glibc-locales} package contains data for all the
1483locales supported by the GNU@tie{}libc and weighs in at around
f97c9175 1484110@tie{}MiB. Alternatively, the @code{glibc-utf8-locales} is smaller but
0e2d0213
LC
1485limited to a few UTF-8 locales.
1486
85e57214
LC
1487The @code{GUIX_LOCPATH} variable plays a role similar to @code{LOCPATH}
1488(@pxref{Locale Names, @code{LOCPATH},, libc, The GNU C Library Reference
1489Manual}). There are two important differences though:
1490
1491@enumerate
1492@item
f97c9175 1493@code{GUIX_LOCPATH} is honored only by the libc in Guix, and not by the libc
85e57214 1494provided by foreign distros. Thus, using @code{GUIX_LOCPATH} allows you
f97c9175 1495to make sure the programs of the foreign distro will not end up loading
85e57214
LC
1496incompatible locale data.
1497
1498@item
1499libc suffixes each entry of @code{GUIX_LOCPATH} with @code{/X.Y}, where
1500@code{X.Y} is the libc version---e.g., @code{2.22}. This means that,
1501should your Guix profile contain a mixture of programs linked against
1502different libc version, each libc version will only try to load locale
1503data in the right format.
1504@end enumerate
1505
1506This is important because the locale data format used by different libc
1507versions may be incompatible.
1508
9a5187b6
LC
1509@subsection Name Service Switch
1510
1511@cindex name service switch, glibc
1512@cindex NSS (name service switch), glibc
1513@cindex nscd (name service caching daemon)
1514@cindex name service caching daemon (nscd)
1515When using Guix on a foreign distro, we @emph{strongly recommend} that
1516the system run the GNU C library's @dfn{name service cache daemon},
1517@command{nscd}, which should be listening on the
1518@file{/var/run/nscd/socket} socket. Failing to do that, applications
1519installed with Guix may fail to look up host names or user accounts, or
1520may even crash. The next paragraphs explain why.
1521
1522@cindex @file{nsswitch.conf}
1523The GNU C library implements a @dfn{name service switch} (NSS), which is
1524an extensible mechanism for ``name lookups'' in general: host name
1525resolution, user accounts, and more (@pxref{Name Service Switch,,, libc,
1526The GNU C Library Reference Manual}).
1527
1528@cindex Network information service (NIS)
1529@cindex NIS (Network information service)
1530Being extensible, the NSS supports @dfn{plugins}, which provide new name
1531lookup implementations: for example, the @code{nss-mdns} plugin allow
1532resolution of @code{.local} host names, the @code{nis} plugin allows
1533user account lookup using the Network information service (NIS), and so
1534on. These extra ``lookup services'' are configured system-wide in
1535@file{/etc/nsswitch.conf}, and all the programs running on the system
1536honor those settings (@pxref{NSS Configuration File,,, libc, The GNU C
1537Reference Manual}).
1538
1539When they perform a name lookup---for instance by calling the
1540@code{getaddrinfo} function in C---applications first try to connect to
1541the nscd; on success, nscd performs name lookups on their behalf. If
1542the nscd is not running, then they perform the name lookup by
1543themselves, by loading the name lookup services into their own address
1544space and running it. These name lookup services---the
1545@file{libnss_*.so} files---are @code{dlopen}'d, but they may come from
1546the host system's C library, rather than from the C library the
1547application is linked against (the C library coming from Guix).
1548
1549And this is where the problem is: if your application is linked against
1550Guix's C library (say, glibc 2.24) and tries to load NSS plugins from
1551another C library (say, @code{libnss_mdns.so} for glibc 2.22), it will
1552likely crash or have its name lookups fail unexpectedly.
1553
1554Running @command{nscd} on the system, among other advantages, eliminates
1555this binary incompatibility problem because those @code{libnss_*.so}
1556files are loaded in the @command{nscd} process, not in applications
1557themselves.
1558
0e2d0213
LC
1559@subsection X11 Fonts
1560
e32171ee 1561@cindex fonts
4988dd40 1562The majority of graphical applications use Fontconfig to locate and
f97c9175
AE
1563load fonts and perform X11-client-side rendering. The @code{fontconfig}
1564package in Guix looks for fonts in @file{$HOME/.guix-profile}
0e2d0213 1565by default. Thus, to allow graphical applications installed with Guix
f97c9175 1566to display fonts, you have to install fonts with Guix as well.
0e2d0213 1567Essential font packages include @code{gs-fonts}, @code{font-dejavu}, and
8fe5b1d1 1568@code{font-gnu-freefont-ttf}.
0e2d0213 1569
5c36edc8
LC
1570To display text written in Chinese languages, Japanese, or Korean in
1571graphical applications, consider installing
1572@code{font-adobe-source-han-sans} or @code{font-wqy-zenhei}. The former
1573has multiple outputs, one per language family (@pxref{Packages with
1574Multiple Outputs}). For instance, the following command installs fonts
1575for Chinese languages:
1576
1577@example
1578guix package -i font-adobe-source-han-sans:cn
1579@end example
1580
e32171ee 1581@cindex @code{xterm}
1a3e6b15
AK
1582Older programs such as @command{xterm} do not use Fontconfig and instead
1583rely on server-side font rendering. Such programs require to specify a
1584full name of a font using XLFD (X Logical Font Description), like this:
1585
1586@example
1587-*-dejavu sans-medium-r-normal-*-*-100-*-*-*-*-*-1
1588@end example
1589
1590To be able to use such full names for the TrueType fonts installed in
1591your Guix profile, you need to extend the font path of the X server:
1592
ca041ec1
LC
1593@c Note: 'xset' does not accept symlinks so the trick below arranges to
1594@c get at the real directory. See <https://bugs.gnu.org/30655>.
1a3e6b15 1595@example
ca041ec1 1596xset +fp $(dirname $(readlink -f ~/.guix-profile/share/fonts/truetype/fonts.dir))
1a3e6b15
AK
1597@end example
1598
e32171ee 1599@cindex @code{xlsfonts}
1a3e6b15
AK
1600After that, you can run @code{xlsfonts} (from @code{xlsfonts} package)
1601to make sure your TrueType fonts are listed there.
1602
e5942cbf
RW
1603@cindex @code{fc-cache}
1604@cindex font cache
1605After installing fonts you may have to refresh the font cache to use
1606them in applications. The same applies when applications installed via
1607Guix do not seem to find fonts. To force rebuilding of the font cache
1608run @code{fc-cache -f}. The @code{fc-cache} command is provided by the
1609@code{fontconfig} package.
1610
b3129f2b
LC
1611@subsection X.509 Certificates
1612
e32171ee 1613@cindex @code{nss-certs}
b3129f2b
LC
1614The @code{nss-certs} package provides X.509 certificates, which allow
1615programs to authenticate Web servers accessed over HTTPS.
1616
1617When using Guix on a foreign distro, you can install this package and
1618define the relevant environment variables so that packages know where to
80d944b7 1619look for certificates. @xref{X.509 Certificates}, for detailed
b3129f2b
LC
1620information.
1621
6d97319c
AK
1622@subsection Emacs Packages
1623
e32171ee 1624@cindex @code{emacs}
6d97319c
AK
1625When you install Emacs packages with Guix, the elisp files may be placed
1626either in @file{$HOME/.guix-profile/share/emacs/site-lisp/} or in
1627sub-directories of
1628@file{$HOME/.guix-profile/share/emacs/site-lisp/guix.d/}. The latter
1629directory exists because potentially there may exist thousands of Emacs
d2c3be99 1630packages and storing all their files in a single directory may not be
6d97319c
AK
1631reliable (because of name conflicts). So we think using a separate
1632directory for each package is a good idea. It is very similar to how
1633the Emacs package system organizes the file structure (@pxref{Package
1634Files,,, emacs, The GNU Emacs Manual}).
1635
1636By default, Emacs (installed with Guix) ``knows'' where these packages
f97c9175 1637are placed, so you do not need to perform any configuration. If, for
6d97319c 1638some reason, you want to avoid auto-loading Emacs packages installed
f97c9175 1639with Guix, you can do so by running Emacs with @code{--no-site-file}
6d97319c
AK
1640option (@pxref{Init File,,, emacs, The GNU Emacs Manual}).
1641
2f0c4b82
RW
1642@subsection The GCC toolchain
1643
1644@cindex GCC
1645@cindex ld-wrapper
1646
1647Guix offers individual compiler packages such as @code{gcc} but if you
1648are in need of a complete toolchain for compiling and linking source
1649code what you really want is the @code{gcc-toolchain} package. This
1650package provides a complete GCC toolchain for C/C++ development,
1651including GCC itself, the GNU C Library (headers and binaries, plus
1652debugging symbols in the @code{debug} output), Binutils, and a linker
1653wrapper.
1654
1655@cindex attempt to use impure library, error message
1656
1657The wrapper's purpose is to inspect the @code{-L} and @code{-l} switches
1658passed to the linker, add corresponding @code{-rpath} arguments, and
1659invoke the actual linker with this new set of arguments. By default,
1660the linker wrapper refuses to link to libraries outside the store to
1661ensure ``purity''. This can be annoying when using the toolchain to
1662link with local libraries. To allow references to libraries outside the
1663store you need to define the environment variable
1664@code{GUIX_LD_WRAPPER_ALLOW_IMPURITIES}.
1665
0e2d0213
LC
1666@c TODO What else?
1667
eeaf4427
LC
1668@c *********************************************************************
1669@node Package Management
1670@chapter Package Management
1671
e32171ee 1672@cindex packages
f8348b91 1673The purpose of GNU Guix is to allow users to easily install, upgrade, and
eeaf4427 1674remove software packages, without having to know about their build
f97c9175 1675procedures or dependencies. Guix also goes beyond this obvious set of
eeaf4427
LC
1676features.
1677
8ca0c88a
AK
1678This chapter describes the main features of Guix, as well as the
1679package management tools it provides. Along with the command-line
1680interface described below (@pxref{Invoking guix package, @code{guix
08c597d7 1681package}}), you may also use the Emacs-Guix interface (@pxref{Top,,,
8ca0c88a
AK
1682emacs-guix, The Emacs-Guix Reference Manual}), after installing
1683@code{emacs-guix} package (run @kbd{M-x guix-help} command to start
1684with it):
deb6276d
AK
1685
1686@example
1687guix package -i emacs-guix
1688@end example
eeaf4427
LC
1689
1690@menu
1691* Features:: How Guix will make your life brighter.
e49951eb 1692* Invoking guix package:: Package installation, removal, etc.
c4202d60 1693* Substitutes:: Downloading pre-built binaries.
760c60d6 1694* Packages with Multiple Outputs:: Single source package, multiple outputs.
e49951eb 1695* Invoking guix gc:: Running the garbage collector.
f651b477 1696* Invoking guix pull:: Fetching the latest Guix and distribution.
239c2266 1697* Invoking guix pack:: Creating software bundles.
760c60d6 1698* Invoking guix archive:: Exporting and importing store files.
eeaf4427
LC
1699@end menu
1700
1701@node Features
1702@section Features
1703
1704When using Guix, each package ends up in the @dfn{package store}, in its
1705own directory---something that resembles
deb6276d 1706@file{/gnu/store/xxx-package-1.2}, where @code{xxx} is a base32 string.
eeaf4427
LC
1707
1708Instead of referring to these directories, users have their own
1709@dfn{profile}, which points to the packages that they actually want to
821b0015
LC
1710use. These profiles are stored within each user's home directory, at
1711@code{$HOME/.guix-profile}.
eeaf4427 1712
821b0015 1713For example, @code{alice} installs GCC 4.7.2. As a result,
eeaf4427 1714@file{/home/alice/.guix-profile/bin/gcc} points to
834129e0 1715@file{/gnu/store/@dots{}-gcc-4.7.2/bin/gcc}. Now, on the same machine,
821b0015
LC
1716@code{bob} had already installed GCC 4.8.0. The profile of @code{bob}
1717simply continues to point to
834129e0 1718@file{/gnu/store/@dots{}-gcc-4.8.0/bin/gcc}---i.e., both versions of GCC
821b0015 1719coexist on the same system without any interference.
eeaf4427 1720
e49951eb 1721The @command{guix package} command is the central tool to manage
f97c9175 1722packages (@pxref{Invoking guix package}). It operates on the per-user
821b0015 1723profiles, and can be used @emph{with normal user privileges}.
eeaf4427 1724
e32171ee 1725@cindex transactions
eeaf4427
LC
1726The command provides the obvious install, remove, and upgrade
1727operations. Each invocation is actually a @emph{transaction}: either
ba55b1cb 1728the specified operation succeeds, or nothing happens. Thus, if the
e49951eb 1729@command{guix package} process is terminated during the transaction,
eeaf4427
LC
1730or if a power outage occurs during the transaction, then the user's
1731profile remains in its previous state, and remains usable.
1732
1733In addition, any package transaction may be @emph{rolled back}. So, if,
1734for example, an upgrade installs a new version of a package that turns
1735out to have a serious bug, users may roll back to the previous instance
4af2447e 1736of their profile, which was known to work well. Similarly, the global
6f773606
LC
1737system configuration on GuixSD is subject to
1738transactional upgrades and roll-back
4af2447e 1739(@pxref{Using the Configuration System}).
eeaf4427 1740
f97c9175
AE
1741All packages in the package store may be @emph{garbage-collected}.
1742Guix can determine which packages are still referenced by user
fe8ff028 1743profiles, and remove those that are provably no longer referenced
e49951eb 1744(@pxref{Invoking guix gc}). Users may also explicitly remove old
fe8ff028
LC
1745generations of their profile so that the packages they refer to can be
1746collected.
eeaf4427 1747
e900c503
LC
1748@cindex reproducibility
1749@cindex reproducible builds
eeaf4427
LC
1750Finally, Guix takes a @dfn{purely functional} approach to package
1751management, as described in the introduction (@pxref{Introduction}).
834129e0 1752Each @file{/gnu/store} package directory name contains a hash of all the
eeaf4427
LC
1753inputs that were used to build that package---compiler, libraries, build
1754scripts, etc. This direct correspondence allows users to make sure a
1755given package installation matches the current state of their
e900c503
LC
1756distribution. It also helps maximize @dfn{build reproducibility}:
1757thanks to the isolated build environments that are used, a given build
1758is likely to yield bit-identical files when performed on different
1759machines (@pxref{Invoking guix-daemon, container}).
eeaf4427 1760
c4202d60 1761@cindex substitutes
eeaf4427 1762This foundation allows Guix to support @dfn{transparent binary/source
c4202d60 1763deployment}. When a pre-built binary for a @file{/gnu/store} item is
18f2887b 1764available from an external source---a @dfn{substitute}, Guix just
c4202d60
LC
1765downloads it and unpacks it;
1766otherwise, it builds the package from source, locally
bf9eacd2
LC
1767(@pxref{Substitutes}). Because build results are usually bit-for-bit
1768reproducible, users do not have to trust servers that provide
1769substitutes: they can force a local build and @emph{challenge} providers
1770(@pxref{Invoking guix challenge}).
eeaf4427 1771
f5fd4fd2
LC
1772Control over the build environment is a feature that is also useful for
1773developers. The @command{guix environment} command allows developers of
1774a package to quickly set up the right development environment for their
f97c9175
AE
1775package, without having to manually install the dependencies of the
1776package into their profile (@pxref{Invoking guix environment}).
f5fd4fd2 1777
e49951eb
MW
1778@node Invoking guix package
1779@section Invoking @command{guix package}
eeaf4427 1780
e32171ee
JD
1781@cindex installing packages
1782@cindex removing packages
1783@cindex package installation
1784@cindex package removal
e49951eb 1785The @command{guix package} command is the tool that allows users to
eeaf4427
LC
1786install, upgrade, and remove packages, as well as rolling back to
1787previous configurations. It operates only on the user's own profile,
1788and works with normal user privileges (@pxref{Features}). Its syntax
1789is:
1790
1791@example
e49951eb 1792guix package @var{options}
eeaf4427 1793@end example
e32171ee 1794@cindex transactions
ba55b1cb 1795Primarily, @var{options} specifies the operations to be performed during
eeaf4427 1796the transaction. Upon completion, a new profile is created, but
99bd74d5 1797previous @dfn{generations} of the profile remain available, should the user
eeaf4427
LC
1798want to roll back.
1799
6447738c
MW
1800For example, to remove @code{lua} and install @code{guile} and
1801@code{guile-cairo} in a single transaction:
1802
1803@example
1804guix package -r lua -i guile guile-cairo
1805@end example
1806
99bd74d5
LC
1807@command{guix package} also supports a @dfn{declarative approach}
1808whereby the user specifies the exact set of packages to be available and
1809passes it @i{via} the @option{--manifest} option
1810(@pxref{profile-manifest, @option{--manifest}}).
1811
e32171ee 1812@cindex profile
b9e5c0a9 1813For each user, a symlink to the user's default profile is automatically
0ec1af59 1814created in @file{$HOME/.guix-profile}. This symlink always points to the
b9e5c0a9
LC
1815current generation of the user's default profile. Thus, users can add
1816@file{$HOME/.guix-profile/bin} to their @code{PATH} environment
1817variable, and so on.
d664f1b4
LC
1818@cindex search paths
1819If you are not using the Guix System Distribution, consider adding the
1820following lines to your @file{~/.bash_profile} (@pxref{Bash Startup
1821Files,,, bash, The GNU Bash Reference Manual}) so that newly-spawned
1822shells get all the right environment variable definitions:
1823
1824@example
bd7e136d 1825GUIX_PROFILE="$HOME/.guix-profile" ; \
d664f1b4
LC
1826source "$HOME/.guix-profile/etc/profile"
1827@end example
b9e5c0a9 1828
4379c35b
LC
1829In a multi-user setup, user profiles are stored in a place registered as
1830a @dfn{garbage-collector root}, which @file{$HOME/.guix-profile} points
1831to (@pxref{Invoking guix gc}). That directory is normally
fae7973e 1832@code{@var{localstatedir}/guix/profiles/per-user/@var{user}}, where
0ec1af59 1833@var{localstatedir} is the value passed to @code{configure} as
4379c35b
LC
1834@code{--localstatedir}, and @var{user} is the user name. The
1835@file{per-user} directory is created when @command{guix-daemon} is
1836started, and the @var{user} sub-directory is created by @command{guix
1837package}.
0ec1af59
LC
1838
1839The @var{options} can be among the following:
1840
eeaf4427
LC
1841@table @code
1842
6447738c
MW
1843@item --install=@var{package} @dots{}
1844@itemx -i @var{package} @dots{}
1845Install the specified @var{package}s.
eeaf4427 1846
6447738c 1847Each @var{package} may specify either a simple package name, such as
1b846da8
ML
1848@code{guile}, or a package name followed by an at-sign and version number,
1849such as @code{guile@@1.8.8} or simply @code{guile@@1.8} (in the latter
724311a2
LC
1850case, the newest version prefixed by @code{1.8} is selected.)
1851
1852If no version number is specified, the
dc5669cd
MW
1853newest available version will be selected. In addition, @var{package}
1854may contain a colon, followed by the name of one of the outputs of the
1b846da8 1855package, as in @code{gcc:doc} or @code{binutils@@2.22:lib}
e7f34eb0
LC
1856(@pxref{Packages with Multiple Outputs}). Packages with a corresponding
1857name (and optionally version) are searched for among the GNU
1858distribution modules (@pxref{Package Modules}).
eeaf4427 1859
461572cc
LC
1860@cindex propagated inputs
1861Sometimes packages have @dfn{propagated inputs}: these are dependencies
21461f27
LC
1862that automatically get installed along with the required package
1863(@pxref{package-propagated-inputs, @code{propagated-inputs} in
1864@code{package} objects}, for information about propagated inputs in
1865package definitions).
461572cc 1866
21461f27 1867@anchor{package-cmd-propagated-inputs}
461572cc
LC
1868An example is the GNU MPC library: its C header files refer to those of
1869the GNU MPFR library, which in turn refer to those of the GMP library.
1870Thus, when installing MPC, the MPFR and GMP libraries also get installed
1871in the profile; removing MPC also removes MPFR and GMP---unless they had
f97c9175 1872also been explicitly installed by the user.
461572cc 1873
ba7ea5ce 1874Besides, packages sometimes rely on the definition of environment
5924080d 1875variables for their search paths (see explanation of
ba7ea5ce 1876@code{--search-paths} below). Any missing or possibly incorrect
5924080d
LC
1877environment variable definitions are reported here.
1878
5d4b411f
LC
1879@item --install-from-expression=@var{exp}
1880@itemx -e @var{exp}
1881Install the package @var{exp} evaluates to.
1882
1883@var{exp} must be a Scheme expression that evaluates to a
1884@code{<package>} object. This option is notably useful to disambiguate
1885between same-named variants of a package, with expressions such as
1886@code{(@@ (gnu packages base) guile-final)}.
1887
1888Note that this option installs the first output of the specified
1889package, which may be insufficient when needing a specific output of a
1890multiple-output package.
1891
0d279400
DT
1892@item --install-from-file=@var{file}
1893@itemx -f @var{file}
1894Install the package that the code within @var{file} evaluates to.
1895
1896As an example, @var{file} might contain a definition like this
1897(@pxref{Defining Packages}):
1898
1899@example
1900@verbatiminclude package-hello.scm
1901@end example
1902
baacf042 1903Developers may find it useful to include such a @file{guix.scm} file
f97c9175 1904in the root of their project source tree that can be used to test
0d279400
DT
1905development snapshots and create reproducible development environments
1906(@pxref{Invoking guix environment}).
1907
6447738c
MW
1908@item --remove=@var{package} @dots{}
1909@itemx -r @var{package} @dots{}
1910Remove the specified @var{package}s.
eeaf4427 1911
6447738c 1912As for @code{--install}, each @var{package} may specify a version number
13ed095c
LC
1913and/or output name in addition to the package name. For instance,
1914@code{-r glibc:debug} would remove the @code{debug} output of
1915@code{glibc}.
1916
6447738c
MW
1917@item --upgrade[=@var{regexp} @dots{}]
1918@itemx -u [@var{regexp} @dots{}]
e32171ee 1919@cindex upgrading packages
6447738c
MW
1920Upgrade all the installed packages. If one or more @var{regexp}s are
1921specified, upgrade only installed packages whose name matches a
d5f01e48 1922@var{regexp}. Also see the @code{--do-not-upgrade} option below.
eeaf4427 1923
f651b477
LC
1924Note that this upgrades package to the latest version of packages found
1925in the distribution currently installed. To update your distribution,
1926you should regularly run @command{guix pull} (@pxref{Invoking guix
1927pull}).
1928
d5f01e48
MW
1929@item --do-not-upgrade[=@var{regexp} @dots{}]
1930When used together with the @code{--upgrade} option, do @emph{not}
1931upgrade any packages whose name matches a @var{regexp}. For example, to
1932upgrade all packages in the current profile except those containing the
1933substring ``emacs'':
1934
1935@example
1936$ guix package --upgrade . --do-not-upgrade emacs
1937@end example
1938
99bd74d5 1939@item @anchor{profile-manifest}--manifest=@var{file}
1b676447 1940@itemx -m @var{file}
99bd74d5
LC
1941@cindex profile declaration
1942@cindex profile manifest
1943Create a new generation of the profile from the manifest object
1b676447
DT
1944returned by the Scheme code in @var{file}.
1945
99bd74d5
LC
1946This allows you to @emph{declare} the profile's contents rather than
1947constructing it through a sequence of @code{--install} and similar
1948commands. The advantage is that @var{file} can be put under version
1949control, copied to different machines to reproduce the same profile, and
1950so on.
1951
1952@c FIXME: Add reference to (guix profile) documentation when available.
1953@var{file} must return a @dfn{manifest} object, which is roughly a list
1954of packages:
1b676447 1955
99bd74d5 1956@findex packages->manifest
1b676447 1957@example
99bd74d5 1958(use-package-modules guile emacs)
1b676447
DT
1959
1960(packages->manifest
99bd74d5
LC
1961 (list emacs
1962 guile-2.0
1b676447 1963 ;; Use a specific package output.
99bd74d5 1964 (list guile-2.0 "debug")))
1b676447
DT
1965@end example
1966
c08ea55e 1967@findex specifications->manifest
6cd10593
LC
1968In this example we have to know which modules define the @code{emacs}
1969and @code{guile-2.0} variables to provide the right
1970@code{use-package-modules} line, which can be cumbersome. We can
1971instead provide regular package specifications and let
c08ea55e 1972@code{specifications->manifest} look up the corresponding package
6cd10593
LC
1973objects, like this:
1974
1975@example
c08ea55e
LC
1976(specifications->manifest
1977 '("emacs" "guile@@2.2" "guile@@2.2:debug"))
6cd10593
LC
1978@end example
1979
24e262f0 1980@item --roll-back
e32171ee
JD
1981@cindex rolling back
1982@cindex undoing transactions
1983@cindex transactions, undoing
24e262f0
LC
1984Roll back to the previous @dfn{generation} of the profile---i.e., undo
1985the last transaction.
1986
1987When combined with options such as @code{--install}, roll back occurs
1988before any other actions.
1989
d9307267 1990When rolling back from the first generation that actually contains
4b2bc804 1991installed packages, the profile is made to point to the @dfn{zeroth
f97c9175 1992generation}, which contains no files apart from its own metadata.
d9307267 1993
f97c9175
AE
1994After having rolled back, installing, removing, or upgrading packages
1995overwrites previous future generations. Thus, the history of the
1996generations in a profile is always linear.
82fe08ed 1997
b3bb82f1
AK
1998@item --switch-generation=@var{pattern}
1999@itemx -S @var{pattern}
e32171ee 2000@cindex generations
b3bb82f1
AK
2001Switch to a particular generation defined by @var{pattern}.
2002
2003@var{pattern} may be either a generation number or a number prefixed
2004with ``+'' or ``-''. The latter means: move forward/backward by a
2005specified number of generations. For example, if you want to return to
2006the latest generation after @code{--roll-back}, use
2007@code{--switch-generation=+1}.
2008
2009The difference between @code{--roll-back} and
2010@code{--switch-generation=-1} is that @code{--switch-generation} will
2011not make a zeroth generation, so if a specified generation does not
2012exist, the current generation will not be changed.
2013
dbc31ab2 2014@item --search-paths[=@var{kind}]
5924080d
LC
2015@cindex search paths
2016Report environment variable definitions, in Bash syntax, that may be
2017needed in order to use the set of installed packages. These environment
2018variables are used to specify @dfn{search paths} for files used by some
2019of the installed packages.
2020
2021For example, GCC needs the @code{CPATH} and @code{LIBRARY_PATH}
2022environment variables to be defined so it can look for headers and
2023libraries in the user's profile (@pxref{Environment Variables,,, gcc,
2024Using the GNU Compiler Collection (GCC)}). If GCC and, say, the C
2025library are installed in the profile, then @code{--search-paths} will
2026suggest setting these variables to @code{@var{profile}/include} and
2027@code{@var{profile}/lib}, respectively.
2028
dbc31ab2
LC
2029The typical use case is to define these environment variables in the
2030shell:
2031
2032@example
2033$ eval `guix package --search-paths`
2034@end example
2035
2036@var{kind} may be one of @code{exact}, @code{prefix}, or @code{suffix},
2037meaning that the returned environment variable definitions will either
2038be exact settings, or prefixes or suffixes of the current value of these
2039variables. When omitted, @var{kind} defaults to @code{exact}.
2040
fc2d2339
LC
2041This option can also be used to compute the @emph{combined} search paths
2042of several profiles. Consider this example:
2043
2044@example
2045$ guix package -p foo -i guile
2046$ guix package -p bar -i guile-json
2047$ guix package -p foo -p bar --search-paths
2048@end example
2049
2050The last command above reports about the @code{GUILE_LOAD_PATH}
2051variable, even though, taken individually, neither @file{foo} nor
2052@file{bar} would lead to that recommendation.
2053
2054
eeaf4427
LC
2055@item --profile=@var{profile}
2056@itemx -p @var{profile}
2057Use @var{profile} instead of the user's default profile.
2058
fc95dc4c
LC
2059@cindex collisions, in a profile
2060@cindex colliding packages in profiles
2061@cindex profile collisions
2062@item --allow-collisions
2063Allow colliding packages in the new profile. Use at your own risk!
2064
2065By default, @command{guix package} reports as an error @dfn{collisions}
2066in the profile. Collisions happen when two or more different versions
2067or variants of a given package end up in the profile.
2068
70915c1a 2069@item --verbose
f97c9175
AE
2070Produce verbose output. In particular, emit the build log of the
2071environment on the standard error port.
70915c1a 2072
eeaf4427
LC
2073@item --bootstrap
2074Use the bootstrap Guile to build the profile. This option is only
2075useful to distribution developers.
2076
2077@end table
2078
f97c9175 2079In addition to these actions, @command{guix package} supports the
733b4130
LC
2080following options to query the current state of a profile, or the
2081availability of packages:
eeaf4427 2082
733b4130
LC
2083@table @option
2084
acc08466
NK
2085@item --search=@var{regexp}
2086@itemx -s @var{regexp}
b110869d 2087@cindex searching for packages
5763ad92 2088List the available packages whose name, synopsis, or description matches
4e863eb3 2089@var{regexp}, sorted by relevance. Print all the metadata of matching packages in
299112d3
LC
2090@code{recutils} format (@pxref{Top, GNU recutils databases,, recutils,
2091GNU recutils manual}).
acc08466 2092
299112d3
LC
2093This allows specific fields to be extracted using the @command{recsel}
2094command, for instance:
2095
2096@example
4e863eb3
LC
2097$ guix package -s malloc | recsel -p name,version,relevance
2098name: jemalloc
2099version: 4.5.0
2100relevance: 6
2101
299112d3 2102name: glibc
4e863eb3
LC
2103version: 2.25
2104relevance: 1
299112d3
LC
2105
2106name: libgc
4e863eb3
LC
2107version: 7.6.0
2108relevance: 1
299112d3 2109@end example
acc08466 2110
a12d92f5
LC
2111Similarly, to show the name of all the packages available under the
2112terms of the GNU@tie{}LGPL version 3:
2113
2114@example
2115$ guix package -s "" | recsel -p name -e 'license ~ "LGPL 3"'
2116name: elfutils
2117
2118name: gmp
2119@dots{}
2120@end example
2121
db5a9444
LC
2122It is also possible to refine search results using several @code{-s}
2123flags. For example, the following command returns a list of board
2124games:
2125
2126@example
2127$ guix package -s '\<board\>' -s game | recsel -p name
2128name: gnubg
2129@dots{}
2130@end example
2131
2132If we were to omit @code{-s game}, we would also get software packages
2133that deal with printed circuit boards; removing the angle brackets
2134around @code{board} would further add packages that have to do with
2135keyboards.
2136
b110869d
LC
2137And now for a more elaborate example. The following command searches
2138for cryptographic libraries, filters out Haskell, Perl, Python, and Ruby
2139libraries, and prints the name and synopsis of the matching packages:
2140
2141@example
2142$ guix package -s crypto -s library | \
2143 recsel -e '! (name ~ "^(ghc|perl|python|ruby)")' -p name,synopsis
2144@end example
2145
2146@noindent
2147@xref{Selection Expressions,,, recutils, GNU recutils manual}, for more
2148information on @dfn{selection expressions} for @code{recsel -e}.
2149
2aa6efb0
CR
2150@item --show=@var{package}
2151Show details about @var{package}, taken from the list of available packages, in
2152@code{recutils} format (@pxref{Top, GNU recutils databases,, recutils, GNU
2153recutils manual}).
2154
2155@example
2156$ guix package --show=python | recsel -p name,version
2157name: python
2158version: 2.7.6
2159
2160name: python
2161version: 3.3.5
2162@end example
2163
2164You may also specify the full name of a package to only get details about a
2165specific version of it:
2166@example
ea206df4 2167$ guix package --show=python@@3.4 | recsel -p name,version
2aa6efb0 2168name: python
ea206df4 2169version: 3.4.3
2aa6efb0
CR
2170@end example
2171
2172
2173
733b4130
LC
2174@item --list-installed[=@var{regexp}]
2175@itemx -I [@var{regexp}]
bd9bde1c
LC
2176List the currently installed packages in the specified profile, with the
2177most recently installed packages shown last. When @var{regexp} is
2178specified, list only installed packages whose name matches @var{regexp}.
733b4130
LC
2179
2180For each installed package, print the following items, separated by
2181tabs: the package name, its version string, the part of the package that
2182is installed (for instance, @code{out} for the default output,
2183@code{include} for its headers, etc.), and the path of this package in
2184the store.
2185
64fc89b6
LC
2186@item --list-available[=@var{regexp}]
2187@itemx -A [@var{regexp}]
5763ad92 2188List packages currently available in the distribution for this system
a1ba8475
LC
2189(@pxref{GNU Distribution}). When @var{regexp} is specified, list only
2190installed packages whose name matches @var{regexp}.
64fc89b6
LC
2191
2192For each package, print the following items separated by tabs: its name,
6e721c4d
LC
2193its version string, the parts of the package (@pxref{Packages with
2194Multiple Outputs}), and the source location of its definition.
64fc89b6 2195
f566d765
LC
2196@item --list-generations[=@var{pattern}]
2197@itemx -l [@var{pattern}]
e32171ee 2198@cindex generations
f566d765
LC
2199Return a list of generations along with their creation dates; for each
2200generation, show the installed packages, with the most recently
4b2bc804
NK
2201installed packages shown last. Note that the zeroth generation is never
2202shown.
f566d765
LC
2203
2204For each installed package, print the following items, separated by
2205tabs: the name of a package, its version string, the part of the package
2206that is installed (@pxref{Packages with Multiple Outputs}), and the
2207location of this package in the store.
2208
2209When @var{pattern} is used, the command returns only matching
2210generations. Valid patterns include:
2211
2212@itemize
2213@item @emph{Integers and comma-separated integers}. Both patterns denote
2214generation numbers. For instance, @code{--list-generations=1} returns
2215the first one.
2216
2217And @code{--list-generations=1,8,2} outputs three generations in the
2218specified order. Neither spaces nor trailing commas are allowed.
2219
2220@item @emph{Ranges}. @code{--list-generations=2..9} prints the
2221specified generations and everything in between. Note that the start of
f97c9175 2222a range must be smaller than its end.
f566d765
LC
2223
2224It is also possible to omit the endpoint. For example,
2225@code{--list-generations=2..}, returns all generations starting from the
2226second one.
2227
2228@item @emph{Durations}. You can also get the last @emph{N}@tie{}days, weeks,
2229or months by passing an integer along with the first letter of the
d7ddb257
LC
2230duration. For example, @code{--list-generations=20d} lists generations
2231that are up to 20 days old.
f566d765
LC
2232@end itemize
2233
b7884ca3
NK
2234@item --delete-generations[=@var{pattern}]
2235@itemx -d [@var{pattern}]
d7ddb257
LC
2236When @var{pattern} is omitted, delete all generations except the current
2237one.
b7884ca3
NK
2238
2239This command accepts the same patterns as @option{--list-generations}.
d7ddb257
LC
2240When @var{pattern} is specified, delete the matching generations. When
2241@var{pattern} specifies a duration, generations @emph{older} than the
2242specified duration match. For instance, @code{--delete-generations=1m}
2243deletes generations that are more than one month old.
2244
391bdd8f
LC
2245If the current generation matches, it is @emph{not} deleted. Also, the
2246zeroth generation is never deleted.
b7884ca3 2247
f97c9175 2248Note that deleting generations prevents rolling back to them.
1bb9900a
LC
2249Consequently, this command must be used with care.
2250
733b4130 2251@end table
eeaf4427 2252
70ee5642 2253Finally, since @command{guix package} may actually start build
ccd7158d 2254processes, it supports all the common build options (@pxref{Common Build
f97c9175 2255Options}). It also supports package transformation options, such as
b8638f03
LC
2256@option{--with-source} (@pxref{Package Transformation Options}).
2257However, note that package transformations are lost when upgrading; to
f97c9175 2258preserve transformations across upgrades, you should define your own
b8638f03
LC
2259package variant in a Guile module and add it to @code{GUIX_PACKAGE_PATH}
2260(@pxref{Defining Packages}).
2261
c4202d60
LC
2262@node Substitutes
2263@section Substitutes
2264
2265@cindex substitutes
2266@cindex pre-built binaries
2267Guix supports transparent source/binary deployment, which means that it
2268can either build things locally, or download pre-built items from a
77f92158
CM
2269server, or both. We call these pre-built items @dfn{substitutes}---they
2270are substitutes for local build results. In many cases, downloading a
c4202d60
LC
2271substitute is much faster than building things locally.
2272
2273Substitutes can be anything resulting from a derivation build
2274(@pxref{Derivations}). Of course, in the common case, they are
2275pre-built package binaries, but source tarballs, for instance, which
2276also result from derivation builds, can be available as substitutes.
2277
77f92158
CM
2278@menu
2279* Official Substitute Server:: One particular source of substitutes.
2280* Substitute Server Authorization:: How to enable or disable substitutes.
2281* Substitute Authentication:: How Guix verifies substitutes.
2282* Proxy Settings:: How to get substitutes via proxy.
2283* Substitution Failure:: What happens when substitution fails.
2284* On Trusting Binaries:: How can you trust that binary blob?
2285@end menu
2286
2287@node Official Substitute Server
2288@subsection Official Substitute Server
2289
2290@cindex hydra
2291@cindex build farm
39b27f4e
LC
2292The @code{mirror.hydra.gnu.org} server is a front-end to an official build farm
2293that builds packages from Guix continuously for some
deb6276d 2294architectures, and makes them available as substitutes. This is the
f8a8e0fe
LC
2295default source of substitutes; it can be overridden by passing the
2296@option{--substitute-urls} option either to @command{guix-daemon}
2297(@pxref{daemon-substitute-urls,, @code{guix-daemon --substitute-urls}})
2298or to client tools such as @command{guix package}
2299(@pxref{client-substitute-urls,, client @option{--substitute-urls}
2300option}).
c4202d60 2301
1dbe3a8d 2302Substitute URLs can be either HTTP or HTTPS.
9b7bd1b1
LC
2303HTTPS is recommended because communications are encrypted; conversely,
2304using HTTP makes all communications visible to an eavesdropper, who
2305could use the information gathered to determine, for instance, whether
2306your system has unpatched security vulnerabilities.
2307
77f92158
CM
2308Substitutes from the official build farm are enabled by default when
2309using the Guix System Distribution (@pxref{GNU Distribution}). However,
2310they are disabled by default when using Guix on a foreign distribution,
2311unless you have explicitly enabled them via one of the recommended
2312installation steps (@pxref{Installation}). The following paragraphs
2313describe how to enable or disable substitutes for the official build
2314farm; the same procedure can also be used to enable substitutes for any
2315other substitute server.
2316
2317@node Substitute Server Authorization
2318@subsection Substitute Server Authorization
2319
c4202d60 2320@cindex security
e32171ee 2321@cindex substitutes, authorization thereof
a9468b42
LC
2322@cindex access control list (ACL), for substitutes
2323@cindex ACL (access control list), for substitutes
df061d07
LC
2324To allow Guix to download substitutes from @code{hydra.gnu.org} or a
2325mirror thereof, you
c4202d60
LC
2326must add its public key to the access control list (ACL) of archive
2327imports, using the @command{guix archive} command (@pxref{Invoking guix
2328archive}). Doing so implies that you trust @code{hydra.gnu.org} to not
2329be compromised and to serve genuine substitutes.
2330
77f92158 2331The public key for @code{hydra.gnu.org} is installed along with Guix, in
c4202d60
LC
2332@code{@var{prefix}/share/guix/hydra.gnu.org.pub}, where @var{prefix} is
2333the installation prefix of Guix. If you installed Guix from source,
2334make sure you checked the GPG signature of
2335@file{guix-@value{VERSION}.tar.gz}, which contains this public key file.
2336Then, you can run something like this:
2337
2338@example
d65d7759 2339# guix archive --authorize < @var{prefix}/share/guix/hydra.gnu.org.pub
c4202d60
LC
2340@end example
2341
39b27f4e
LC
2342@quotation Note
2343Similarly, the @file{berlin.guixsd.org.pub} file contains the public key
2344for the project's new build farm, reachable at
2345@indicateurl{https://berlin.guixsd.org}.
2346
2347As of this writing @code{berlin.guixsd.org} is being upgraded so it can
2348better scale up, but you might want to give it a try. It is backed by
234920 x86_64/i686 build nodes and may be able to provide substitutes more
2350quickly than @code{mirror.hydra.gnu.org}.
2351@end quotation
2352
c4202d60
LC
2353Once this is in place, the output of a command like @code{guix build}
2354should change from something like:
2355
2356@example
2357$ guix build emacs --dry-run
2358The following derivations would be built:
2359 /gnu/store/yr7bnx8xwcayd6j95r2clmkdl1qh688w-emacs-24.3.drv
2360 /gnu/store/x8qsh1hlhgjx6cwsjyvybnfv2i37z23w-dbus-1.6.4.tar.gz.drv
2361 /gnu/store/1ixwp12fl950d15h2cj11c73733jay0z-alsa-lib-1.0.27.1.tar.bz2.drv
2362 /gnu/store/nlma1pw0p603fpfiqy7kn4zm105r5dmw-util-linux-2.21.drv
2363@dots{}
2364@end example
2365
2366@noindent
2367to something like:
2368
2369@example
2370$ guix build emacs --dry-run
39b27f4e 2371112.3 MB would be downloaded:
c4202d60
LC
2372 /gnu/store/pk3n22lbq6ydamyymqkkz7i69wiwjiwi-emacs-24.3
2373 /gnu/store/2ygn4ncnhrpr61rssa6z0d9x22si0va3-libjpeg-8d
2374 /gnu/store/71yz6lgx4dazma9dwn2mcjxaah9w77jq-cairo-1.12.16
2375 /gnu/store/7zdhgp0n1518lvfn8mb96sxqfmvqrl7v-libxrender-0.9.7
2376@dots{}
2377@end example
2378
2379@noindent
2380This indicates that substitutes from @code{hydra.gnu.org} are usable and
2381will be downloaded, when possible, for future builds.
2382
77f92158
CM
2383@cindex substitutes, how to disable
2384The substitute mechanism can be disabled globally by running
2385@code{guix-daemon} with @code{--no-substitutes} (@pxref{Invoking
2386guix-daemon}). It can also be disabled temporarily by passing the
2387@code{--no-substitutes} option to @command{guix package}, @command{guix
2388build}, and other command-line tools.
2389
2390@node Substitute Authentication
2391@subsection Substitute Authentication
2392
2393@cindex digital signatures
a9468b42
LC
2394Guix detects and raises an error when attempting to use a substitute
2395that has been tampered with. Likewise, it ignores substitutes that are
2396not signed, or that are not signed by one of the keys listed in the ACL.
2397
2398There is one exception though: if an unauthorized server provides
2399substitutes that are @emph{bit-for-bit identical} to those provided by
2400an authorized server, then the unauthorized server becomes eligible for
2401downloads. For example, assume we have chosen two substitute servers
2402with this option:
2403
2404@example
2405--substitute-urls="https://a.example.org https://b.example.org"
2406@end example
2407
2408@noindent
2409@cindex reproducible builds
2410If the ACL contains only the key for @code{b.example.org}, and if
2411@code{a.example.org} happens to serve the @emph{exact same} substitutes,
2412then Guix will download substitutes from @code{a.example.org} because it
2413comes first in the list and can be considered a mirror of
2414@code{b.example.org}. In practice, independent build machines usually
2415produce the same binaries, thanks to bit-reproducible builds (see
2416below).
c4202d60 2417
9b7bd1b1
LC
2418When using HTTPS, the server's X.509 certificate is @emph{not} validated
2419(in other words, the server is not authenticated), contrary to what
2420HTTPS clients such as Web browsers usually do. This is because Guix
2421authenticates substitute information itself, as explained above, which
2422is what we care about (whereas X.509 certificates are about
2423authenticating bindings between domain names and public keys.)
2424
77f92158
CM
2425@node Proxy Settings
2426@subsection Proxy Settings
c4202d60 2427
77f92158
CM
2428@vindex http_proxy
2429Substitutes are downloaded over HTTP or HTTPS.
2430The @code{http_proxy} environment
2431variable can be set in the environment of @command{guix-daemon} and is
2432honored for downloads of substitutes. Note that the value of
2433@code{http_proxy} in the environment where @command{guix build},
2434@command{guix package}, and other client commands are run has
2435@emph{absolutely no effect}.
9b7bd1b1 2436
77f92158
CM
2437@node Substitution Failure
2438@subsection Substitution Failure
2439
2440Even when a substitute for a derivation is available, sometimes the
2441substitution attempt will fail. This can happen for a variety of
2442reasons: the substitute server might be offline, the substitute may
2443recently have been deleted, the connection might have been interrupted,
2444etc.
2445
2446When substitutes are enabled and a substitute for a derivation is
2447available, but the substitution attempt fails, Guix will attempt to
2448build the derivation locally depending on whether or not
2449@code{--fallback} was given (@pxref{fallback-option,, common build
2450option @code{--fallback}}). Specifically, if @code{--fallback} was
2451omitted, then no local build will be performed, and the derivation is
2452considered to have failed. However, if @code{--fallback} was given,
2453then Guix will attempt to build the derivation locally, and the success
2454or failure of the derivation depends on the success or failure of the
2455local build. Note that when substitutes are disabled or no substitute
2456is available for the derivation in question, a local build will
2457@emph{always} be performed, regardless of whether or not
2458@code{--fallback} was given.
2459
2460To get an idea of how many substitutes are available right now, you can
2461try running the @command{guix weather} command (@pxref{Invoking guix
2462weather}). This command provides statistics on the substitutes provided
2463by a server.
2464
2465@node On Trusting Binaries
2466@subsection On Trusting Binaries
2467
2468@cindex trust, of pre-built binaries
c4202d60
LC
2469Today, each individual's control over their own computing is at the
2470mercy of institutions, corporations, and groups with enough power and
2471determination to subvert the computing infrastructure and exploit its
2472weaknesses. While using @code{hydra.gnu.org} substitutes can be
2473convenient, we encourage users to also build on their own, or even run
2474their own build farm, such that @code{hydra.gnu.org} is less of an
8ce229fc
LC
2475interesting target. One way to help is by publishing the software you
2476build using @command{guix publish} so that others have one more choice
2477of server to download substitutes from (@pxref{Invoking guix publish}).
c4202d60
LC
2478
2479Guix has the foundations to maximize build reproducibility
2480(@pxref{Features}). In most cases, independent builds of a given
2481package or derivation should yield bit-identical results. Thus, through
2482a diverse set of independent package builds, we can strengthen the
d23c20f1
LC
2483integrity of our systems. The @command{guix challenge} command aims to
2484help users assess substitute servers, and to assist developers in
2485finding out about non-deterministic package builds (@pxref{Invoking guix
a8d65643
LC
2486challenge}). Similarly, the @option{--check} option of @command{guix
2487build} allows users to check whether previously-installed substitutes
2488are genuine by rebuilding them locally (@pxref{build-check,
2489@command{guix build --check}}).
c4202d60
LC
2490
2491In the future, we want Guix to have support to publish and retrieve
2492binaries to/from other users, in a peer-to-peer fashion. If you would
2493like to discuss this project, join us on @email{guix-devel@@gnu.org}.
2494
6e721c4d
LC
2495@node Packages with Multiple Outputs
2496@section Packages with Multiple Outputs
2497
2498@cindex multiple-output packages
2499@cindex package outputs
e32171ee 2500@cindex outputs
6e721c4d
LC
2501
2502Often, packages defined in Guix have a single @dfn{output}---i.e., the
f97c9175 2503source package leads to exactly one directory in the store. When running
6e721c4d
LC
2504@command{guix package -i glibc}, one installs the default output of the
2505GNU libc package; the default output is called @code{out}, but its name
2506can be omitted as shown in this command. In this particular case, the
2507default output of @code{glibc} contains all the C header files, shared
2508libraries, static libraries, Info documentation, and other supporting
2509files.
2510
2511Sometimes it is more appropriate to separate the various types of files
2512produced from a single source package into separate outputs. For
2513instance, the GLib C library (used by GTK+ and related packages)
2514installs more than 20 MiB of reference documentation as HTML pages.
2515To save space for users who do not need it, the documentation goes to a
2516separate output, called @code{doc}. To install the main GLib output,
2517which contains everything but the documentation, one would run:
2518
2519@example
2520guix package -i glib
2521@end example
2522
e32171ee 2523@cindex documentation
6e721c4d
LC
2524The command to install its documentation is:
2525
2526@example
2527guix package -i glib:doc
2528@end example
2529
2530Some packages install programs with different ``dependency footprints''.
f97c9175 2531For instance, the WordNet package installs both command-line tools and
6e721c4d
LC
2532graphical user interfaces (GUIs). The former depend solely on the C
2533library, whereas the latter depend on Tcl/Tk and the underlying X
2534libraries. In this case, we leave the command-line tools in the default
2535output, whereas the GUIs are in a separate output. This allows users
fcc58db6
LC
2536who do not need the GUIs to save space. The @command{guix size} command
2537can help find out about such situations (@pxref{Invoking guix size}).
88856916 2538@command{guix graph} can also be helpful (@pxref{Invoking guix graph}).
6e721c4d
LC
2539
2540There are several such multiple-output packages in the GNU distribution.
91ef73d4
LC
2541Other conventional output names include @code{lib} for libraries and
2542possibly header files, @code{bin} for stand-alone programs, and
2543@code{debug} for debugging information (@pxref{Installing Debugging
2544Files}). The outputs of a packages are listed in the third column of
2545the output of @command{guix package --list-available} (@pxref{Invoking
2546guix package}).
6e721c4d 2547
eeaf4427 2548
e49951eb
MW
2549@node Invoking guix gc
2550@section Invoking @command{guix gc}
fe8ff028
LC
2551
2552@cindex garbage collector
e32171ee 2553@cindex disk space
f97c9175 2554Packages that are installed, but not used, may be @dfn{garbage-collected}.
e49951eb 2555The @command{guix gc} command allows users to explicitly run the garbage
c22eb992
LC
2556collector to reclaim space from the @file{/gnu/store} directory. It is
2557the @emph{only} way to remove files from @file{/gnu/store}---removing
2558files or directories manually may break it beyond repair!
fe8ff028 2559
6a98b9f3
LC
2560@cindex GC roots
2561@cindex garbage collector roots
fe8ff028 2562The garbage collector has a set of known @dfn{roots}: any file under
834129e0 2563@file{/gnu/store} reachable from a root is considered @dfn{live} and
fe8ff028 2564cannot be deleted; any other file is considered @dfn{dead} and may be
6a98b9f3
LC
2565deleted. The set of garbage collector roots (``GC roots'' for short)
2566includes default user profiles; by default, the symlinks under
2567@file{/var/guix/gcroots} represent these GC roots. New GC roots can be
2568added with @command{guix build --root}, for example (@pxref{Invoking
2569guix build}).
fe8ff028 2570
1bb9900a
LC
2571Prior to running @code{guix gc --collect-garbage} to make space, it is
2572often useful to remove old generations from user profiles; that way, old
2573package builds referenced by those generations can be reclaimed. This
2574is achieved by running @code{guix package --delete-generations}
2575(@pxref{Invoking guix package}).
2576
457103b9
LC
2577Our recommendation is to run a garbage collection periodically, or when
2578you are short on disk space. For instance, to guarantee that at least
25795@tie{}GB are available on your disk, simply run:
2580
2581@example
2582guix gc -F 5G
2583@end example
2584
2585It is perfectly safe to run as a non-interactive periodic job
2586(@pxref{Scheduled Job Execution}, for how to set up such a job on
2587GuixSD). Running @command{guix gc} with no arguments will collect as
2588much garbage as it can, but that is often inconvenient: you may find
2589yourself having to rebuild or re-download software that is ``dead'' from
2590the GC viewpoint but that is necessary to build other pieces of
2591software---e.g., the compiler tool chain.
2592
e49951eb 2593The @command{guix gc} command has three modes of operation: it can be
fe8ff028 2594used to garbage-collect any dead files (the default), to delete specific
7770aafc
LC
2595files (the @code{--delete} option), to print garbage-collector
2596information, or for more advanced queries. The garbage collection
2597options are as follows:
fe8ff028
LC
2598
2599@table @code
2600@item --collect-garbage[=@var{min}]
2601@itemx -C [@var{min}]
834129e0 2602Collect garbage---i.e., unreachable @file{/gnu/store} files and
fe8ff028
LC
2603sub-directories. This is the default operation when no option is
2604specified.
2605
2606When @var{min} is given, stop once @var{min} bytes have been collected.
2607@var{min} may be a number of bytes, or it may include a unit as a
4a44d7bb
LC
2608suffix, such as @code{MiB} for mebibytes and @code{GB} for gigabytes
2609(@pxref{Block size, size specifications,, coreutils, GNU Coreutils}).
fe8ff028
LC
2610
2611When @var{min} is omitted, collect all the garbage.
2612
0054e470
LC
2613@item --free-space=@var{free}
2614@itemx -F @var{free}
2615Collect garbage until @var{free} space is available under
2616@file{/gnu/store}, if possible; @var{free} denotes storage space, such
2617as @code{500MiB}, as described above.
2618
2619When @var{free} or more is already available in @file{/gnu/store}, do
2620nothing and exit immediately.
2621
fe8ff028
LC
2622@item --delete
2623@itemx -d
2624Attempt to delete all the store files and directories specified as
2625arguments. This fails if some of the files are not in the store, or if
2626they are still live.
2627
30d9aa54
LC
2628@item --list-failures
2629List store items corresponding to cached build failures.
2630
2631This prints nothing unless the daemon was started with
2632@option{--cache-failures} (@pxref{Invoking guix-daemon,
2633@option{--cache-failures}}).
2634
2635@item --clear-failures
2636Remove the specified store items from the failed-build cache.
2637
2638Again, this option only makes sense when the daemon is started with
2639@option{--cache-failures}. Otherwise, it does nothing.
2640
fe8ff028
LC
2641@item --list-dead
2642Show the list of dead files and directories still present in the
2643store---i.e., files and directories no longer reachable from any root.
2644
2645@item --list-live
2646Show the list of live store files and directories.
ba8b732d
LC
2647
2648@end table
2649
2650In addition, the references among existing store files can be queried:
2651
2652@table @code
2653
2654@item --references
2655@itemx --referrers
e32171ee 2656@cindex package dependencies
ba8b732d
LC
2657List the references (respectively, the referrers) of store files given
2658as arguments.
2659
8e59fdd5
LC
2660@item --requisites
2661@itemx -R
fcc58db6 2662@cindex closure
8e59fdd5
LC
2663List the requisites of the store files passed as arguments. Requisites
2664include the store files themselves, their references, and the references
2665of these, recursively. In other words, the returned list is the
2666@dfn{transitive closure} of the store files.
2667
f97c9175
AE
2668@xref{Invoking guix size}, for a tool to profile the size of the closure
2669of an element. @xref{Invoking guix graph}, for a tool to visualize
88856916 2670the graph of references.
fcc58db6 2671
8980eea5
LC
2672@item --derivers
2673@cindex derivation
2674Return the derivation(s) leading to the given store items
2675(@pxref{Derivations}).
2676
2677For example, this command:
2678
2679@example
2680guix gc --derivers `guix package -I ^emacs$ | cut -f4`
2681@end example
2682
2683@noindent
2684returns the @file{.drv} file(s) leading to the @code{emacs} package
2685installed in your profile.
2686
2687Note that there may be zero matching @file{.drv} files, for instance
2688because these files have been garbage-collected. There can also be more
2689than one matching @file{.drv} due to fixed-output derivations.
fe8ff028
LC
2690@end table
2691
7770aafc
LC
2692Lastly, the following options allow you to check the integrity of the
2693store and to control disk usage.
2694
2695@table @option
2696
2697@item --verify[=@var{options}]
2698@cindex integrity, of the store
2699@cindex integrity checking
2700Verify the integrity of the store.
2701
2702By default, make sure that all the store items marked as valid in the
f97c9175 2703database of the daemon actually exist in @file{/gnu/store}.
7770aafc 2704
f97c9175 2705When provided, @var{options} must be a comma-separated list containing one
7770aafc
LC
2706or more of @code{contents} and @code{repair}.
2707
7414de0a 2708When passing @option{--verify=contents}, the daemon computes the
f97c9175 2709content hash of each store item and compares it against its hash in the
7770aafc
LC
2710database. Hash mismatches are reported as data corruptions. Because it
2711traverses @emph{all the files in the store}, this command can take a
2712long time, especially on systems with a slow disk drive.
2713
2714@cindex repairing the store
6da5bb7b 2715@cindex corruption, recovering from
7770aafc
LC
2716Using @option{--verify=repair} or @option{--verify=contents,repair}
2717causes the daemon to try to repair corrupt store items by fetching
2718substitutes for them (@pxref{Substitutes}). Because repairing is not
2719atomic, and thus potentially dangerous, it is available only to the
6da5bb7b
LC
2720system administrator. A lightweight alternative, when you know exactly
2721which items in the store are corrupt, is @command{guix build --repair}
2722(@pxref{Invoking guix build}).
7770aafc
LC
2723
2724@item --optimize
2725@cindex deduplication
2726Optimize the store by hard-linking identical files---this is
2727@dfn{deduplication}.
2728
2729The daemon performs deduplication after each successful build or archive
2730import, unless it was started with @code{--disable-deduplication}
2731(@pxref{Invoking guix-daemon, @code{--disable-deduplication}}). Thus,
2732this option is primarily useful when the daemon was running with
2733@code{--disable-deduplication}.
2734
2735@end table
eeaf4427 2736
f651b477
LC
2737@node Invoking guix pull
2738@section Invoking @command{guix pull}
2739
e32171ee 2740@cindex upgrading Guix
7fcf2a0b 2741@cindex updating Guix
e32171ee
JD
2742@cindex @command{guix pull}
2743@cindex pull
f651b477
LC
2744Packages are installed or upgraded to the latest version available in
2745the distribution currently available on your local machine. To update
2746that distribution, along with the Guix tools, you must run @command{guix
2747pull}: the command downloads the latest Guix source code and package
59a16275
LC
2748descriptions, and deploys it. Source code is downloaded from a
2749@uref{https://git-scm.com, Git} repository.
f651b477
LC
2750
2751On completion, @command{guix package} will use packages and package
2752versions from this just-retrieved copy of Guix. Not only that, but all
2753the Guix commands and Scheme modules will also be taken from that latest
2754version. New @command{guix} sub-commands added by the update also
cb05108a
LC
2755become available.
2756
2757Any user can update their Guix copy using @command{guix pull}, and the
2758effect is limited to the user who run @command{guix pull}. For
2759instance, when user @code{root} runs @command{guix pull}, this has no
2760effect on the version of Guix that user @code{alice} sees, and vice
75e24d7b
LC
2761versa.
2762
2763The result of running @command{guix pull} is a @dfn{profile} available
2764under @file{~/.config/guix/current} containing the latest Guix. Thus,
2765make sure to add it to the beginning of your search path so that you use
2766the latest version, and similarly for the Info manual
2767(@pxref{Documentation}):
2768
2769@example
2770export PATH="$HOME/.config/guix/current/bin:$PATH"
2771export INFOPATH="$HOME/.config/guix/current/share/info:$INFOPATH"
2772@end example
2773
e2f8be06
LC
2774The @code{--list-generations} or @code{-l} option lists past generations
2775produced by @command{guix pull}, along with details about their provenance:
2776
2777@example
2778$ guix pull -l
2779Generation 1 Jun 10 2018 00:18:18
2780 guix 65956ad
2781 repository URL: https://git.savannah.gnu.org/git/guix.git
2782 branch: origin/master
2783 commit: 65956ad3526ba09e1f7a40722c96c6ef7c0936fe
2784
2785Generation 2 Jun 11 2018 11:02:49
2786 guix e0cc7f6
2787 repository URL: https://git.savannah.gnu.org/git/guix.git
2788 branch: origin/master
2789 commit: e0cc7f669bec22c37481dd03a7941c7d11a64f1d
dc733e6a
LC
2790 2 new packages: keepalived, libnfnetlink
2791 6 packages upgraded: emacs-nix-mode@@2.0.4,
2792 guile2.0-guix@@0.14.0-12.77a1aac, guix@@0.14.0-12.77a1aac,
2793 heimdal@@7.5.0, milkytracker@@1.02.00, nix@@2.0.4
e2f8be06
LC
2794
2795Generation 3 Jun 13 2018 23:31:07 (current)
2796 guix 844cc1c
2797 repository URL: https://git.savannah.gnu.org/git/guix.git
2798 branch: origin/master
2799 commit: 844cc1c8f394f03b404c5bb3aee086922373490c
dc733e6a
LC
2800 28 new packages: emacs-helm-ls-git, emacs-helm-mu, @dots{}
2801 69 packages upgraded: borg@@1.1.6, cheese@@3.28.0, @dots{}
e2f8be06
LC
2802@end example
2803
75e24d7b
LC
2804This @code{~/.config/guix/current} profile works like any other profile
2805created by @command{guix package} (@pxref{Invoking guix package}). That
2806is, you can list generations, roll back to the previous
2807generation---i.e., the previous Guix---and so on:
2808
2809@example
75e24d7b
LC
2810$ guix package -p ~/.config/guix/current --roll-back
2811switched from generation 3 to 2
e2f8be06
LC
2812$ guix package -p ~/.config/guix/current --delete-generations=1
2813deleting /home/charlie/.config/guix/current-1-link
75e24d7b 2814@end example
f651b477
LC
2815
2816The @command{guix pull} command is usually invoked with no arguments,
2817but it supports the following options:
2818
2819@table @code
2820@item --verbose
2821Produce verbose output, writing build logs to the standard error output.
2822
ab5d72ad 2823@item --url=@var{url}
59a16275 2824Download Guix from the Git repository at @var{url}.
ab5d72ad 2825
cca6941f 2826@vindex GUIX_PULL_URL
59a16275 2827By default, the source is taken from its canonical Git repository at
cca6941f
OP
2828@code{gnu.org}, for the stable branch of Guix. To use a different source,
2829set the @code{GUIX_PULL_URL} environment variable.
ab5d72ad 2830
59a16275
LC
2831@item --commit=@var{commit}
2832Deploy @var{commit}, a valid Git commit ID represented as a hexadecimal
2833string.
8a9cffb2 2834
59a16275
LC
2835@item --branch=@var{branch}
2836Deploy the tip of @var{branch}, the name of a Git branch available on
2837the repository at @var{url}.
8a9cffb2 2838
e2f8be06
LC
2839@item --list-generations[=@var{pattern}]
2840@itemx -l [@var{pattern}]
2841List all the generations of @file{~/.config/guix/current} or, if @var{pattern}
2842is provided, the subset of generations that match @var{pattern}.
2843The syntax of @var{pattern} is the same as with @code{guix package
2844--list-generations} (@pxref{Invoking guix package}).
2845
f651b477
LC
2846@item --bootstrap
2847Use the bootstrap Guile to build the latest Guix. This option is only
2848useful to Guix developers.
2849@end table
2850
4902d3c4
LC
2851In addition, @command{guix pull} supports all the common build options
2852(@pxref{Common Build Options}).
760c60d6 2853
239c2266
LC
2854@node Invoking guix pack
2855@section Invoking @command{guix pack}
2856
2857Occasionally you want to pass software to people who are not (yet!)
2858lucky enough to be using Guix. You'd tell them to run @command{guix
2859package -i @var{something}}, but that's not possible in this case. This
2860is where @command{guix pack} comes in.
2861
9d4399b8
LC
2862@quotation Note
2863If you are looking for ways to exchange binaries among machines that
2864already run Guix, @pxref{Invoking guix copy}, @ref{Invoking guix
2865publish}, and @ref{Invoking guix archive}.
2866@end quotation
2867
239c2266
LC
2868@cindex pack
2869@cindex bundle
2870@cindex application bundle
2871@cindex software bundle
2872The @command{guix pack} command creates a shrink-wrapped @dfn{pack} or
2873@dfn{software bundle}: it creates a tarball or some other archive
2874containing the binaries of the software you're interested in, and all
2875its dependencies. The resulting archive can be used on any machine that
2876does not have Guix, and people can run the exact same binaries as those
107b8da6
LC
2877you have with Guix. The pack itself is created in a bit-reproducible
2878fashion, so anyone can verify that it really contains the build results
2879that you pretend to be shipping.
239c2266
LC
2880
2881For example, to create a bundle containing Guile, Emacs, Geiser, and all
2882their dependencies, you can run:
2883
2884@example
2885$ guix pack guile emacs geiser
2886@dots{}
2887/gnu/store/@dots{}-pack.tar.gz
2888@end example
2889
2890The result here is a tarball containing a @file{/gnu/store} directory
2891with all the relevant packages. The resulting tarball contains a
2892@dfn{profile} with the three packages of interest; the profile is the
2893same as would be created by @command{guix package -i}. It is this
2894mechanism that is used to create Guix's own standalone binary tarball
2895(@pxref{Binary Installation}).
2896
5895ec8a
LC
2897Users of this pack would have to run
2898@file{/gnu/store/@dots{}-profile/bin/guile} to run Guile, which you may
2899find inconvenient. To work around it, you can create, say, a
2900@file{/opt/gnu/bin} symlink to the profile:
2901
2902@example
2903guix pack -S /opt/gnu/bin=bin guile emacs geiser
2904@end example
2905
2906@noindent
2907That way, users can happily type @file{/opt/gnu/bin/guile} and enjoy.
2908
47a60325
LC
2909@cindex relocatable binaries, with @command{guix pack}
2910What if the recipient of your pack does not have root privileges on
2911their machine, and thus cannot unpack it in the root file system? In
2912that case, you will want to use the @code{--relocatable} option (see
2913below). This option produces @dfn{relocatable binaries}, meaning they
2914they can be placed anywhere in the file system hierarchy: in the example
2915above, users can unpack your tarball in their home directory and
2916directly run @file{./opt/gnu/bin/guile}.
2917
ed71cda2 2918@cindex Docker, build an image with guix pack
708b54a9
LC
2919Alternatively, you can produce a pack in the Docker image format using
2920the following command:
b1edfbc3
LC
2921
2922@example
2923guix pack -f docker guile emacs geiser
2924@end example
2925
2926@noindent
2927The result is a tarball that can be passed to the @command{docker load}
2928command. See the
2929@uref{https://docs.docker.com/engine/reference/commandline/load/, Docker
2930documentation} for more information.
2931
b2817f0f
RW
2932@cindex Singularity, build an image with guix pack
2933@cindex SquashFS, build an image with guix pack
2934Yet another option is to produce a SquashFS image with the following
2935command:
2936
2937@example
2938guix pack -f squashfs guile emacs geiser
2939@end example
2940
2941@noindent
2942The result is a SquashFS file system image that can either be mounted or
2943directly be used as a file system container image with the
2944@uref{http://singularity.lbl.gov, Singularity container execution
2945environment}, using commands like @command{singularity shell} or
2946@command{singularity exec}.
2947
239c2266
LC
2948Several command-line options allow you to customize your pack:
2949
2950@table @code
708b54a9
LC
2951@item --format=@var{format}
2952@itemx -f @var{format}
2953Produce a pack in the given @var{format}.
2954
2955The available formats are:
2956
2957@table @code
2958@item tarball
2959This is the default format. It produces a tarball containing all the
7b14c48b 2960specified binaries and symlinks.
708b54a9
LC
2961
2962@item docker
2963This produces a tarball that follows the
2964@uref{https://github.com/docker/docker/blob/master/image/spec/v1.2.md,
2965Docker Image Specification}.
b2817f0f
RW
2966
2967@item squashfs
2968This produces a SquashFS image containing all the specified binaries and
2969symlinks, as well as empty mount points for virtual file systems like
2970procfs.
708b54a9
LC
2971@end table
2972
47a60325
LC
2973@item --relocatable
2974@itemx -R
2975Produce @dfn{relocatable binaries}---i.e., binaries that can be placed
2976anywhere in the file system hierarchy and run from there. For example,
2977if you create a pack containing Bash with:
2978
2979@example
2980guix pack -R -S /mybin=bin bash
2981@end example
2982
2983@noindent
2984... you can copy that pack to a machine that lacks Guix, and from your
2985home directory as a normal user, run:
2986
2987@example
2988tar xf pack.tar.gz
2989./mybin/sh
2990@end example
2991
2992@noindent
2993In that shell, if you type @code{ls /gnu/store}, you'll notice that
2994@file{/gnu/store} shows up and contains all the dependencies of
2995@code{bash}, even though the machine actually lacks @file{/gnu/store}
2996altogether! That is probably the simplest way to deploy Guix-built
2997software on a non-Guix machine.
2998
2999There's a gotcha though: this technique relies on the @dfn{user
3000namespace} feature of the kernel Linux, which allows unprivileged users
3001to mount or change root. Old versions of Linux did not support it, and
3002some GNU/Linux distributions turn it off; on these systems, programs
3003from the pack @emph{will fail to run}, unless they are unpacked in the
3004root file system.
3005
83cfa024
LC
3006@item --expression=@var{expr}
3007@itemx -e @var{expr}
3008Consider the package @var{expr} evaluates to.
3009
3010This has the same purpose as the same-named option in @command{guix
3011build} (@pxref{Additional Build Options, @code{--expression} in
3012@command{guix build}}).
3013
4a979afe
KH
3014@item --manifest=@var{file}
3015@itemx -m @var{file}
3016Use the packages contained in the manifest object returned by the Scheme
3017code in @var{file}.
3018
3019This has a similar purpose as the same-named option in @command{guix
3020package} (@pxref{profile-manifest, @option{--manifest}}) and uses the
3021same manifest files. It allows you to define a collection of packages
3022once and use it both for creating profiles and for creating archives
3023for use on machines that do not have Guix installed. Note that you can
3024specify @emph{either} a manifest file @emph{or} a list of packages,
3025but not both.
3026
239c2266
LC
3027@item --system=@var{system}
3028@itemx -s @var{system}
3029Attempt to build for @var{system}---e.g., @code{i686-linux}---instead of
3030the system type of the build host.
3031
5461115e
LC
3032@item --target=@var{triplet}
3033@cindex cross-compilation
3034Cross-build for @var{triplet}, which must be a valid GNU triplet, such
3035as @code{"mips64el-linux-gnu"} (@pxref{Specifying target triplets, GNU
3036configuration triplets,, autoconf, Autoconf}).
3037
239c2266
LC
3038@item --compression=@var{tool}
3039@itemx -C @var{tool}
3040Compress the resulting tarball using @var{tool}---one of @code{gzip},
af735661 3041@code{bzip2}, @code{xz}, @code{lzip}, or @code{none} for no compression.
6b63c43e 3042
5895ec8a
LC
3043@item --symlink=@var{spec}
3044@itemx -S @var{spec}
3045Add the symlinks specified by @var{spec} to the pack. This option can
3046appear several times.
3047
3048@var{spec} has the form @code{@var{source}=@var{target}}, where
3049@var{source} is the symlink that will be created and @var{target} is the
3050symlink target.
3051
3052For instance, @code{-S /opt/gnu/bin=bin} creates a @file{/opt/gnu/bin}
3053symlink pointing to the @file{bin} sub-directory of the profile.
3054
6b63c43e
LC
3055@item --localstatedir
3056Include the ``local state directory'', @file{/var/guix}, in the
3057resulting pack.
3058
3059@file{/var/guix} contains the store database (@pxref{The Store}) as well
3060as garbage-collector roots (@pxref{Invoking guix gc}). Providing it in
3061the pack means that the store is ``complete'' and manageable by Guix;
3062not providing it pack means that the store is ``dead'': items cannot be
3063added to it or removed from it after extraction of the pack.
3064
3065One use case for this is the Guix self-contained binary tarball
3066(@pxref{Binary Installation}).
272c0709
CM
3067
3068@item --bootstrap
3069Use the bootstrap binaries to build the pack. This option is only
3070useful to Guix developers.
239c2266
LC
3071@end table
3072
3073In addition, @command{guix pack} supports all the common build options
3074(@pxref{Common Build Options}) and all the package transformation
3075options (@pxref{Package Transformation Options}).
3076
3077
760c60d6
LC
3078@node Invoking guix archive
3079@section Invoking @command{guix archive}
3080
e32171ee
JD
3081@cindex @command{guix archive}
3082@cindex archive
760c60d6 3083The @command{guix archive} command allows users to @dfn{export} files
9d4399b8
LC
3084from the store into a single archive, and to later @dfn{import} them on
3085a machine that runs Guix.
760c60d6 3086In particular, it allows store files to be transferred from one machine
4d4c4816
AE
3087to the store on another machine.
3088
9d4399b8 3089@quotation Note
6628921a 3090If you're looking for a way to produce archives in a format suitable for
9d4399b8
LC
3091tools other than Guix, @pxref{Invoking guix pack}.
3092@end quotation
3093
e32171ee 3094@cindex exporting store items
4d4c4816
AE
3095To export store files as an archive to standard output, run:
3096
3097@example
3098guix archive --export @var{options} @var{specifications}...
3099@end example
3100
3101@var{specifications} may be either store file names or package
3102specifications, as for @command{guix package} (@pxref{Invoking guix
3103package}). For instance, the following command creates an archive
3104containing the @code{gui} output of the @code{git} package and the main
3105output of @code{emacs}:
3106
3107@example
3108guix archive --export git:gui /gnu/store/...-emacs-24.3 > great.nar
3109@end example
3110
3111If the specified packages are not built yet, @command{guix archive}
3112automatically builds them. The build process may be controlled with the
3113common build options (@pxref{Common Build Options}).
3114
3115To transfer the @code{emacs} package to a machine connected over SSH,
3116one would run:
760c60d6
LC
3117
3118@example
56607088 3119guix archive --export -r emacs | ssh the-machine guix archive --import
760c60d6
LC
3120@end example
3121
87236aed 3122@noindent
56607088
LC
3123Similarly, a complete user profile may be transferred from one machine
3124to another like this:
3125
3126@example
3127guix archive --export -r $(readlink -f ~/.guix-profile) | \
3128 ssh the-machine guix-archive --import
3129@end example
3130
3131@noindent
3132However, note that, in both examples, all of @code{emacs} and the
3133profile as well as all of their dependencies are transferred (due to
f97c9175
AE
3134@code{-r}), regardless of what is already available in the store on the
3135target machine. The @code{--missing} option can help figure out which
f11c444d
LC
3136items are missing from the target store. The @command{guix copy}
3137command simplifies and optimizes this whole process, so this is probably
3138what you should use in this case (@pxref{Invoking guix copy}).
87236aed 3139
5597b3ae
LC
3140@cindex nar, archive format
3141@cindex normalized archive (nar)
b1edfbc3 3142Archives are stored in the ``normalized archive'' or ``nar'' format, which is
5597b3ae 3143comparable in spirit to `tar', but with differences
0dbd88db 3144that make it more appropriate for our purposes. First, rather than
5597b3ae 3145recording all Unix metadata for each file, the nar format only mentions
0dbd88db
LC
3146the file type (regular, directory, or symbolic link); Unix permissions
3147and owner/group are dismissed. Second, the order in which directory
3148entries are stored always follows the order of file names according to
3149the C locale collation order. This makes archive production fully
3150deterministic.
3151
3152When exporting, the daemon digitally signs the contents of the archive,
3153and that digital signature is appended. When importing, the daemon
3154verifies the signature and rejects the import in case of an invalid
3155signature or if the signing key is not authorized.
760c60d6
LC
3156@c FIXME: Add xref to daemon doc about signatures.
3157
3158The main options are:
3159
3160@table @code
3161@item --export
3162Export the specified store files or packages (see below.) Write the
3163resulting archive to the standard output.
3164
56607088
LC
3165Dependencies are @emph{not} included in the output, unless
3166@code{--recursive} is passed.
3167
3168@item -r
3169@itemx --recursive
3170When combined with @code{--export}, this instructs @command{guix
3171archive} to include dependencies of the given items in the archive.
3172Thus, the resulting archive is self-contained: it contains the closure
3173of the exported store items.
3174
760c60d6
LC
3175@item --import
3176Read an archive from the standard input, and import the files listed
3177therein into the store. Abort if the archive has an invalid digital
f82cc5fd
LC
3178signature, or if it is signed by a public key not among the authorized
3179keys (see @code{--authorize} below.)
554f26ec 3180
87236aed
LC
3181@item --missing
3182Read a list of store file names from the standard input, one per line,
3183and write on the standard output the subset of these files missing from
3184the store.
3185
554f26ec 3186@item --generate-key[=@var{parameters}]
f82cc5fd 3187@cindex signing, archives
f97c9175 3188Generate a new key pair for the daemon. This is a prerequisite before
554f26ec
LC
3189archives can be exported with @code{--export}. Note that this operation
3190usually takes time, because it needs to gather enough entropy to
3191generate the key pair.
3192
3193The generated key pair is typically stored under @file{/etc/guix}, in
3194@file{signing-key.pub} (public key) and @file{signing-key.sec} (private
867d8473
LC
3195key, which must be kept secret.) When @var{parameters} is omitted,
3196an ECDSA key using the Ed25519 curve is generated, or, for Libgcrypt
3197versions before 1.6.0, it is a 4096-bit RSA key.
f97c9175 3198Alternatively, @var{parameters} can specify
554f26ec
LC
3199@code{genkey} parameters suitable for Libgcrypt (@pxref{General
3200public-key related Functions, @code{gcry_pk_genkey},, gcrypt, The
3201Libgcrypt Reference Manual}).
f82cc5fd
LC
3202
3203@item --authorize
3204@cindex authorizing, archives
3205Authorize imports signed by the public key passed on standard input.
3206The public key must be in ``s-expression advanced format''---i.e., the
3207same format as the @file{signing-key.pub} file.
3208
3209The list of authorized keys is kept in the human-editable file
3210@file{/etc/guix/acl}. The file contains
3211@url{http://people.csail.mit.edu/rivest/Sexp.txt, ``advanced-format
3212s-expressions''} and is structured as an access-control list in the
3213@url{http://theworld.com/~cme/spki.txt, Simple Public-Key Infrastructure
3214(SPKI)}.
c6f8e9dd
LC
3215
3216@item --extract=@var{directory}
3217@itemx -x @var{directory}
3218Read a single-item archive as served by substitute servers
3219(@pxref{Substitutes}) and extract it to @var{directory}. This is a
3220low-level operation needed in only very narrow use cases; see below.
3221
3222For example, the following command extracts the substitute for Emacs
3223served by @code{hydra.gnu.org} to @file{/tmp/emacs}:
3224
3225@example
3226$ wget -O - \
df061d07 3227 https://hydra.gnu.org/nar/@dots{}-emacs-24.5 \
c6f8e9dd
LC
3228 | bunzip2 | guix archive -x /tmp/emacs
3229@end example
3230
3231Single-item archives are different from multiple-item archives produced
3232by @command{guix archive --export}; they contain a single store item,
3233and they do @emph{not} embed a signature. Thus this operation does
3234@emph{no} signature verification and its output should be considered
3235unsafe.
3236
3237The primary purpose of this operation is to facilitate inspection of
3238archive contents coming from possibly untrusted substitute servers.
3239
760c60d6
LC
3240@end table
3241
568717fd
LC
3242@c *********************************************************************
3243@node Programming Interface
3244@chapter Programming Interface
3245
3dc1970d
LC
3246GNU Guix provides several Scheme programming interfaces (APIs) to
3247define, build, and query packages. The first interface allows users to
3248write high-level package definitions. These definitions refer to
3249familiar packaging concepts, such as the name and version of a package,
3250its build system, and its dependencies. These definitions can then be
3251turned into concrete build actions.
3252
ba55b1cb 3253Build actions are performed by the Guix daemon, on behalf of users. In a
3dc1970d 3254standard setup, the daemon has write access to the store---the
834129e0 3255@file{/gnu/store} directory---whereas users do not. The recommended
3dc1970d
LC
3256setup also has the daemon perform builds in chroots, under a specific
3257build users, to minimize interference with the rest of the system.
3258
3259@cindex derivation
3260Lower-level APIs are available to interact with the daemon and the
3261store. To instruct the daemon to perform a build action, users actually
3262provide it with a @dfn{derivation}. A derivation is a low-level
3263representation of the build actions to be taken, and the environment in
3264which they should occur---derivations are to package definitions what
49ad317a
LC
3265assembly is to C programs. The term ``derivation'' comes from the fact
3266that build results @emph{derive} from them.
3dc1970d
LC
3267
3268This chapter describes all these APIs in turn, starting from high-level
3269package definitions.
3270
568717fd 3271@menu
b860f382 3272* Defining Packages:: Defining new packages.
7458bd0a 3273* Build Systems:: Specifying how packages are built.
b860f382
LC
3274* The Store:: Manipulating the package store.
3275* Derivations:: Low-level interface to package derivations.
3276* The Store Monad:: Purely functional interface to the store.
21b679f6 3277* G-Expressions:: Manipulating build expressions.
2ca299ca 3278* Invoking guix repl:: Fiddling with Guix interactively.
568717fd
LC
3279@end menu
3280
3281@node Defining Packages
3282@section Defining Packages
3283
3dc1970d
LC
3284The high-level interface to package definitions is implemented in the
3285@code{(guix packages)} and @code{(guix build-system)} modules. As an
3286example, the package definition, or @dfn{recipe}, for the GNU Hello
3287package looks like this:
3288
3289@example
e7f34eb0
LC
3290(define-module (gnu packages hello)
3291 #:use-module (guix packages)
3292 #:use-module (guix download)
3293 #:use-module (guix build-system gnu)
a6dcdcac
SB
3294 #:use-module (guix licenses)
3295 #:use-module (gnu packages gawk))
b22a12fd 3296
79f5dd59 3297(define-public hello
3dc1970d
LC
3298 (package
3299 (name "hello")
17d8e33f 3300 (version "2.10")
3dc1970d 3301 (source (origin
17d8e33f
ML
3302 (method url-fetch)
3303 (uri (string-append "mirror://gnu/hello/hello-" version
3304 ".tar.gz"))
3305 (sha256
3306 (base32
3307 "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i"))))
3dc1970d 3308 (build-system gnu-build-system)
654c0d97 3309 (arguments '(#:configure-flags '("--enable-silent-rules")))
3dc1970d 3310 (inputs `(("gawk" ,gawk)))
7458bd0a
LC
3311 (synopsis "Hello, GNU world: An example GNU package")
3312 (description "Guess what GNU Hello prints!")
3dc1970d 3313 (home-page "http://www.gnu.org/software/hello/")
b22a12fd 3314 (license gpl3+)))
3dc1970d
LC
3315@end example
3316
3317@noindent
3318Without being a Scheme expert, the reader may have guessed the meaning
f97c9175
AE
3319of the various fields here. This expression binds the variable
3320@code{hello} to a @code{<package>} object, which is essentially a record
3dc1970d
LC
3321(@pxref{SRFI-9, Scheme records,, guile, GNU Guile Reference Manual}).
3322This package object can be inspected using procedures found in the
3323@code{(guix packages)} module; for instance, @code{(package-name hello)}
3324returns---surprise!---@code{"hello"}.
3325
2f7d2d91
LC
3326With luck, you may be able to import part or all of the definition of
3327the package you are interested in from another repository, using the
3328@code{guix import} command (@pxref{Invoking guix import}).
3329
f97c9175 3330In the example above, @var{hello} is defined in a module of its own,
e7f34eb0
LC
3331@code{(gnu packages hello)}. Technically, this is not strictly
3332necessary, but it is convenient to do so: all the packages defined in
3333modules under @code{(gnu packages @dots{})} are automatically known to
3334the command-line tools (@pxref{Package Modules}).
3335
3dc1970d
LC
3336There are a few points worth noting in the above package definition:
3337
3338@itemize
3339@item
a2bf4907
LC
3340The @code{source} field of the package is an @code{<origin>} object
3341(@pxref{origin Reference}, for the complete reference).
3dc1970d
LC
3342Here, the @code{url-fetch} method from @code{(guix download)} is used,
3343meaning that the source is a file to be downloaded over FTP or HTTP.
3344
3345The @code{mirror://gnu} prefix instructs @code{url-fetch} to use one of
3346the GNU mirrors defined in @code{(guix download)}.
3347
3348The @code{sha256} field specifies the expected SHA256 hash of the file
3349being downloaded. It is mandatory, and allows Guix to check the
3350integrity of the file. The @code{(base32 @dots{})} form introduces the
6c365eca 3351base32 representation of the hash. You can obtain this information with
210cc920
LC
3352@code{guix download} (@pxref{Invoking guix download}) and @code{guix
3353hash} (@pxref{Invoking guix hash}).
3dc1970d 3354
f9cc8971
LC
3355@cindex patches
3356When needed, the @code{origin} form can also have a @code{patches} field
3357listing patches to be applied, and a @code{snippet} field giving a
3358Scheme expression to modify the source code.
3359
3dc1970d
LC
3360@item
3361@cindex GNU Build System
7458bd0a
LC
3362The @code{build-system} field specifies the procedure to build the
3363package (@pxref{Build Systems}). Here, @var{gnu-build-system}
3364represents the familiar GNU Build System, where packages may be
3365configured, built, and installed with the usual @code{./configure &&
3366make && make check && make install} command sequence.
3367
3368@item
3369The @code{arguments} field specifies options for the build system
3370(@pxref{Build Systems}). Here it is interpreted by
3371@var{gnu-build-system} as a request run @file{configure} with the
3372@code{--enable-silent-rules} flag.
3dc1970d 3373
654c0d97
LC
3374@cindex quote
3375@cindex quoting
3376@findex '
3377@findex quote
3378What about these quote (@code{'}) characters? They are Scheme syntax to
3379introduce a literal list; @code{'} is synonymous with @code{quote}.
3380@xref{Expression Syntax, quoting,, guile, GNU Guile Reference Manual},
3381for details. Here the value of the @code{arguments} field is a list of
3382arguments passed to the build system down the road, as with @code{apply}
3383(@pxref{Fly Evaluation, @code{apply},, guile, GNU Guile Reference
3384Manual}).
3385
3386The hash-colon (@code{#:}) sequence defines a Scheme @dfn{keyword}
3387(@pxref{Keywords,,, guile, GNU Guile Reference Manual}), and
3388@code{#:configure-flags} is a keyword used to pass a keyword argument
3389to the build system (@pxref{Coding With Keywords,,, guile, GNU Guile
3390Reference Manual}).
3391
3dc1970d
LC
3392@item
3393The @code{inputs} field specifies inputs to the build process---i.e.,
3394build-time or run-time dependencies of the package. Here, we define an
3395input called @code{"gawk"} whose value is that of the @var{gawk}
3396variable; @var{gawk} is itself bound to a @code{<package>} object.
3397
654c0d97
LC
3398@cindex backquote (quasiquote)
3399@findex `
3400@findex quasiquote
3401@cindex comma (unquote)
3402@findex ,
3403@findex unquote
3404@findex ,@@
3405@findex unquote-splicing
3406Again, @code{`} (a backquote, synonymous with @code{quasiquote}) allows
3407us to introduce a literal list in the @code{inputs} field, while
3408@code{,} (a comma, synonymous with @code{unquote}) allows us to insert a
3409value in that list (@pxref{Expression Syntax, unquote,, guile, GNU Guile
3410Reference Manual}).
3411
3dc1970d
LC
3412Note that GCC, Coreutils, Bash, and other essential tools do not need to
3413be specified as inputs here. Instead, @var{gnu-build-system} takes care
7458bd0a 3414of ensuring that they are present (@pxref{Build Systems}).
3dc1970d
LC
3415
3416However, any other dependencies need to be specified in the
3417@code{inputs} field. Any dependency not specified here will simply be
3418unavailable to the build process, possibly leading to a build failure.
3419@end itemize
3420
87eafdbd
TUBK
3421@xref{package Reference}, for a full description of possible fields.
3422
2f7d2d91 3423Once a package definition is in place, the
e49951eb 3424package may actually be built using the @code{guix build} command-line
fc06b15e
AP
3425tool (@pxref{Invoking guix build}), troubleshooting any build failures
3426you encounter (@pxref{Debugging Build Failures}). You can easily jump back to the
39bee8a2
LC
3427package definition using the @command{guix edit} command
3428(@pxref{Invoking guix edit}).
3429@xref{Packaging Guidelines}, for
b4f5e0e8
CR
3430more information on how to test package definitions, and
3431@ref{Invoking guix lint}, for information on how to check a definition
3432for style conformance.
b7ebcfe3
LC
3433@vindex GUIX_PACKAGE_PATH
3434Lastly, @pxref{Package Modules}, for information
3435on how to extend the distribution by adding your own package definitions
3436to @code{GUIX_PACKAGE_PATH}.
b4f5e0e8 3437
f97c9175 3438Finally, updating the package definition to a new upstream version
7458bd0a
LC
3439can be partly automated by the @command{guix refresh} command
3440(@pxref{Invoking guix refresh}).
3dc1970d
LC
3441
3442Behind the scenes, a derivation corresponding to the @code{<package>}
3443object is first computed by the @code{package-derivation} procedure.
834129e0 3444That derivation is stored in a @code{.drv} file under @file{/gnu/store}.
ba55b1cb 3445The build actions it prescribes may then be realized by using the
3dc1970d
LC
3446@code{build-derivations} procedure (@pxref{The Store}).
3447
3448@deffn {Scheme Procedure} package-derivation @var{store} @var{package} [@var{system}]
59688fc4
LC
3449Return the @code{<derivation>} object of @var{package} for @var{system}
3450(@pxref{Derivations}).
3dc1970d
LC
3451
3452@var{package} must be a valid @code{<package>} object, and @var{system}
3453must be a string denoting the target system type---e.g.,
3454@code{"x86_64-linux"} for an x86_64 Linux-based GNU system. @var{store}
3455must be a connection to the daemon, which operates on the store
3456(@pxref{The Store}).
3457@end deffn
568717fd 3458
9c1edabd
LC
3459@noindent
3460@cindex cross-compilation
3461Similarly, it is possible to compute a derivation that cross-builds a
3462package for some other system:
3463
3464@deffn {Scheme Procedure} package-cross-derivation @var{store} @
3465 @var{package} @var{target} [@var{system}]
59688fc4
LC
3466Return the @code{<derivation>} object of @var{package} cross-built from
3467@var{system} to @var{target}.
9c1edabd
LC
3468
3469@var{target} must be a valid GNU triplet denoting the target hardware
3470and operating system, such as @code{"mips64el-linux-gnu"}
3471(@pxref{Configuration Names, GNU configuration triplets,, configure, GNU
3472Configure and Build System}).
3473@end deffn
3474
2a75b0b6
LC
3475@cindex package transformations
3476@cindex input rewriting
3477@cindex dependency tree rewriting
3478Packages can be manipulated in arbitrary ways. An example of a useful
3479transformation is @dfn{input rewriting}, whereby the dependency tree of
3480a package is rewritten by replacing specific inputs by others:
3481
3482@deffn {Scheme Procedure} package-input-rewriting @var{replacements} @
3483 [@var{rewrite-name}]
3484Return a procedure that, when passed a package, replaces its direct and
3485indirect dependencies (but not its implicit inputs) according to
3486@var{replacements}. @var{replacements} is a list of package pairs; the
3487first element of each pair is the package to replace, and the second one
3488is the replacement.
3489
3490Optionally, @var{rewrite-name} is a one-argument procedure that takes
3491the name of a package and returns its new name after rewrite.
3492@end deffn
3493
3494@noindent
3495Consider this example:
3496
3497@example
3498(define libressl-instead-of-openssl
3499 ;; This is a procedure to replace OPENSSL by LIBRESSL,
3500 ;; recursively.
3501 (package-input-rewriting `((,openssl . ,libressl))))
3502
3503(define git-with-libressl
3504 (libressl-instead-of-openssl git))
3505@end example
3506
3507@noindent
3508Here we first define a rewriting procedure that replaces @var{openssl}
3509with @var{libressl}. Then we use it to define a @dfn{variant} of the
3510@var{git} package that uses @var{libressl} instead of @var{openssl}.
3511This is exactly what the @option{--with-input} command-line option does
3512(@pxref{Package Transformation Options, @option{--with-input}}).
3513
f37f2b83
LC
3514A more generic procedure to rewrite a package dependency graph is
3515@code{package-mapping}: it supports arbitrary changes to nodes in the
3516graph.
3517
3518@deffn {Scheme Procedure} package-mapping @var{proc} [@var{cut?}]
3519Return a procedure that, given a package, applies @var{proc} to all the packages
3520depended on and returns the resulting package. The procedure stops recursion
3521when @var{cut?} returns true for a given package.
3522@end deffn
3523
87eafdbd 3524@menu
fa4ebd2f 3525* package Reference:: The package data type.
87eafdbd
TUBK
3526* origin Reference:: The origin data type.
3527@end menu
3528
3529
3530@node package Reference
3531@subsection @code{package} Reference
3532
3533This section summarizes all the options available in @code{package}
3534declarations (@pxref{Defining Packages}).
3535
3536@deftp {Data Type} package
3537This is the data type representing a package recipe.
3538
3539@table @asis
3540@item @code{name}
3541The name of the package, as a string.
3542
3543@item @code{version}
3544The version of the package, as a string.
3545
3546@item @code{source}
da675305
LC
3547An object telling how the source code for the package should be
3548acquired. Most of the time, this is an @code{origin} object, which
3549denotes a file fetched from the Internet (@pxref{origin Reference}). It
3550can also be any other ``file-like'' object such as a @code{local-file},
3551which denotes a file from the local file system (@pxref{G-Expressions,
3552@code{local-file}}).
87eafdbd
TUBK
3553
3554@item @code{build-system}
3555The build system that should be used to build the package (@pxref{Build
3556Systems}).
3557
3558@item @code{arguments} (default: @code{'()})
3559The arguments that should be passed to the build system. This is a
3560list, typically containing sequential keyword-value pairs.
3561
3562@item @code{inputs} (default: @code{'()})
70650c68
LC
3563@itemx @code{native-inputs} (default: @code{'()})
3564@itemx @code{propagated-inputs} (default: @code{'()})
3565@cindex inputs, of packages
3566These fields list dependencies of the package. Each one is a list of
3567tuples, where each tuple has a label for the input (a string) as its
3568first element, a package, origin, or derivation as its second element,
3569and optionally the name of the output thereof that should be used, which
3570defaults to @code{"out"} (@pxref{Packages with Multiple Outputs}, for
f97c9175 3571more on package outputs). For example, the list below specifies three
70650c68 3572inputs:
87eafdbd 3573
70650c68
LC
3574@example
3575`(("libffi" ,libffi)
3576 ("libunistring" ,libunistring)
3577 ("glib:bin" ,glib "bin")) ;the "bin" output of Glib
3578@end example
3579
3580@cindex cross compilation, package dependencies
3581The distinction between @code{native-inputs} and @code{inputs} is
3582necessary when considering cross-compilation. When cross-compiling,
3583dependencies listed in @code{inputs} are built for the @emph{target}
3584architecture; conversely, dependencies listed in @code{native-inputs}
3585are built for the architecture of the @emph{build} machine.
3586
f97c9175
AE
3587@code{native-inputs} is typically used to list tools needed at
3588build time, but not at run time, such as Autoconf, Automake, pkg-config,
70650c68
LC
3589Gettext, or Bison. @command{guix lint} can report likely mistakes in
3590this area (@pxref{Invoking guix lint}).
3591
3592@anchor{package-propagated-inputs}
3593Lastly, @code{propagated-inputs} is similar to @code{inputs}, but the
f97c9175
AE
3594specified packages will be automatically installed alongside the package
3595they belong to (@pxref{package-cmd-propagated-inputs, @command{guix
70650c68
LC
3596package}}, for information on how @command{guix package} deals with
3597propagated inputs.)
21461f27 3598
e0508b6b
LC
3599For example this is necessary when a C/C++ library needs headers of
3600another library to compile, or when a pkg-config file refers to another
3601one @i{via} its @code{Requires} field.
3602
f97c9175
AE
3603Another example where @code{propagated-inputs} is useful is for languages
3604that lack a facility to record the run-time search path akin to the
c8ebb4c4 3605@code{RUNPATH} of ELF files; this includes Guile, Python, Perl, and
e0508b6b
LC
3606more. To ensure that libraries written in those languages can find
3607library code they depend on at run time, run-time dependencies must be
3608listed in @code{propagated-inputs} rather than @code{inputs}.
87eafdbd 3609
87eafdbd
TUBK
3610@item @code{self-native-input?} (default: @code{#f})
3611This is a Boolean field telling whether the package should use itself as
3612a native input when cross-compiling.
3613
3614@item @code{outputs} (default: @code{'("out")})
3615The list of output names of the package. @xref{Packages with Multiple
3616Outputs}, for typical uses of additional outputs.
3617
3618@item @code{native-search-paths} (default: @code{'()})
3619@itemx @code{search-paths} (default: @code{'()})
3620A list of @code{search-path-specification} objects describing
3621search-path environment variables honored by the package.
3622
3623@item @code{replacement} (default: @code{#f})
f97c9175 3624This must be either @code{#f} or a package object that will be used as a
87eafdbd
TUBK
3625@dfn{replacement} for this package. @xref{Security Updates, grafts},
3626for details.
3627
3628@item @code{synopsis}
3629A one-line description of the package.
3630
3631@item @code{description}
3632A more elaborate description of the package.
3633
3634@item @code{license}
e32171ee 3635@cindex license, of packages
f97c9175
AE
3636The license of the package; a value from @code{(guix licenses)},
3637or a list of such values.
87eafdbd
TUBK
3638
3639@item @code{home-page}
3640The URL to the home-page of the package, as a string.
3641
3642@item @code{supported-systems} (default: @var{%supported-systems})
3643The list of systems supported by the package, as strings of the form
3644@code{architecture-kernel}, for example @code{"x86_64-linux"}.
3645
3646@item @code{maintainers} (default: @code{'()})
3647The list of maintainers of the package, as @code{maintainer} objects.
3648
3649@item @code{location} (default: source location of the @code{package} form)
f97c9175 3650The source location of the package. It is useful to override this when
87eafdbd
TUBK
3651inheriting from another package, in which case this field is not
3652automatically corrected.
3653@end table
3654@end deftp
3655
3656
3657@node origin Reference
3658@subsection @code{origin} Reference
3659
3660This section summarizes all the options available in @code{origin}
3661declarations (@pxref{Defining Packages}).
3662
3663@deftp {Data Type} origin
3664This is the data type representing a source code origin.
3665
3666@table @asis
3667@item @code{uri}
3668An object containing the URI of the source. The object type depends on
3669the @code{method} (see below). For example, when using the
3670@var{url-fetch} method of @code{(guix download)}, the valid @code{uri}
3671values are: a URL represented as a string, or a list thereof.
3672
3673@item @code{method}
f97c9175 3674A procedure that handles the URI.
87eafdbd
TUBK
3675
3676Examples include:
3677
3678@table @asis
3679@item @var{url-fetch} from @code{(guix download)}
f97c9175 3680download a file from the HTTP, HTTPS, or FTP URL specified in the
87eafdbd
TUBK
3681@code{uri} field;
3682
db97a03a 3683@vindex git-fetch
87eafdbd
TUBK
3684@item @var{git-fetch} from @code{(guix git-download)}
3685clone the Git version control repository, and check out the revision
3686specified in the @code{uri} field as a @code{git-reference} object; a
3687@code{git-reference} looks like this:
3688
3689@example
3690(git-reference
3691 (url "git://git.debian.org/git/pkg-shadow/shadow")
3692 (commit "v4.1.5.1"))
3693@end example
3694@end table
3695
3696@item @code{sha256}
3697A bytevector containing the SHA-256 hash of the source. Typically the
3698@code{base32} form is used here to generate the bytevector from a
3699base-32 string.
3700
db97a03a
LC
3701You can obtain this information using @code{guix download}
3702(@pxref{Invoking guix download}) or @code{guix hash} (@pxref{Invoking
3703guix hash}).
3704
87eafdbd
TUBK
3705@item @code{file-name} (default: @code{#f})
3706The file name under which the source code should be saved. When this is
3707@code{#f}, a sensible default value will be used in most cases. In case
3708the source is fetched from a URL, the file name from the URL will be
f97c9175 3709used. For version control checkouts, it is recommended to provide the
87eafdbd
TUBK
3710file name explicitly because the default is not very descriptive.
3711
3712@item @code{patches} (default: @code{'()})
ec5495ba
LC
3713A list of file names, origins, or file-like objects (@pxref{G-Expressions,
3714file-like objects}) pointing to patches to be applied to the source.
87eafdbd 3715
0dfebdaa
LC
3716This list of patches must be unconditional. In particular, it cannot
3717depend on the value of @code{%current-system} or
3718@code{%current-target-system}.
3719
87eafdbd 3720@item @code{snippet} (default: @code{#f})
1929fdba
LC
3721A G-expression (@pxref{G-Expressions}) or S-expression that will be run
3722in the source directory. This is a convenient way to modify the source,
3723sometimes more convenient than a patch.
87eafdbd
TUBK
3724
3725@item @code{patch-flags} (default: @code{'("-p1")})
3726A list of command-line flags that should be passed to the @code{patch}
3727command.
3728
3729@item @code{patch-inputs} (default: @code{#f})
3730Input packages or derivations to the patching process. When this is
3731@code{#f}, the usual set of inputs necessary for patching are provided,
3732such as GNU@tie{}Patch.
3733
3734@item @code{modules} (default: @code{'()})
3735A list of Guile modules that should be loaded during the patching
3736process and while running the code in the @code{snippet} field.
3737
87eafdbd
TUBK
3738@item @code{patch-guile} (default: @code{#f})
3739The Guile package that should be used in the patching process. When
3740this is @code{#f}, a sensible default is used.
3741@end table
3742@end deftp
3743
9c1edabd 3744
7458bd0a
LC
3745@node Build Systems
3746@section Build Systems
3747
3748@cindex build system
3749Each package definition specifies a @dfn{build system} and arguments for
3750that build system (@pxref{Defining Packages}). This @code{build-system}
f97c9175 3751field represents the build procedure of the package, as well as implicit
7458bd0a
LC
3752dependencies of that build procedure.
3753
3754Build systems are @code{<build-system>} objects. The interface to
3755create and manipulate them is provided by the @code{(guix build-system)}
3756module, and actual build systems are exported by specific modules.
3757
f5fd4fd2 3758@cindex bag (low-level package representation)
0d5a559f
LC
3759Under the hood, build systems first compile package objects to
3760@dfn{bags}. A @dfn{bag} is like a package, but with less
3761ornamentation---in other words, a bag is a lower-level representation of
3762a package, which includes all the inputs of that package, including some
3763that were implicitly added by the build system. This intermediate
3764representation is then compiled to a derivation (@pxref{Derivations}).
3765
7458bd0a
LC
3766Build systems accept an optional list of @dfn{arguments}. In package
3767definitions, these are passed @i{via} the @code{arguments} field
3768(@pxref{Defining Packages}). They are typically keyword arguments
3769(@pxref{Optional Arguments, keyword arguments in Guile,, guile, GNU
3770Guile Reference Manual}). The value of these arguments is usually
3771evaluated in the @dfn{build stratum}---i.e., by a Guile process launched
3772by the daemon (@pxref{Derivations}).
3773
3774The main build system is @var{gnu-build-system}, which implements the
f97c9175 3775standard build procedure for GNU and many other packages. It
7458bd0a
LC
3776is provided by the @code{(guix build-system gnu)} module.
3777
3778@defvr {Scheme Variable} gnu-build-system
3779@var{gnu-build-system} represents the GNU Build System, and variants
3780thereof (@pxref{Configuration, configuration and makefile conventions,,
3781standards, GNU Coding Standards}).
3782
3783@cindex build phases
f97c9175 3784In a nutshell, packages using it are configured, built, and installed with
7458bd0a
LC
3785the usual @code{./configure && make && make check && make install}
3786command sequence. In practice, a few additional steps are often needed.
3787All these steps are split up in separate @dfn{phases},
3788notably@footnote{Please see the @code{(guix build gnu-build-system)}
3789modules for more details about the build phases.}:
3790
3791@table @code
3792@item unpack
3793Unpack the source tarball, and change the current directory to the
3794extracted source tree. If the source is actually a directory, copy it
3795to the build tree, and enter that directory.
3796
3797@item patch-source-shebangs
3798Patch shebangs encountered in source files so they refer to the right
3799store file names. For instance, this changes @code{#!/bin/sh} to
3800@code{#!/gnu/store/@dots{}-bash-4.3/bin/sh}.
3801
3802@item configure
3803Run the @file{configure} script with a number of default options, such
3804as @code{--prefix=/gnu/store/@dots{}}, as well as the options specified
3805by the @code{#:configure-flags} argument.
3806
3807@item build
3808Run @code{make} with the list of flags specified with
0917e80e 3809@code{#:make-flags}. If the @code{#:parallel-build?} argument is true
7458bd0a
LC
3810(the default), build with @code{make -j}.
3811
3812@item check
3813Run @code{make check}, or some other target specified with
3814@code{#:test-target}, unless @code{#:tests? #f} is passed. If the
3815@code{#:parallel-tests?} argument is true (the default), run @code{make
3816check -j}.
3817
3818@item install
3819Run @code{make install} with the flags listed in @code{#:make-flags}.
3820
3821@item patch-shebangs
3822Patch shebangs on the installed executable files.
3823
3824@item strip
3825Strip debugging symbols from ELF files (unless @code{#:strip-binaries?}
3826is false), copying them to the @code{debug} output when available
3827(@pxref{Installing Debugging Files}).
3828@end table
3829
3830@vindex %standard-phases
3831The build-side module @code{(guix build gnu-build-system)} defines
3832@var{%standard-phases} as the default list of build phases.
3833@var{%standard-phases} is a list of symbol/procedure pairs, where the
3834procedure implements the actual phase.
3835
3836The list of phases used for a particular package can be changed with the
3837@code{#:phases} parameter. For instance, passing:
3838
3839@example
c2c5dc79 3840#:phases (modify-phases %standard-phases (delete 'configure))
7458bd0a
LC
3841@end example
3842
9bf404e9 3843means that all the phases described above will be used, except the
7458bd0a
LC
3844@code{configure} phase.
3845
3846In addition, this build system ensures that the ``standard'' environment
3847for GNU packages is available. This includes tools such as GCC, libc,
3848Coreutils, Bash, Make, Diffutils, grep, and sed (see the @code{(guix
f97c9175
AE
3849build-system gnu)} module for a complete list). We call these the
3850@dfn{implicit inputs} of a package, because package definitions do not
7458bd0a
LC
3851have to mention them.
3852@end defvr
3853
3854Other @code{<build-system>} objects are defined to support other
3855conventions and tools used by free software packages. They inherit most
3856of @var{gnu-build-system}, and differ mainly in the set of inputs
3857implicitly added to the build process, and in the list of phases
3858executed. Some of these build systems are listed below.
3859
5f7a1a4d
RW
3860@defvr {Scheme Variable} ant-build-system
3861This variable is exported by @code{(guix build-system ant)}. It
3862implements the build procedure for Java packages that can be built with
3863@url{http://ant.apache.org/, Ant build tool}.
3864
3865It adds both @code{ant} and the @dfn{Java Development Kit} (JDK) as
3866provided by the @code{icedtea} package to the set of inputs. Different
3867packages can be specified with the @code{#:ant} and @code{#:jdk}
3868parameters, respectively.
3869
3870When the original package does not provide a suitable Ant build file,
3871the parameter @code{#:jar-name} can be used to generate a minimal Ant
3872build file @file{build.xml} with tasks to build the specified jar
8df64f73
HG
3873archive. In this case the parameter @code{#:source-dir} can be used to
3874specify the source sub-directory, defaulting to ``src''.
5f7a1a4d 3875
8df1faa0
JL
3876The @code{#:main-class} parameter can be used with the minimal ant
3877buildfile to specify the main class of the resulting jar. This makes the
f403d7ab
JL
3878jar file executable. The @code{#:test-include} parameter can be used to
3879specify the list of junit tests to run. It defaults to
3880@code{(list "**/*Test.java")}. The @code{#:test-exclude} can be used to
3881disable some tests. It defaults to @code{(list "**/Abstract*.java")},
3882because abstract classes cannot be run as tests.
8df1faa0 3883
5f7a1a4d
RW
3884The parameter @code{#:build-target} can be used to specify the Ant task
3885that should be run during the @code{build} phase. By default the
3886``jar'' task will be run.
3887
3888@end defvr
3889
ad23a3fb
DM
3890@defvr {Scheme Variable} android-ndk-build-system
3891@cindex Android distribution
3892@cindex Android NDK build system
3893This variable is exported by @code{(guix build-system android-ndk)}. It
3894implements a build procedure for Android NDK (native development kit)
3895packages using a Guix-specific build process.
3896
3897The build system assumes that packages install their public interface
3898(header) files to the subdirectory "include" of the "out" output and
3899their libraries to the subdirectory "lib" of the "out" output.
3900
3901It's also assumed that the union of all the dependencies of a package
3902has no conflicting files.
3903
3904For the time being, cross-compilation is not supported - so right now
3905the libraries and header files are assumed to be host tools.
3906
3907@end defvr
3908
a1b30f99
AP
3909@defvr {Scheme Variable} asdf-build-system/source
3910@defvrx {Scheme Variable} asdf-build-system/sbcl
3911@defvrx {Scheme Variable} asdf-build-system/ecl
3912
3913These variables, exported by @code{(guix build-system asdf)}, implement
3914build procedures for Common Lisp packages using
3915@url{https://common-lisp.net/project/asdf/, ``ASDF''}. ASDF is a system
3916definition facility for Common Lisp programs and libraries.
3917
3918The @code{asdf-build-system/source} system installs the packages in
3919source form, and can be loaded using any common lisp implementation, via
3920ASDF. The others, such as @code{asdf-build-system/sbcl}, install binary
3921systems in the format which a particular implementation understands.
3922These build systems can also be used to produce executable programs, or
3923lisp images which contain a set of packages pre-loaded.
3924
3925The build system uses naming conventions. For binary packages, the
8a3814cd
AP
3926package name should be prefixed with the lisp implementation, such as
3927@code{sbcl-} for @code{asdf-build-system/sbcl}.
a1b30f99
AP
3928
3929Additionally, the corresponding source package should be labeled using
3930the same convention as python packages (see @ref{Python Modules}), using
3931the @code{cl-} prefix.
3932
3933For binary packages, each system should be defined as a Guix package.
3934If one package @code{origin} contains several systems, package variants
3935can be created in order to build all the systems. Source packages,
3936which use @code{asdf-build-system/source}, may contain several systems.
3937
3938In order to create executable programs and images, the build-side
3939procedures @code{build-program} and @code{build-image} can be used.
3940They should be called in a build phase after the @code{create-symlinks}
3941phase, so that the system which was just built can be used within the
3942resulting image. @code{build-program} requires a list of Common Lisp
3943expressions to be passed as the @code{#:entry-program} argument.
3944
3945If the system is not defined within its own @code{.asd} file of the same
3946name, then the @code{#:asd-file} parameter should be used to specify
8a3814cd
AP
3947which file the system is defined in. Furthermore, if the package
3948defines a system for its tests in a separate file, it will be loaded
3949before the tests are run if it is specified by the
3950@code{#:test-asd-file} parameter. If it is not set, the files
3951@code{<system>-tests.asd}, @code{<system>-test.asd}, @code{tests.asd},
3952and @code{test.asd} will be tried if they exist.
3953
3954If for some reason the package must be named in a different way than the
3955naming conventions suggest, the @code{#:asd-system-name} parameter can
3956be used to specify the name of the system.
a1b30f99
AP
3957
3958@end defvr
3959
1ec34dd7
LC
3960@defvr {Scheme Variable} cargo-build-system
3961@cindex Rust programming language
3962@cindex Cargo (Rust build system)
3963This variable is exported by @code{(guix build-system cargo)}. It
3964supports builds of packages using Cargo, the build tool of the
3965@uref{https://www.rust-lang.org, Rust programming language}.
3966
3967In its @code{configure} phase, this build system replaces dependencies
3968specified in the @file{Carto.toml} file with inputs to the Guix package.
3969The @code{install} phase installs the binaries, and it also installs the
3970source code and @file{Cargo.toml} file.
3971@end defvr
3972
7458bd0a
LC
3973@defvr {Scheme Variable} cmake-build-system
3974This variable is exported by @code{(guix build-system cmake)}. It
3975implements the build procedure for packages using the
3976@url{http://www.cmake.org, CMake build tool}.
3977
3978It automatically adds the @code{cmake} package to the set of inputs.
3979Which package is used can be specified with the @code{#:cmake}
3980parameter.
9849cfc1
LC
3981
3982The @code{#:configure-flags} parameter is taken as a list of flags
3983passed to the @command{cmake} command. The @code{#:build-type}
3984parameter specifies in abstract terms the flags passed to the compiler;
3985it defaults to @code{"RelWithDebInfo"} (short for ``release mode with
3986debugging information''), which roughly means that code is compiled with
3987@code{-O2 -g}, as is the case for Autoconf-based packages by default.
7458bd0a
LC
3988@end defvr
3989
91525b48
LF
3990@defvr {Scheme Variable} go-build-system
3991This variable is exported by @code{(guix build-system go)}. It
3992implements a build procedure for Go packages using the standard
3993@url{https://golang.org/cmd/go/#hdr-Compile_packages_and_dependencies,
3994Go build mechanisms}.
3995
3996The user is expected to provide a value for the key @code{#:import-path}
3997and, in some cases, @code{#:unpack-path}. The
3998@url{https://golang.org/doc/code.html#ImportPaths, import path}
162a1374 3999corresponds to the file system path expected by the package's build
91525b48
LF
4000scripts and any referring packages, and provides a unique way to
4001refer to a Go package. It is typically based on a combination of the
162a1374 4002package source code's remote URI and file system hierarchy structure. In
91525b48
LF
4003some cases, you will need to unpack the package's source code to a
4004different directory structure than the one indicated by the import path,
4005and @code{#:unpack-path} should be used in such cases.
9c43f432
LF
4006
4007Packages that provide Go libraries should be installed along with their
4008source code. The key @code{#:install-source?}, which defaults to
4009@code{#t}, controls whether or not the source code is installed. It can
4010be set to @code{#f} for packages that only provide executable files.
91525b48
LF
4011@end defvr
4012
3afcf52b
FB
4013@defvr {Scheme Variable} glib-or-gtk-build-system
4014This variable is exported by @code{(guix build-system glib-or-gtk)}. It
4015is intended for use with packages making use of GLib or GTK+.
4016
4017This build system adds the following two phases to the ones defined by
4018@var{gnu-build-system}:
4019
4020@table @code
4021@item glib-or-gtk-wrap
f97c9175
AE
4022The phase @code{glib-or-gtk-wrap} ensures that programs in
4023@file{bin/} are able to find GLib ``schemas'' and
3afcf52b
FB
4024@uref{https://developer.gnome.org/gtk3/stable/gtk-running.html, GTK+
4025modules}. This is achieved by wrapping the programs in launch scripts
4026that appropriately set the @code{XDG_DATA_DIRS} and @code{GTK_PATH}
4027environment variables.
4028
73aa8ddb
LC
4029It is possible to exclude specific package outputs from that wrapping
4030process by listing their names in the
4031@code{#:glib-or-gtk-wrap-excluded-outputs} parameter. This is useful
4032when an output is known not to contain any GLib or GTK+ binaries, and
4033where wrapping would gratuitously add a dependency of that output on
4034GLib and GTK+.
4035
3afcf52b 4036@item glib-or-gtk-compile-schemas
f97c9175 4037The phase @code{glib-or-gtk-compile-schemas} makes sure that all
3afcf52b 4038@uref{https://developer.gnome.org/gio/stable/glib-compile-schemas.html,
f97c9175 4039GSettings schemas} of GLib are compiled. Compilation is performed by the
3afcf52b
FB
4040@command{glib-compile-schemas} program. It is provided by the package
4041@code{glib:bin} which is automatically imported by the build system.
4042The @code{glib} package providing @command{glib-compile-schemas} can be
4043specified with the @code{#:glib} parameter.
4044@end table
4045
4046Both phases are executed after the @code{install} phase.
4047@end defvr
4048
2a3b1b32
LC
4049@defvr {Scheme Variable} guile-build-system
4050This build system is for Guile packages that consist exclusively of Scheme
4051code and that are so lean that they don't even have a makefile, let alone a
4052@file{configure} script. It compiles Scheme code using @command{guild
4053compile} (@pxref{Compilation,,, guile, GNU Guile Reference Manual}) and
4054installs the @file{.scm} and @file{.go} files in the right place. It also
4055installs documentation.
4056
4057This build system supports cross-compilation by using the @code{--target}
4058option of @command{guild compile}.
4059
4060Packages built with @code{guile-build-system} must provide a Guile package in
4061their @code{native-inputs} field.
4062@end defvr
4063
88c8f247
RW
4064@defvr {Scheme Variable} minify-build-system
4065This variable is exported by @code{(guix build-system minify)}. It
4066implements a minification procedure for simple JavaScript packages.
4067
4068It adds @code{uglify-js} to the set of inputs and uses it to compress
4069all JavaScript files in the @file{src} directory. A different minifier
4070package can be specified with the @code{#:uglify-js} parameter, but it
4071is expected that the package writes the minified code to the standard
4072output.
4073
4074When the input JavaScript files are not all located in the @file{src}
4075directory, the parameter @code{#:javascript-files} can be used to
4076specify a list of file names to feed to the minifier.
4077@end defvr
4078
3184f14a 4079@defvr {Scheme Variable} ocaml-build-system
9fc221b5 4080This variable is exported by @code{(guix build-system ocaml)}. It implements
3184f14a
JL
4081a build procedure for @uref{https://ocaml.org, OCaml} packages, which consists
4082of choosing the correct set of commands to run for each package. OCaml
4083packages can expect many different commands to be run. This build system will
4084try some of them.
4085
4086When the package has a @file{setup.ml} file present at the top-level, it will
4087run @code{ocaml setup.ml -configure}, @code{ocaml setup.ml -build} and
4088@code{ocaml setup.ml -install}. The build system will assume that this file
4089was generated by @uref{http://oasis.forge.ocamlcore.org/, OASIS} and will take
4090care of setting the prefix and enabling tests if they are not disabled. You
4091can pass configure and build flags with the @code{#:configure-flags} and
4092@code{#:build-flags}. The @code{#:test-flags} key can be passed to change the
4093set of flags used to enable tests. The @code{#:use-make?} key can be used to
4094bypass this system in the build and install phases.
4095
4096When the package has a @file{configure} file, it is assumed that it is a
4097hand-made configure script that requires a different argument format than
4098in the @code{gnu-build-system}. You can add more flags with the
4099@code{#:configure-flags} key.
4100
4101When the package has a @file{Makefile} file (or @code{#:use-make?} is
4102@code{#t}), it will be used and more flags can be passed to the build and
4103install phases with the @code{#:make-flags} key.
4104
4105Finally, some packages do not have these files and use a somewhat standard
4106location for its build system. In that case, the build system will run
4107@code{ocaml pkg/pkg.ml} or @code{ocaml pkg/build.ml} and take care of
4108providing the path to the required findlib module. Additional flags can
4109be passed via the @code{#:build-flags} key. Install is taken care of by
4110@command{opam-installer}. In this case, the @code{opam} package must
4111be added to the @code{native-inputs} field of the package definition.
4112
4113Note that most OCaml packages assume they will be installed in the same
88ba7852 4114directory as OCaml, which is not what we want in guix. In particular, they
3184f14a 4115will install @file{.so} files in their module's directory, which is usually
88ba7852 4116fine because it is in the OCaml compiler directory. In guix though, these
3184f14a
JL
4117libraries cannot be found and we use @code{CAML_LD_LIBRARY_PATH}. This
4118variable points to @file{lib/ocaml/site-lib/stubslibs} and this is where
4119@file{.so} libraries should be installed.
4120@end defvr
4121
7458bd0a
LC
4122@defvr {Scheme Variable} python-build-system
4123This variable is exported by @code{(guix build-system python)}. It
4124implements the more or less standard build procedure used by Python
4125packages, which consists in running @code{python setup.py build} and
4126then @code{python setup.py install --prefix=/gnu/store/@dots{}}.
4127
4128For packages that install stand-alone Python programs under @code{bin/},
f97c9175 4129it takes care of wrapping these programs so that their @code{PYTHONPATH}
7458bd0a
LC
4130environment variable points to all the Python libraries they depend on.
4131
8a46205b
CM
4132Which Python package is used to perform the build can be specified with
4133the @code{#:python} parameter. This is a useful way to force a package
4134to be built for a specific version of the Python interpreter, which
4135might be necessary if the package is only compatible with a single
4136interpreter version.
5f7565d1
HG
4137
4138By default guix calls @code{setup.py} under control of
4139@code{setuptools}, much like @command{pip} does. Some packages are not
4140compatible with setuptools (and pip), thus you can disable this by
4141setting the @code{#:use-setuptools} parameter to @code{#f}.
7458bd0a
LC
4142@end defvr
4143
4144@defvr {Scheme Variable} perl-build-system
4145This variable is exported by @code{(guix build-system perl)}. It
2d2a53fc
EB
4146implements the standard build procedure for Perl packages, which either
4147consists in running @code{perl Build.PL --prefix=/gnu/store/@dots{}},
4148followed by @code{Build} and @code{Build install}; or in running
4149@code{perl Makefile.PL PREFIX=/gnu/store/@dots{}}, followed by
f97c9175 4150@code{make} and @code{make install}, depending on which of
2d2a53fc
EB
4151@code{Build.PL} or @code{Makefile.PL} is present in the package
4152distribution. Preference is given to the former if both @code{Build.PL}
4153and @code{Makefile.PL} exist in the package distribution. This
4154preference can be reversed by specifying @code{#t} for the
4155@code{#:make-maker?} parameter.
4156
4157The initial @code{perl Makefile.PL} or @code{perl Build.PL} invocation
4158passes flags specified by the @code{#:make-maker-flags} or
4159@code{#:module-build-flags} parameter, respectively.
7458bd0a
LC
4160
4161Which Perl package is used can be specified with @code{#:perl}.
4162@end defvr
4163
f8f3bef6
RW
4164@defvr {Scheme Variable} r-build-system
4165This variable is exported by @code{(guix build-system r)}. It
4166implements the build procedure used by @uref{http://r-project.org, R}
4167packages, which essentially is little more than running @code{R CMD
4168INSTALL --library=/gnu/store/@dots{}} in an environment where
4169@code{R_LIBS_SITE} contains the paths to all R package inputs. Tests
4170are run after installation using the R function
4171@code{tools::testInstalledPackage}.
4172@end defvr
4173
205794c8
RW
4174@defvr {Scheme Variable} texlive-build-system
4175This variable is exported by @code{(guix build-system texlive)}. It is
4176used to build TeX packages in batch mode with a specified engine. The
4177build system sets the @code{TEXINPUTS} variable to find all TeX source
4178files in the inputs.
4179
4180By default it runs @code{luatex} on all files ending on @code{ins}. A
4181different engine and format can be specified with the
4182@code{#:tex-format} argument. Different build targets can be specified
4183with the @code{#:build-targets} argument, which expects a list of file
4184names. The build system adds only @code{texlive-bin} and
4185@code{texlive-latex-base} (both from @code{(gnu packages tex}) to the
4186inputs. Both can be overridden with the arguments @code{#:texlive-bin}
4187and @code{#:texlive-latex-base}, respectively.
4188
4189The @code{#:tex-directory} parameter tells the build system where to
4190install the built files under the texmf tree.
4191@end defvr
4192
c08f9818
DT
4193@defvr {Scheme Variable} ruby-build-system
4194This variable is exported by @code{(guix build-system ruby)}. It
4195implements the RubyGems build procedure used by Ruby packages, which
4196involves running @code{gem build} followed by @code{gem install}.
4197
5dc87623
DT
4198The @code{source} field of a package that uses this build system
4199typically references a gem archive, since this is the format that Ruby
4200developers use when releasing their software. The build system unpacks
4201the gem archive, potentially patches the source, runs the test suite,
4202repackages the gem, and installs it. Additionally, directories and
4203tarballs may be referenced to allow building unreleased gems from Git or
4204a traditional source release tarball.
e83c6d00 4205
c08f9818 4206Which Ruby package is used can be specified with the @code{#:ruby}
6e9f2913
PP
4207parameter. A list of additional flags to be passed to the @command{gem}
4208command can be specified with the @code{#:gem-flags} parameter.
c08f9818 4209@end defvr
7458bd0a 4210
a677c726
RW
4211@defvr {Scheme Variable} waf-build-system
4212This variable is exported by @code{(guix build-system waf)}. It
4213implements a build procedure around the @code{waf} script. The common
4214phases---@code{configure}, @code{build}, and @code{install}---are
4215implemented by passing their names as arguments to the @code{waf}
4216script.
4217
4218The @code{waf} script is executed by the Python interpreter. Which
4219Python package is used to run the script can be specified with the
4220@code{#:python} parameter.
4221@end defvr
4222
3d0aa7f7
AI
4223@defvr {Scheme Variable} scons-build-system
4224This variable is exported by @code{(guix build-system scons)}. It
4225implements the build procedure used by the SCons software construction
4226tool. This build system runs @code{scons} to build the package,
4227@code{scons test} to run tests, and then @code{scons install} to install
4228the package.
4229
4230Additional flags to be passed to @code{scons} can be specified with the
4231@code{#:scons-flags} parameter. The version of Python used to run SCons
4232can be specified by selecting the appropriate SCons package with the
4233@code{#:scons} parameter.
4234@end defvr
4235
14dfdf2e
FB
4236@defvr {Scheme Variable} haskell-build-system
4237This variable is exported by @code{(guix build-system haskell)}. It
4238implements the Cabal build procedure used by Haskell packages, which
4239involves running @code{runhaskell Setup.hs configure
4240--prefix=/gnu/store/@dots{}} and @code{runhaskell Setup.hs build}.
4241Instead of installing the package by running @code{runhaskell Setup.hs
4242install}, to avoid trying to register libraries in the read-only
4243compiler store directory, the build system uses @code{runhaskell
4244Setup.hs copy}, followed by @code{runhaskell Setup.hs register}. In
4245addition, the build system generates the package documentation by
4246running @code{runhaskell Setup.hs haddock}, unless @code{#:haddock? #f}
4247is passed. Optional Haddock parameters can be passed with the help of
4248the @code{#:haddock-flags} parameter. If the file @code{Setup.hs} is
4249not found, the build system looks for @code{Setup.lhs} instead.
4250
4251Which Haskell compiler is used can be specified with the @code{#:haskell}
a54bd6d7 4252parameter which defaults to @code{ghc}.
14dfdf2e
FB
4253@end defvr
4254
65e862d1
DM
4255@defvr {Scheme Variable} dub-build-system
4256This variable is exported by @code{(guix build-system dub)}. It
4257implements the Dub build procedure used by D packages, which
4258involves running @code{dub build} and @code{dub run}.
4259Installation is done by copying the files manually.
4260
4261Which D compiler is used can be specified with the @code{#:ldc}
4262parameter which defaults to @code{ldc}.
4263@end defvr
4264
e9137a53
FB
4265@defvr {Scheme Variable} emacs-build-system
4266This variable is exported by @code{(guix build-system emacs)}. It
f97c9175
AE
4267implements an installation procedure similar to the packaging system
4268of Emacs itself (@pxref{Packages,,, emacs, The GNU Emacs Manual}).
e9137a53
FB
4269
4270It first creates the @code{@var{package}-autoloads.el} file, then it
4271byte compiles all Emacs Lisp files. Differently from the Emacs
4272packaging system, the Info documentation files are moved to the standard
4273documentation directory and the @file{dir} file is deleted. Each
4274package is installed in its own directory under
4275@file{share/emacs/site-lisp/guix.d}.
4276@end defvr
4277
3d90fa98
AI
4278@defvr {Scheme Variable} font-build-system
4279This variable is exported by @code{(guix build-system font)}. It
4280implements an installation procedure for font packages where upstream
4281provides pre-compiled TrueType, OpenType, etc. font files that merely
4282need to be copied into place. It copies font files to standard
4283locations in the output directory.
4284@end defvr
4285
07c101e2
PM
4286@defvr {Scheme Variable} meson-build-system
4287This variable is exported by @code{(guix build-system meson)}. It
4288implements the build procedure for packages that use
4289@url{http://mesonbuild.com, Meson} as their build system.
4290
4291It adds both Meson and @uref{https://ninja-build.org/, Ninja} to the set
4292of inputs, and they can be changed with the parameters @code{#:meson}
4293and @code{#:ninja} if needed. The default Meson is
4294@code{meson-for-build}, which is special because it doesn't clear the
4295@code{RUNPATH} of binaries and libraries when they are installed.
4296
4297This build system is an extension of @var{gnu-build-system}, but with the
4298following phases changed to some specific for Meson:
4299
4300@table @code
4301
4302@item configure
4303The phase runs @code{meson} with the flags specified in
4304@code{#:configure-flags}. The flag @code{--build-type} is always set to
4305@code{plain} unless something else is specified in @code{#:build-type}.
4306
4307@item build
4308The phase runs @code{ninja} to build the package in parallel by default, but
4309this can be changed with @code{#:parallel-build?}.
4310
4311@item check
4312The phase runs @code{ninja} with the target specified in @code{#:test-target},
4313which is @code{"test"} by default.
4314
4315@item install
4316The phase runs @code{ninja install} and can not be changed.
4317@end table
4318
4319Apart from that, the build system also adds the following phases:
4320
4321@table @code
4322
4323@item fix-runpath
782c94fe
TGR
4324This phase ensures that all binaries can find the libraries they need.
4325It searches for required libraries in subdirectories of the package being
4326built, and adds those to @code{RUNPATH} where needed. It also removes
4327references to libraries left over from the build phase by
4328@code{meson-for-build}, such as test dependencies, that aren't actually
4329required for the program to run.
07c101e2
PM
4330
4331@item glib-or-gtk-wrap
4332This phase is the phase provided by @code{glib-or-gtk-build-system}, and it
4333is not enabled by default. It can be enabled with @code{#:glib-or-gtk?}.
4334
4335@item glib-or-gtk-compile-schemas
4336This phase is the phase provided by @code{glib-or-gtk-build-system}, and it
4337is not enabled by default. It can be enabled with @code{#:glib-or-gtk?}.
4338@end table
4339@end defvr
4340
7458bd0a
LC
4341Lastly, for packages that do not need anything as sophisticated, a
4342``trivial'' build system is provided. It is trivial in the sense that
4343it provides basically no support: it does not pull any implicit inputs,
4344and does not have a notion of build phases.
4345
4346@defvr {Scheme Variable} trivial-build-system
4347This variable is exported by @code{(guix build-system trivial)}.
4348
4349This build system requires a @code{#:builder} argument. This argument
f97c9175 4350must be a Scheme expression that builds the package output(s)---as
7458bd0a
LC
4351with @code{build-expression->derivation} (@pxref{Derivations,
4352@code{build-expression->derivation}}).
4353@end defvr
4354
568717fd
LC
4355@node The Store
4356@section The Store
4357
e531ac2a 4358@cindex store
1ddee424 4359@cindex store items
e531ac2a
LC
4360@cindex store paths
4361
f97c9175
AE
4362Conceptually, the @dfn{store} is the place where derivations that have
4363been built successfully are stored---by default, @file{/gnu/store}.
1ddee424
LC
4364Sub-directories in the store are referred to as @dfn{store items} or
4365sometimes @dfn{store paths}. The store has an associated database that
4366contains information such as the store paths referred to by each store
4367path, and the list of @emph{valid} store items---results of successful
ef5f5c86
LC
4368builds. This database resides in @file{@var{localstatedir}/guix/db},
4369where @var{localstatedir} is the state directory specified @i{via}
4370@option{--localstatedir} at configure time, usually @file{/var}.
1ddee424
LC
4371
4372The store is @emph{always} accessed by the daemon on behalf of its clients
e531ac2a 4373(@pxref{Invoking guix-daemon}). To manipulate the store, clients
f97c9175
AE
4374connect to the daemon over a Unix-domain socket, send requests to it,
4375and read the result---these are remote procedure calls, or RPCs.
e531ac2a 4376
1ddee424
LC
4377@quotation Note
4378Users must @emph{never} modify files under @file{/gnu/store} directly.
4379This would lead to inconsistencies and break the immutability
4380assumptions of Guix's functional model (@pxref{Introduction}).
4381
4382@xref{Invoking guix gc, @command{guix gc --verify}}, for information on
4383how to check the integrity of the store and attempt recovery from
4384accidental modifications.
4385@end quotation
4386
e531ac2a 4387The @code{(guix store)} module provides procedures to connect to the
1397b422
LC
4388daemon, and to perform RPCs. These are described below. By default,
4389@code{open-connection}, and thus all the @command{guix} commands,
4390connect to the local daemon or to the URI specified by the
4391@code{GUIX_DAEMON_SOCKET} environment variable.
e531ac2a 4392
1397b422
LC
4393@defvr {Environment Variable} GUIX_DAEMON_SOCKET
4394When set, the value of this variable should be a file name or a URI
4395designating the daemon endpoint. When it is a file name, it denotes a
4396Unix-domain socket to connect to. In addition to file names, the
4397supported URI schemes are:
4398
4399@table @code
4400@item file
4401@itemx unix
4402These are for Unix-domain sockets.
4403@code{file:///var/guix/daemon-socket/socket} is equivalent to
4404@file{/var/guix/daemon-socket/socket}.
3dff90ce
LC
4405
4406@item guix
1071f781
LC
4407@cindex daemon, remote access
4408@cindex remote access to the daemon
4409@cindex daemon, cluster setup
4410@cindex clusters, daemon setup
3dff90ce 4411These URIs denote connections over TCP/IP, without encryption nor
5df1395a
LC
4412authentication of the remote host. The URI must specify the host name
4413and optionally a port number (by default port 44146 is used):
3dff90ce
LC
4414
4415@example
4416guix://master.guix.example.org:1234
4417@end example
4418
4419This setup is suitable on local networks, such as clusters, where only
4420trusted nodes may connect to the build daemon at
4421@code{master.guix.example.org}.
285f63e8 4422
1071f781
LC
4423The @code{--listen} option of @command{guix-daemon} can be used to
4424instruct it to listen for TCP connections (@pxref{Invoking guix-daemon,
4425@code{--listen}}).
4426
285f63e8
LC
4427@item ssh
4428@cindex SSH access to build daemons
4429These URIs allow you to connect to a remote daemon over
4430SSH@footnote{This feature requires Guile-SSH (@pxref{Requirements}).}.
4431A typical URL might look like this:
4432
4433@example
4434ssh://charlie@@guix.example.org:22
4435@end example
4436
4437As for @command{guix copy}, the usual OpenSSH client configuration files
4438are honored (@pxref{Invoking guix copy}).
1397b422
LC
4439@end table
4440
4441Additional URI schemes may be supported in the future.
285f63e8
LC
4442
4443@c XXX: Remove this note when the protocol incurs fewer round trips
4444@c and when (guix derivations) no longer relies on file system access.
4445@quotation Note
4446The ability to connect to remote build daemons is considered
4447experimental as of @value{VERSION}. Please get in touch with us to
4448share any problems or suggestions you may have (@pxref{Contributing}).
4449@end quotation
1397b422
LC
4450@end defvr
4451
4452@deffn {Scheme Procedure} open-connection [@var{uri}] [#:reserve-space? #t]
4453Connect to the daemon over the Unix-domain socket at @var{uri} (a string). When
e531ac2a
LC
4454@var{reserve-space?} is true, instruct it to reserve a little bit of
4455extra space on the file system so that the garbage collector can still
f97c9175 4456operate should the disk become full. Return a server object.
e531ac2a
LC
4457
4458@var{file} defaults to @var{%default-socket-path}, which is the normal
4459location given the options that were passed to @command{configure}.
4460@end deffn
4461
4462@deffn {Scheme Procedure} close-connection @var{server}
4463Close the connection to @var{server}.
4464@end deffn
4465
4466@defvr {Scheme Variable} current-build-output-port
4467This variable is bound to a SRFI-39 parameter, which refers to the port
4468where build and error logs sent by the daemon should be written.
4469@end defvr
4470
4471Procedures that make RPCs all take a server object as their first
4472argument.
4473
4474@deffn {Scheme Procedure} valid-path? @var{server} @var{path}
06b76acc
LC
4475@cindex invalid store items
4476Return @code{#t} when @var{path} designates a valid store item and
4477@code{#f} otherwise (an invalid item may exist on disk but still be
4478invalid, for instance because it is the result of an aborted or failed
4479build.)
4480
4481A @code{&nix-protocol-error} condition is raised if @var{path} is not
4482prefixed by the store directory (@file{/gnu/store}).
e531ac2a
LC
4483@end deffn
4484
cfbf9160 4485@deffn {Scheme Procedure} add-text-to-store @var{server} @var{name} @var{text} [@var{references}]
e531ac2a
LC
4486Add @var{text} under file @var{name} in the store, and return its store
4487path. @var{references} is the list of store paths referred to by the
4488resulting store path.
4489@end deffn
4490
874e6874 4491@deffn {Scheme Procedure} build-derivations @var{server} @var{derivations}
59688fc4
LC
4492Build @var{derivations} (a list of @code{<derivation>} objects or
4493derivation paths), and return when the worker is done building them.
4494Return @code{#t} on success.
874e6874
LC
4495@end deffn
4496
b860f382
LC
4497Note that the @code{(guix monads)} module provides a monad as well as
4498monadic versions of the above procedures, with the goal of making it
4499more convenient to work with code that accesses the store (@pxref{The
4500Store Monad}).
4501
e531ac2a
LC
4502@c FIXME
4503@i{This section is currently incomplete.}
568717fd
LC
4504
4505@node Derivations
4506@section Derivations
4507
874e6874
LC
4508@cindex derivations
4509Low-level build actions and the environment in which they are performed
70458ed5 4510are represented by @dfn{derivations}. A derivation contains the
874e6874
LC
4511following pieces of information:
4512
4513@itemize
4514@item
4515The outputs of the derivation---derivations produce at least one file or
4516directory in the store, but may produce more.
4517
4518@item
4519The inputs of the derivations, which may be other derivations or plain
4520files in the store (patches, build scripts, etc.)
4521
4522@item
4523The system type targeted by the derivation---e.g., @code{x86_64-linux}.
4524
4525@item
4526The file name of a build script in the store, along with the arguments
4527to be passed.
4528
4529@item
4530A list of environment variables to be defined.
4531
4532@end itemize
4533
4534@cindex derivation path
4535Derivations allow clients of the daemon to communicate build actions to
4536the store. They exist in two forms: as an in-memory representation,
4537both on the client- and daemon-side, and as files in the store whose
4538name end in @code{.drv}---these files are referred to as @dfn{derivation
4539paths}. Derivations paths can be passed to the @code{build-derivations}
4540procedure to perform the build actions they prescribe (@pxref{The
4541Store}).
4542
8785bd77
LC
4543@cindex fixed-output derivations
4544Operations such as file downloads and version-control checkouts for
4545which the expected content hash is known in advance are modeled as
4546@dfn{fixed-output derivations}. Unlike regular derivations, the outputs
4547of a fixed-output derivation are independent of its inputs---e.g., a
4548source code download produces the same result regardless of the download
4549method and tools being used.
4550
874e6874
LC
4551The @code{(guix derivations)} module provides a representation of
4552derivations as Scheme objects, along with procedures to create and
4553otherwise manipulate derivations. The lowest-level primitive to create
4554a derivation is the @code{derivation} procedure:
4555
1909431c
LC
4556@deffn {Scheme Procedure} derivation @var{store} @var{name} @var{builder} @
4557 @var{args} [#:outputs '("out")] [#:hash #f] [#:hash-algo #f] @
2096ef47 4558 [#:recursive? #f] [#:inputs '()] [#:env-vars '()] @
1909431c 4559 [#:system (%current-system)] [#:references-graphs #f] @
35b5ca78
LC
4560 [#:allowed-references #f] [#:disallowed-references #f] @
4561 [#:leaked-env-vars #f] [#:local-build? #f] @
4a6aeb67 4562 [#:substitutable? #t]
59688fc4
LC
4563Build a derivation with the given arguments, and return the resulting
4564@code{<derivation>} object.
874e6874 4565
2096ef47 4566When @var{hash} and @var{hash-algo} are given, a
874e6874 4567@dfn{fixed-output derivation} is created---i.e., one whose result is
36bbbbd1
LC
4568known in advance, such as a file download. If, in addition,
4569@var{recursive?} is true, then that fixed output may be an executable
4570file or a directory and @var{hash} must be the hash of an archive
4571containing this output.
5b0c9d16 4572
858e9282 4573When @var{references-graphs} is true, it must be a list of file
5b0c9d16
LC
4574name/store path pairs. In that case, the reference graph of each store
4575path is exported in the build environment in the corresponding file, in
4576a simple text format.
1909431c 4577
b53be755 4578When @var{allowed-references} is true, it must be a list of store items
35b5ca78
LC
4579or outputs that the derivation's output may refer to. Likewise,
4580@var{disallowed-references}, if true, must be a list of things the
4581outputs may @emph{not} refer to.
b53be755 4582
c0468155
LC
4583When @var{leaked-env-vars} is true, it must be a list of strings
4584denoting environment variables that are allowed to ``leak'' from the
4585daemon's environment to the build environment. This is only applicable
4586to fixed-output derivations---i.e., when @var{hash} is true. The main
4587use is to allow variables such as @code{http_proxy} to be passed to
4588derivations that download files.
4589
1909431c
LC
4590When @var{local-build?} is true, declare that the derivation is not a
4591good candidate for offloading and should rather be built locally
4592(@pxref{Daemon Offload Setup}). This is the case for small derivations
4593where the costs of data transfers would outweigh the benefits.
4a6aeb67
LC
4594
4595When @var{substitutable?} is false, declare that substitutes of the
4596derivation's output should not be used (@pxref{Substitutes}). This is
4597useful, for instance, when building packages that capture details of the
4598host CPU instruction set.
874e6874
LC
4599@end deffn
4600
4601@noindent
4602Here's an example with a shell script as its builder, assuming
4603@var{store} is an open connection to the daemon, and @var{bash} points
4604to a Bash executable in the store:
4605
4606@lisp
4607(use-modules (guix utils)
4608 (guix store)
4609 (guix derivations))
4610
59688fc4
LC
4611(let ((builder ; add the Bash script to the store
4612 (add-text-to-store store "my-builder.sh"
4613 "echo hello world > $out\n" '())))
4614 (derivation store "foo"
4615 bash `("-e" ,builder)
21b679f6 4616 #:inputs `((,bash) (,builder))
59688fc4 4617 #:env-vars '(("HOME" . "/homeless"))))
834129e0 4618@result{} #<derivation /gnu/store/@dots{}-foo.drv => /gnu/store/@dots{}-foo>
874e6874
LC
4619@end lisp
4620
21b679f6
LC
4621As can be guessed, this primitive is cumbersome to use directly. A
4622better approach is to write build scripts in Scheme, of course! The
4623best course of action for that is to write the build code as a
4624``G-expression'', and to pass it to @code{gexp->derivation}. For more
6621cdb6 4625information, @pxref{G-Expressions}.
21b679f6 4626
f2fadbc1
AE
4627Once upon a time, @code{gexp->derivation} did not exist and constructing
4628derivations with build code written in Scheme was achieved with
4629@code{build-expression->derivation}, documented below. This procedure
4630is now deprecated in favor of the much nicer @code{gexp->derivation}.
4631
4632@deffn {Scheme Procedure} build-expression->derivation @var{store} @
4633 @var{name} @var{exp} @
4634 [#:system (%current-system)] [#:inputs '()] @
4635 [#:outputs '("out")] [#:hash #f] [#:hash-algo #f] @
4636 [#:recursive? #f] [#:env-vars '()] [#:modules '()] @
4637 [#:references-graphs #f] [#:allowed-references #f] @
35b5ca78 4638 [#:disallowed-references #f] @
f2fadbc1
AE
4639 [#:local-build? #f] [#:substitutable? #t] [#:guile-for-build #f]
4640Return a derivation that executes Scheme expression @var{exp} as a
4641builder for derivation @var{name}. @var{inputs} must be a list of
4642@code{(name drv-path sub-drv)} tuples; when @var{sub-drv} is omitted,
4643@code{"out"} is assumed. @var{modules} is a list of names of Guile
4644modules from the current search path to be copied in the store,
4645compiled, and made available in the load path during the execution of
4646@var{exp}---e.g., @code{((guix build utils) (guix build
4647gnu-build-system))}.
4648
4649@var{exp} is evaluated in an environment where @code{%outputs} is bound
4650to a list of output/path pairs, and where @code{%build-inputs} is bound
4651to a list of string/output-path pairs made from @var{inputs}.
4652Optionally, @var{env-vars} is a list of string pairs specifying the name
4653and value of environment variables visible to the builder. The builder
4654terminates by passing the result of @var{exp} to @code{exit}; thus, when
4655@var{exp} returns @code{#f}, the build is considered to have failed.
4656
4657@var{exp} is built using @var{guile-for-build} (a derivation). When
4658@var{guile-for-build} is omitted or is @code{#f}, the value of the
4659@code{%guile-for-build} fluid is used instead.
4660
4661See the @code{derivation} procedure for the meaning of
35b5ca78
LC
4662@var{references-graphs}, @var{allowed-references},
4663@var{disallowed-references}, @var{local-build?}, and
4664@var{substitutable?}.
f2fadbc1
AE
4665@end deffn
4666
4667@noindent
4668Here's an example of a single-output derivation that creates a directory
4669containing one file:
4670
4671@lisp
4672(let ((builder '(let ((out (assoc-ref %outputs "out")))
4673 (mkdir out) ; create /gnu/store/@dots{}-goo
4674 (call-with-output-file (string-append out "/test")
4675 (lambda (p)
4676 (display '(hello guix) p))))))
4677 (build-expression->derivation store "goo" builder))
4678
4679@result{} #<derivation /gnu/store/@dots{}-goo.drv => @dots{}>
4680@end lisp
4681
568717fd 4682
b860f382
LC
4683@node The Store Monad
4684@section The Store Monad
4685
4686@cindex monad
4687
4688The procedures that operate on the store described in the previous
4689sections all take an open connection to the build daemon as their first
4690argument. Although the underlying model is functional, they either have
4691side effects or depend on the current state of the store.
4692
4693The former is inconvenient: the connection to the build daemon has to be
4694carried around in all those functions, making it impossible to compose
4695functions that do not take that parameter with functions that do. The
4696latter can be problematic: since store operations have side effects
4697and/or depend on external state, they have to be properly sequenced.
4698
4699@cindex monadic values
4700@cindex monadic functions
4701This is where the @code{(guix monads)} module comes in. This module
4702provides a framework for working with @dfn{monads}, and a particularly
4703useful monad for our uses, the @dfn{store monad}. Monads are a
4704construct that allows two things: associating ``context'' with values
4705(in our case, the context is the store), and building sequences of
4827b36d 4706computations (here computations include accesses to the store). Values
b860f382
LC
4707in a monad---values that carry this additional context---are called
4708@dfn{monadic values}; procedures that return such values are called
4709@dfn{monadic procedures}.
4710
4711Consider this ``normal'' procedure:
4712
4713@example
45adbd62
LC
4714(define (sh-symlink store)
4715 ;; Return a derivation that symlinks the 'bash' executable.
4716 (let* ((drv (package-derivation store bash))
4717 (out (derivation->output-path drv))
4718 (sh (string-append out "/bin/bash")))
4719 (build-expression->derivation store "sh"
4720 `(symlink ,sh %output))))
b860f382
LC
4721@end example
4722
c6f30b81
LC
4723Using @code{(guix monads)} and @code{(guix gexp)}, it may be rewritten
4724as a monadic function:
b860f382
LC
4725
4726@example
45adbd62 4727(define (sh-symlink)
b860f382 4728 ;; Same, but return a monadic value.
c6f30b81
LC
4729 (mlet %store-monad ((drv (package->derivation bash)))
4730 (gexp->derivation "sh"
4731 #~(symlink (string-append #$drv "/bin/bash")
4732 #$output))))
b860f382
LC
4733@end example
4734
4827b36d 4735There are several things to note in the second version: the @code{store}
c6f30b81
LC
4736parameter is now implicit and is ``threaded'' in the calls to the
4737@code{package->derivation} and @code{gexp->derivation} monadic
4738procedures, and the monadic value returned by @code{package->derivation}
4739is @dfn{bound} using @code{mlet} instead of plain @code{let}.
4740
4741As it turns out, the call to @code{package->derivation} can even be
4742omitted since it will take place implicitly, as we will see later
4743(@pxref{G-Expressions}):
4744
4745@example
4746(define (sh-symlink)
4747 (gexp->derivation "sh"
4748 #~(symlink (string-append #$bash "/bin/bash")
4749 #$output)))
4750@end example
b860f382 4751
7ce21611 4752@c See
a01ad638 4753@c <https://syntaxexclamation.wordpress.com/2014/06/26/escaping-continuations/>
7ce21611
LC
4754@c for the funny quote.
4755Calling the monadic @code{sh-symlink} has no effect. As someone once
4756said, ``you exit a monad like you exit a building on fire: by running''.
4757So, to exit the monad and get the desired effect, one must use
4758@code{run-with-store}:
b860f382
LC
4759
4760@example
8e9aa37f
CAW
4761(run-with-store (open-connection) (sh-symlink))
4762@result{} /gnu/store/...-sh-symlink
b860f382
LC
4763@end example
4764
f97c9175 4765Note that the @code{(guix monad-repl)} module extends the Guile REPL with
b9b86078 4766new ``meta-commands'' to make it easier to deal with monadic procedures:
f97c9175 4767@code{run-in-store}, and @code{enter-store-monad}. The former is used
b9b86078
LC
4768to ``run'' a single monadic value through the store:
4769
4770@example
4771scheme@@(guile-user)> ,run-in-store (package->derivation hello)
4772$1 = #<derivation /gnu/store/@dots{}-hello-2.9.drv => @dots{}>
4773@end example
4774
4775The latter enters a recursive REPL, where all the return values are
4776automatically run through the store:
4777
4778@example
4779scheme@@(guile-user)> ,enter-store-monad
4780store-monad@@(guile-user) [1]> (package->derivation hello)
4781$2 = #<derivation /gnu/store/@dots{}-hello-2.9.drv => @dots{}>
4782store-monad@@(guile-user) [1]> (text-file "foo" "Hello!")
4783$3 = "/gnu/store/@dots{}-foo"
4784store-monad@@(guile-user) [1]> ,q
4785scheme@@(guile-user)>
4786@end example
4787
4788@noindent
4789Note that non-monadic values cannot be returned in the
4790@code{store-monad} REPL.
4791
e87f0591
LC
4792The main syntactic forms to deal with monads in general are provided by
4793the @code{(guix monads)} module and are described below.
b860f382
LC
4794
4795@deffn {Scheme Syntax} with-monad @var{monad} @var{body} ...
4796Evaluate any @code{>>=} or @code{return} forms in @var{body} as being
4797in @var{monad}.
4798@end deffn
4799
4800@deffn {Scheme Syntax} return @var{val}
4801Return a monadic value that encapsulates @var{val}.
4802@end deffn
4803
751630c9 4804@deffn {Scheme Syntax} >>= @var{mval} @var{mproc} ...
b860f382 4805@dfn{Bind} monadic value @var{mval}, passing its ``contents'' to monadic
751630c9
LC
4806procedures @var{mproc}@dots{}@footnote{This operation is commonly
4807referred to as ``bind'', but that name denotes an unrelated procedure in
4808Guile. Thus we use this somewhat cryptic symbol inherited from the
4809Haskell language.}. There can be one @var{mproc} or several of them, as
4810in this example:
4811
4812@example
4813(run-with-state
4814 (with-monad %state-monad
4815 (>>= (return 1)
4816 (lambda (x) (return (+ 1 x)))
4817 (lambda (x) (return (* 2 x)))))
4818 'some-state)
4819
4820@result{} 4
4821@result{} some-state
4822@end example
b860f382
LC
4823@end deffn
4824
4825@deffn {Scheme Syntax} mlet @var{monad} ((@var{var} @var{mval}) ...) @
4826 @var{body} ...
4827@deffnx {Scheme Syntax} mlet* @var{monad} ((@var{var} @var{mval}) ...) @
4828 @var{body} ...
4829Bind the variables @var{var} to the monadic values @var{mval} in
8bc2183f
CM
4830@var{body}, which is a sequence of expressions. As with the bind
4831operator, this can be thought of as ``unpacking'' the raw, non-monadic
4832value ``contained'' in @var{mval} and making @var{var} refer to that
4833raw, non-monadic value within the scope of the @var{body}. The form
4834(@var{var} -> @var{val}) binds @var{var} to the ``normal'' value
4835@var{val}, as per @code{let}. The binding operations occur in sequence
4836from left to right. The last expression of @var{body} must be a monadic
4837expression, and its result will become the result of the @code{mlet} or
4838@code{mlet*} when run in the @var{monad}.
b860f382
LC
4839
4840@code{mlet*} is to @code{mlet} what @code{let*} is to @code{let}
4841(@pxref{Local Bindings,,, guile, GNU Guile Reference Manual}).
4842@end deffn
4843
405a9d4e
LC
4844@deffn {Scheme System} mbegin @var{monad} @var{mexp} ...
4845Bind @var{mexp} and the following monadic expressions in sequence,
8bc2183f
CM
4846returning the result of the last expression. Every expression in the
4847sequence must be a monadic expression.
405a9d4e
LC
4848
4849This is akin to @code{mlet}, except that the return values of the
4850monadic expressions are ignored. In that sense, it is analogous to
4851@code{begin}, but applied to monadic expressions.
4852@end deffn
4853
60a9fcb1
CM
4854@deffn {Scheme System} mwhen @var{condition} @var{mexp0} @var{mexp*} ...
4855When @var{condition} is true, evaluate the sequence of monadic
4856expressions @var{mexp0}..@var{mexp*} as in an @code{mbegin}. When
4857@var{condition} is false, return @code{*unspecified*} in the current
4858monad. Every expression in the sequence must be a monadic expression.
4859@end deffn
4860
4861@deffn {Scheme System} munless @var{condition} @var{mexp0} @var{mexp*} ...
4862When @var{condition} is false, evaluate the sequence of monadic
4863expressions @var{mexp0}..@var{mexp*} as in an @code{mbegin}. When
4864@var{condition} is true, return @code{*unspecified*} in the current
4865monad. Every expression in the sequence must be a monadic expression.
4866@end deffn
4867
561fb6c3
LC
4868@cindex state monad
4869The @code{(guix monads)} module provides the @dfn{state monad}, which
4870allows an additional value---the state---to be @emph{threaded} through
4871monadic procedure calls.
4872
4873@defvr {Scheme Variable} %state-monad
4874The state monad. Procedures in the state monad can access and change
4875the state that is threaded.
4876
4877Consider the example below. The @code{square} procedure returns a value
4878in the state monad. It returns the square of its argument, but also
4879increments the current state value:
4880
4881@example
4882(define (square x)
4883 (mlet %state-monad ((count (current-state)))
4884 (mbegin %state-monad
4885 (set-current-state (+ 1 count))
4886 (return (* x x)))))
4887
4888(run-with-state (sequence %state-monad (map square (iota 3))) 0)
4889@result{} (0 1 4)
4890@result{} 3
4891@end example
4892
4893When ``run'' through @var{%state-monad}, we obtain that additional state
4894value, which is the number of @code{square} calls.
4895@end defvr
4896
4897@deffn {Monadic Procedure} current-state
4898Return the current state as a monadic value.
4899@end deffn
4900
4901@deffn {Monadic Procedure} set-current-state @var{value}
4902Set the current state to @var{value} and return the previous state as a
4903monadic value.
4904@end deffn
4905
4906@deffn {Monadic Procedure} state-push @var{value}
4907Push @var{value} to the current state, which is assumed to be a list,
4908and return the previous state as a monadic value.
4909@end deffn
4910
4911@deffn {Monadic Procedure} state-pop
4912Pop a value from the current state and return it as a monadic value.
4913The state is assumed to be a list.
4914@end deffn
4915
4916@deffn {Scheme Procedure} run-with-state @var{mval} [@var{state}]
4917Run monadic value @var{mval} starting with @var{state} as the initial
4918state. Return two values: the resulting value, and the resulting state.
4919@end deffn
4920
e87f0591
LC
4921The main interface to the store monad, provided by the @code{(guix
4922store)} module, is as follows.
b860f382
LC
4923
4924@defvr {Scheme Variable} %store-monad
561fb6c3
LC
4925The store monad---an alias for @var{%state-monad}.
4926
4927Values in the store monad encapsulate accesses to the store. When its
4928effect is needed, a value of the store monad must be ``evaluated'' by
4929passing it to the @code{run-with-store} procedure (see below.)
b860f382
LC
4930@end defvr
4931
4932@deffn {Scheme Procedure} run-with-store @var{store} @var{mval} [#:guile-for-build] [#:system (%current-system)]
4933Run @var{mval}, a monadic value in the store monad, in @var{store}, an
4934open store connection.
4935@end deffn
4936
ad372953 4937@deffn {Monadic Procedure} text-file @var{name} @var{text} [@var{references}]
b860f382 4938Return as a monadic value the absolute file name in the store of the file
ad372953
LC
4939containing @var{text}, a string. @var{references} is a list of store items that the
4940resulting text file refers to; it defaults to the empty list.
45adbd62
LC
4941@end deffn
4942
f3a42251
JN
4943@deffn {Monadic Procedure} binary-file @var{name} @var{data} [@var{references}]
4944Return as a monadic value the absolute file name in the store of the file
4945containing @var{data}, a bytevector. @var{references} is a list of store
4946items that the resulting binary file refers to; it defaults to the empty list.
4947@end deffn
4948
0a90af15 4949@deffn {Monadic Procedure} interned-file @var{file} [@var{name}] @
1ec32f4a 4950 [#:recursive? #t] [#:select? (const #t)]
0a90af15
LC
4951Return the name of @var{file} once interned in the store. Use
4952@var{name} as its store name, or the basename of @var{file} if
4953@var{name} is omitted.
4954
4955When @var{recursive?} is true, the contents of @var{file} are added
4956recursively; if @var{file} designates a flat file and @var{recursive?}
4957is true, its contents are added, and its permission bits are kept.
4958
1ec32f4a
LC
4959When @var{recursive?} is true, call @code{(@var{select?} @var{file}
4960@var{stat})} for each directory entry, where @var{file} is the entry's
4961absolute file name and @var{stat} is the result of @code{lstat}; exclude
4962entries for which @var{select?} does not return true.
4963
0a90af15
LC
4964The example below adds a file to the store, under two different names:
4965
4966@example
4967(run-with-store (open-connection)
4968 (mlet %store-monad ((a (interned-file "README"))
4969 (b (interned-file "README" "LEGU-MIN")))
4970 (return (list a b))))
4971
4972@result{} ("/gnu/store/rwm@dots{}-README" "/gnu/store/44i@dots{}-LEGU-MIN")
4973@end example
4974
4975@end deffn
4976
e87f0591
LC
4977The @code{(guix packages)} module exports the following package-related
4978monadic procedures:
4979
b860f382 4980@deffn {Monadic Procedure} package-file @var{package} [@var{file}] @
4231f05b 4981 [#:system (%current-system)] [#:target #f] @
f97c9175
AE
4982 [#:output "out"]
4983Return as a monadic
b860f382
LC
4984value in the absolute file name of @var{file} within the @var{output}
4985directory of @var{package}. When @var{file} is omitted, return the name
4231f05b
LC
4986of the @var{output} directory of @var{package}. When @var{target} is
4987true, use it as a cross-compilation target triplet.
b860f382
LC
4988@end deffn
4989
b860f382 4990@deffn {Monadic Procedure} package->derivation @var{package} [@var{system}]
4231f05b
LC
4991@deffnx {Monadic Procedure} package->cross-derivation @var{package} @
4992 @var{target} [@var{system}]
4993Monadic version of @code{package-derivation} and
4994@code{package-cross-derivation} (@pxref{Defining Packages}).
b860f382
LC
4995@end deffn
4996
4997
21b679f6
LC
4998@node G-Expressions
4999@section G-Expressions
5000
5001@cindex G-expression
5002@cindex build code quoting
5003So we have ``derivations'', which represent a sequence of build actions
5004to be performed to produce an item in the store (@pxref{Derivations}).
f97c9175 5005These build actions are performed when asking the daemon to actually
21b679f6
LC
5006build the derivations; they are run by the daemon in a container
5007(@pxref{Invoking guix-daemon}).
5008
5009@cindex strata of code
f97c9175 5010It should come as no surprise that we like to write these build actions
21b679f6
LC
5011in Scheme. When we do that, we end up with two @dfn{strata} of Scheme
5012code@footnote{The term @dfn{stratum} in this context was coined by
ef4ab0a4
LC
5013Manuel Serrano et al.@: in the context of their work on Hop. Oleg
5014Kiselyov, who has written insightful
5015@url{http://okmij.org/ftp/meta-programming/#meta-scheme, essays and code
5016on this topic}, refers to this kind of code generation as
5017@dfn{staging}.}: the ``host code''---code that defines packages, talks
5018to the daemon, etc.---and the ``build code''---code that actually
5019performs build actions, such as making directories, invoking
5020@command{make}, etc.
21b679f6
LC
5021
5022To describe a derivation and its build actions, one typically needs to
5023embed build code inside host code. It boils down to manipulating build
f97c9175 5024code as data, and the homoiconicity of Scheme---code has a direct
21b679f6 5025representation as data---comes in handy for that. But we need more than
f97c9175 5026the normal @code{quasiquote} mechanism in Scheme to construct build
21b679f6
LC
5027expressions.
5028
5029The @code{(guix gexp)} module implements @dfn{G-expressions}, a form of
5030S-expressions adapted to build expressions. G-expressions, or
f97c9175 5031@dfn{gexps}, consist essentially of three syntactic forms: @code{gexp},
21b679f6 5032@code{ungexp}, and @code{ungexp-splicing} (or simply: @code{#~},
f97c9175
AE
5033@code{#$}, and @code{#$@@}), which are comparable to
5034@code{quasiquote}, @code{unquote}, and @code{unquote-splicing},
4827b36d 5035respectively (@pxref{Expression Syntax, @code{quasiquote},, guile,
f97c9175 5036GNU Guile Reference Manual}). However, there are major differences:
21b679f6
LC
5037
5038@itemize
5039@item
5040Gexps are meant to be written to a file and run or manipulated by other
5041processes.
5042
5043@item
b39fc6f7
LC
5044When a high-level object such as a package or derivation is unquoted
5045inside a gexp, the result is as if its output file name had been
5046introduced.
ff40e9b7 5047
21b679f6
LC
5048@item
5049Gexps carry information about the packages or derivations they refer to,
5050and these dependencies are automatically added as inputs to the build
5051processes that use them.
5052@end itemize
5053
c2b84676 5054@cindex lowering, of high-level objects in gexps
343eacbe
LC
5055This mechanism is not limited to package and derivation
5056objects: @dfn{compilers} able to ``lower'' other high-level objects to
c2b84676
LC
5057derivations or files in the store can be defined,
5058such that these objects can also be inserted
f97c9175 5059into gexps. For example, a useful type of high-level objects that can be
343eacbe 5060inserted in a gexp is ``file-like objects'', which make it easy to
f97c9175 5061add files to the store and to refer to them in
558e8b11
LC
5062derivations and such (see @code{local-file} and @code{plain-file}
5063below.)
b39fc6f7 5064
21b679f6
LC
5065To illustrate the idea, here is an example of a gexp:
5066
5067@example
5068(define build-exp
5069 #~(begin
5070 (mkdir #$output)
5071 (chdir #$output)
aff8ce7c 5072 (symlink (string-append #$coreutils "/bin/ls")
21b679f6
LC
5073 "list-files")))
5074@end example
5075
5076This gexp can be passed to @code{gexp->derivation}; we obtain a
5077derivation that builds a directory containing exactly one symlink to
5078@file{/gnu/store/@dots{}-coreutils-8.22/bin/ls}:
5079
5080@example
5081(gexp->derivation "the-thing" build-exp)
5082@end example
5083
e20fd1bf 5084As one would expect, the @code{"/gnu/store/@dots{}-coreutils-8.22"} string is
21b679f6
LC
5085substituted to the reference to the @var{coreutils} package in the
5086actual build code, and @var{coreutils} is automatically made an input to
5087the derivation. Likewise, @code{#$output} (equivalent to @code{(ungexp
f97c9175
AE
5088output)}) is replaced by a string containing the directory name of the
5089output of the derivation.
667b2508
LC
5090
5091@cindex cross compilation
5092In a cross-compilation context, it is useful to distinguish between
5093references to the @emph{native} build of a package---that can run on the
5094host---versus references to cross builds of a package. To that end, the
5095@code{#+} plays the same role as @code{#$}, but is a reference to a
5096native package build:
5097
5098@example
5099(gexp->derivation "vi"
5100 #~(begin
5101 (mkdir #$output)
5102 (system* (string-append #+coreutils "/bin/ln")
5103 "-s"
5104 (string-append #$emacs "/bin/emacs")
5105 (string-append #$output "/bin/vi")))
4a3b6aa5 5106 #:target "mips64el-linux-gnu")
667b2508
LC
5107@end example
5108
5109@noindent
5110In the example above, the native build of @var{coreutils} is used, so
5111that @command{ln} can actually run on the host; but then the
5112cross-compiled build of @var{emacs} is referenced.
5113
0bb9929e
LC
5114@cindex imported modules, for gexps
5115@findex with-imported-modules
5116Another gexp feature is @dfn{imported modules}: sometimes you want to be
5117able to use certain Guile modules from the ``host environment'' in the
5118gexp, so those modules should be imported in the ``build environment''.
5119The @code{with-imported-modules} form allows you to express that:
5120
5121@example
5122(let ((build (with-imported-modules '((guix build utils))
5123 #~(begin
5124 (use-modules (guix build utils))
5125 (mkdir-p (string-append #$output "/bin"))))))
5126 (gexp->derivation "empty-dir"
5127 #~(begin
5128 #$build
5129 (display "success!\n")
5130 #t)))
5131@end example
5132
5133@noindent
5134In this example, the @code{(guix build utils)} module is automatically
5135pulled into the isolated build environment of our gexp, such that
5136@code{(use-modules (guix build utils))} works as expected.
5137
7ca87354
LC
5138@cindex module closure
5139@findex source-module-closure
5140Usually you want the @emph{closure} of the module to be imported---i.e.,
5141the module itself and all the modules it depends on---rather than just
5142the module; failing to do that, attempts to use the module will fail
5143because of missing dependent modules. The @code{source-module-closure}
5144procedure computes the closure of a module by looking at its source file
5145headers, which comes in handy in this case:
5146
5147@example
5148(use-modules (guix modules)) ;for 'source-module-closure'
5149
5150(with-imported-modules (source-module-closure
5151 '((guix build utils)
5152 (gnu build vm)))
5153 (gexp->derivation "something-with-vms"
5154 #~(begin
5155 (use-modules (guix build utils)
5156 (gnu build vm))
5157 @dots{})))
5158@end example
5159
838e17d8
LC
5160@cindex extensions, for gexps
5161@findex with-extensions
5162In the same vein, sometimes you want to import not just pure-Scheme
5163modules, but also ``extensions'' such as Guile bindings to C libraries
5164or other ``full-blown'' packages. Say you need the @code{guile-json}
5165package available on the build side, here's how you would do it:
5166
5167@example
5168(use-modules (gnu packages guile)) ;for 'guile-json'
5169
5170(with-extensions (list guile-json)
5171 (gexp->derivation "something-with-json"
5172 #~(begin
5173 (use-modules (json))
5174 @dots{})))
5175@end example
5176
667b2508 5177The syntactic form to construct gexps is summarized below.
21b679f6
LC
5178
5179@deffn {Scheme Syntax} #~@var{exp}
5180@deffnx {Scheme Syntax} (gexp @var{exp})
5181Return a G-expression containing @var{exp}. @var{exp} may contain one
5182or more of the following forms:
5183
5184@table @code
5185@item #$@var{obj}
5186@itemx (ungexp @var{obj})
b39fc6f7
LC
5187Introduce a reference to @var{obj}. @var{obj} may have one of the
5188supported types, for example a package or a
21b679f6
LC
5189derivation, in which case the @code{ungexp} form is replaced by its
5190output file name---e.g., @code{"/gnu/store/@dots{}-coreutils-8.22}.
5191
b39fc6f7
LC
5192If @var{obj} is a list, it is traversed and references to supported
5193objects are substituted similarly.
21b679f6
LC
5194
5195If @var{obj} is another gexp, its contents are inserted and its
5196dependencies are added to those of the containing gexp.
5197
5198If @var{obj} is another kind of object, it is inserted as is.
5199
b39fc6f7
LC
5200@item #$@var{obj}:@var{output}
5201@itemx (ungexp @var{obj} @var{output})
21b679f6 5202This is like the form above, but referring explicitly to the
b39fc6f7
LC
5203@var{output} of @var{obj}---this is useful when @var{obj} produces
5204multiple outputs (@pxref{Packages with Multiple Outputs}).
21b679f6 5205
667b2508
LC
5206@item #+@var{obj}
5207@itemx #+@var{obj}:output
5208@itemx (ungexp-native @var{obj})
5209@itemx (ungexp-native @var{obj} @var{output})
5210Same as @code{ungexp}, but produces a reference to the @emph{native}
5211build of @var{obj} when used in a cross compilation context.
5212
21b679f6
LC
5213@item #$output[:@var{output}]
5214@itemx (ungexp output [@var{output}])
5215Insert a reference to derivation output @var{output}, or to the main
5216output when @var{output} is omitted.
5217
5218This only makes sense for gexps passed to @code{gexp->derivation}.
5219
5220@item #$@@@var{lst}
5221@itemx (ungexp-splicing @var{lst})
5222Like the above, but splices the contents of @var{lst} inside the
5223containing list.
5224
667b2508
LC
5225@item #+@@@var{lst}
5226@itemx (ungexp-native-splicing @var{lst})
5227Like the above, but refers to native builds of the objects listed in
5228@var{lst}.
5229
21b679f6
LC
5230@end table
5231
5232G-expressions created by @code{gexp} or @code{#~} are run-time objects
5233of the @code{gexp?} type (see below.)
5234@end deffn
5235
0bb9929e
LC
5236@deffn {Scheme Syntax} with-imported-modules @var{modules} @var{body}@dots{}
5237Mark the gexps defined in @var{body}@dots{} as requiring @var{modules}
d938a58b
LC
5238in their execution environment.
5239
5240Each item in @var{modules} can be the name of a module, such as
5241@code{(guix build utils)}, or it can be a module name, followed by an
5242arrow, followed by a file-like object:
5243
5244@example
5245`((guix build utils)
5246 (guix gcrypt)
5247 ((guix config) => ,(scheme-file "config.scm"
5248 #~(define-module @dots{}))))
5249@end example
5250
5251@noindent
5252In the example above, the first two modules are taken from the search
5253path, and the last one is created from the given file-like object.
0bb9929e
LC
5254
5255This form has @emph{lexical} scope: it has an effect on the gexps
5256directly defined in @var{body}@dots{}, but not on those defined, say, in
5257procedures called from @var{body}@dots{}.
5258@end deffn
5259
838e17d8
LC
5260@deffn {Scheme Syntax} with-extensions @var{extensions} @var{body}@dots{}
5261Mark the gexps defined in @var{body}@dots{} as requiring
5262@var{extensions} in their build and execution environment.
5263@var{extensions} is typically a list of package objects such as those
5264defined in the @code{(gnu packages guile)} module.
5265
5266Concretely, the packages listed in @var{extensions} are added to the
5267load path while compiling imported modules in @var{body}@dots{}; they
5268are also added to the load path of the gexp returned by
5269@var{body}@dots{}.
5270@end deffn
5271
21b679f6
LC
5272@deffn {Scheme Procedure} gexp? @var{obj}
5273Return @code{#t} if @var{obj} is a G-expression.
5274@end deffn
5275
5276G-expressions are meant to be written to disk, either as code building
5277some derivation, or as plain files in the store. The monadic procedures
5278below allow you to do that (@pxref{The Store Monad}, for more
5279information about monads.)
5280
5281@deffn {Monadic Procedure} gexp->derivation @var{name} @var{exp} @
ce45eb4c 5282 [#:system (%current-system)] [#:target #f] [#:graft? #t] @
21b679f6
LC
5283 [#:hash #f] [#:hash-algo #f] @
5284 [#:recursive? #f] [#:env-vars '()] [#:modules '()] @
4684f301 5285 [#:module-path @var{%load-path}] @
838e17d8 5286 [#:effective-version "2.2"] @
c8351d9a 5287 [#:references-graphs #f] [#:allowed-references #f] @
3f4ecf32 5288 [#:disallowed-references #f] @
c0468155 5289 [#:leaked-env-vars #f] @
0309e1b0 5290 [#:script-name (string-append @var{name} "-builder")] @
a912c723 5291 [#:deprecation-warnings #f] @
4a6aeb67 5292 [#:local-build? #f] [#:substitutable? #t] [#:guile-for-build #f]
21b679f6 5293Return a derivation @var{name} that runs @var{exp} (a gexp) with
0309e1b0
LC
5294@var{guile-for-build} (a derivation) on @var{system}; @var{exp} is
5295stored in a file called @var{script-name}. When @var{target} is true,
5296it is used as the cross-compilation target triplet for packages referred
5297to by @var{exp}.
21b679f6 5298
0bb9929e
LC
5299@var{modules} is deprecated in favor of @code{with-imported-modules}.
5300Its meaning is to
5301make @var{modules} available in the evaluation context of @var{exp};
ce45eb4c
LC
5302@var{modules} is a list of names of Guile modules searched in
5303@var{module-path} to be copied in the store, compiled, and made available in
21b679f6
LC
5304the load path during the execution of @var{exp}---e.g., @code{((guix
5305build utils) (guix build gnu-build-system))}.
5306
838e17d8
LC
5307@var{effective-version} determines the string to use when adding extensions of
5308@var{exp} (see @code{with-extensions}) to the search path---e.g., @code{"2.2"}.
5309
ce45eb4c
LC
5310@var{graft?} determines whether packages referred to by @var{exp} should be grafted when
5311applicable.
5312
b53833b2
LC
5313When @var{references-graphs} is true, it must be a list of tuples of one of the
5314following forms:
5315
5316@example
5317(@var{file-name} @var{package})
5318(@var{file-name} @var{package} @var{output})
5319(@var{file-name} @var{derivation})
5320(@var{file-name} @var{derivation} @var{output})
5321(@var{file-name} @var{store-item})
5322@end example
5323
5324The right-hand-side of each element of @var{references-graphs} is automatically made
5325an input of the build process of @var{exp}. In the build environment, each
5326@var{file-name} contains the reference graph of the corresponding item, in a simple
5327text format.
5328
c8351d9a
LC
5329@var{allowed-references} must be either @code{#f} or a list of output names and packages.
5330In the latter case, the list denotes store items that the result is allowed to
5331refer to. Any reference to another store item will lead to a build error.
3f4ecf32
LC
5332Similarly for @var{disallowed-references}, which can list items that must not be
5333referenced by the outputs.
c8351d9a 5334
a912c723
LC
5335@var{deprecation-warnings} determines whether to show deprecation warnings while
5336compiling modules. It can be @code{#f}, @code{#t}, or @code{'detailed}.
5337
e20fd1bf 5338The other arguments are as for @code{derivation} (@pxref{Derivations}).
21b679f6
LC
5339@end deffn
5340
343eacbe 5341@cindex file-like objects
e1c153e0
LC
5342The @code{local-file}, @code{plain-file}, @code{computed-file},
5343@code{program-file}, and @code{scheme-file} procedures below return
5344@dfn{file-like objects}. That is, when unquoted in a G-expression,
5345these objects lead to a file in the store. Consider this G-expression:
343eacbe
LC
5346
5347@example
a9e5e92f 5348#~(system* #$(file-append glibc "/sbin/nscd") "-f"
343eacbe
LC
5349 #$(local-file "/tmp/my-nscd.conf"))
5350@end example
5351
5352The effect here is to ``intern'' @file{/tmp/my-nscd.conf} by copying it
5353to the store. Once expanded, for instance @i{via}
5354@code{gexp->derivation}, the G-expression refers to that copy under
5355@file{/gnu/store}; thus, modifying or removing the file in @file{/tmp}
5356does not have any effect on what the G-expression does.
5357@code{plain-file} can be used similarly; it differs in that the file
5358content is directly passed as a string.
5359
d9ae938f 5360@deffn {Scheme Procedure} local-file @var{file} [@var{name}] @
0687fc9c 5361 [#:recursive? #f] [#:select? (const #t)]
d9ae938f 5362Return an object representing local file @var{file} to add to the store; this
9d3994f7
LC
5363object can be used in a gexp. If @var{file} is a relative file name, it is looked
5364up relative to the source file where this form appears. @var{file} will be added to
5365the store under @var{name}--by default the base name of @var{file}.
d9ae938f
LC
5366
5367When @var{recursive?} is true, the contents of @var{file} are added recursively; if @var{file}
5368designates a flat file and @var{recursive?} is true, its contents are added, and its
5369permission bits are kept.
5370
0687fc9c
LC
5371When @var{recursive?} is true, call @code{(@var{select?} @var{file}
5372@var{stat})} for each directory entry, where @var{file} is the entry's
5373absolute file name and @var{stat} is the result of @code{lstat}; exclude
5374entries for which @var{select?} does not return true.
5375
d9ae938f
LC
5376This is the declarative counterpart of the @code{interned-file} monadic
5377procedure (@pxref{The Store Monad, @code{interned-file}}).
5378@end deffn
5379
558e8b11
LC
5380@deffn {Scheme Procedure} plain-file @var{name} @var{content}
5381Return an object representing a text file called @var{name} with the given
e8e1f295 5382@var{content} (a string or a bytevector) to be added to the store.
558e8b11
LC
5383
5384This is the declarative counterpart of @code{text-file}.
5385@end deffn
5386
91937029 5387@deffn {Scheme Procedure} computed-file @var{name} @var{gexp} @
a769bffb 5388 [#:options '(#:local-build? #t)]
91937029 5389Return an object representing the store item @var{name}, a file or
a769bffb 5390directory computed by @var{gexp}. @var{options}
91937029
LC
5391is a list of additional arguments to pass to @code{gexp->derivation}.
5392
5393This is the declarative counterpart of @code{gexp->derivation}.
5394@end deffn
5395
1ae16033
LC
5396@deffn {Monadic Procedure} gexp->script @var{name} @var{exp} @
5397 [#:guile (default-guile)] [#:module-path %load-path]
21b679f6 5398Return an executable script @var{name} that runs @var{exp} using
9c14a487 5399@var{guile}, with @var{exp}'s imported modules in its search path.
1ae16033 5400Look up @var{exp}'s modules in @var{module-path}.
21b679f6
LC
5401
5402The example below builds a script that simply invokes the @command{ls}
5403command:
5404
5405@example
5406(use-modules (guix gexp) (gnu packages base))
5407
5408(gexp->script "list-files"
a9e5e92f 5409 #~(execl #$(file-append coreutils "/bin/ls")
21b679f6
LC
5410 "ls"))
5411@end example
5412
5413When ``running'' it through the store (@pxref{The Store Monad,
e20fd1bf 5414@code{run-with-store}}), we obtain a derivation that produces an
21b679f6
LC
5415executable file @file{/gnu/store/@dots{}-list-files} along these lines:
5416
5417@example
5418#!/gnu/store/@dots{}-guile-2.0.11/bin/guile -ds
5419!#
a9e5e92f 5420(execl "/gnu/store/@dots{}-coreutils-8.22"/bin/ls" "ls")
21b679f6
LC
5421@end example
5422@end deffn
5423
15a01c72 5424@deffn {Scheme Procedure} program-file @var{name} @var{exp} @
427ec19e 5425 [#:guile #f] [#:module-path %load-path]
15a01c72
LC
5426Return an object representing the executable store item @var{name} that
5427runs @var{gexp}. @var{guile} is the Guile package used to execute that
427ec19e 5428script. Imported modules of @var{gexp} are looked up in @var{module-path}.
15a01c72
LC
5429
5430This is the declarative counterpart of @code{gexp->script}.
5431@end deffn
5432
2b418579 5433@deffn {Monadic Procedure} gexp->file @var{name} @var{exp} @
1ae16033 5434 [#:set-load-path? #t] [#:module-path %load-path] @
4fbd1a2b 5435 [#:splice? #f] @
1ae16033 5436 [#:guile (default-guile)]
21b679f6 5437Return a derivation that builds a file @var{name} containing @var{exp}.
4fbd1a2b
LC
5438When @var{splice?} is true, @var{exp} is considered to be a list of
5439expressions that will be spliced in the resulting file.
5440
2b418579
LC
5441When @var{set-load-path?} is true, emit code in the resulting file to
5442set @code{%load-path} and @code{%load-compiled-path} to honor
1ae16033
LC
5443@var{exp}'s imported modules. Look up @var{exp}'s modules in
5444@var{module-path}.
21b679f6
LC
5445
5446The resulting file holds references to all the dependencies of @var{exp}
5447or a subset thereof.
5448@end deffn
1ed19464 5449
4fbd1a2b 5450@deffn {Scheme Procedure} scheme-file @var{name} @var{exp} [#:splice? #f]
e1c153e0
LC
5451Return an object representing the Scheme file @var{name} that contains
5452@var{exp}.
5453
5454This is the declarative counterpart of @code{gexp->file}.
5455@end deffn
5456
1ed19464
LC
5457@deffn {Monadic Procedure} text-file* @var{name} @var{text} @dots{}
5458Return as a monadic value a derivation that builds a text file
5459containing all of @var{text}. @var{text} may list, in addition to
d9ae938f
LC
5460strings, objects of any type that can be used in a gexp: packages,
5461derivations, local file objects, etc. The resulting store file holds
5462references to all these.
1ed19464
LC
5463
5464This variant should be preferred over @code{text-file} anytime the file
5465to create will reference items from the store. This is typically the
5466case when building a configuration file that embeds store file names,
5467like this:
5468
5469@example
5470(define (profile.sh)
5471 ;; Return the name of a shell script in the store that
5472 ;; initializes the 'PATH' environment variable.
5473 (text-file* "profile.sh"
5474 "export PATH=" coreutils "/bin:"
5475 grep "/bin:" sed "/bin\n"))
5476@end example
5477
5478In this example, the resulting @file{/gnu/store/@dots{}-profile.sh} file
b7899749 5479will reference @var{coreutils}, @var{grep}, and @var{sed}, thereby
1ed19464
LC
5480preventing them from being garbage-collected during its lifetime.
5481@end deffn
21b679f6 5482
b751cde3
LC
5483@deffn {Scheme Procedure} mixed-text-file @var{name} @var{text} @dots{}
5484Return an object representing store file @var{name} containing
5485@var{text}. @var{text} is a sequence of strings and file-like objects,
5486as in:
5487
5488@example
5489(mixed-text-file "profile"
5490 "export PATH=" coreutils "/bin:" grep "/bin")
5491@end example
5492
5493This is the declarative counterpart of @code{text-file*}.
5494@end deffn
5495
dedb512f
LC
5496@deffn {Scheme Procedure} file-union @var{name} @var{files}
5497Return a @code{<computed-file>} that builds a directory containing all of @var{files}.
5498Each item in @var{files} must be a two-element list where the first element is the
5499file name to use in the new directory, and the second element is a gexp
5500denoting the target file. Here's an example:
5501
5502@example
5503(file-union "etc"
5504 `(("hosts" ,(plain-file "hosts"
5505 "127.0.0.1 localhost"))
5506 ("bashrc" ,(plain-file "bashrc"
142869f8 5507 "alias ls='ls --color=auto'"))))
dedb512f
LC
5508@end example
5509
5510This yields an @code{etc} directory containing these two files.
5511@end deffn
5512
d298c815
LC
5513@deffn {Scheme Procedure} directory-union @var{name} @var{things}
5514Return a directory that is the union of @var{things}, where @var{things} is a list of
5515file-like objects denoting directories. For example:
5516
5517@example
5518(directory-union "guile+emacs" (list guile emacs))
5519@end example
5520
5521yields a directory that is the union of the @code{guile} and @code{emacs} packages.
5522@end deffn
5523
a9e5e92f
LC
5524@deffn {Scheme Procedure} file-append @var{obj} @var{suffix} @dots{}
5525Return a file-like object that expands to the concatenation of @var{obj}
5526and @var{suffix}, where @var{obj} is a lowerable object and each
5527@var{suffix} is a string.
5528
5529As an example, consider this gexp:
5530
5531@example
5532(gexp->script "run-uname"
5533 #~(system* #$(file-append coreutils
5534 "/bin/uname")))
5535@end example
5536
5537The same effect could be achieved with:
5538
5539@example
5540(gexp->script "run-uname"
5541 #~(system* (string-append #$coreutils
5542 "/bin/uname")))
5543@end example
5544
5545There is one difference though: in the @code{file-append} case, the
5546resulting script contains the absolute file name as a string, whereas in
5547the second case, the resulting script contains a @code{(string-append
5548@dots{})} expression to construct the file name @emph{at run time}.
5549@end deffn
5550
5551
21b679f6
LC
5552Of course, in addition to gexps embedded in ``host'' code, there are
5553also modules containing build tools. To make it clear that they are
5554meant to be used in the build stratum, these modules are kept in the
5555@code{(guix build @dots{})} name space.
5556
c2b84676
LC
5557@cindex lowering, of high-level objects in gexps
5558Internally, high-level objects are @dfn{lowered}, using their compiler,
5559to either derivations or store items. For instance, lowering a package
5560yields a derivation, and lowering a @code{plain-file} yields a store
5561item. This is achieved using the @code{lower-object} monadic procedure.
5562
5563@deffn {Monadic Procedure} lower-object @var{obj} [@var{system}] @
5564 [#:target #f]
5565Return as a value in @var{%store-monad} the derivation or store item
5566corresponding to @var{obj} for @var{system}, cross-compiling for
5567@var{target} if @var{target} is true. @var{obj} must be an object that
5568has an associated gexp compiler, such as a @code{<package>}.
5569@end deffn
5570
2ca299ca
LC
5571@node Invoking guix repl
5572@section Invoking @command{guix repl}
5573
5574@cindex REPL, read-eval-print loop
5575The @command{guix repl} command spawns a Guile @dfn{read-eval-print loop}
5576(REPL) for interactive programming (@pxref{Using Guile Interactively,,, guile,
5577GNU Guile Reference Manual}). Compared to just launching the @command{guile}
5578command, @command{guix repl} guarantees that all the Guix modules and all its
5579dependencies are available in the search path. You can use it this way:
5580
5581@example
5582$ guix repl
5583scheme@@(guile-user)> ,use (gnu packages base)
5584scheme@@(guile-user)> coreutils
5585$1 = #<package coreutils@@8.29 gnu/packages/base.scm:327 3e28300>
5586@end example
5587
5588@cindex inferiors
5589In addition, @command{guix repl} implements a simple machine-readable REPL
5590protocol for use by @code{(guix inferior)}, a facility to interact with
5591@dfn{inferiors}, separate processes running a potentially different revision
5592of Guix.
5593
5594The available options are as follows:
5595
5596@table @code
5597@item --type=@var{type}
5598@itemx -t @var{type}
5599Start a REPL of the given @var{TYPE}, which can be one of the following:
5600
5601@table @code
5602@item guile
5603This is default, and it spawns a standard full-featured Guile REPL.
5604@item machine
5605Spawn a REPL that uses the machine-readable protocol. This is the protocol
5606that the @code{(guix inferior)} module speaks.
5607@end table
5608
5609@item --listen=@var{endpoint}
5610By default, @command{guix repl} reads from standard input and writes to
5611standard output. When this option is passed, it will instead listen for
5612connections on @var{endpoint}. Here are examples of valid options:
5613
5614@table @code
5615@item --listen=tcp:37146
5616Accept connections on localhost on port 37146.
5617
5618@item --listen=unix:/tmp/socket
5619Accept connections on the Unix-domain socket @file{/tmp/socket}.
5620@end table
5621@end table
21b679f6 5622
568717fd
LC
5623@c *********************************************************************
5624@node Utilities
5625@chapter Utilities
5626
6f773606
LC
5627This section describes Guix command-line utilities. Some of them are
5628primarily targeted at developers and users who write new package
5629definitions, while others are more generally useful. They complement
5630the Scheme programming interface of Guix in a convenient way.
210cc920 5631
568717fd 5632@menu
37166310 5633* Invoking guix build:: Building packages from the command line.
39bee8a2 5634* Invoking guix edit:: Editing package definitions.
210cc920 5635* Invoking guix download:: Downloading a file and printing its hash.
37166310 5636* Invoking guix hash:: Computing the cryptographic hash of a file.
2f7d2d91 5637* Invoking guix import:: Importing package definitions.
37166310 5638* Invoking guix refresh:: Updating package definitions.
b4f5e0e8 5639* Invoking guix lint:: Finding errors in package definitions.
fcc58db6 5640* Invoking guix size:: Profiling disk usage.
88856916 5641* Invoking guix graph:: Visualizing the graph of packages.
372c4bbc 5642* Invoking guix environment:: Setting up development environments.
aff8ce7c 5643* Invoking guix publish:: Sharing substitutes.
d23c20f1 5644* Invoking guix challenge:: Challenging substitute servers.
f11c444d 5645* Invoking guix copy:: Copying to and from a remote store.
32efa254 5646* Invoking guix container:: Process isolation.
585347d7 5647* Invoking guix weather:: Assessing substitute availability.
568717fd
LC
5648@end menu
5649
e49951eb
MW
5650@node Invoking guix build
5651@section Invoking @command{guix build}
568717fd 5652
e32171ee
JD
5653@cindex package building
5654@cindex @command{guix build}
e49951eb 5655The @command{guix build} command builds packages or derivations and
6798a8e4
LC
5656their dependencies, and prints the resulting store paths. Note that it
5657does not modify the user's profile---this is the job of the
e49951eb 5658@command{guix package} command (@pxref{Invoking guix package}). Thus,
6798a8e4
LC
5659it is mainly useful for distribution developers.
5660
5661The general syntax is:
c78bd12b
LC
5662
5663@example
e49951eb 5664guix build @var{options} @var{package-or-derivation}@dots{}
c78bd12b
LC
5665@end example
5666
f97c9175 5667As an example, the following command builds the latest versions of Emacs
ccd7158d
LC
5668and of Guile, displays their build logs, and finally displays the
5669resulting directories:
5670
5671@example
5672guix build emacs guile
5673@end example
5674
5675Similarly, the following command builds all the available packages:
5676
5677@example
5284339d 5678guix build --quiet --keep-going \
ccd7158d
LC
5679 `guix package -A | cut -f1,2 --output-delimiter=@@`
5680@end example
5681
c78bd12b 5682@var{package-or-derivation} may be either the name of a package found in
5401dd75 5683the software distribution such as @code{coreutils} or
e1a65ae5 5684@code{coreutils@@8.20}, or a derivation such as
834129e0 5685@file{/gnu/store/@dots{}-coreutils-8.19.drv}. In the former case, a
e7f34eb0
LC
5686package with the corresponding name (and optionally version) is searched
5687for among the GNU distribution modules (@pxref{Package Modules}).
5688
5689Alternatively, the @code{--expression} option may be used to specify a
5690Scheme expression that evaluates to a package; this is useful when
b7899749 5691disambiguating among several same-named packages or package variants is
e7f34eb0 5692needed.
c78bd12b 5693
ccd7158d
LC
5694There may be zero or more @var{options}. The available options are
5695described in the subsections below.
5696
5697@menu
5698* Common Build Options:: Build options for most commands.
f11c444d 5699* Package Transformation Options:: Creating variants of packages.
ccd7158d 5700* Additional Build Options:: Options specific to 'guix build'.
10f4353d 5701* Debugging Build Failures:: Real life packaging experience.
ccd7158d
LC
5702@end menu
5703
5704@node Common Build Options
5705@subsection Common Build Options
5706
5707A number of options that control the build process are common to
5708@command{guix build} and other commands that can spawn builds, such as
5709@command{guix package} or @command{guix archive}. These are the
5710following:
5711
5712@table @code
5713
5714@item --load-path=@var{directory}
5715@itemx -L @var{directory}
5716Add @var{directory} to the front of the package module search path
5717(@pxref{Package Modules}).
5718
5719This allows users to define their own packages and make them visible to
5720the command-line tools.
5721
5722@item --keep-failed
5723@itemx -K
b7899749 5724Keep the build tree of failed builds. Thus, if a build fails, its build
ccd7158d
LC
5725tree is kept under @file{/tmp}, in a directory whose name is shown at
5726the end of the build log. This is useful when debugging build issues.
fc06b15e
AP
5727@xref{Debugging Build Failures}, for tips and tricks on how to debug
5728build issues.
ccd7158d
LC
5729
5730@item --keep-going
5731@itemx -k
5732Keep going when some of the derivations fail to build; return only once
5733all the builds have either completed or failed.
5734
5735The default behavior is to stop as soon as one of the specified
5736derivations has failed.
5737
5738@item --dry-run
5739@itemx -n
5740Do not build the derivations.
5741
77f92158 5742@anchor{fallback-option}
ccd7158d
LC
5743@item --fallback
5744When substituting a pre-built binary fails, fall back to building
77f92158 5745packages locally (@pxref{Substitution Failure}).
ccd7158d
LC
5746
5747@item --substitute-urls=@var{urls}
5748@anchor{client-substitute-urls}
5749Consider @var{urls} the whitespace-separated list of substitute source
5750URLs, overriding the default list of URLs of @command{guix-daemon}
5751(@pxref{daemon-substitute-urls,, @command{guix-daemon} URLs}).
5752
5753This means that substitutes may be downloaded from @var{urls}, provided
5754they are signed by a key authorized by the system administrator
5755(@pxref{Substitutes}).
5756
71e2065a
LC
5757When @var{urls} is the empty string, substitutes are effectively
5758disabled.
5759
ccd7158d
LC
5760@item --no-substitutes
5761Do not use substitutes for build products. That is, always build things
5762locally instead of allowing downloads of pre-built binaries
5763(@pxref{Substitutes}).
5764
7573d30f
LC
5765@item --no-grafts
5766Do not ``graft'' packages. In practice, this means that package updates
5767available as grafts are not applied. @xref{Security Updates}, for more
5768information on grafts.
5769
ccd7158d
LC
5770@item --rounds=@var{n}
5771Build each derivation @var{n} times in a row, and raise an error if
5772consecutive build results are not bit-for-bit identical.
5773
5774This is a useful way to detect non-deterministic builds processes.
5775Non-deterministic build processes are a problem because they make it
5776practically impossible for users to @emph{verify} whether third-party
5777binaries are genuine. @xref{Invoking guix challenge}, for more.
5778
5779Note that, currently, the differing build results are not kept around,
5780so you will have to manually investigate in case of an error---e.g., by
e66d1f59
ML
5781stashing one of the build results with @code{guix archive --export}
5782(@pxref{Invoking guix archive}), then rebuilding, and finally comparing
5783the two results.
ccd7158d
LC
5784
5785@item --no-build-hook
f97c9175 5786Do not attempt to offload builds @i{via} the ``build hook'' of the daemon
ccd7158d
LC
5787(@pxref{Daemon Offload Setup}). That is, always build things locally
5788instead of offloading builds to remote machines.
5789
5790@item --max-silent-time=@var{seconds}
5791When the build or substitution process remains silent for more than
5792@var{seconds}, terminate it and report a build failure.
5793
2ca9f51e
LC
5794By default, the daemon's setting is honored (@pxref{Invoking
5795guix-daemon, @code{--max-silent-time}}).
5796
ccd7158d
LC
5797@item --timeout=@var{seconds}
5798Likewise, when the build or substitution process lasts for more than
5799@var{seconds}, terminate it and report a build failure.
5800
2ca9f51e
LC
5801By default, the daemon's setting is honored (@pxref{Invoking
5802guix-daemon, @code{--timeout}}).
ccd7158d
LC
5803
5804@item --verbosity=@var{level}
5805Use the given verbosity level. @var{level} must be an integer between 0
5806and 5; higher means more verbose output. Setting a level of 4 or more
5807may be helpful when debugging setup issues with the build daemon.
5808
5809@item --cores=@var{n}
5810@itemx -c @var{n}
5811Allow the use of up to @var{n} CPU cores for the build. The special
5812value @code{0} means to use as many CPU cores as available.
5813
5814@item --max-jobs=@var{n}
5815@itemx -M @var{n}
5816Allow at most @var{n} build jobs in parallel. @xref{Invoking
5817guix-daemon, @code{--max-jobs}}, for details about this option and the
5818equivalent @command{guix-daemon} option.
5819
5820@end table
5821
5822Behind the scenes, @command{guix build} is essentially an interface to
5823the @code{package-derivation} procedure of the @code{(guix packages)}
5824module, and to the @code{build-derivations} procedure of the @code{(guix
5825derivations)} module.
5826
5827In addition to options explicitly passed on the command line,
5828@command{guix build} and other @command{guix} commands that support
5829building honor the @code{GUIX_BUILD_OPTIONS} environment variable.
5830
5831@defvr {Environment Variable} GUIX_BUILD_OPTIONS
5832Users can define this variable to a list of command line options that
5833will automatically be used by @command{guix build} and other
5834@command{guix} commands that can perform builds, as in the example
5835below:
5836
5837@example
5838$ export GUIX_BUILD_OPTIONS="--no-substitutes -c 2 -L /foo/bar"
5839@end example
5840
5841These options are parsed independently, and the result is appended to
5842the parsed command-line options.
5843@end defvr
5844
88ad6ded
LC
5845
5846@node Package Transformation Options
5847@subsection Package Transformation Options
5848
5849@cindex package variants
5850Another set of command-line options supported by @command{guix build}
b8638f03 5851and also @command{guix package} are @dfn{package transformation
f97c9175 5852options}. These are options that make it possible to define @dfn{package
b8638f03
LC
5853variants}---for instance, packages built from different source code.
5854This is a convenient way to create customized packages on the fly
5855without having to type in the definitions of package variants
5856(@pxref{Defining Packages}).
88ad6ded
LC
5857
5858@table @code
5859
5860@item --with-source=@var{source}
3e30cdf1
LC
5861@itemx --with-source=@var{package}=@var{source}
5862@itemx --with-source=@var{package}@@@var{version}=@var{source}
5863Use @var{source} as the source of @var{package}, and @var{version} as
5864its version number.
88ad6ded
LC
5865@var{source} must be a file name or a URL, as for @command{guix
5866download} (@pxref{Invoking guix download}).
5867
3e30cdf1
LC
5868When @var{package} is omitted,
5869it is taken to be the package name specified on the
5870command line that matches the base of @var{source}---e.g.,
f97c9175 5871if @var{source} is @code{/src/guile-2.0.10.tar.gz}, the corresponding
3e30cdf1
LC
5872package is @code{guile}.
5873
5874Likewise, when @var{version} is omitted, the version string is inferred from
f97c9175 5875@var{source}; in the previous example, it is @code{2.0.10}.
88ad6ded
LC
5876
5877This option allows users to try out versions of packages other than the
5878one provided by the distribution. The example below downloads
5879@file{ed-1.7.tar.gz} from a GNU mirror and uses that as the source for
5880the @code{ed} package:
5881
5882@example
5883guix build ed --with-source=mirror://gnu/ed/ed-1.7.tar.gz
5884@end example
5885
5886As a developer, @code{--with-source} makes it easy to test release
5887candidates:
5888
5889@example
5890guix build guile --with-source=../guile-2.0.9.219-e1bb7.tar.xz
5891@end example
5892
5893@dots{} or to build from a checkout in a pristine environment:
5894
5895@example
5896$ git clone git://git.sv.gnu.org/guix.git
3e30cdf1 5897$ guix build guix --with-source=guix@@1.0=./guix
88ad6ded
LC
5898@end example
5899
47c0f92c
LC
5900@item --with-input=@var{package}=@var{replacement}
5901Replace dependency on @var{package} by a dependency on
5902@var{replacement}. @var{package} must be a package name, and
5903@var{replacement} must be a package specification such as @code{guile}
5904or @code{guile@@1.8}.
5905
f97c9175 5906For instance, the following command builds Guix, but replaces its
47c0f92c 5907dependency on the current stable version of Guile with a dependency on
f6396d86 5908the legacy version of Guile, @code{guile@@2.0}:
47c0f92c
LC
5909
5910@example
f6396d86 5911guix build --with-input=guile=guile@@2.0 guix
47c0f92c
LC
5912@end example
5913
5914This is a recursive, deep replacement. So in this example, both
5915@code{guix} and its dependency @code{guile-json} (which also depends on
f6396d86 5916@code{guile}) get rebuilt against @code{guile@@2.0}.
47c0f92c 5917
2a75b0b6
LC
5918This is implemented using the @code{package-input-rewriting} Scheme
5919procedure (@pxref{Defining Packages, @code{package-input-rewriting}}).
645b9df8
LC
5920
5921@item --with-graft=@var{package}=@var{replacement}
5922This is similar to @code{--with-input} but with an important difference:
9b4ec573 5923instead of rebuilding the whole dependency chain, @var{replacement} is
645b9df8
LC
5924built and then @dfn{grafted} onto the binaries that were initially
5925referring to @var{package}. @xref{Security Updates}, for more
5926information on grafts.
5927
5928For example, the command below grafts version 3.5.4 of GnuTLS onto Wget
5929and all its dependencies, replacing references to the version of GnuTLS
5930they currently refer to:
5931
5932@example
5933guix build --with-graft=gnutls=gnutls@@3.5.4 wget
5934@end example
5935
5936This has the advantage of being much faster than rebuilding everything.
5937But there is a caveat: it works if and only if @var{package} and
5938@var{replacement} are strictly compatible---for example, if they provide
5939a library, the application binary interface (ABI) of those libraries
5940must be compatible. If @var{replacement} is somehow incompatible with
5941@var{package}, then the resulting package may be unusable. Use with
5942care!
5943
88ad6ded
LC
5944@end table
5945
ccd7158d
LC
5946@node Additional Build Options
5947@subsection Additional Build Options
5948
5949The command-line options presented below are specific to @command{guix
5950build}.
c78bd12b
LC
5951
5952@table @code
5953
5284339d
LC
5954@item --quiet
5955@itemx -q
5956Build quietly, without displaying the build log. Upon completion, the
5957build log is kept in @file{/var} (or similar) and can always be
5958retrieved using the @option{--log-file} option.
5959
34a1783f
DT
5960@item --file=@var{file}
5961@itemx -f @var{file}
5962
5963Build the package or derivation that the code within @var{file}
5964evaluates to.
5965
5966As an example, @var{file} might contain a package definition like this
5967(@pxref{Defining Packages}):
5968
5969@example
5970@verbatiminclude package-hello.scm
5971@end example
5972
c78bd12b
LC
5973@item --expression=@var{expr}
5974@itemx -e @var{expr}
ac5de156 5975Build the package or derivation @var{expr} evaluates to.
c78bd12b 5976
5401dd75 5977For example, @var{expr} may be @code{(@@ (gnu packages guile)
c78bd12b
LC
5978guile-1.8)}, which unambiguously designates this specific variant of
5979version 1.8 of Guile.
5980
f97c9175 5981Alternatively, @var{expr} may be a G-expression, in which case it is used
56b82106
LC
5982as a build program passed to @code{gexp->derivation}
5983(@pxref{G-Expressions}).
5984
5985Lastly, @var{expr} may refer to a zero-argument monadic procedure
ac5de156
LC
5986(@pxref{The Store Monad}). The procedure must return a derivation as a
5987monadic value, which is then passed through @code{run-with-store}.
5988
c78bd12b
LC
5989@item --source
5990@itemx -S
f97c9175 5991Build the source derivations of the packages, rather than the packages
c78bd12b
LC
5992themselves.
5993
e49951eb 5994For instance, @code{guix build -S gcc} returns something like
f97c9175
AE
5995@file{/gnu/store/@dots{}-gcc-4.7.2.tar.bz2}, which is the GCC
5996source tarball.
c78bd12b 5997
f9cc8971 5998The returned source tarball is the result of applying any patches and
f97c9175 5999code snippets specified in the package @code{origin} (@pxref{Defining
f9cc8971
LC
6000Packages}).
6001
2cdfe13d
EB
6002@item --sources
6003Fetch and return the source of @var{package-or-derivation} and all their
6004dependencies, recursively. This is a handy way to obtain a local copy
6005of all the source code needed to build @var{packages}, allowing you to
6006eventually build them even without network access. It is an extension
6007of the @code{--source} option and can accept one of the following
6008optional argument values:
6009
6010@table @code
6011@item package
6012This value causes the @code{--sources} option to behave in the same way
6013as the @code{--source} option.
6014
6015@item all
f97c9175
AE
6016Build the source derivations of all packages, including any source that
6017might be listed as @code{inputs}. This is the default value.
2cdfe13d
EB
6018
6019@example
6020$ guix build --sources tzdata
6021The following derivations will be built:
6022 /gnu/store/@dots{}-tzdata2015b.tar.gz.drv
6023 /gnu/store/@dots{}-tzcode2015b.tar.gz.drv
6024@end example
6025
6026@item transitive
f97c9175
AE
6027Build the source derivations of all packages, as well of all transitive
6028inputs to the packages. This can be used e.g. to
2cdfe13d
EB
6029prefetch package source for later offline building.
6030
6031@example
6032$ guix build --sources=transitive tzdata
6033The following derivations will be built:
6034 /gnu/store/@dots{}-tzcode2015b.tar.gz.drv
6035 /gnu/store/@dots{}-findutils-4.4.2.tar.xz.drv
6036 /gnu/store/@dots{}-grep-2.21.tar.xz.drv
6037 /gnu/store/@dots{}-coreutils-8.23.tar.xz.drv
6038 /gnu/store/@dots{}-make-4.1.tar.xz.drv
6039 /gnu/store/@dots{}-bash-4.3.tar.xz.drv
6040@dots{}
6041@end example
6042
6043@end table
6044
c78bd12b
LC
6045@item --system=@var{system}
6046@itemx -s @var{system}
6047Attempt to build for @var{system}---e.g., @code{i686-linux}---instead of
f97c9175 6048the system type of the build host.
c78bd12b 6049
71b98b9d
LC
6050@quotation Note
6051The @code{--system} flag is for @emph{native} compilation and must not
6052be confused with cross-compilation. See @code{--target} below for
6053information on cross-compilation.
6054@end quotation
6055
c78bd12b
LC
6056An example use of this is on Linux-based systems, which can emulate
6057different personalities. For instance, passing
162825f9
EF
6058@code{--system=i686-linux} on an @code{x86_64-linux} system or
6059@code{--system=armhf-linux} on an @code{aarch64-linux} system allows you
c78bd12b
LC
6060to build packages in a complete 32-bit environment.
6061
162825f9
EF
6062@quotation Note
6063Building for an @code{armhf-linux} system is unconditionally enabled on
6064@code{aarch64-linux} machines, although certain aarch64 chipsets do not
6065allow for this functionality, notably the ThunderX.
6066@end quotation
6067
71b98b9d
LC
6068Similarly, when transparent emulation with QEMU and @code{binfmt_misc}
6069is enabled (@pxref{Virtualization Services,
6070@code{qemu-binfmt-service-type}}), you can build for any system for
6071which a QEMU @code{binfmt_misc} handler is installed.
6072
6073Builds for a system other than that of the machine you are using can
6074also be offloaded to a remote machine of the right architecture.
6075@xref{Daemon Offload Setup}, for more information on offloading.
6076
e55ec43d
LC
6077@item --target=@var{triplet}
6078@cindex cross-compilation
6079Cross-build for @var{triplet}, which must be a valid GNU triplet, such
5461115e
LC
6080as @code{"mips64el-linux-gnu"} (@pxref{Specifying target triplets, GNU
6081configuration triplets,, autoconf, Autoconf}).
e55ec43d 6082
a8d65643
LC
6083@anchor{build-check}
6084@item --check
6085@cindex determinism, checking
6086@cindex reproducibility, checking
6087Rebuild @var{package-or-derivation}, which are already available in the
6088store, and raise an error if the build results are not bit-for-bit
6089identical.
6090
f97c9175
AE
6091This mechanism allows you to check whether previously installed
6092substitutes are genuine (@pxref{Substitutes}), or whether the build result
6093of a package is deterministic. @xref{Invoking guix challenge}, for more
a8d65643
LC
6094background information and tools.
6095
7f3b2510
ED
6096When used in conjunction with @option{--keep-failed}, the differing
6097output is kept in the store, under @file{/gnu/store/@dots{}-check}.
6098This makes it easy to look for differences between the two results.
6099
6da5bb7b
LC
6100@item --repair
6101@cindex repairing store items
6102@cindex corruption, recovering from
6103Attempt to repair the specified store items, if they are corrupt, by
6104re-downloading or rebuilding them.
6105
6106This operation is not atomic and thus restricted to @code{root}.
6107
c78bd12b
LC
6108@item --derivations
6109@itemx -d
6110Return the derivation paths, not the output paths, of the given
6111packages.
6112
70ee5642
LC
6113@item --root=@var{file}
6114@itemx -r @var{file}
6a98b9f3
LC
6115@cindex GC roots, adding
6116@cindex garbage collector roots, adding
70ee5642
LC
6117Make @var{file} a symlink to the result, and register it as a garbage
6118collector root.
6119
6a98b9f3
LC
6120Consequently, the results of this @command{guix build} invocation are
6121protected from garbage collection until @var{file} is removed. When
6122that option is omitted, build results are eligible for garbage
6123collection as soon as the build completes. @xref{Invoking guix gc}, for
6124more on GC roots.
6125
70ee5642 6126@item --log-file
c04ffadb 6127@cindex build logs, access
3f208ad7 6128Return the build log file names or URLs for the given
f97c9175 6129@var{package-or-derivation}, or raise an error if build logs are
70ee5642
LC
6130missing.
6131
6132This works regardless of how packages or derivations are specified. For
6133instance, the following invocations are equivalent:
6134
6135@example
6136guix build --log-file `guix build -d guile`
6137guix build --log-file `guix build guile`
6138guix build --log-file guile
6139guix build --log-file -e '(@@ (gnu packages guile) guile-2.0)'
6140@end example
6141
3f208ad7
LC
6142If a log is unavailable locally, and unless @code{--no-substitutes} is
6143passed, the command looks for a corresponding log on one of the
6144substitute servers (as specified with @code{--substitute-urls}.)
70ee5642 6145
f97c9175
AE
6146So for instance, imagine you want to see the build log of GDB on MIPS,
6147but you are actually on an @code{x86_64} machine:
3f208ad7
LC
6148
6149@example
a01ad638 6150$ guix build --log-file gdb -s mips64el-linux
df061d07 6151https://hydra.gnu.org/log/@dots{}-gdb-7.10
3f208ad7
LC
6152@end example
6153
6154You can freely access a huge library of build logs!
70ee5642
LC
6155@end table
6156
fc06b15e
AP
6157@node Debugging Build Failures
6158@subsection Debugging Build Failures
6159
6160@cindex build failures, debugging
6161When defining a new package (@pxref{Defining Packages}), you will
6162probably find yourself spending some time debugging and tweaking the
6163build until it succeeds. To do that, you need to operate the build
6164commands yourself in an environment as close as possible to the one the
6165build daemon uses.
6166
6167To that end, the first thing to do is to use the @option{--keep-failed}
6168or @option{-K} option of @command{guix build}, which will keep the
6169failed build tree in @file{/tmp} or whatever directory you specified as
6170@code{TMPDIR} (@pxref{Invoking guix build, @code{--keep-failed}}).
6171
6172From there on, you can @command{cd} to the failed build tree and source
6173the @file{environment-variables} file, which contains all the
6174environment variable definitions that were in place when the build
6175failed. So let's say you're debugging a build failure in package
6176@code{foo}; a typical session would look like this:
6177
6178@example
6179$ guix build foo -K
6180@dots{} @i{build fails}
6181$ cd /tmp/guix-build-foo.drv-0
6182$ source ./environment-variables
6183$ cd foo-1.2
6184@end example
6185
6186Now, you can invoke commands as if you were the daemon (almost) and
6187troubleshoot your build process.
6188
6189Sometimes it happens that, for example, a package's tests pass when you
6190run them manually but they fail when the daemon runs them. This can
6191happen because the daemon runs builds in containers where, unlike in our
6192environment above, network access is missing, @file{/bin/sh} does not
6193exist, etc. (@pxref{Build Environment Setup}).
6194
6195In such cases, you may need to run inspect the build process from within
6196a container similar to the one the build daemon creates:
6197
6198@example
6199$ guix build -K foo
6200@dots{}
6201$ cd /tmp/guix-build-foo.drv-0
fa511e29 6202$ guix environment --no-grafts -C foo --ad-hoc strace gdb
fc06b15e
AP
6203[env]# source ./environment-variables
6204[env]# cd foo-1.2
6205@end example
6206
6207Here, @command{guix environment -C} creates a container and spawns a new
6208shell in it (@pxref{Invoking guix environment}). The @command{--ad-hoc
6209strace gdb} part adds the @command{strace} and @command{gdb} commands to
fa511e29
LC
6210the container, which would may find handy while debugging. The
6211@option{--no-grafts} option makes sure we get the exact same
6212environment, with ungrafted packages (@pxref{Security Updates}, for more
6213info on grafts).
fc06b15e
AP
6214
6215To get closer to a container like that used by the build daemon, we can
6216remove @file{/bin/sh}:
6217
6218@example
6219[env]# rm /bin/sh
6220@end example
6221
6222(Don't worry, this is harmless: this is all happening in the throw-away
6223container created by @command{guix environment}.)
6224
6225The @command{strace} command is probably not in the search path, but we
6226can run:
6227
6228@example
6229[env]# $GUIX_ENVIRONMENT/bin/strace -f -o log make check
6230@end example
6231
6232In this way, not only you will have reproduced the environment variables
6233the daemon uses, you will also be running the build process in a container
6234similar to the one the daemon uses.
6235
16eb115e 6236
39bee8a2
LC
6237@node Invoking guix edit
6238@section Invoking @command{guix edit}
6239
e32171ee 6240@cindex @command{guix edit}
39bee8a2
LC
6241@cindex package definition, editing
6242So many packages, so many source files! The @command{guix edit} command
424a323e
GC
6243facilitates the life of users and packagers by pointing their editor at
6244the source file containing the definition of the specified packages.
6245For instance:
39bee8a2
LC
6246
6247@example
7b9a66e5 6248guix edit gcc@@4.9 vim
39bee8a2
LC
6249@end example
6250
6251@noindent
6237b9fa 6252launches the program specified in the @code{VISUAL} or in the
424a323e 6253@code{EDITOR} environment variable to view the recipe of GCC@tie{}4.9.3
6237b9fa 6254and that of Vim.
39bee8a2 6255
424a323e
GC
6256If you are using a Guix Git checkout (@pxref{Building from Git}), or
6257have created your own packages on @code{GUIX_PACKAGE_PATH}
6258(@pxref{Defining Packages}), you will be able to edit the package
6259recipes. Otherwise, you will be able to examine the read-only recipes
6260for packages currently in the store.
6261
39bee8a2 6262
210cc920
LC
6263@node Invoking guix download
6264@section Invoking @command{guix download}
6265
e32171ee
JD
6266@cindex @command{guix download}
6267@cindex downloading package sources
210cc920 6268When writing a package definition, developers typically need to download
f97c9175 6269a source tarball, compute its SHA256 hash, and write that
210cc920
LC
6270hash in the package definition (@pxref{Defining Packages}). The
6271@command{guix download} tool helps with this task: it downloads a file
6272from the given URI, adds it to the store, and prints both its file name
6273in the store and its SHA256 hash.
6274
6275The fact that the downloaded file is added to the store saves bandwidth:
6276when the developer eventually tries to build the newly defined package
6277with @command{guix build}, the source tarball will not have to be
6278downloaded again because it is already in the store. It is also a
6279convenient way to temporarily stash files, which may be deleted
6280eventually (@pxref{Invoking guix gc}).
6281
6282The @command{guix download} command supports the same URIs as used in
6283package definitions. In particular, it supports @code{mirror://} URIs.
6284@code{https} URIs (HTTP over TLS) are supported @emph{provided} the
6285Guile bindings for GnuTLS are available in the user's environment; when
537c8bb3
LC
6286they are not available, an error is raised. @xref{Guile Preparations,
6287how to install the GnuTLS bindings for Guile,, gnutls-guile,
6288GnuTLS-Guile}, for more information.
210cc920 6289
bc3c41ce
LC
6290@command{guix download} verifies HTTPS server certificates by loading
6291the certificates of X.509 authorities from the directory pointed to by
6292the @code{SSL_CERT_DIR} environment variable (@pxref{X.509
64b8695c 6293Certificates}), unless @option{--no-check-certificate} is used.
bc3c41ce 6294
64b8695c 6295The following options are available:
210cc920
LC
6296
6297@table @code
6298@item --format=@var{fmt}
6299@itemx -f @var{fmt}
6300Write the hash in the format specified by @var{fmt}. For more
081145cf 6301information on the valid values for @var{fmt}, @pxref{Invoking guix hash}.
64b8695c
LC
6302
6303@item --no-check-certificate
6304Do not validate the X.509 certificates of HTTPS servers.
6305
6306When using this option, you have @emph{absolutely no guarantee} that you
6307are communicating with the authentic server responsible for the given
6308URL, which makes you vulnerable to ``man-in-the-middle'' attacks.
6309
1bcc87bb
LC
6310@item --output=@var{file}
6311@itemx -o @var{file}
6312Save the downloaded file to @var{file} instead of adding it to the
6313store.
210cc920
LC
6314@end table
6315
6c365eca
NK
6316@node Invoking guix hash
6317@section Invoking @command{guix hash}
6318
e32171ee 6319@cindex @command{guix hash}
210cc920 6320The @command{guix hash} command computes the SHA256 hash of a file.
6c365eca
NK
6321It is primarily a convenience tool for anyone contributing to the
6322distribution: it computes the cryptographic hash of a file, which can be
6323used in the definition of a package (@pxref{Defining Packages}).
6324
6325The general syntax is:
6326
6327@example
6328guix hash @var{option} @var{file}
6329@end example
6330
343dc117
LC
6331When @var{file} is @code{-} (a hyphen), @command{guix hash} computes the
6332hash of data read from standard input. @command{guix hash} has the
6333following options:
6c365eca
NK
6334
6335@table @code
6336
6337@item --format=@var{fmt}
6338@itemx -f @var{fmt}
210cc920 6339Write the hash in the format specified by @var{fmt}.
6c365eca
NK
6340
6341Supported formats: @code{nix-base32}, @code{base32}, @code{base16}
6342(@code{hex} and @code{hexadecimal} can be used as well).
6343
6344If the @option{--format} option is not specified, @command{guix hash}
6345will output the hash in @code{nix-base32}. This representation is used
6346in the definitions of packages.
6347
3140f2df
LC
6348@item --recursive
6349@itemx -r
6350Compute the hash on @var{file} recursively.
6351
6352In this case, the hash is computed on an archive containing @var{file},
f97c9175
AE
6353including its children if it is a directory. Some of the metadata of
6354@var{file} is part of the archive; for instance, when @var{file} is a
3140f2df 6355regular file, the hash is different depending on whether @var{file} is
f97c9175 6356executable or not. Metadata such as time stamps has no impact on the
3140f2df
LC
6357hash (@pxref{Invoking guix archive}).
6358@c FIXME: Replace xref above with xref to an ``Archive'' section when
6359@c it exists.
6360
392a4e12
JN
6361@item --exclude-vcs
6362@itemx -x
6363When combined with @option{--recursive}, exclude version control system
6364directories (@file{.bzr}, @file{.git}, @file{.hg}, etc.)
6365
db97a03a
LC
6366@vindex git-fetch
6367As an example, here is how you would compute the hash of a Git checkout,
6368which is useful when using the @code{git-fetch} method (@pxref{origin
6369Reference}):
6370
6371@example
6372$ git clone http://example.org/foo.git
6373$ cd foo
392a4e12 6374$ guix hash -rx .
db97a03a 6375@end example
6c365eca
NK
6376@end table
6377
2f7d2d91
LC
6378@node Invoking guix import
6379@section Invoking @command{guix import}
6380
6381@cindex importing packages
6382@cindex package import
6383@cindex package conversion
e32171ee 6384@cindex Invoking @command{guix import}
f97c9175
AE
6385The @command{guix import} command is useful for people who would like to
6386add a package to the distribution with as little work as
6387possible---a legitimate demand. The command knows of a few
6388repositories from which it can ``import'' package metadata. The result
2f7d2d91
LC
6389is a package definition, or a template thereof, in the format we know
6390(@pxref{Defining Packages}).
6391
6392The general syntax is:
6393
6394@example
6395guix import @var{importer} @var{options}@dots{}
6396@end example
6397
6398@var{importer} specifies the source from which to import package
f97c9175 6399metadata, and @var{options} specifies a package identifier and other
2f7d2d91
LC
6400options specific to @var{importer}. Currently, the available
6401``importers'' are:
6402
6403@table @code
6404@item gnu
f97c9175 6405Import metadata for the given GNU package. This provides a template
2f7d2d91
LC
6406for the latest version of that GNU package, including the hash of its
6407source tarball, and its canonical synopsis and description.
6408
f97c9175 6409Additional information such as the package dependencies and its
2f7d2d91
LC
6410license needs to be figured out manually.
6411
6412For example, the following command returns a package definition for
6413GNU@tie{}Hello:
6414
6415@example
6416guix import gnu hello
6417@end example
6418
6419Specific command-line options are:
6420
6421@table @code
6422@item --key-download=@var{policy}
6423As for @code{guix refresh}, specify the policy to handle missing OpenPGP
f97c9175 6424keys when verifying the package signature. @xref{Invoking guix
2f7d2d91
LC
6425refresh, @code{--key-download}}.
6426@end table
6427
6428@item pypi
6429@cindex pypi
f97c9175 6430Import metadata from the @uref{https://pypi.python.org/, Python Package
2f7d2d91
LC
6431Index}@footnote{This functionality requires Guile-JSON to be installed.
6432@xref{Requirements}.}. Information is taken from the JSON-formatted
6433description available at @code{pypi.python.org} and usually includes all
266785d2
CR
6434the relevant information, including package dependencies. For maximum
6435efficiency, it is recommended to install the @command{unzip} utility, so
6436that the importer can unzip Python wheels and gather data from them.
2f7d2d91 6437
f97c9175 6438The command below imports metadata for the @code{itsdangerous} Python
2f7d2d91
LC
6439package:
6440
6441@example
6442guix import pypi itsdangerous
6443@end example
6444
3aae8145
DT
6445@item gem
6446@cindex gem
f97c9175 6447Import metadata from @uref{https://rubygems.org/,
3aae8145
DT
6448RubyGems}@footnote{This functionality requires Guile-JSON to be
6449installed. @xref{Requirements}.}. Information is taken from the
6450JSON-formatted description available at @code{rubygems.org} and includes
6451most relevant information, including runtime dependencies. There are
f97c9175 6452some caveats, however. The metadata doesn't distinguish between
3aae8145
DT
6453synopses and descriptions, so the same string is used for both fields.
6454Additionally, the details of non-Ruby dependencies required to build
6455native extensions is unavailable and left as an exercise to the
6456packager.
6457
f97c9175 6458The command below imports metadata for the @code{rails} Ruby package:
3aae8145
DT
6459
6460@example
6461guix import gem rails
6462@end example
6463
88388766
OP
6464@table @code
6465@item --recursive
6466@itemx -r
6467Traverse the dependency graph of the given upstream package recursively
6468and generate package expressions for all those packages that are not yet
6469in Guix.
6470@end table
6471
d45dc6da
EB
6472@item cpan
6473@cindex CPAN
3c192e4e
AE
6474Import metadata from @uref{https://www.metacpan.org/, MetaCPAN}@footnote{This
6475functionality requires Guile-JSON to be installed.
6476@xref{Requirements}.}.
f97c9175 6477Information is taken from the JSON-formatted metadata provided through
ecb28e64 6478@uref{https://fastapi.metacpan.org/, MetaCPAN's API} and includes most
66392e47
EB
6479relevant information, such as module dependencies. License information
6480should be checked closely. If Perl is available in the store, then the
6481@code{corelist} utility will be used to filter core modules out of the
6482list of dependencies.
d45dc6da 6483
f97c9175 6484The command command below imports metadata for the @code{Acme::Boolean}
d45dc6da
EB
6485Perl module:
6486
6487@example
6488guix import cpan Acme::Boolean
6489@end example
6490
e1248602
RW
6491@item cran
6492@cindex CRAN
d0bd632f 6493@cindex Bioconductor
e9960d8c 6494Import metadata from @uref{https://cran.r-project.org/, CRAN}, the
e1248602
RW
6495central repository for the @uref{http://r-project.org, GNU@tie{}R
6496statistical and graphical environment}.
6497
f97c9175 6498Information is extracted from the @code{DESCRIPTION} file of the package.
e1248602 6499
f97c9175 6500The command command below imports metadata for the @code{Cairo}
e1248602
RW
6501R package:
6502
6503@example
6504guix import cran Cairo
6505@end example
6506
64ce53eb
RW
6507When @code{--recursive} is added, the importer will traverse the
6508dependency graph of the given upstream package recursively and generate
6509package expressions for all those packages that are not yet in Guix.
6510
f97c9175 6511When @code{--archive=bioconductor} is added, metadata is imported from
5713bbf1 6512@uref{https://www.bioconductor.org/, Bioconductor}, a repository of R
d0bd632f
RW
6513packages for for the analysis and comprehension of high-throughput
6514genomic data in bioinformatics.
6515
f97c9175 6516Information is extracted from the @code{DESCRIPTION} file of a package
d0bd632f
RW
6517published on the web interface of the Bioconductor SVN repository.
6518
f97c9175 6519The command below imports metadata for the @code{GenomicRanges}
d0bd632f
RW
6520R package:
6521
6522@example
6523guix import cran --archive=bioconductor GenomicRanges
6524@end example
6525
afbc9419
RW
6526@item texlive
6527@cindex TeX Live
6528@cindex CTAN
6529Import metadata from @uref{http://www.ctan.org/, CTAN}, the
6530comprehensive TeX archive network for TeX packages that are part of the
6531@uref{https://www.tug.org/texlive/, TeX Live distribution}.
6532
6533Information about the package is obtained through the XML API provided
6534by CTAN, while the source code is downloaded from the SVN repository of
6535the Tex Live project. This is done because the CTAN does not keep
6536versioned archives.
6537
6538The command command below imports metadata for the @code{fontspec}
6539TeX package:
6540
6541@example
6542guix import texlive fontspec
6543@end example
6544
6545When @code{--archive=DIRECTORY} is added, the source code is downloaded
6546not from the @file{latex} sub-directory of the @file{texmf-dist/source}
6547tree in the TeX Live SVN repository, but from the specified sibling
6548directory under the same root.
6549
6550The command below imports metadata for the @code{ifxetex} package from
6551CTAN while fetching the sources from the directory
6552@file{texmf/source/generic}:
6553
6554@example
6555guix import texlive --archive=generic ifxetex
6556@end example
6557
fb1db385
RW
6558@item json
6559@cindex JSON, import
6560Import package metadata from a local JSON file@footnote{This
6561functionality requires Guile-JSON to be installed.
6562@xref{Requirements}.}. Consider the following example package
6563definition in JSON format:
6564
6565@example
6566@{
6567 "name": "hello",
6568 "version": "2.10",
6569 "source": "mirror://gnu/hello/hello-2.10.tar.gz",
6570 "build-system": "gnu",
6571 "home-page": "https://www.gnu.org/software/hello/",
6572 "synopsis": "Hello, GNU world: An example GNU package",
6573 "description": "GNU Hello prints a greeting.",
6574 "license": "GPL-3.0+",
6575 "native-inputs": ["gcc@@6"]
6576@}
6577@end example
6578
6579The field names are the same as for the @code{<package>} record
6580(@xref{Defining Packages}). References to other packages are provided
6581as JSON lists of quoted package specification strings such as
6582@code{guile} or @code{guile@@2.0}.
6583
6584The importer also supports a more explicit source definition using the
6585common fields for @code{<origin>} records:
6586
6587@example
6588@{
6589 @dots{}
6590 "source": @{
6591 "method": "url-fetch",
6592 "uri": "mirror://gnu/hello/hello-2.10.tar.gz",
6593 "sha256": @{
6594 "base32": "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i"
6595 @}
6596 @}
6597 @dots{}
6598@}
6599@end example
6600
6601The command below reads metadata from the JSON file @code{hello.json}
6602and outputs a package expression:
6603
6604@example
6605guix import json hello.json
6606@end example
6607
2f7d2d91 6608@item nix
f97c9175 6609Import metadata from a local copy of the source of the
2f7d2d91
LC
6610@uref{http://nixos.org/nixpkgs/, Nixpkgs distribution}@footnote{This
6611relies on the @command{nix-instantiate} command of
6612@uref{http://nixos.org/nix/, Nix}.}. Package definitions in Nixpkgs are
6613typically written in a mixture of Nix-language and Bash code. This
6614command only imports the high-level package structure that is written in
6615the Nix language. It normally includes all the basic fields of a
6616package definition.
6617
6618When importing a GNU package, the synopsis and descriptions are replaced
6619by their canonical upstream variant.
6620
961d0d2d
LC
6621Usually, you will first need to do:
6622
6623@example
6624export NIX_REMOTE=daemon
6625@end example
6626
6627@noindent
6628so that @command{nix-instantiate} does not try to open the Nix database.
6629
2f7d2d91
LC
6630As an example, the command below imports the package definition of
6631LibreOffice (more precisely, it imports the definition of the package
6632bound to the @code{libreoffice} top-level attribute):
6633
6634@example
6635guix import nix ~/path/to/nixpkgs libreoffice
6636@end example
863af4e1
FB
6637
6638@item hackage
6639@cindex hackage
f97c9175 6640Import metadata from the Haskell community's central package archive
863af4e1
FB
6641@uref{https://hackage.haskell.org/, Hackage}. Information is taken from
6642Cabal files and includes all the relevant information, including package
6643dependencies.
6644
6645Specific command-line options are:
6646
6647@table @code
a4154748
FB
6648@item --stdin
6649@itemx -s
f97c9175 6650Read a Cabal file from standard input.
863af4e1
FB
6651@item --no-test-dependencies
6652@itemx -t
f97c9175 6653Do not include dependencies required only by the test suites.
a4154748
FB
6654@item --cabal-environment=@var{alist}
6655@itemx -e @var{alist}
6656@var{alist} is a Scheme alist defining the environment in which the
6657Cabal conditionals are evaluated. The accepted keys are: @code{os},
6658@code{arch}, @code{impl} and a string representing the name of a flag.
6659The value associated with a flag has to be either the symbol
6660@code{true} or @code{false}. The value associated with other keys
6661has to conform to the Cabal file format definition. The default value
6662associated with the keys @code{os}, @code{arch} and @code{impl} is
f97c9175 6663@samp{linux}, @samp{x86_64} and @samp{ghc}, respectively.
a9285961
RW
6664@item --recursive
6665@itemx -r
6666Traverse the dependency graph of the given upstream package recursively
6667and generate package expressions for all those packages that are not yet
6668in Guix.
863af4e1
FB
6669@end table
6670
f97c9175 6671The command below imports metadata for the latest version of the
a4154748
FB
6672@code{HTTP} Haskell package without including test dependencies and
6673specifying the value of the flag @samp{network-uri} as @code{false}:
863af4e1
FB
6674
6675@example
a4154748 6676guix import hackage -t -e "'((\"network-uri\" . false))" HTTP
863af4e1
FB
6677@end example
6678
6679A specific package version may optionally be specified by following the
1b846da8 6680package name by an at-sign and a version number as in the following example:
863af4e1
FB
6681
6682@example
1b846da8 6683guix import hackage mtl@@2.1.3.1
863af4e1 6684@end example
7f74a931 6685
bc5844d1
FB
6686@item stackage
6687@cindex stackage
6688The @code{stackage} importer is a wrapper around the @code{hackage} one.
6689It takes a package name, looks up the package version included in a
6690long-term support (LTS) @uref{https://www.stackage.org, Stackage}
6691release and uses the @code{hackage} importer to retrieve its metadata.
6692Note that it is up to you to select an LTS release compatible with the
6693GHC compiler used by Guix.
6694
6695Specific command-line options are:
6696
6697@table @code
6698@item --no-test-dependencies
6699@itemx -t
6700Do not include dependencies required only by the test suites.
6701@item --lts-version=@var{version}
6702@itemx -r @var{version}
6703@var{version} is the desired LTS release version. If omitted the latest
6704release is used.
6705@end table
6706
6707The command below imports metadata for the @code{HTTP} Haskell package
6708included in the LTS Stackage release version 7.18:
6709
6710@example
6711guix import stackage --lts-version=7.18 HTTP
6712@end example
6713
7f74a931
FB
6714@item elpa
6715@cindex elpa
f97c9175 6716Import metadata from an Emacs Lisp Package Archive (ELPA) package
7f74a931
FB
6717repository (@pxref{Packages,,, emacs, The GNU Emacs Manual}).
6718
6719Specific command-line options are:
6720
6721@table @code
6722@item --archive=@var{repo}
6723@itemx -a @var{repo}
6724@var{repo} identifies the archive repository from which to retrieve the
6725information. Currently the supported repositories and their identifiers
6726are:
6727@itemize -
6728@item
840bd1d3 6729@uref{http://elpa.gnu.org/packages, GNU}, selected by the @code{gnu}
7f74a931
FB
6730identifier. This is the default.
6731
624144e0
LC
6732Packages from @code{elpa.gnu.org} are signed with one of the keys
6733contained in the GnuPG keyring at
6734@file{share/emacs/25.1/etc/package-keyring.gpg} (or similar) in the
6735@code{emacs} package (@pxref{Package Installation, ELPA package
6736signatures,, emacs, The GNU Emacs Manual}).
6737
7f74a931 6738@item
840bd1d3 6739@uref{http://stable.melpa.org/packages, MELPA-Stable}, selected by the
7f74a931
FB
6740@code{melpa-stable} identifier.
6741
6742@item
840bd1d3 6743@uref{http://melpa.org/packages, MELPA}, selected by the @code{melpa}
7f74a931
FB
6744identifier.
6745@end itemize
74032da3
OP
6746
6747@item --recursive
6748@itemx -r
6749Traverse the dependency graph of the given upstream package recursively
6750and generate package expressions for all those packages that are not yet
6751in Guix.
7f74a931 6752@end table
3e0c0365
DC
6753
6754@item crate
6755@cindex crate
6756Import metadata from the crates.io Rust package repository
6757@uref{https://crates.io, crates.io}.
b24443bf
JL
6758
6759@item opam
6760@cindex OPAM
6761@cindex OCaml
6762Import metadata from the @uref{https://opam.ocaml.org/, OPAM} package
6763repository used by the OCaml community.
2f7d2d91
LC
6764@end table
6765
6766The structure of the @command{guix import} code is modular. It would be
6767useful to have more importers for other package formats, and your help
6768is welcome here (@pxref{Contributing}).
6769
37166310
LC
6770@node Invoking guix refresh
6771@section Invoking @command{guix refresh}
6772
e32171ee 6773@cindex @command {guix refresh}
37166310
LC
6774The primary audience of the @command{guix refresh} command is developers
6775of the GNU software distribution. By default, it reports any packages
6776provided by the distribution that are outdated compared to the latest
6777upstream version, like this:
6778
6779@example
6780$ guix refresh
6781gnu/packages/gettext.scm:29:13: gettext would be upgraded from 0.18.1.1 to 0.18.2.1
6782gnu/packages/glib.scm:77:12: glib would be upgraded from 2.34.3 to 2.37.0
6783@end example
6784
e9c72306
LC
6785Alternately, one can specify packages to consider, in which case a
6786warning is emitted for packages that lack an updater:
6787
6788@example
6789$ guix refresh coreutils guile guile-ssh
6790gnu/packages/ssh.scm:205:2: warning: no updater for guile-ssh
6791gnu/packages/guile.scm:136:12: guile would be upgraded from 2.0.12 to 2.0.13
6792@end example
6793
6794@command{guix refresh} browses the upstream repository of each package and determines
6795the highest version number of the releases therein. The command
bcb571cb 6796knows how to update specific types of packages: GNU packages, ELPA
e9c72306 6797packages, etc.---see the documentation for @option{--type} below. There
bcb571cb
LC
6798are many packages, though, for which it lacks a method to determine
6799whether a new upstream release is available. However, the mechanism is
6800extensible, so feel free to get in touch with us to add a new method!
37166310 6801
a5e03674
LC
6802Sometimes the upstream name differs from the package name used in Guix,
6803and @command{guix refresh} needs a little help. Most updaters honor the
6804@code{upstream-name} property in package definitions, which can be used
6805to that effect:
6806
6807@example
6808(define-public network-manager
6809 (package
6810 (name "network-manager")
6811 ;; @dots{}
6812 (properties '((upstream-name . "NetworkManager")))))
6813@end example
6814
37166310 6815When passed @code{--update}, it modifies distribution source files to
f97c9175 6816update the version numbers and source tarball hashes of those package
37166310
LC
6817recipes (@pxref{Defining Packages}). This is achieved by downloading
6818each package's latest source tarball and its associated OpenPGP
6819signature, authenticating the downloaded tarball against its signature
6820using @command{gpg}, and finally computing its hash. When the public
6821key used to sign the tarball is missing from the user's keyring, an
6822attempt is made to automatically retrieve it from a public key server;
f97c9175 6823when this is successful, the key is added to the user's keyring; otherwise,
37166310
LC
6824@command{guix refresh} reports an error.
6825
6826The following options are supported:
6827
6828@table @code
6829
2d7fc7da
LC
6830@item --expression=@var{expr}
6831@itemx -e @var{expr}
6832Consider the package @var{expr} evaluates to.
6833
6834This is useful to precisely refer to a package, as in this example:
6835
6836@example
6837guix refresh -l -e '(@@@@ (gnu packages commencement) glibc-final)'
6838@end example
6839
6840This command lists the dependents of the ``final'' libc (essentially all
6841the packages.)
6842
37166310
LC
6843@item --update
6844@itemx -u
38e16b49
LC
6845Update distribution source files (package recipes) in place. This is
6846usually run from a checkout of the Guix source tree (@pxref{Running
6847Guix Before It Is Installed}):
6848
6849@example
e9c72306 6850$ ./pre-inst-env guix refresh -s non-core -u
38e16b49
LC
6851@end example
6852
081145cf 6853@xref{Defining Packages}, for more information on package definitions.
37166310
LC
6854
6855@item --select=[@var{subset}]
6856@itemx -s @var{subset}
6857Select all the packages in @var{subset}, one of @code{core} or
6858@code{non-core}.
6859
6860The @code{core} subset refers to all the packages at the core of the
6861distribution---i.e., packages that are used to build ``everything
6862else''. This includes GCC, libc, Binutils, Bash, etc. Usually,
6863changing one of these packages in the distribution entails a rebuild of
6864all the others. Thus, such updates are an inconvenience to users in
6865terms of build time or bandwidth used to achieve the upgrade.
6866
6867The @code{non-core} subset refers to the remaining packages. It is
6868typically useful in cases where an update of the core packages would be
6869inconvenient.
6870
1335ac31
MO
6871@item --manifest=@var{file}
6872@itemx -m @var{file}
6873Select all the packages from the manifest in @var{file}. This is useful to
6874check if any packages of the user manifest can be updated.
6875
bcb571cb
LC
6876@item --type=@var{updater}
6877@itemx -t @var{updater}
7191adc5
AK
6878Select only packages handled by @var{updater} (may be a comma-separated
6879list of updaters). Currently, @var{updater} may be one of:
bcb571cb
LC
6880
6881@table @code
6882@item gnu
6883the updater for GNU packages;
e80c0f85
LC
6884@item gnome
6885the updater for GNOME packages;
9c97afe8
DC
6886@item kde
6887the updater for KDE packages;
62061d6b
AW
6888@item xorg
6889the updater for X.org packages;
2fd370e8
LC
6890@item kernel.org
6891the updater for packages hosted on kernel.org;
bcb571cb 6892@item elpa
d882c235
LC
6893the updater for @uref{http://elpa.gnu.org/, ELPA} packages;
6894@item cran
e9960d8c 6895the updater for @uref{https://cran.r-project.org/, CRAN} packages;
d0bd632f 6896@item bioconductor
5713bbf1 6897the updater for @uref{https://www.bioconductor.org/, Bioconductor} R packages;
200cdf81
EB
6898@item cpan
6899the updater for @uref{http://www.cpan.org/, CPAN} packages;
bab020d7 6900@item pypi
b9d044ef 6901the updater for @uref{https://pypi.python.org, PyPI} packages.
fbc5b815
BW
6902@item gem
6903the updater for @uref{https://rubygems.org, RubyGems} packages.
917a2a58
BW
6904@item github
6905the updater for @uref{https://github.com, GitHub} packages.
42efe27a
EB
6906@item hackage
6907the updater for @uref{https://hackage.haskell.org, Hackage} packages.
bc5844d1
FB
6908@item stackage
6909the updater for @uref{https://www.stackage.org, Stackage} packages.
8ac52987
DC
6910@item crate
6911the updater for @uref{https://crates.io, Crates} packages.
bcb571cb
LC
6912@end table
6913
f97c9175
AE
6914For instance, the following command only checks for updates of Emacs
6915packages hosted at @code{elpa.gnu.org} and for updates of CRAN packages:
bcb571cb
LC
6916
6917@example
7191adc5 6918$ guix refresh --type=elpa,cran
d882c235 6919gnu/packages/statistics.scm:819:13: r-testthat would be upgraded from 0.10.0 to 0.11.0
bcb571cb
LC
6920gnu/packages/emacs.scm:856:13: emacs-auctex would be upgraded from 11.88.6 to 11.88.9
6921@end example
6922
37166310
LC
6923@end table
6924
6925In addition, @command{guix refresh} can be passed one or more package
6926names, as in this example:
6927
6928@example
e9c72306 6929$ ./pre-inst-env guix refresh -u emacs idutils gcc@@4.8
37166310
LC
6930@end example
6931
6932@noindent
6933The command above specifically updates the @code{emacs} and
6934@code{idutils} packages. The @code{--select} option would have no
6935effect in this case.
6936
7d193ec3
EB
6937When considering whether to upgrade a package, it is sometimes
6938convenient to know which packages would be affected by the upgrade and
6939should be checked for compatibility. For this the following option may
6940be used when passing @command{guix refresh} one or more package names:
6941
6942@table @code
6943
6ffa706b
AK
6944@item --list-updaters
6945@itemx -L
6946List available updaters and exit (see @option{--type} above.)
6947
3676f892
LC
6948For each updater, display the fraction of packages it covers; at the
6949end, display the fraction of packages covered by all these updaters.
6950
7d193ec3
EB
6951@item --list-dependent
6952@itemx -l
6953List top-level dependent packages that would need to be rebuilt as a
6954result of upgrading one or more packages.
6955
b96a0640
LC
6956@xref{Invoking guix graph, the @code{reverse-package} type of
6957@command{guix graph}}, for information on how to visualize the list of
6958dependents of a package.
6959
7d193ec3
EB
6960@end table
6961
6962Be aware that the @code{--list-dependent} option only
6963@emph{approximates} the rebuilds that would be required as a result of
6964an upgrade. More rebuilds might be required under some circumstances.
6965
6966@example
7779ab61
LC
6967$ guix refresh --list-dependent flex
6968Building the following 120 packages would ensure 213 dependent packages are rebuilt:
6d1a5e5f 6969hop@@2.4.0 geiser@@0.4 notmuch@@0.18 mu@@0.9.9.5 cflow@@1.4 idutils@@4.6 @dots{}
7d193ec3
EB
6970@end example
6971
6972The command above lists a set of packages that could be built to check
6973for compatibility with an upgraded @code{flex} package.
6974
f9230085
LC
6975The following options can be used to customize GnuPG operation:
6976
6977@table @code
6978
f9230085
LC
6979@item --gpg=@var{command}
6980Use @var{command} as the GnuPG 2.x command. @var{command} is searched
6981for in @code{$PATH}.
6982
2bc53ba9
LC
6983@item --key-download=@var{policy}
6984Handle missing OpenPGP keys according to @var{policy}, which may be one
6985of:
6986
6987@table @code
6988@item always
6989Always download missing OpenPGP keys from the key server, and add them
6990to the user's GnuPG keyring.
6991
6992@item never
6993Never try to download missing OpenPGP keys. Instead just bail out.
6994
6995@item interactive
6996When a package signed with an unknown OpenPGP key is encountered, ask
6997the user whether to download it or not. This is the default behavior.
6998@end table
6999
7000@item --key-server=@var{host}
7001Use @var{host} as the OpenPGP key server when importing a public key.
7002
f9230085
LC
7003@end table
7004
917a2a58
BW
7005The @code{github} updater uses the
7006@uref{https://developer.github.com/v3/, GitHub API} to query for new
7007releases. When used repeatedly e.g. when refreshing all packages,
7008GitHub will eventually refuse to answer any further API requests. By
7009default 60 API requests per hour are allowed, and a full refresh on all
7010GitHub packages in Guix requires more than this. Authentication with
7011GitHub through the use of an API token alleviates these limits. To use
7012an API token, set the environment variable @code{GUIX_GITHUB_TOKEN} to a
7013token procured from @uref{https://github.com/settings/tokens} or
7014otherwise.
7015
7016
b4f5e0e8
CR
7017@node Invoking guix lint
7018@section Invoking @command{guix lint}
e32171ee
JD
7019
7020@cindex @command{guix lint}
7021@cindex package, checking for errors
f97c9175
AE
7022The @command{guix lint} command is meant to help package developers avoid
7023common errors and use a consistent style. It runs a number of checks on
7024a given set of packages in order to find common mistakes in their
873c4085
LC
7025definitions. Available @dfn{checkers} include (see
7026@code{--list-checkers} for a complete list):
7027
7028@table @code
7029@item synopsis
7030@itemx description
7031Validate certain typographical and stylistic rules about package
7032descriptions and synopses.
7033
7034@item inputs-should-be-native
7035Identify inputs that should most likely be native inputs.
7036
7037@item source
7038@itemx home-page
fac46e3f 7039@itemx mirror-url
50f5c46d 7040@itemx source-file-name
873c4085 7041Probe @code{home-page} and @code{source} URLs and report those that are
fac46e3f
LC
7042invalid. Suggest a @code{mirror://} URL when applicable. Check that
7043the source file name is meaningful, e.g. is not
f97c9175
AE
7044just a version number or ``git-checkout'', without a declared
7045@code{file-name} (@pxref{origin Reference}).
40a7d4e5 7046
5432734b 7047@item cve
09866b39
LC
7048@cindex security vulnerabilities
7049@cindex CVE, Common Vulnerabilities and Exposures
5432734b 7050Report known vulnerabilities found in the Common Vulnerabilities and
09866b39 7051Exposures (CVE) databases of the current and past year
5432734b
LC
7052@uref{https://nvd.nist.gov/download.cfm#CVE_FEED, published by the US
7053NIST}.
7054
09866b39
LC
7055To view information about a particular vulnerability, visit pages such as:
7056
7057@itemize
7058@item
7059@indicateurl{https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-YYYY-ABCD}
7060@item
7061@indicateurl{https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-YYYY-ABCD}
7062@end itemize
7063
7064@noindent
7065where @code{CVE-YYYY-ABCD} is the CVE identifier---e.g.,
7066@code{CVE-2015-7554}.
7067
99effc8f
LC
7068Package developers can specify in package recipes the
7069@uref{https://nvd.nist.gov/cpe.cfm,Common Platform Enumeration (CPE)}
5ac7bf56
BH
7070name and version of the package when they differ from the name or version
7071that Guix uses, as in this example:
99effc8f
LC
7072
7073@example
7074(package
7075 (name "grub")
7076 ;; @dots{}
7077 ;; CPE calls this package "grub2".
5ac7bf56
BH
7078 (properties '((cpe-name . "grub2")
7079 (cpe-version . "2.3")))
7080@end example
7081
7082@c See <http://www.openwall.com/lists/oss-security/2017/03/15/3>.
7083Some entries in the CVE database do not specify which version of a
7084package they apply to, and would thus ``stick around'' forever. Package
7085developers who found CVE alerts and verified they can be ignored can
7086declare them as in this example:
7087
7088@example
7089(package
7090 (name "t1lib")
7091 ;; @dots{}
7092 ;; These CVEs no longer apply and can be safely ignored.
7093 (properties `((lint-hidden-cve . ("CVE-2011-0433"
7094 "CVE-2011-1553"
7095 "CVE-2011-1554"
7096 "CVE-2011-5244")))))
99effc8f
LC
7097@end example
7098
40a7d4e5
LC
7099@item formatting
7100Warn about obvious source code formatting issues: trailing white space,
7101use of tabulations, etc.
873c4085 7102@end table
b4f5e0e8
CR
7103
7104The general syntax is:
7105
7106@example
7107guix lint @var{options} @var{package}@dots{}
7108@end example
7109
7110If no package is given on the command line, then all packages are checked.
7111The @var{options} may be zero or more of the following:
7112
7113@table @code
f97c9175
AE
7114@item --list-checkers
7115@itemx -l
7116List and describe all the available checkers that will be run on packages
7117and exit.
b4f5e0e8 7118
dd7c013d
CR
7119@item --checkers
7120@itemx -c
7121Only enable the checkers specified in a comma-separated list using the
7122names returned by @code{--list-checkers}.
7123
b4f5e0e8 7124@end table
37166310 7125
fcc58db6
LC
7126@node Invoking guix size
7127@section Invoking @command{guix size}
7128
e32171ee
JD
7129@cindex size
7130@cindex package size
7131@cindex closure
7132@cindex @command{guix size}
fcc58db6
LC
7133The @command{guix size} command helps package developers profile the
7134disk usage of packages. It is easy to overlook the impact of an
7135additional dependency added to a package, or the impact of using a
7136single output for a package that could easily be split (@pxref{Packages
f97c9175 7137with Multiple Outputs}). Such are the typical issues that
fcc58db6
LC
7138@command{guix size} can highlight.
7139
2fd345cd
LC
7140The command can be passed one or more package specifications
7141such as @code{gcc@@4.8}
fcc58db6
LC
7142or @code{guile:debug}, or a file name in the store. Consider this
7143example:
7144
7145@example
7146$ guix size coreutils
7147store item total self
63dbdf80
LC
7148/gnu/store/@dots{}-gcc-5.5.0-lib 60.4 30.1 38.1%
7149/gnu/store/@dots{}-glibc-2.27 30.3 28.8 36.6%
7150/gnu/store/@dots{}-coreutils-8.28 78.9 15.0 19.0%
7151/gnu/store/@dots{}-gmp-6.1.2 63.1 2.7 3.4%
7152/gnu/store/@dots{}-bash-static-4.4.12 1.5 1.5 1.9%
7153/gnu/store/@dots{}-acl-2.2.52 61.1 0.4 0.5%
7154/gnu/store/@dots{}-attr-2.4.47 60.6 0.2 0.3%
7155/gnu/store/@dots{}-libcap-2.25 60.5 0.2 0.2%
7156total: 78.9 MiB
fcc58db6
LC
7157@end example
7158
7159@cindex closure
7160The store items listed here constitute the @dfn{transitive closure} of
7161Coreutils---i.e., Coreutils and all its dependencies, recursively---as
7162would be returned by:
7163
7164@example
7165$ guix gc -R /gnu/store/@dots{}-coreutils-8.23
7166@end example
7167
f97c9175 7168Here the output shows three columns next to store items. The first column,
fcc58db6
LC
7169labeled ``total'', shows the size in mebibytes (MiB) of the closure of
7170the store item---that is, its own size plus the size of all its
7171dependencies. The next column, labeled ``self'', shows the size of the
f97c9175
AE
7172item itself. The last column shows the ratio of the size of the item
7173itself to the space occupied by all the items listed here.
fcc58db6
LC
7174
7175In this example, we see that the closure of Coreutils weighs in at
63dbdf80
LC
717679@tie{}MiB, most of which is taken by libc and GCC's run-time support
7177libraries. (That libc and GCC's libraries represent a large fraction of
7178the closure is not a problem @i{per se} because they are always available
7179on the system anyway.)
fcc58db6 7180
2fd345cd
LC
7181When the package(s) passed to @command{guix size} are available in the
7182store@footnote{More precisely, @command{guix size} looks for the
7183@emph{ungrafted} variant of the given package(s), as returned by
7184@code{guix build @var{package} --no-grafts}. @xref{Security Updates},
7185for information on grafts.}, @command{guix size} queries the daemon to determine its
fcc58db6
LC
7186dependencies, and measures its size in the store, similar to @command{du
7187-ms --apparent-size} (@pxref{du invocation,,, coreutils, GNU
7188Coreutils}).
7189
2fd345cd 7190When the given packages are @emph{not} in the store, @command{guix size}
f97c9175
AE
7191reports information based on the available substitutes
7192(@pxref{Substitutes}). This makes it possible it to profile disk usage of
7193store items that are not even on disk, only available remotely.
fcc58db6 7194
db761534
LC
7195You can also specify several package names:
7196
7197@example
7198$ guix size coreutils grep sed bash
7199store item total self
7200/gnu/store/@dots{}-coreutils-8.24 77.8 13.8 13.4%
7201/gnu/store/@dots{}-grep-2.22 73.1 0.8 0.8%
7202/gnu/store/@dots{}-bash-4.3.42 72.3 4.7 4.6%
7203/gnu/store/@dots{}-readline-6.3 67.6 1.2 1.2%
7204@dots{}
7205total: 102.3 MiB
7206@end example
7207
7208@noindent
7209In this example we see that the combination of the four packages takes
7210102.3@tie{}MiB in total, which is much less than the sum of each closure
7211since they have a lot of dependencies in common.
7212
a8f996c6 7213The available options are:
fcc58db6
LC
7214
7215@table @option
7216
d490d06e
LC
7217@item --substitute-urls=@var{urls}
7218Use substitute information from @var{urls}.
7219@xref{client-substitute-urls, the same option for @code{guix build}}.
7220
a6c1fe82
LC
7221@item --sort=@var{key}
7222Sort lines according to @var{key}, one of the following options:
7223
7224@table @code
a6c1fe82 7225@item self
fb255088
LC
7226the size of each item (the default);
7227@item closure
7228the total size of the item's closure.
a6c1fe82
LC
7229@end table
7230
a8f996c6 7231@item --map-file=@var{file}
f97c9175 7232Write a graphical map of disk usage in PNG format to @var{file}.
a8f996c6
LC
7233
7234For the example above, the map looks like this:
7235
7236@image{images/coreutils-size-map,5in,, map of Coreutils disk usage
7237produced by @command{guix size}}
7238
7239This option requires that
7240@uref{http://wingolog.org/software/guile-charting/, Guile-Charting} be
7241installed and visible in Guile's module search path. When that is not
7242the case, @command{guix size} fails as it tries to load it.
7243
fcc58db6
LC
7244@item --system=@var{system}
7245@itemx -s @var{system}
7246Consider packages for @var{system}---e.g., @code{x86_64-linux}.
7247
7248@end table
7249
88856916
LC
7250@node Invoking guix graph
7251@section Invoking @command{guix graph}
7252
7253@cindex DAG
e32171ee
JD
7254@cindex @command{guix graph}
7255@cindex package dependencies
88856916
LC
7256Packages and their dependencies form a @dfn{graph}, specifically a
7257directed acyclic graph (DAG). It can quickly become difficult to have a
f97c9175 7258mental model of the package DAG, so the @command{guix graph} command
9ea36197
LC
7259provides a visual representation of the DAG. By default,
7260@command{guix graph} emits a DAG representation in the input format of
88856916 7261@uref{http://www.graphviz.org/, Graphviz}, so its output can be passed
9ea36197
LC
7262directly to the @command{dot} command of Graphviz. It can also emit an
7263HTML page with embedded JavaScript code to display a ``chord diagram''
5899fafb
RJ
7264in a Web browser, using the @uref{https://d3js.org/, d3.js} library, or
7265emit Cypher queries to construct a graph in a graph database supporting
7266the @uref{http://www.opencypher.org/, openCypher} query language.
9ea36197 7267The general syntax is:
88856916
LC
7268
7269@example
7270guix graph @var{options} @var{package}@dots{}
7271@end example
7272
7273For example, the following command generates a PDF file representing the
7274package DAG for the GNU@tie{}Core Utilities, showing its build-time
7275dependencies:
7276
7277@example
7278guix graph coreutils | dot -Tpdf > dag.pdf
7279@end example
7280
7281The output looks like this:
7282
7283@image{images/coreutils-graph,2in,,Dependency graph of the GNU Coreutils}
7284
7285Nice little graph, no?
7286
f97c9175 7287But there is more than one graph! The one above is concise: it is the
88856916 7288graph of package objects, omitting implicit inputs such as GCC, libc,
f97c9175
AE
7289grep, etc. It is often useful to have such a concise graph, but
7290sometimes one may want to see more details. @command{guix graph} supports
7291several types of graphs, allowing you to choose the level of detail:
88856916
LC
7292
7293@table @code
7294@item package
f97c9175 7295This is the default type used in the example above. It shows the DAG of
88856916
LC
7296package objects, excluding implicit dependencies. It is concise, but
7297filters out many details.
7298
b96a0640
LC
7299@item reverse-package
7300This shows the @emph{reverse} DAG of packages. For example:
7301
7302@example
7303guix graph --type=reverse-package ocaml
7304@end example
7305
7306... yields the graph of packages that depend on OCaml.
7307
7308Note that for core packages this can yield huge graphs. If all you want
7309is to know the number of packages that depend on a given package, use
7310@command{guix refresh --list-dependent} (@pxref{Invoking guix refresh,
7311@option{--list-dependent}}).
7312
88856916
LC
7313@item bag-emerged
7314This is the package DAG, @emph{including} implicit inputs.
7315
7316For instance, the following command:
7317
7318@example
7319guix graph --type=bag-emerged coreutils | dot -Tpdf > dag.pdf
7320@end example
7321
7322... yields this bigger graph:
7323
7324@image{images/coreutils-bag-graph,,5in,Detailed dependency graph of the GNU Coreutils}
7325
7326At the bottom of the graph, we see all the implicit inputs of
7327@var{gnu-build-system} (@pxref{Build Systems, @code{gnu-build-system}}).
7328
f97c9175 7329Now, note that the dependencies of these implicit inputs---that is, the
88856916
LC
7330@dfn{bootstrap dependencies} (@pxref{Bootstrapping})---are not shown
7331here, for conciseness.
7332
7333@item bag
7334Similar to @code{bag-emerged}, but this time including all the bootstrap
7335dependencies.
7336
38b92daa
LC
7337@item bag-with-origins
7338Similar to @code{bag}, but also showing origins and their dependencies.
7339
fff236aa 7340@item derivation
88856916
LC
7341This is the most detailed representation: It shows the DAG of
7342derivations (@pxref{Derivations}) and plain store items. Compared to
7343the above representation, many additional nodes are visible, including
f97c9175 7344build scripts, patches, Guile modules, etc.
88856916 7345
a773c314
LC
7346For this type of graph, it is also possible to pass a @file{.drv} file
7347name instead of a package name, as in:
7348
7349@example
7350guix graph -t derivation `guix system build -d my-config.scm`
7351@end example
b06a70e0
LC
7352
7353@item module
7354This is the graph of @dfn{package modules} (@pxref{Package Modules}).
7355For example, the following command shows the graph for the package
7356module that defines the @code{guile} package:
7357
7358@example
7359guix graph -t module guile | dot -Tpdf > module-graph.pdf
7360@end example
88856916
LC
7361@end table
7362
f97c9175 7363All the types above correspond to @emph{build-time dependencies}. The
88856916
LC
7364following graph type represents the @emph{run-time dependencies}:
7365
7366@table @code
7367@item references
7368This is the graph of @dfn{references} of a package output, as returned
7369by @command{guix gc --references} (@pxref{Invoking guix gc}).
7370
7371If the given package output is not available in the store, @command{guix
7372graph} attempts to obtain dependency information from substitutes.
a773c314
LC
7373
7374Here you can also pass a store file name instead of a package name. For
7375example, the command below produces the reference graph of your profile
7376(which can be big!):
7377
7378@example
7379guix graph -t references `readlink -f ~/.guix-profile`
7380@end example
7f8fec0f
LC
7381
7382@item referrers
7383This is the graph of the @dfn{referrers} of a store item, as returned by
7384@command{guix gc --referrers} (@pxref{Invoking guix gc}).
7385
7386This relies exclusively on local information from your store. For
7387instance, let us suppose that the current Inkscape is available in 10
7388profiles on your machine; @command{guix graph -t referrers inkscape}
7389will show a graph rooted at Inkscape and with those 10 profiles linked
7390to it.
7391
7392It can help determine what is preventing a store item from being garbage
7393collected.
7394
88856916
LC
7395@end table
7396
7397The available options are the following:
7398
7399@table @option
7400@item --type=@var{type}
7401@itemx -t @var{type}
7402Produce a graph output of @var{type}, where @var{type} must be one of
7403the values listed above.
7404
7405@item --list-types
7406List the supported graph types.
4c8f997a 7407
642339dc
RW
7408@item --backend=@var{backend}
7409@itemx -b @var{backend}
7410Produce a graph using the selected @var{backend}.
7411
7412@item --list-backends
7413List the supported graph backends.
7414
9ea36197
LC
7415Currently, the available backends are Graphviz and d3.js.
7416
4c8f997a
LC
7417@item --expression=@var{expr}
7418@itemx -e @var{expr}
7419Consider the package @var{expr} evaluates to.
7420
7421This is useful to precisely refer to a package, as in this example:
7422
7423@example
7424guix graph -e '(@@@@ (gnu packages commencement) gnu-make-final)'
7425@end example
88856916
LC
7426@end table
7427
7428
372c4bbc
DT
7429@node Invoking guix environment
7430@section Invoking @command{guix environment}
7431
f5fd4fd2 7432@cindex reproducible build environments
fe36d84e 7433@cindex development environments
e32171ee
JD
7434@cindex @command{guix environment}
7435@cindex environment, package build environment
372c4bbc
DT
7436The purpose of @command{guix environment} is to assist hackers in
7437creating reproducible development environments without polluting their
7438package profile. The @command{guix environment} tool takes one or more
f97c9175 7439packages, builds all of their inputs, and creates a shell
372c4bbc
DT
7440environment to use them.
7441
7442The general syntax is:
7443
7444@example
7445guix environment @var{options} @var{package}@dots{}
7446@end example
7447
fe36d84e
LC
7448The following example spawns a new shell set up for the development of
7449GNU@tie{}Guile:
372c4bbc
DT
7450
7451@example
7452guix environment guile
7453@end example
7454
f97c9175
AE
7455If the needed dependencies are not built yet, @command{guix environment}
7456automatically builds them. The environment of the new shell is an augmented
372c4bbc
DT
7457version of the environment that @command{guix environment} was run in.
7458It contains the necessary search paths for building the given package
7459added to the existing environment variables. To create a ``pure''
f97c9175 7460environment, in which the original environment variables have been unset,
50500f7c
LC
7461use the @code{--pure} option@footnote{Users sometimes wrongfully augment
7462environment variables such as @code{PATH} in their @file{~/.bashrc}
7463file. As a consequence, when @code{guix environment} launches it, Bash
7464may read @file{~/.bashrc}, thereby introducing ``impurities'' in these
7465environment variables. It is an error to define such environment
7466variables in @file{.bashrc}; instead, they should be defined in
7467@file{.bash_profile}, which is sourced only by log-in shells.
7468@xref{Bash Startup Files,,, bash, The GNU Bash Reference Manual}, for
7469details on Bash start-up files.}.
372c4bbc 7470
28de8d25
LC
7471@vindex GUIX_ENVIRONMENT
7472@command{guix environment} defines the @code{GUIX_ENVIRONMENT}
20185522
LC
7473variable in the shell it spawns; its value is the file name of the
7474profile of this environment. This allows users to, say, define a
28de8d25
LC
7475specific prompt for development environments in their @file{.bashrc}
7476(@pxref{Bash Startup Files,,, bash, The GNU Bash Reference Manual}):
7477
7478@example
7479if [ -n "$GUIX_ENVIRONMENT" ]
7480then
7481 export PS1="\u@@\h \w [dev]\$ "
7482fi
7483@end example
7484
20185522
LC
7485@noindent
7486... or to browse the profile:
7487
7488@example
7489$ ls "$GUIX_ENVIRONMENT/bin"
7490@end example
7491
372c4bbc
DT
7492Additionally, more than one package may be specified, in which case the
7493union of the inputs for the given packages are used. For example, the
7494command below spawns a shell where all of the dependencies of both Guile
7495and Emacs are available:
7496
7497@example
7498guix environment guile emacs
7499@end example
7500
1de2fe95
DT
7501Sometimes an interactive shell session is not desired. An arbitrary
7502command may be invoked by placing the @code{--} token to separate the
7503command from the rest of the arguments:
372c4bbc
DT
7504
7505@example
1de2fe95 7506guix environment guile -- make -j4
372c4bbc
DT
7507@end example
7508
fe36d84e
LC
7509In other situations, it is more convenient to specify the list of
7510packages needed in the environment. For example, the following command
7511runs @command{python} from an environment containing Python@tie{}2.7 and
7512NumPy:
7513
7514@example
1de2fe95 7515guix environment --ad-hoc python2-numpy python-2.7 -- python
fe36d84e
LC
7516@end example
7517
cc90fbbf
DT
7518Furthermore, one might want the dependencies of a package and also some
7519additional packages that are not build-time or runtime dependencies, but
7520are useful when developing nonetheless. Because of this, the
7521@code{--ad-hoc} flag is positional. Packages appearing before
7522@code{--ad-hoc} are interpreted as packages whose dependencies will be
7523added to the environment. Packages appearing after are interpreted as
7524packages that will be added to the environment directly. For example,
7525the following command creates a Guix development environment that
7526additionally includes Git and strace:
7527
7528@example
7529guix environment guix --ad-hoc git strace
7530@end example
7531
f535dcbe
DT
7532Sometimes it is desirable to isolate the environment as much as
7533possible, for maximal purity and reproducibility. In particular, when
7534using Guix on a host distro that is not GuixSD, it is desirable to
7535prevent access to @file{/usr/bin} and other system-wide resources from
7536the development environment. For example, the following command spawns
7537a Guile REPL in a ``container'' where only the store and the current
7538working directory are mounted:
7539
7540@example
7541guix environment --ad-hoc --container guile -- guile
7542@end example
7543
0f252e26 7544@quotation Note
cfd35b4e 7545The @code{--container} option requires Linux-libre 3.19 or newer.
0f252e26
DT
7546@end quotation
7547
fe36d84e 7548The available options are summarized below.
372c4bbc
DT
7549
7550@table @code
f943c317
LC
7551@item --root=@var{file}
7552@itemx -r @var{file}
7553@cindex persistent environment
7554@cindex garbage collector root, for environments
7555Make @var{file} a symlink to the profile for this environment, and
7556register it as a garbage collector root.
7557
7558This is useful if you want to protect your environment from garbage
7559collection, to make it ``persistent''.
7560
7561When this option is omitted, the environment is protected from garbage
7562collection only for the duration of the @command{guix environment}
7563session. This means that next time you recreate the same environment,
6a98b9f3
LC
7564you could have to rebuild or re-download packages. @xref{Invoking guix
7565gc}, for more on GC roots.
f943c317 7566
372c4bbc
DT
7567@item --expression=@var{expr}
7568@itemx -e @var{expr}
c9c282ce
DT
7569Create an environment for the package or list of packages that
7570@var{expr} evaluates to.
372c4bbc 7571
fe36d84e
LC
7572For example, running:
7573
7574@example
7575guix environment -e '(@@ (gnu packages maths) petsc-openmpi)'
7576@end example
7577
7578starts a shell with the environment for this specific variant of the
7579PETSc package.
7580
c9c282ce
DT
7581Running:
7582
7583@example
5c2b2f00 7584guix environment --ad-hoc -e '(@@ (gnu) %base-packages)'
c9c282ce
DT
7585@end example
7586
7587starts a shell with all the GuixSD base packages available.
7588
fa445d64 7589The above commands only use the default output of the given packages.
779aa003
DT
7590To select other outputs, two element tuples can be specified:
7591
7592@example
158eadef 7593guix environment --ad-hoc -e '(list (@@ (gnu packages bash) bash) "include")'
779aa003
DT
7594@end example
7595
372c4bbc
DT
7596@item --load=@var{file}
7597@itemx -l @var{file}
c9c282ce
DT
7598Create an environment for the package or list of packages that the code
7599within @var{file} evaluates to.
372c4bbc 7600
fe36d84e
LC
7601As an example, @var{file} might contain a definition like this
7602(@pxref{Defining Packages}):
7603
7604@example
7605@verbatiminclude environment-gdb.scm
7606@end example
7607
267379f8
DT
7608@item --manifest=@var{file}
7609@itemx -m @var{file}
7610Create an environment for the packages contained in the manifest object
7611returned by the Scheme code in @var{file}.
7612
7613This is similar to the same-named option in @command{guix package}
7614(@pxref{profile-manifest, @option{--manifest}}) and uses the same
7615manifest files.
7616
a54bd6d7
DT
7617@item --ad-hoc
7618Include all specified packages in the resulting environment, as if an
7619@i{ad hoc} package were defined with them as inputs. This option is
7620useful for quickly creating an environment without having to write a
7621package expression to contain the desired inputs.
7622
7623For instance, the command:
7624
7625@example
1de2fe95 7626guix environment --ad-hoc guile guile-sdl -- guile
a54bd6d7
DT
7627@end example
7628
7629runs @command{guile} in an environment where Guile and Guile-SDL are
7630available.
7631
417c39f1 7632Note that this example implicitly asks for the default output of
f97c9175 7633@code{guile} and @code{guile-sdl}, but it is possible to ask for a
417c39f1
LC
7634specific output---e.g., @code{glib:bin} asks for the @code{bin} output
7635of @code{glib} (@pxref{Packages with Multiple Outputs}).
7636
cc90fbbf
DT
7637This option may be composed with the default behavior of @command{guix
7638environment}. Packages appearing before @code{--ad-hoc} are interpreted
7639as packages whose dependencies will be added to the environment, the
7640default behavior. Packages appearing after are interpreted as packages
7641that will be added to the environment directly.
7642
372c4bbc
DT
7643@item --pure
7644Unset existing environment variables when building the new environment.
7645This has the effect of creating an environment in which search paths
7646only contain package inputs.
7647
7648@item --search-paths
7649Display the environment variable definitions that make up the
7650environment.
ce367ef3
LC
7651
7652@item --system=@var{system}
7653@itemx -s @var{system}
7654Attempt to build for @var{system}---e.g., @code{i686-linux}.
f535dcbe
DT
7655
7656@item --container
7657@itemx -C
7658@cindex container
7659Run @var{command} within an isolated container. The current working
a01ad638 7660directory outside the container is mapped inside the container.
e37944d8
MG
7661Additionally, unless overridden with @code{--user}, a dummy home
7662directory is created that matches the current user's home directory, and
7663@file{/etc/passwd} is configured accordingly. The spawned process runs
7664as the current user outside the container, but has root privileges in
7665the context of the container.
f535dcbe
DT
7666
7667@item --network
7668@itemx -N
7669For containers, share the network namespace with the host system.
7670Containers created without this flag only have access to the loopback
7671device.
7672
07ec3492
MG
7673@item --link-profile
7674@itemx -P
7675For containers, link the environment profile to
7676@file{~/.guix-profile} within the container. This is equivalent to
7677running the command @command{ln -s $GUIX_ENVIRONMENT ~/.guix-profile}
7678within the container. Linking will fail and abort the environment if
7679the directory already exists, which will certainly be the case if
7680@command{guix environment} was invoked in the user's home directory.
7681
7682Certain packages are configured to look in
7683@code{~/.guix-profile} for configuration files and data;@footnote{For
7684example, the @code{fontconfig} package inspects
7685@file{~/.guix-profile/share/fonts} for additional fonts.}
7686@code{--link-profile} allows these programs to behave as expected within
7687the environment.
7688
e37944d8
MG
7689@item --user=@var{user}
7690@itemx -u @var{user}
7691For containers, use the username @var{user} in place of the current
7692user. The generated @file{/etc/passwd} entry within the container will
7693contain the name @var{user}; the home directory will be
7694@file{/home/USER}; and no user GECOS data will be copied. @var{user}
7695need not exist on the system.
7696
7697Additionally, any shared or exposed path (see @code{--share} and
7698@code{--expose} respectively) whose target is within the current user's
7699home directory will be remapped relative to @file{/home/USER}; this
7700includes the automatic mapping of the current working directory.
7701
7702@example
7703# will expose paths as /home/foo/wd, /home/foo/test, and /home/foo/target
7704cd $HOME/wd
7705guix environment --container --user=foo \
7706 --expose=$HOME/test \
7707 --expose=/tmp/target=$HOME/target
7708@end example
7709
7710While this will limit the leaking of user identity through home paths
7711and each of the user fields, this is only one useful component of a
7712broader privacy/anonymity solution---not one in and of itself.
7713
f535dcbe
DT
7714@item --expose=@var{source}[=@var{target}]
7715For containers, expose the file system @var{source} from the host system
7716as the read-only file system @var{target} within the container. If
7717@var{target} is not specified, @var{source} is used as the target mount
7718point in the container.
7719
7720The example below spawns a Guile REPL in a container in which the user's
7721home directory is accessible read-only via the @file{/exchange}
7722directory:
7723
7724@example
da31b9c7 7725guix environment --container --expose=$HOME=/exchange --ad-hoc guile -- guile
f535dcbe
DT
7726@end example
7727
5c2b2f00 7728@item --share=@var{source}[=@var{target}]
f535dcbe
DT
7729For containers, share the file system @var{source} from the host system
7730as the writable file system @var{target} within the container. If
7731@var{target} is not specified, @var{source} is used as the target mount
7732point in the container.
7733
7734The example below spawns a Guile REPL in a container in which the user's
7735home directory is accessible for both reading and writing via the
7736@file{/exchange} directory:
7737
7738@example
da31b9c7 7739guix environment --container --share=$HOME=/exchange --ad-hoc guile -- guile
f535dcbe 7740@end example
372c4bbc
DT
7741@end table
7742
fdcb04af
HG
7743@command{guix environment}
7744also supports all of the common build options that @command{guix
ccd7158d 7745build} supports (@pxref{Common Build Options}).
372c4bbc 7746
fdcb04af 7747
aff8ce7c
DT
7748@node Invoking guix publish
7749@section Invoking @command{guix publish}
7750
e32171ee 7751@cindex @command{guix publish}
aff8ce7c 7752The purpose of @command{guix publish} is to enable users to easily share
f97c9175 7753their store with others, who can then use it as a substitute server
8ce229fc
LC
7754(@pxref{Substitutes}).
7755
7756When @command{guix publish} runs, it spawns an HTTP server which allows
7757anyone with network access to obtain substitutes from it. This means
7758that any machine running Guix can also act as if it were a build farm,
7759since the HTTP interface is compatible with Hydra, the software behind
7760the @code{hydra.gnu.org} build farm.
aff8ce7c
DT
7761
7762For security, each substitute is signed, allowing recipients to check
7763their authenticity and integrity (@pxref{Substitutes}). Because
f97c9175 7764@command{guix publish} uses the signing key of the system, which is only
5463fe51
LC
7765readable by the system administrator, it must be started as root; the
7766@code{--user} option makes it drop root privileges early on.
aff8ce7c 7767
b18812b6
LC
7768The signing key pair must be generated before @command{guix publish} is
7769launched, using @command{guix archive --generate-key} (@pxref{Invoking
7770guix archive}).
7771
aff8ce7c
DT
7772The general syntax is:
7773
7774@example
7775guix publish @var{options}@dots{}
7776@end example
7777
7778Running @command{guix publish} without any additional arguments will
7779spawn an HTTP server on port 8080:
7780
7781@example
7782guix publish
7783@end example
7784
7785Once a publishing server has been authorized (@pxref{Invoking guix
7786archive}), the daemon may download substitutes from it:
7787
7788@example
7789guix-daemon --substitute-urls=http://example.org:8080
7790@end example
7791
00753f70
LC
7792By default, @command{guix publish} compresses archives on the fly as it
7793serves them. This ``on-the-fly'' mode is convenient in that it requires
7794no setup and is immediately available. However, when serving lots of
7795clients, we recommend using the @option{--cache} option, which enables
7796caching of the archives before they are sent to clients---see below for
585347d7
LC
7797details. The @command{guix weather} command provides a handy way to
7798check what a server provides (@pxref{Invoking guix weather}).
00753f70 7799
ff6638d1
LC
7800As a bonus, @command{guix publish} also serves as a content-addressed
7801mirror for source files referenced in @code{origin} records
7802(@pxref{origin Reference}). For instance, assuming @command{guix
7803publish} is running on @code{example.org}, the following URL returns the
7804raw @file{hello-2.10.tar.gz} file with the given SHA256 hash
7805(represented in @code{nix-base32} format, @pxref{Invoking guix hash}):
7806
7807@example
7808http://example.org/file/hello-2.10.tar.gz/sha256/0ssi1@dots{}ndq1i
7809@end example
7810
7811Obviously, these URLs only work for files that are in the store; in
7812other cases, they return 404 (``Not Found'').
7813
c04ffadb
LC
7814@cindex build logs, publication
7815Build logs are available from @code{/log} URLs like:
7816
7817@example
7818http://example.org/log/gwspk@dots{}-guile-2.2.3
7819@end example
7820
7821@noindent
7822When @command{guix-daemon} is configured to save compressed build logs,
7823as is the case by default (@pxref{Invoking guix-daemon}), @code{/log}
7824URLs return the compressed log as-is, with an appropriate
7825@code{Content-Type} and/or @code{Content-Encoding} header. We recommend
7826running @command{guix-daemon} with @code{--log-compression=gzip} since
7827Web browsers can automatically decompress it, which is not the case with
7828bzip2 compression.
7829
aff8ce7c
DT
7830The following options are available:
7831
7832@table @code
7833@item --port=@var{port}
7834@itemx -p @var{port}
7835Listen for HTTP requests on @var{port}.
7836
9e2292ef
LC
7837@item --listen=@var{host}
7838Listen on the network interface for @var{host}. The default is to
7839accept connections from any interface.
7840
5463fe51
LC
7841@item --user=@var{user}
7842@itemx -u @var{user}
7843Change privileges to @var{user} as soon as possible---i.e., once the
7844server socket is open and the signing key has been read.
7845
4a1fc562
LC
7846@item --compression[=@var{level}]
7847@itemx -C [@var{level}]
7848Compress data using the given @var{level}. When @var{level} is zero,
7849disable compression. The range 1 to 9 corresponds to different gzip
7850compression levels: 1 is the fastest, and 9 is the best (CPU-intensive).
7851The default is 3.
7852
00753f70
LC
7853Unless @option{--cache} is used, compression occurs on the fly and
7854the compressed streams are not
4a1fc562 7855cached. Thus, to reduce load on the machine that runs @command{guix
00753f70
LC
7856publish}, it may be a good idea to choose a low compression level, to
7857run @command{guix publish} behind a caching proxy, or to use
7858@option{--cache}. Using @option{--cache} has the advantage that it
7859allows @command{guix publish} to add @code{Content-Length} HTTP header
7860to its responses.
7861
7862@item --cache=@var{directory}
7863@itemx -c @var{directory}
7864Cache archives and meta-data (@code{.narinfo} URLs) to @var{directory}
7865and only serve archives that are in cache.
7866
7867When this option is omitted, archives and meta-data are created
7868on-the-fly. This can reduce the available bandwidth, especially when
7869compression is enabled, since this may become CPU-bound. Another
7870drawback of the default mode is that the length of archives is not known
7871in advance, so @command{guix publish} does not add a
7872@code{Content-Length} HTTP header to its responses, which in turn
7873prevents clients from knowing the amount of data being downloaded.
7874
7875Conversely, when @option{--cache} is used, the first request for a store
7876item (@i{via} a @code{.narinfo} URL) returns 404 and triggers a
7877background process to @dfn{bake} the archive---computing its
7878@code{.narinfo} and compressing the archive, if needed. Once the
7879archive is cached in @var{directory}, subsequent requests succeed and
7880are served directly from the cache, which guarantees that clients get
7881the best possible bandwidth.
7882
7883The ``baking'' process is performed by worker threads. By default, one
7884thread per CPU core is created, but this can be customized. See
7885@option{--workers} below.
7886
d72b4206
LC
7887When @option{--ttl} is used, cached entries are automatically deleted
7888when they have expired.
7889
00753f70
LC
7890@item --workers=@var{N}
7891When @option{--cache} is used, request the allocation of @var{N} worker
7892threads to ``bake'' archives.
4a1fc562 7893
e4c7a5f7
LC
7894@item --ttl=@var{ttl}
7895Produce @code{Cache-Control} HTTP headers that advertise a time-to-live
7896(TTL) of @var{ttl}. @var{ttl} must denote a duration: @code{5d} means 5
7897days, @code{1m} means 1 month, and so on.
7898
7899This allows the user's Guix to keep substitute information in cache for
7900@var{ttl}. However, note that @code{guix publish} does not itself
7901guarantee that the store items it provides will indeed remain available
7902for as long as @var{ttl}.
7903
d72b4206 7904Additionally, when @option{--cache} is used, cached entries that have
c95644f0
LC
7905not been accessed for @var{ttl} and that no longer have a corresponding
7906item in the store, may be deleted.
d72b4206 7907
4bb5e0ae
LC
7908@item --nar-path=@var{path}
7909Use @var{path} as the prefix for the URLs of ``nar'' files
7910(@pxref{Invoking guix archive, normalized archives}).
7911
7912By default, nars are served at a URL such as
7913@code{/nar/gzip/@dots{}-coreutils-8.25}. This option allows you to
7914change the @code{/nar} part to @var{path}.
7915
46f58390
LC
7916@item --public-key=@var{file}
7917@itemx --private-key=@var{file}
7918Use the specific @var{file}s as the public/private key pair used to sign
7919the store items being published.
7920
7921The files must correspond to the same key pair (the private key is used
7922for signing and the public key is merely advertised in the signature
7923metadata). They must contain keys in the canonical s-expression format
7924as produced by @command{guix archive --generate-key} (@pxref{Invoking
7925guix archive}). By default, @file{/etc/guix/signing-key.pub} and
7926@file{/etc/guix/signing-key.sec} are used.
7927
aff8ce7c
DT
7928@item --repl[=@var{port}]
7929@itemx -r [@var{port}]
7930Spawn a Guile REPL server (@pxref{REPL Servers,,, guile, GNU Guile
8ce229fc
LC
7931Reference Manual}) on @var{port} (37146 by default). This is used
7932primarily for debugging a running @command{guix publish} server.
aff8ce7c
DT
7933@end table
7934
1c52181f 7935Enabling @command{guix publish} on a GuixSD system is a one-liner: just
f1e900a3
LC
7936instantiate a @code{guix-publish-service-type} service in the @code{services} field
7937of the @code{operating-system} declaration (@pxref{guix-publish-service-type,
7938@code{guix-publish-service-type}}).
1c52181f 7939
332d7903
HG
7940If you are instead running Guix on a ``foreign distro'', follow these
7941instructions:”
7942
7943@itemize
7944@item
7945If your host distro uses the systemd init system:
7946
7947@example
7948# ln -s ~root/.guix-profile/lib/systemd/system/guix-publish.service \
7949 /etc/systemd/system/
7950# systemctl start guix-publish && systemctl enable guix-publish
7951@end example
7952
7953@item
7954If your host distro uses the Upstart init system:
7955
7956@example
7957# ln -s ~root/.guix-profile/lib/upstart/system/guix-publish.conf /etc/init/
7958# start guix-publish
7959@end example
7960
7961@item
7962Otherwise, proceed similarly with your distro's init system.
7963@end itemize
d23c20f1
LC
7964
7965@node Invoking guix challenge
7966@section Invoking @command{guix challenge}
7967
7968@cindex reproducible builds
7969@cindex verifiable builds
e32171ee
JD
7970@cindex @command{guix challenge}
7971@cindex challenge
d23c20f1 7972Do the binaries provided by this server really correspond to the source
f97c9175 7973code it claims to build? Is a package build process deterministic?
d23c20f1
LC
7974These are the questions the @command{guix challenge} command attempts to
7975answer.
7976
7977The former is obviously an important question: Before using a substitute
f97c9175 7978server (@pxref{Substitutes}), one had better @emph{verify} that it
d23c20f1
LC
7979provides the right binaries, and thus @emph{challenge} it. The latter
7980is what enables the former: If package builds are deterministic, then
7981independent builds of the package should yield the exact same result,
7982bit for bit; if a server provides a binary different from the one
7983obtained locally, it may be either corrupt or malicious.
7984
7985We know that the hash that shows up in @file{/gnu/store} file names is
7986the hash of all the inputs of the process that built the file or
7987directory---compilers, libraries, build scripts,
7988etc. (@pxref{Introduction}). Assuming deterministic build processes,
7989one store file name should map to exactly one build output.
7990@command{guix challenge} checks whether there is, indeed, a single
7991mapping by comparing the build outputs of several independent builds of
7992any given store item.
7993
f97c9175 7994The command output looks like this:
d23c20f1
LC
7995
7996@smallexample
ddbc7f7d
LC
7997$ guix challenge --substitute-urls="https://hydra.gnu.org https://guix.example.org"
7998updating list of substitutes from 'https://hydra.gnu.org'... 100.0%
7999updating list of substitutes from 'https://guix.example.org'... 100.0%
d23c20f1
LC
8000/gnu/store/@dots{}-openssl-1.0.2d contents differ:
8001 local hash: 0725l22r5jnzazaacncwsvp9kgf42266ayyp814v7djxs7nk963q
ddbc7f7d
LC
8002 https://hydra.gnu.org/nar/@dots{}-openssl-1.0.2d: 0725l22r5jnzazaacncwsvp9kgf42266ayyp814v7djxs7nk963q
8003 https://guix.example.org/nar/@dots{}-openssl-1.0.2d: 1zy4fmaaqcnjrzzajkdn3f5gmjk754b43qkq47llbyak9z0qjyim
d23c20f1
LC
8004/gnu/store/@dots{}-git-2.5.0 contents differ:
8005 local hash: 00p3bmryhjxrhpn2gxs2fy0a15lnip05l97205pgbk5ra395hyha
ddbc7f7d
LC
8006 https://hydra.gnu.org/nar/@dots{}-git-2.5.0: 069nb85bv4d4a6slrwjdy8v1cn4cwspm3kdbmyb81d6zckj3nq9f
8007 https://guix.example.org/nar/@dots{}-git-2.5.0: 0mdqa9w1p6cmli6976v4wi0sw9r4p5prkj7lzfd1877wk11c9c73
d23c20f1
LC
8008/gnu/store/@dots{}-pius-2.1.1 contents differ:
8009 local hash: 0k4v3m9z1zp8xzzizb7d8kjj72f9172xv078sq4wl73vnq9ig3ax
ddbc7f7d
LC
8010 https://hydra.gnu.org/nar/@dots{}-pius-2.1.1: 0k4v3m9z1zp8xzzizb7d8kjj72f9172xv078sq4wl73vnq9ig3ax
8011 https://guix.example.org/nar/@dots{}-pius-2.1.1: 1cy25x1a4fzq5rk0pmvc8xhwyffnqz95h2bpvqsz2mpvlbccy0gs
bf7dfb1f
LC
8012
8013@dots{}
8014
80156,406 store items were analyzed:
8016 - 4,749 (74.1%) were identical
8017 - 525 (8.2%) differed
8018 - 1,132 (17.7%) were inconclusive
d23c20f1
LC
8019@end smallexample
8020
8021@noindent
8022In this example, @command{guix challenge} first scans the store to
8023determine the set of locally-built derivations---as opposed to store
8024items that were downloaded from a substitute server---and then queries
8025all the substitute servers. It then reports those store items for which
8026the servers obtained a result different from the local build.
8027
8028@cindex non-determinism, in package builds
8029As an example, @code{guix.example.org} always gets a different answer.
8030Conversely, @code{hydra.gnu.org} agrees with local builds, except in the
8031case of Git. This might indicate that the build process of Git is
8032non-deterministic, meaning that its output varies as a function of
8033various things that Guix does not fully control, in spite of building
8034packages in isolated environments (@pxref{Features}). Most common
8035sources of non-determinism include the addition of timestamps in build
8036results, the inclusion of random numbers, and directory listings sorted
a70a5004 8037by inode number. See @uref{https://reproducible-builds.org/docs/}, for
d23c20f1
LC
8038more information.
8039
f97c9175 8040To find out what is wrong with this Git binary, we can do something along
d23c20f1
LC
8041these lines (@pxref{Invoking guix archive}):
8042
8043@example
ddbc7f7d 8044$ wget -q -O - https://hydra.gnu.org/nar/@dots{}-git-2.5.0 \
d23c20f1 8045 | guix archive -x /tmp/git
043f4698 8046$ diff -ur --no-dereference /gnu/store/@dots{}-git.2.5.0 /tmp/git
d23c20f1
LC
8047@end example
8048
8049This command shows the difference between the files resulting from the
8050local build, and the files resulting from the build on
8051@code{hydra.gnu.org} (@pxref{Overview, Comparing and Merging Files,,
8052diffutils, Comparing and Merging Files}). The @command{diff} command
8053works great for text files. When binary files differ, a better option
ddbc7f7d 8054is @uref{https://diffoscope.org/, Diffoscope}, a tool that helps
d23c20f1
LC
8055visualize differences for all kinds of files.
8056
f97c9175 8057Once you have done that work, you can tell whether the differences are due
d23c20f1
LC
8058to a non-deterministic build process or to a malicious server. We try
8059hard to remove sources of non-determinism in packages to make it easier
f97c9175
AE
8060to verify substitutes, but of course, this is a process that
8061involves not just Guix, but a large part of the free software community.
d23c20f1
LC
8062In the meantime, @command{guix challenge} is one tool to help address
8063the problem.
8064
8065If you are writing packages for Guix, you are encouraged to check
8066whether @code{hydra.gnu.org} and other substitute servers obtain the
8067same build result as you did with:
8068
8069@example
8070$ guix challenge @var{package}
8071@end example
8072
8073@noindent
f97c9175 8074where @var{package} is a package specification such as
7cffaeb6 8075@code{guile@@2.0} or @code{glibc:debug}.
d23c20f1
LC
8076
8077The general syntax is:
8078
8079@example
8080guix challenge @var{options} [@var{packages}@dots{}]
8081@end example
8082
7cffaeb6
LC
8083When a difference is found between the hash of a locally-built item and
8084that of a server-provided substitute, or among substitutes provided by
8085different servers, the command displays it as in the example above and
a17417a8
LC
8086its exit code is 2 (other non-zero exit codes denote other kinds of
8087errors.)
7cffaeb6 8088
d23c20f1
LC
8089The one option that matters is:
8090
8091@table @code
8092
8093@item --substitute-urls=@var{urls}
8094Consider @var{urls} the whitespace-separated list of substitute source
8095URLs to compare to.
8096
153b6295
LC
8097@item --verbose
8098@itemx -v
8099Show details about matches (identical contents) in addition to
8100information about mismatches.
8101
d23c20f1
LC
8102@end table
8103
f11c444d
LC
8104@node Invoking guix copy
8105@section Invoking @command{guix copy}
8106
8107@cindex copy, of store items, over SSH
8108@cindex SSH, copy of store items
8109@cindex sharing store items across machines
8110@cindex transferring store items across machines
8111The @command{guix copy} command copies items from the store of one
8112machine to that of another machine over a secure shell (SSH)
8113connection@footnote{This command is available only when Guile-SSH was
8114found. @xref{Requirements}, for details.}. For example, the following
8115command copies the @code{coreutils} package, the user's profile, and all
8116their dependencies over to @var{host}, logged in as @var{user}:
8117
8118@example
8119guix copy --to=@var{user}@@@var{host} \
8120 coreutils `readlink -f ~/.guix-profile`
8121@end example
8122
8123If some of the items to be copied are already present on @var{host},
8124they are not actually sent.
8125
8126The command below retrieves @code{libreoffice} and @code{gimp} from
8127@var{host}, assuming they are available there:
8128
8129@example
8130guix copy --from=@var{host} libreoffice gimp
8131@end example
8132
8133The SSH connection is established using the Guile-SSH client, which is
8134compatible with OpenSSH: it honors @file{~/.ssh/known_hosts} and
8135@file{~/.ssh/config}, and uses the SSH agent for authentication.
8136
8137The key used to sign items that are sent must be accepted by the remote
8138machine. Likewise, the key used by the remote machine to sign items you
8139are retrieving must be in @file{/etc/guix/acl} so it is accepted by your
8140own daemon. @xref{Invoking guix archive}, for more information about
8141store item authentication.
8142
8143The general syntax is:
8144
8145@example
8146guix copy [--to=@var{spec}|--from=@var{spec}] @var{items}@dots{}
8147@end example
8148
8149You must always specify one of the following options:
8150
8151@table @code
8152@item --to=@var{spec}
8153@itemx --from=@var{spec}
8154Specify the host to send to or receive from. @var{spec} must be an SSH
8155spec such as @code{example.org}, @code{charlie@@example.org}, or
8156@code{charlie@@example.org:2222}.
8157@end table
8158
8159The @var{items} can be either package names, such as @code{gimp}, or
8160store items, such as @file{/gnu/store/@dots{}-idutils-4.6}.
8161
8162When specifying the name of a package to send, it is first built if
8163needed, unless @option{--dry-run} was specified. Common build options
8164are supported (@pxref{Common Build Options}).
8165
d23c20f1 8166
32efa254
DT
8167@node Invoking guix container
8168@section Invoking @command{guix container}
8169@cindex container
e32171ee 8170@cindex @command{guix container}
32efa254
DT
8171@quotation Note
8172As of version @value{VERSION}, this tool is experimental. The interface
8173is subject to radical change in the future.
8174@end quotation
8175
8176The purpose of @command{guix container} is to manipulate processes
8177running within an isolated environment, commonly known as a
46c36586 8178``container'', typically created by the @command{guix environment}
32efa254
DT
8179(@pxref{Invoking guix environment}) and @command{guix system container}
8180(@pxref{Invoking guix system}) commands.
8181
8182The general syntax is:
8183
8184@example
8185guix container @var{action} @var{options}@dots{}
8186@end example
8187
8188@var{action} specifies the operation to perform with a container, and
8189@var{options} specifies the context-specific arguments for the action.
8190
8191The following actions are available:
8192
8193@table @code
8194@item exec
8195Execute a command within the context of a running container.
8196
8197The syntax is:
8198
8199@example
8200guix container exec @var{pid} @var{program} @var{arguments}@dots{}
8201@end example
8202
8203@var{pid} specifies the process ID of the running container.
f97c9175
AE
8204@var{program} specifies an executable file name within the root file
8205system of the container. @var{arguments} are the additional options that
8206will be passed to @var{program}.
32efa254
DT
8207
8208The following command launches an interactive login shell inside a
8209GuixSD container, started by @command{guix system container}, and whose
8210process ID is 9001:
8211
8212@example
8213guix container exec 9001 /run/current-system/profile/bin/bash --login
8214@end example
8215
8216Note that the @var{pid} cannot be the parent process of a container. It
f97c9175 8217must be PID 1 of the container or one of its child processes.
32efa254
DT
8218
8219@end table
8220
585347d7
LC
8221@node Invoking guix weather
8222@section Invoking @command{guix weather}
8223
8224Occasionally you're grumpy because substitutes are lacking and you end
8225up building packages by yourself (@pxref{Substitutes}). The
8226@command{guix weather} command reports on substitute availability on the
8227specified servers so you can have an idea of whether you'll be grumpy
8228today. It can sometimes be useful info as a user, but it is primarily
8229useful to people running @command{guix publish} (@pxref{Invoking guix
8230publish}).
8231
8232@cindex statistics, for substitutes
8233@cindex availability of substitutes
8234@cindex substitute availability
8235@cindex weather, substitute availability
8236Here's a sample run:
8237
8238@example
8239$ guix weather --substitute-urls=https://guix.example.org
8240computing 5,872 package derivations for x86_64-linux...
8241looking for 6,128 store items on https://guix.example.org..
8242updating list of substitutes from 'https://guix.example.org'... 100.0%
8243https://guix.example.org
8244 43.4% substitutes available (2,658 out of 6,128)
8245 7,032.5 MiB of nars (compressed)
8246 19,824.2 MiB on disk (uncompressed)
8247 0.030 seconds per request (182.9 seconds in total)
8248 33.5 requests per second
183445a6
LC
8249
8250 9.8% (342 out of 3,470) of the missing items are queued
8251 867 queued builds
8252 x86_64-linux: 518 (59.7%)
8253 i686-linux: 221 (25.5%)
8254 aarch64-linux: 128 (14.8%)
8255 build rate: 23.41 builds per hour
8256 x86_64-linux: 11.16 builds per hour
8257 i686-linux: 6.03 builds per hour
8258 aarch64-linux: 6.41 builds per hour
585347d7
LC
8259@end example
8260
183445a6 8261@cindex continuous integration, statistics
585347d7
LC
8262As you can see, it reports the fraction of all the packages for which
8263substitutes are available on the server---regardless of whether
8264substitutes are enabled, and regardless of whether this server's signing
8265key is authorized. It also reports the size of the compressed archives
8266(``nars'') provided by the server, the size the corresponding store
8267items occupy in the store (assuming deduplication is turned off), and
183445a6
LC
8268the server's throughput. The second part gives continuous integration
8269(CI) statistics, if the server supports it.
585347d7
LC
8270
8271To achieve that, @command{guix weather} queries over HTTP(S) meta-data
8272(@dfn{narinfos}) for all the relevant store items. Like @command{guix
8273challenge}, it ignores signatures on those substitutes, which is
8274innocuous since the command only gathers statistics and cannot install
8275those substitutes.
8276
8277Among other things, it is possible to query specific system types and
8278specific package sets. The available options are listed below.
8279
8280@table @code
8281@item --substitute-urls=@var{urls}
8282@var{urls} is the space-separated list of substitute server URLs to
8283query. When this option is omitted, the default set of substitute
8284servers is queried.
8285
8286@item --system=@var{system}
8287@itemx -s @var{system}
8288Query substitutes for @var{system}---e.g., @code{aarch64-linux}. This
8289option can be repeated, in which case @command{guix weather} will query
8290substitutes for several system types.
8291
8292@item --manifest=@var{file}
8293Instead of querying substitutes for all the packages, only ask for those
8294specified in @var{file}. @var{file} must contain a @dfn{manifest}, as
8295with the @code{-m} option of @command{guix package} (@pxref{Invoking
8296guix package}).
8297@end table
8298
8299
a1ba8475
LC
8300@c *********************************************************************
8301@node GNU Distribution
8302@chapter GNU Distribution
8303
3ca2731c 8304@cindex Guix System Distribution
4705641f 8305@cindex GuixSD
3ca2731c
LC
8306Guix comes with a distribution of the GNU system consisting entirely of
8307free software@footnote{The term ``free'' here refers to the
a1ba8475 8308@url{http://www.gnu.org/philosophy/free-sw.html,freedom provided to
3ca2731c 8309users of that software}.}. The
35ed9306
LC
8310distribution can be installed on its own (@pxref{System Installation}),
8311but it is also possible to install Guix as a package manager on top of
8312an installed GNU/Linux system (@pxref{Installation}). To distinguish
3ca2731c 8313between the two, we refer to the standalone distribution as the Guix
4705641f 8314System Distribution, or GuixSD.
35ed9306
LC
8315
8316The distribution provides core GNU packages such as GNU libc, GCC, and
8317Binutils, as well as many GNU and non-GNU applications. The complete
8318list of available packages can be browsed
093ae1be 8319@url{http://www.gnu.org/software/guix/packages,on-line} or by
d03bb653 8320running @command{guix package} (@pxref{Invoking guix package}):
a1ba8475
LC
8321
8322@example
e49951eb 8323guix package --list-available
a1ba8475
LC
8324@end example
8325
f97c9175 8326Our goal is to provide a practical 100% free software distribution of
401c53c4
LC
8327Linux-based and other variants of GNU, with a focus on the promotion and
8328tight integration of GNU components, and an emphasis on programs and
8329tools that help users exert that freedom.
8330
3ca2731c 8331Packages are currently available on the following platforms:
c320011d
LC
8332
8333@table @code
8334
8335@item x86_64-linux
8336Intel/AMD @code{x86_64} architecture, Linux-Libre kernel;
8337
8338@item i686-linux
8339Intel 32-bit architecture (IA32), Linux-Libre kernel;
8340
aa1e1947 8341@item armhf-linux
aa725117 8342ARMv7-A architecture with hard float, Thumb-2 and NEON,
f97c9175
AE
8343using the EABI hard-float application binary interface (ABI),
8344and Linux-Libre kernel.
aa1e1947 8345
3b88f376
EF
8346@item aarch64-linux
8347little-endian 64-bit ARMv8-A processors, Linux-Libre kernel. This is
be2ba697 8348currently in an experimental stage, with limited support.
3b88f376
EF
8349@xref{Contributing}, for how to help!
8350
c320011d
LC
8351@item mips64el-linux
8352little-endian 64-bit MIPS processors, specifically the Loongson series,
f97c9175 8353n32 ABI, and Linux-Libre kernel.
c320011d
LC
8354
8355@end table
8356
4705641f 8357GuixSD itself is currently only available on @code{i686} and @code{x86_64}.
3ca2731c 8358
c320011d
LC
8359@noindent
8360For information on porting to other architectures or kernels,
f97c9175 8361@pxref{Porting}.
c320011d 8362
401c53c4 8363@menu
5af6de3e 8364* System Installation:: Installing the whole operating system.
35ed9306 8365* System Configuration:: Configuring the operating system.
31f1f593 8366* Documentation:: Browsing software user manuals.
91ef73d4 8367* Installing Debugging Files:: Feeding the debugger.
05962f29 8368* Security Updates:: Deploying security fixes quickly.
401c53c4 8369* Package Modules:: Packages from the programmer's viewpoint.
da7cabd4 8370* Packaging Guidelines:: Growing the distribution.
401c53c4 8371* Bootstrapping:: GNU/Linux built from scratch.
8b315a6d 8372* Porting:: Targeting another platform or kernel.
401c53c4
LC
8373@end menu
8374
8375Building this distribution is a cooperative effort, and you are invited
081145cf 8376to join! @xref{Contributing}, for information about how you can help.
401c53c4 8377
5af6de3e
LC
8378@node System Installation
8379@section System Installation
8380
e32171ee 8381@cindex installing GuixSD
3ca2731c 8382@cindex Guix System Distribution
c8b54374 8383This section explains how to install the Guix System Distribution (GuixSD)
3ca2731c 8384on a machine. The Guix package manager can
35ed9306
LC
8385also be installed on top of a running GNU/Linux system,
8386@pxref{Installation}.
5af6de3e
LC
8387
8388@ifinfo
9c18cf9b 8389@quotation Note
5af6de3e
LC
8390@c This paragraph is for people reading this from tty2 of the
8391@c installation image.
1068f26b 8392You are reading this documentation with an Info reader. For details on
5af6de3e 8393how to use it, hit the @key{RET} key (``return'' or ``enter'') on the
de341e7c
LC
8394link that follows: @pxref{Top, Info reader,, info-stnd, Stand-alone GNU
8395Info}. Hit @kbd{l} afterwards to come back here.
9c18cf9b
LC
8396
8397Alternately, run @command{info info} in another tty to keep the manual
8398available.
8399@end quotation
5af6de3e
LC
8400@end ifinfo
8401
dedb8d5e 8402@menu
e3009f60
LC
8403* Limitations:: What you can expect.
8404* Hardware Considerations:: Supported hardware.
2626062b 8405* USB Stick and DVD Installation:: Preparing the installation medium.
e3009f60
LC
8406* Preparing for Installation:: Networking, partitioning, etc.
8407* Proceeding with the Installation:: The real thing.
c8b54374 8408* Installing GuixSD in a VM:: GuixSD playground.
e3009f60 8409* Building the Installation Image:: How this comes to be.
dedb8d5e
LC
8410@end menu
8411
8412@node Limitations
8aaaae38
LC
8413@subsection Limitations
8414
4705641f 8415As of version @value{VERSION}, the Guix System Distribution (GuixSD) is
3ca2731c 8416not production-ready. It may contain bugs and lack important
8aaaae38
LC
8417features. Thus, if you are looking for a stable production system that
8418respects your freedom as a computer user, a good solution at this point
8419is to consider @url{http://www.gnu.org/distros/free-distros.html, one of
f97c9175 8420the more established GNU/Linux distributions}. We hope you can soon switch
4705641f 8421to the GuixSD without fear, of course. In the meantime, you can
8aaaae38
LC
8422also keep using your distribution and try out the package manager on top
8423of it (@pxref{Installation}).
8424
8425Before you proceed with the installation, be aware of the following
8426noteworthy limitations applicable to version @value{VERSION}:
8427
8428@itemize
8429@item
8430The installation process does not include a graphical user interface and
8431requires familiarity with GNU/Linux (see the following subsections to
8432get a feel of what that means.)
8433
8aaaae38 8434@item
dbcb0ab1 8435Support for the Logical Volume Manager (LVM) is missing.
8aaaae38
LC
8436
8437@item
0be9b4a9
LC
8438More and more system services are provided (@pxref{Services}), but some
8439may be missing.
8aaaae38
LC
8440
8441@item
63899cc7 8442More than 7,500 packages are available, but you might
8aaaae38 8443occasionally find that a useful package is missing.
5fe01c2d
LC
8444
8445@item
0be9b4a9 8446GNOME, Xfce, LXDE, and Enlightenment are available (@pxref{Desktop Services}),
5fe01c2d
LC
8447as well as a number of X11 window managers. However, some graphical
8448applications may be missing, as well as KDE.
8aaaae38
LC
8449@end itemize
8450
f97c9175
AE
8451You have been warned! But more than a disclaimer, this is an invitation
8452to report issues (and success stories!), and to join us in improving it.
8aaaae38 8453@xref{Contributing}, for more info.
5af6de3e 8454
e3009f60
LC
8455
8456@node Hardware Considerations
8457@subsection Hardware Considerations
8458
8459@cindex hardware support on GuixSD
8460GNU@tie{}GuixSD focuses on respecting the user's computing freedom. It
8461builds around the kernel Linux-libre, which means that only hardware for
e0b3f97e 8462which free software drivers and firmware exist is supported. Nowadays,
e3009f60
LC
8463a wide range of off-the-shelf hardware is supported on
8464GNU/Linux-libre---from keyboards to graphics cards to scanners and
8465Ethernet controllers. Unfortunately, there are still areas where
8466hardware vendors deny users control over their own computing, and such
8467hardware is not supported on GuixSD.
8468
8469@cindex WiFi, hardware support
e0b3f97e 8470One of the main areas where free drivers or firmware are lacking is WiFi
e3009f60
LC
8471devices. WiFi devices known to work include those using Atheros chips
8472(AR9271 and AR7010), which corresponds to the @code{ath9k} Linux-libre
52db41af
EB
8473driver, and those using Broadcom/AirForce chips (BCM43xx with
8474Wireless-Core Revision 5), which corresponds to the @code{b43-open}
8475Linux-libre driver. Free firmware exists for both and is available
e3009f60
LC
8476out-of-the-box on GuixSD, as part of @var{%base-firmware}
8477(@pxref{operating-system Reference, @code{firmware}}).
8478
8479@cindex RYF, Respects Your Freedom
8480The @uref{https://www.fsf.org/, Free Software Foundation} runs
e0b3f97e 8481@uref{https://www.fsf.org/ryf, @dfn{Respects Your Freedom}} (RYF), a
e3009f60
LC
8482certification program for hardware products that respect your freedom
8483and your privacy and ensure that you have control over your device. We
e0b3f97e 8484encourage you to check the list of RYF-certified devices.
e3009f60
LC
8485
8486Another useful resource is the @uref{https://www.h-node.org/, H-Node}
8487web site. It contains a catalog of hardware devices with information
8488about their support in GNU/Linux.
8489
8490
2626062b
LC
8491@node USB Stick and DVD Installation
8492@subsection USB Stick and DVD Installation
5af6de3e 8493
2626062b
LC
8494An ISO-9660 installation image that can be written to a USB stick or
8495burnt to a DVD can be downloaded from
af7914a1 8496@indicateurl{https://alpha.gnu.org/gnu/guix/guixsd-install-@value{VERSION}.@var{system}.iso.xz},
5af6de3e
LC
8497where @var{system} is one of:
8498
8499@table @code
8500@item x86_64-linux
8501for a GNU/Linux system on Intel/AMD-compatible 64-bit CPUs;
8502
8503@item i686-linux
8504for a 32-bit GNU/Linux system on Intel-compatible CPUs.
8505@end table
8506
debc6360
LC
8507@c start duplication of authentication part from ``Binary Installation''
8508Make sure to download the associated @file{.sig} file and to verify the
8509authenticity of the image against it, along these lines:
8510
8511@example
af7914a1 8512$ wget https://alpha.gnu.org/gnu/guix/guixsd-install-@value{VERSION}.@var{system}.iso.xz.sig
3b6e7c70 8513$ gpg --verify guixsd-install-@value{VERSION}.@var{system}.iso.xz.sig
debc6360
LC
8514@end example
8515
8516If that command fails because you do not have the required public key,
8517then run this command to import it:
8518
8519@example
8520$ gpg --keyserver pgp.mit.edu --recv-keys @value{OPENPGP-SIGNING-KEY-ID}
8521@end example
8522
8523@noindent
8524and rerun the @code{gpg --verify} command.
8525@c end duplication
8526
d79013f6
DM
8527This image contains the tools necessary for an installation.
8528It is meant to be copied @emph{as is} to a large-enough USB stick or DVD.
5af6de3e 8529
2626062b
LC
8530@unnumberedsubsubsec Copying to a USB Stick
8531
5af6de3e
LC
8532To copy the image to a USB stick, follow these steps:
8533
8534@enumerate
8535@item
8536Decompress the image using the @command{xz} command:
8537
8538@example
3b6e7c70 8539xz -d guixsd-install-@value{VERSION}.@var{system}.iso.xz
5af6de3e
LC
8540@end example
8541
8542@item
f97c9175
AE
8543Insert a USB stick of 1@tie{}GiB or more into your machine, and determine
8544its device name. Assuming that the USB stick is known as @file{/dev/sdX},
5af6de3e
LC
8545copy the image with:
8546
8547@example
3b6e7c70 8548dd if=guixsd-install-@value{VERSION}.x86_64-linux.iso of=/dev/sdX
0e2bfa3a 8549sync
5af6de3e
LC
8550@end example
8551
8552Access to @file{/dev/sdX} usually requires root privileges.
8553@end enumerate
8554
2626062b 8555@unnumberedsubsubsec Burning on a DVD
d79013f6
DM
8556
8557To copy the image to a DVD, follow these steps:
8558
8559@enumerate
8560@item
8561Decompress the image using the @command{xz} command:
8562
8563@example
3b6e7c70 8564xz -d guixsd-install-@value{VERSION}.@var{system}.iso.xz
d79013f6
DM
8565@end example
8566
8567@item
8568Insert a blank DVD into your machine, and determine
8569its device name. Assuming that the DVD drive is known as @file{/dev/srX},
8570copy the image with:
8571
8572@example
3b6e7c70 8573growisofs -dvd-compat -Z /dev/srX=guixsd-install-@value{VERSION}.x86_64.iso
d79013f6
DM
8574@end example
8575
8576Access to @file{/dev/srX} usually requires root privileges.
8577@end enumerate
8578
2626062b
LC
8579@unnumberedsubsubsec Booting
8580
d79013f6 8581Once this is done, you should be able to reboot the system and boot from
2626062b
LC
8582the USB stick or DVD. The latter usually requires you to get in the
8583BIOS or UEFI boot menu, where you can choose to boot from the USB stick.
d79013f6
DM
8584
8585@xref{Installing GuixSD in a VM}, if, instead, you would like to install
8586GuixSD in a virtual machine (VM).
8587
2626062b 8588
dedb8d5e 8589@node Preparing for Installation
5af6de3e
LC
8590@subsection Preparing for Installation
8591
d79013f6
DM
8592Once you have successfully booted your computer using the installation medium,
8593you should end up with a root prompt. Several console TTYs are configured
8594and can be used to run commands as root. TTY2 shows this documentation,
de341e7c
LC
8595browsable using the Info reader commands (@pxref{Top,,, info-stnd,
8596Stand-alone GNU Info}). The installation system runs the GPM mouse
8597daemon, which allows you to select text with the left mouse button and
8598to paste it with the middle button.
5af6de3e 8599
ff925d37
LC
8600@quotation Note
8601Installation requires access to the Internet so that any missing
8602dependencies of your system configuration can be downloaded. See the
8603``Networking'' section below.
8604@end quotation
8605
0e69cf67
LC
8606The installation system includes many common tools needed for this task.
8607But it is also a full-blown GuixSD system, which means that you can
8608install additional packages, should you need it, using @command{guix
8609package} (@pxref{Invoking guix package}).
8610
dedb8d5e 8611@subsubsection Keyboard Layout
5af6de3e 8612
dedb8d5e
LC
8613@cindex keyboard layout
8614The installation image uses the US qwerty keyboard layout. If you want
8615to change it, you can use the @command{loadkeys} command. For example,
8616the following command selects the Dvorak keyboard layout:
5af6de3e 8617
dedb8d5e
LC
8618@example
8619loadkeys dvorak
8620@end example
8621
8622See the files under @file{/run/current-system/profile/share/keymaps} for
8623a list of available keyboard layouts. Run @command{man loadkeys} for
8624more information.
8625
8626@subsubsection Networking
8627
336e4d61 8628Run the following command to see what your network interfaces are called:
235cba85
LC
8629
8630@example
dedb8d5e 8631ifconfig -a
235cba85
LC
8632@end example
8633
1713c37f
LC
8634@noindent
8635@dots{} or, using the GNU/Linux-specific @command{ip} command:
8636
8637@example
8638ip a
8639@end example
8640
95c559c1 8641@c http://cgit.freedesktop.org/systemd/systemd/tree/src/udev/udev-builtin-net_id.c#n20
dedb8d5e
LC
8642Wired interfaces have a name starting with @samp{e}; for example, the
8643interface corresponding to the first on-board Ethernet controller is
8644called @samp{eno1}. Wireless interfaces have a name starting with
8645@samp{w}, like @samp{w1p2s0}.
8646
8647@table @asis
8648@item Wired connection
8649To configure a wired network run the following command, substituting
8650@var{interface} with the name of the wired interface you want to use.
8651
8652@example
8653ifconfig @var{interface} up
8654@end example
8655
8656@item Wireless connection
e32171ee
JD
8657@cindex wireless
8658@cindex WiFi
dedb8d5e
LC
8659To configure wireless networking, you can create a configuration file
8660for the @command{wpa_supplicant} configuration tool (its location is not
8661important) using one of the available text editors such as
81c63cfc 8662@command{nano}:
dedb8d5e
LC
8663
8664@example
81c63cfc 8665nano wpa_supplicant.conf
dedb8d5e
LC
8666@end example
8667
8668As an example, the following stanza can go to this file and will work
8669for many wireless networks, provided you give the actual SSID and
8670passphrase for the network you are connecting to:
8671
8672@example
8673network=@{
ae768308 8674 ssid="@var{my-ssid}"
dedb8d5e
LC
8675 key_mgmt=WPA-PSK
8676 psk="the network's secret passphrase"
8677@}
8678@end example
8679
8680Start the wireless service and run it in the background with the
8681following command (substitute @var{interface} with the name of the
8682network interface you want to use):
8683
8684@example
8685wpa_supplicant -c wpa_supplicant.conf -i @var{interface} -B
8686@end example
8687
641d0518 8688Run @command{man wpa_supplicant} for more information.
dedb8d5e
LC
8689@end table
8690
e32171ee 8691@cindex DHCP
dedb8d5e
LC
8692At this point, you need to acquire an IP address. On a network where IP
8693addresses are automatically assigned @i{via} DHCP, you can run:
8694
8695@example
15650ac2 8696dhclient -v @var{interface}
dedb8d5e 8697@end example
5af6de3e 8698
dedb8d5e
LC
8699Try to ping a server to see if networking is up and running:
8700
8701@example
8702ping -c 3 gnu.org
8703@end example
5af6de3e
LC
8704
8705Setting up network access is almost always a requirement because the
8706image does not contain all the software and tools that may be needed.
8707
c80cd4df
MB
8708@cindex installing over SSH
8709If you want to, you can continue the installation remotely by starting
8710an SSH server:
8711
8712@example
8713herd start ssh-daemon
8714@end example
8715
8716Make sure to either set a password with @command{passwd}, or configure
8717OpenSSH public key authentication before logging in.
8718
dedb8d5e
LC
8719@subsubsection Disk Partitioning
8720
8721Unless this has already been done, the next step is to partition, and
8722then format the target partition(s).
8723
8724The installation image includes several partitioning tools, including
8725Parted (@pxref{Overview,,, parted, GNU Parted User Manual}),
8726@command{fdisk}, and @command{cfdisk}. Run it and set up your disk with
8727the partition layout you want:
8728
8729@example
8730cfdisk
8731@end example
8732
d918d79f
SB
8733If your disk uses the GUID Partition Table (GPT) format and you plan to
8734install BIOS-based GRUB (which is the default), make sure a BIOS Boot
8735Partition is available (@pxref{BIOS installation,,, grub, GNU GRUB
8736manual}).
8737
8ea98ee1
MB
8738@cindex EFI, installation
8739@cindex UEFI, installation
8740@cindex ESP, EFI system partition
8741If you instead wish to use EFI-based GRUB, a FAT32 @dfn{EFI System Partition}
8742(ESP) is required. This partition should be mounted at @file{/boot/efi} and
8743must have the @code{esp} flag set. E.g., for @command{parted}:
8744
8745@example
8746parted /dev/sda set 1 esp on
8747@end example
8748
fc0e663f
LC
8749@quotation Note
8750@vindex grub-bootloader
8751@vindex grub-efi-bootloader
8752Unsure whether to use EFI- or BIOS-based GRUB? If the directory
c2587d32 8753@file{/sys/firmware/efi} exists in the installation image, then you should
fc0e663f
LC
8754probably perform an EFI installation, using @code{grub-efi-bootloader}.
8755Otherwise you should use the BIOS-based GRUB, known as
8756@code{grub-bootloader}. @xref{Bootloader Configuration}, for more info on
8757bootloaders.
8758@end quotation
8759
dedb8d5e
LC
8760Once you are done partitioning the target hard disk drive, you have to
8761create a file system on the relevant partition(s)@footnote{Currently
b1a505ba 8762GuixSD only supports ext4 and btrfs file systems. In particular, code
01bd3b5e 8763that reads file system UUIDs and labels only works for these file system
6ab63268 8764types.}. For the ESP, if you have one and assuming it is
671dd8d6 8765@file{/dev/sda1}, run:
6ab63268
LC
8766
8767@example
671dd8d6 8768mkfs.fat -F32 /dev/sda1
6ab63268 8769@end example
5af6de3e 8770
45eee2dd 8771Preferably, assign file systems a label so that you can easily and
7ab44369
LC
8772reliably refer to them in @code{file-system} declarations (@pxref{File
8773Systems}). This is typically done using the @code{-L} option of
dedb8d5e 8774@command{mkfs.ext4} and related commands. So, assuming the target root
671dd8d6 8775partition lives at @file{/dev/sda2}, a file system with the label
dedb8d5e 8776@code{my-root} can be created with:
7ab44369 8777
dedb8d5e 8778@example
671dd8d6 8779mkfs.ext4 -L my-root /dev/sda2
dedb8d5e 8780@end example
dd816355 8781
13fb1bd9
LC
8782@cindex encrypted disk
8783If you are instead planning to encrypt the root partition, you can use
8784the Cryptsetup/LUKS utilities to do that (see @inlinefmtifelse{html,
8785@uref{https://linux.die.net/man/8/cryptsetup, @code{man cryptsetup}},
8786@code{man cryptsetup}} for more information.) Assuming you want to
671dd8d6 8787store the root partition on @file{/dev/sda2}, the command sequence would
13fb1bd9 8788be along these lines:
6d6e6281 8789
13fb1bd9 8790@example
671dd8d6
MB
8791cryptsetup luksFormat /dev/sda2
8792cryptsetup open --type luks /dev/sda2 my-partition
13fb1bd9
LC
8793mkfs.ext4 -L my-root /dev/mapper/my-partition
8794@end example
5af6de3e 8795
45eee2dd 8796Once that is done, mount the target file system under @file{/mnt}
13fb1bd9 8797with a command like (again, assuming @code{my-root} is the label of the
45eee2dd 8798root file system):
83a17b62 8799
dedb8d5e 8800@example
13fb1bd9 8801mount LABEL=my-root /mnt
dedb8d5e 8802@end example
83a17b62 8803
01bd3b5e 8804Also mount any other file systems you would like to use on the target
8ea98ee1
MB
8805system relative to this path. If you have @file{/boot} on a separate
8806partition for example, mount it at @file{/mnt/boot} now so it is found
8807by @code{guix system init} afterwards.
8808
31b6cdf8
LC
8809Finally, if you plan to use one or more swap partitions (@pxref{Memory
8810Concepts, swap space,, libc, The GNU C Library Reference Manual}), make
8811sure to initialize them with @command{mkswap}. Assuming you have one
671dd8d6 8812swap partition on @file{/dev/sda3}, you would run:
31b6cdf8
LC
8813
8814@example
671dd8d6
MB
8815mkswap /dev/sda3
8816swapon /dev/sda3
31b6cdf8
LC
8817@end example
8818
a4ca4362
CM
8819Alternatively, you may use a swap file. For example, assuming that in
8820the new system you want to use the file @file{/swapfile} as a swap file,
8821you would run@footnote{This example will work for many types of file
8822systems (e.g., ext4). However, for copy-on-write file systems (e.g.,
8823btrfs), the required steps may be different. For details, see the
8824manual pages for @command{mkswap} and @command{swapon}.}:
8825
8826@example
8827# This is 10 GiB of swap space. Adjust "count" to change the size.
8828dd if=/dev/zero of=/mnt/swapfile bs=1MiB count=10240
8829# For security, make the file readable and writable only by root.
8830chmod 600 /mnt/swapfile
8831mkswap /mnt/swapfile
8832swapon /mnt/swapfile
8833@end example
8834
8835Note that if you have encrypted the root partition and created a swap
8836file in its file system as described above, then the encryption also
8837protects the swap file, just like any other file in that file system.
8838
dedb8d5e
LC
8839@node Proceeding with the Installation
8840@subsection Proceeding with the Installation
83a17b62 8841
dedb8d5e
LC
8842With the target partitions ready and the target root mounted on
8843@file{/mnt}, we're ready to go. First, run:
5af6de3e 8844
dedb8d5e
LC
8845@example
8846herd start cow-store /mnt
8847@end example
5af6de3e 8848
b397c0d5
LC
8849This makes @file{/gnu/store} copy-on-write, such that packages added to it
8850during the installation phase are written to the target disk on @file{/mnt}
8851rather than kept in memory. This is necessary because the first phase of
8852the @command{guix system init} command (see below) entails downloads or
8853builds to @file{/gnu/store} which, initially, is an in-memory file system.
5af6de3e 8854
dedb8d5e 8855Next, you have to edit a file and
5af6de3e 8856provide the declaration of the operating system to be installed. To
81c63cfc
LC
8857that end, the installation system comes with three text editors. We
8858recommend GNU nano (@pxref{Top,,, nano, GNU nano Manual}), which
8859supports syntax highlighting and parentheses matching; other editors
8860include GNU Zile (an Emacs clone), and
a8cb87ab 8861nvi (a clone of the original BSD @command{vi} editor).
efa77c6c
LC
8862We strongly recommend storing that file on the target root file system, say,
8863as @file{/mnt/etc/config.scm}. Failing to do that, you will have lost your
8864configuration file once you have rebooted into the newly-installed system.
5af6de3e 8865
dedb8d5e
LC
8866@xref{Using the Configuration System}, for an overview of the
8867configuration file. The example configurations discussed in that
8868section are available under @file{/etc/configuration} in the
8869installation image. Thus, to get started with a system configuration
8870providing a graphical display server (a ``desktop'' system), you can run
8871something along these lines:
8872
8873@example
8874# mkdir /mnt/etc
8875# cp /etc/configuration/desktop.scm /mnt/etc/config.scm
81c63cfc 8876# nano /mnt/etc/config.scm
dedb8d5e
LC
8877@end example
8878
8879You should pay attention to what your configuration file contains, and
8880in particular:
8881
8882@itemize
8883@item
fdfdecdb
TGR
8884Make sure the @code{bootloader-configuration} form refers to the target
8885you want to install GRUB on. It should mention @code{grub-bootloader} if
045ebb3e
AW
8886you are installing GRUB in the legacy way, or @code{grub-efi-bootloader}
8887for newer UEFI systems. For legacy systems, the @code{target} field
8888names a device, like @code{/dev/sda}; for UEFI systems it names a path
8889to a mounted EFI partition, like @code{/boot/efi}, and do make sure the
8890path is actually mounted.
dedb8d5e
LC
8891
8892@item
01bd3b5e 8893Be sure that your file system labels match the value of their respective
dedb8d5e 8894@code{device} fields in your @code{file-system} configuration, assuming
3480d6f7
JL
8895your @code{file-system} configuration uses the @code{file-system-label}
8896procedure in its @code{device} field.
13fb1bd9
LC
8897
8898@item
8899If there are encrypted or RAID partitions, make sure to add a
8900@code{mapped-devices} field to describe them (@pxref{Mapped Devices}).
dedb8d5e 8901@end itemize
5af6de3e 8902
dd51caac
LC
8903Once you are done preparing the configuration file, the new system must
8904be initialized (remember that the target root file system is mounted
8905under @file{/mnt}):
5af6de3e
LC
8906
8907@example
8908guix system init /mnt/etc/config.scm /mnt
8909@end example
8910
8911@noindent
dedb8d5e 8912This copies all the necessary files and installs GRUB on
f8818360 8913@file{/dev/sdX}, unless you pass the @option{--no-bootloader} option. For
6621cdb6 8914more information, @pxref{Invoking guix system}. This command may trigger
5af6de3e
LC
8915downloads or builds of missing packages, which can take some time.
8916
1bd4e6db
LC
8917Once that command has completed---and hopefully succeeded!---you can run
8918@command{reboot} and boot into the new system. The @code{root} password
8919in the new system is initially empty; other users' passwords need to be
8920initialized by running the @command{passwd} command as @code{root},
8921unless your configuration specifies otherwise
8922(@pxref{user-account-password, user account passwords}).
8923
7fcf2a0b
LC
8924@cindex upgrading GuixSD
8925From then on, you can update GuixSD whenever you want by running
8926@command{guix pull} as @code{root} (@pxref{Invoking guix pull}), and
8927then running @command{guix system reconfigure} to build a new system
8928generation with the latest packages and services (@pxref{Invoking guix
8929system}). We recommend doing that regularly so that your system
8930includes the latest security updates (@pxref{Security Updates}).
8931
1bd4e6db 8932Join us on @code{#guix} on the Freenode IRC network or on
5af6de3e
LC
8933@file{guix-devel@@gnu.org} to share your experience---good or not so
8934good.
8935
c8b54374
VL
8936@node Installing GuixSD in a VM
8937@subsection Installing GuixSD in a Virtual Machine
8938
8939@cindex virtual machine, GuixSD installation
4b236c88
LF
8940@cindex virtual private server (VPS)
8941@cindex VPS (virtual private server)
8942If you'd like to install GuixSD in a virtual machine (VM) or on a
8943virtual private server (VPS) rather than on your beloved machine, this
8944section is for you.
c8b54374
VL
8945
8946To boot a @uref{http://qemu.org/,QEMU} VM for installing GuixSD in a
8947disk image, follow these steps:
8948
8949@enumerate
8950@item
a0885414 8951First, retrieve and decompress the GuixSD installation image as
2626062b 8952described previously (@pxref{USB Stick and DVD Installation}).
c8b54374
VL
8953
8954@item
8955Create a disk image that will hold the installed system. To make a
8956qcow2-formatted disk image, use the @command{qemu-img} command:
8957
8958@example
01049bb0 8959qemu-img create -f qcow2 guixsd.img 50G
c8b54374
VL
8960@end example
8961
01049bb0
LF
8962The resulting file will be much smaller than 50 GB (typically less than
89631 MB), but it will grow as the virtualized storage device is filled up.
c8b54374
VL
8964
8965@item
8966Boot the USB installation image in an VM:
8967
8968@example
8969qemu-system-x86_64 -m 1024 -smp 1 \
d36b8457 8970 -net user -net nic,model=virtio -boot menu=on \
3b6e7c70 8971 -drive file=guixsd-install-@value{VERSION}.@var{system}.iso \
1c25d6d0 8972 -drive file=guixsd.img
c8b54374
VL
8973@end example
8974
1c25d6d0
DM
8975The ordering of the drives matters.
8976
c8b54374
VL
8977In the VM console, quickly press the @kbd{F12} key to enter the boot
8978menu. Then press the @kbd{2} key and the @kbd{RET} key to validate your
8979selection.
8980
8981@item
8982You're now root in the VM, proceed with the installation process.
8983@xref{Preparing for Installation}, and follow the instructions.
8984@end enumerate
8985
8986Once installation is complete, you can boot the system that's on your
8987@file{guixsd.img} image. @xref{Running GuixSD in a VM}, for how to do
8988that.
8989
dedb8d5e 8990@node Building the Installation Image
5af6de3e
LC
8991@subsection Building the Installation Image
8992
e32171ee 8993@cindex installation image
5af6de3e
LC
8994The installation image described above was built using the @command{guix
8995system} command, specifically:
8996
8997@example
a8ac4f08 8998guix system disk-image gnu/system/install.scm
5af6de3e
LC
8999@end example
9000
6e6a0401
AE
9001Have a look at @file{gnu/system/install.scm} in the source tree,
9002and see also @ref{Invoking guix system} for more information
5af6de3e
LC
9003about the installation image.
9004
4ce4fc50
DM
9005@subsection Building the Installation Image for ARM Boards
9006
9007Many ARM boards require a specific variant of the
9008@uref{http://www.denx.de/wiki/U-Boot/, U-Boot} bootloader.
9009
9010If you build a disk image and the bootloader is not available otherwise
9011(on another boot drive etc), it's advisable to build an image that
9012includes the bootloader, specifically:
9013
9014@example
9015guix system disk-image --system=armhf-linux -e '((@@ (gnu system install) os-with-u-boot) (@@ (gnu system install) installation-os) "A20-OLinuXino-Lime2")'
9016@end example
9017
9018@code{A20-OLinuXino-Lime2} is the name of the board. If you specify an invalid
9019board, a list of possible boards will be printed.
9020
cf4a9129
LC
9021@node System Configuration
9022@section System Configuration
b208a005 9023
cf4a9129 9024@cindex system configuration
3ca2731c 9025The Guix System Distribution supports a consistent whole-system configuration
cf4a9129
LC
9026mechanism. By that we mean that all aspects of the global system
9027configuration---such as the available system services, timezone and
9028locale settings, user accounts---are declared in a single place. Such
9029a @dfn{system configuration} can be @dfn{instantiated}---i.e., effected.
91ef73d4 9030
cf4a9129
LC
9031One of the advantages of putting all the system configuration under the
9032control of Guix is that it supports transactional system upgrades, and
1068f26b 9033makes it possible to roll back to a previous system instantiation,
cf4a9129 9034should something go wrong with the new one (@pxref{Features}). Another
1068f26b 9035advantage is that it makes it easy to replicate the exact same configuration
cf4a9129
LC
9036across different machines, or at different points in time, without
9037having to resort to additional administration tools layered on top of
1068f26b 9038the own tools of the system.
cf4a9129 9039@c Yes, we're talking of Puppet, Chef, & co. here. ↑
91ef73d4 9040
cf4a9129
LC
9041This section describes this mechanism. First we focus on the system
9042administrator's viewpoint---explaining how the system is configured and
9043instantiated. Then we show how this mechanism can be extended, for
9044instance to support new system services.
91ef73d4 9045
cf4a9129
LC
9046@menu
9047* Using the Configuration System:: Customizing your GNU system.
7313a52e 9048* operating-system Reference:: Detail of operating-system declarations.
cf4a9129 9049* File Systems:: Configuring file system mounts.
510f9d86 9050* Mapped Devices:: Block device extra processing.
cf4a9129 9051* User Accounts:: Specifying user accounts.
598e19dc 9052* Locales:: Language and cultural convention settings.
cf4a9129 9053* Services:: Specifying system services.
0ae8c15a 9054* Setuid Programs:: Programs running with root privileges.
efb5e833 9055* X.509 Certificates:: Authenticating HTTPS servers.
996ed739 9056* Name Service Switch:: Configuring libc's name service switch.
fd1b1fa2 9057* Initial RAM Disk:: Linux-Libre bootstrapping.
74e64724 9058* Bootloader Configuration:: Configuring the boot loader.
cf4a9129 9059* Invoking guix system:: Instantiating a system configuration.
97d76250 9060* Running GuixSD in a VM:: How to run GuixSD in a virtual machine.
cf4a9129
LC
9061* Defining Services:: Adding new service definitions.
9062@end menu
91ef73d4 9063
cf4a9129
LC
9064@node Using the Configuration System
9065@subsection Using the Configuration System
64d76fa6 9066
cf4a9129
LC
9067The operating system is configured by providing an
9068@code{operating-system} declaration in a file that can then be passed to
9069the @command{guix system} command (@pxref{Invoking guix system}). A
9070simple setup, with the default system services, the default Linux-Libre
9071kernel, initial RAM disk, and boot loader looks like this:
91ef73d4 9072
cf4a9129
LC
9073@findex operating-system
9074@lisp
dd51caac 9075@include os-config-bare-bones.texi
cf4a9129 9076@end lisp
401c53c4 9077
cf4a9129
LC
9078This example should be self-describing. Some of the fields defined
9079above, such as @code{host-name} and @code{bootloader}, are mandatory.
9080Others, such as @code{packages} and @code{services}, can be omitted, in
9081which case they get a default value.
e7f34eb0 9082
5d94ac51
LC
9083Below we discuss the effect of some of the most important fields
9084(@pxref{operating-system Reference}, for details about all the available
9085fields), and how to @dfn{instantiate} the operating system using
9086@command{guix system}.
9087
fc0e663f
LC
9088@unnumberedsubsubsec Bootloader
9089
9090@cindex legacy boot, on Intel machines
9091@cindex BIOS boot, on Intel machines
9092@cindex UEFI boot
9093@cindex EFI boot
9094The @code{bootloader} field describes the method that will be used to boot
9095your system. Machines based on Intel processors can boot in ``legacy'' BIOS
9096mode, as in the example above. However, more recent machines rely instead on
9097the @dfn{Unified Extensible Firmware Interface} (UEFI) to boot. In that case,
9098the @code{bootloader} field should contain something along these lines:
9099
9100@example
9101(bootloader-configuration
9102 (bootloader grub-efi-bootloader)
9103 (target "/boot/efi"))
9104@end example
9105
9106@xref{Bootloader Configuration}, for more information on the available
9107configuration options.
9108
5d94ac51
LC
9109@unnumberedsubsubsec Globally-Visible Packages
9110
cf4a9129 9111@vindex %base-packages
5d94ac51
LC
9112The @code{packages} field lists packages that will be globally visible
9113on the system, for all user accounts---i.e., in every user's @code{PATH}
9114environment variable---in addition to the per-user profiles
9115(@pxref{Invoking guix package}). The @var{%base-packages} variable
9116provides all the tools one would expect for basic user and administrator
9117tasks---including the GNU Core Utilities, the GNU Networking Utilities,
9118the GNU Zile lightweight text editor, @command{find}, @command{grep},
960c40de
LC
9119etc. The example above adds GNU@tie{}Screen and OpenSSH to those,
9120taken from the @code{(gnu packages screen)} and @code{(gnu packages ssh)}
9121modules (@pxref{Package Modules}). The
fe0915cf
JL
9122@code{(list package output)} syntax can be used to add a specific output
9123of a package:
9124
9125@lisp
9126(use-modules (gnu packages))
9127(use-modules (gnu packages dns))
9128
9129(operating-system
9130 ;; ...
9131 (packages (cons (list bind "utils")
9132 %base-packages)))
9133@end lisp
e7f34eb0 9134
f6c9fb1b 9135@findex specification->package
0c3deacc 9136Referring to packages by variable name, like @code{bind} above, has
f6c9fb1b
LC
9137the advantage of being unambiguous; it also allows typos and such to be
9138diagnosed right away as ``unbound variables''. The downside is that one
9139needs to know which module defines which package, and to augment the
9140@code{use-package-modules} line accordingly. To avoid that, one can use
9141the @code{specification->package} procedure of the @code{(gnu packages)}
9142module, which returns the best package for a given name or name and
9143version:
9144
9145@lisp
9146(use-modules (gnu packages))
9147
9148(operating-system
9149 ;; ...
9150 (packages (append (map specification->package
d5e59248 9151 '("tcpdump" "htop" "gnupg@@2.0"))
f6c9fb1b
LC
9152 %base-packages)))
9153@end lisp
9154
5d94ac51
LC
9155@unnumberedsubsubsec System Services
9156
e32171ee 9157@cindex services
cf4a9129
LC
9158@vindex %base-services
9159The @code{services} field lists @dfn{system services} to be made
9160available when the system starts (@pxref{Services}).
9161The @code{operating-system} declaration above specifies that, in
9162addition to the basic services, we want the @command{lshd} secure shell
cd6f6c22
LC
9163daemon listening on port 2222 (@pxref{Networking Services,
9164@code{lsh-service}}). Under the hood,
cf4a9129
LC
9165@code{lsh-service} arranges so that @code{lshd} is started with the
9166right command-line options, possibly with supporting configuration files
cd6f6c22
LC
9167generated as needed (@pxref{Defining Services}).
9168
9169@cindex customization, of services
9170@findex modify-services
9171Occasionally, instead of using the base services as is, you will want to
4d343a14
CM
9172customize them. To do this, use @code{modify-services} (@pxref{Service
9173Reference, @code{modify-services}}) to modify the list.
9174
9175For example, suppose you want to modify @code{guix-daemon} and Mingetty
9176(the console log-in) in the @var{%base-services} list (@pxref{Base
9177Services, @code{%base-services}}). To do that, you can write the
9178following in your operating system declaration:
cd6f6c22
LC
9179
9180@lisp
4d343a14
CM
9181(define %my-services
9182 ;; My very own list of services.
9183 (modify-services %base-services
9184 (guix-service-type config =>
9185 (guix-configuration
9186 (inherit config)
9187 (use-substitutes? #f)
9188 (extra-options '("--gc-keep-derivations"))))
9189 (mingetty-service-type config =>
9190 (mingetty-configuration
317d3b47 9191 (inherit config)))))
4d343a14
CM
9192
9193(operating-system
9194 ;; @dots{}
9195 (services %my-services))
cd6f6c22
LC
9196@end lisp
9197
4d343a14
CM
9198This changes the configuration---i.e., the service parameters---of the
9199@code{guix-service-type} instance, and that of all the
9200@code{mingetty-service-type} instances in the @var{%base-services} list.
9201Observe how this is accomplished: first, we arrange for the original
9202configuration to be bound to the identifier @code{config} in the
9203@var{body}, and then we write the @var{body} so that it evaluates to the
9204desired configuration. In particular, notice how we use @code{inherit}
9205to create a new configuration which has the same values as the old
9206configuration, but with a few modifications.
a1ba8475 9207
13fb1bd9
LC
9208@cindex encrypted disk
9209The configuration for a typical ``desktop'' usage, with an encrypted
9210root partition, the X11 display
d038b674
LC
9211server, GNOME and Xfce (users can choose which of these desktop
9212environments to use at the log-in screen by pressing @kbd{F1}), network
9213management, power management, and more, would look like this:
dd51caac
LC
9214
9215@lisp
9216@include os-config-desktop.texi
9217@end lisp
9218
fc0e663f 9219A graphical system with a choice of lightweight window managers
d038b674
LC
9220instead of full-blown desktop environments would look like this:
9221
9222@lisp
9223@include os-config-lightweight-desktop.texi
9224@end lisp
9225
01bd3b5e 9226This example refers to the @file{/boot/efi} file system by its UUID,
50fcf37c
LC
9227@code{1234-ABCD}. Replace this UUID with the right UUID on your system,
9228as returned by the @command{blkid} command.
9229
dd51caac 9230@xref{Desktop Services}, for the exact list of services provided by
efb5e833
LC
9231@var{%desktop-services}. @xref{X.509 Certificates}, for background
9232information about the @code{nss-certs} package that is used here.
dd51caac 9233
5d94ac51
LC
9234Again, @var{%desktop-services} is just a list of service objects. If
9235you want to remove services from there, you can do so using the
9236procedures for list filtering (@pxref{SRFI-1 Filtering and
9237Partitioning,,, guile, GNU Guile Reference Manual}). For instance, the
9238following expression returns a list that contains all the services in
9239@var{%desktop-services} minus the Avahi service:
9240
9241@example
9242(remove (lambda (service)
9243 (eq? (service-kind service) avahi-service-type))
9244 %desktop-services)
9245@end example
9246
9247@unnumberedsubsubsec Instantiating the System
9248
9249Assuming the @code{operating-system} declaration
9250is stored in the @file{my-system-config.scm}
cf4a9129
LC
9251file, the @command{guix system reconfigure my-system-config.scm} command
9252instantiates that configuration, and makes it the default GRUB boot
65797bff
LC
9253entry (@pxref{Invoking guix system}).
9254
1068f26b 9255The normal way to change the system configuration is by updating this
65797bff 9256file and re-running @command{guix system reconfigure}. One should never
8b499030 9257have to touch files in @file{/etc} or to run commands that modify the
65797bff
LC
9258system state such as @command{useradd} or @command{grub-install}. In
9259fact, you must avoid that since that would not only void your warranty
9260but also prevent you from rolling back to previous versions of your
9261system, should you ever need to.
9262
9263@cindex roll-back, of the operating system
9264Speaking of roll-back, each time you run @command{guix system
9265reconfigure}, a new @dfn{generation} of the system is created---without
9266modifying or deleting previous generations. Old system generations get
74e64724 9267an entry in the bootloader boot menu, allowing you to boot them in case
65797bff
LC
9268something went wrong with the latest generation. Reassuring, no? The
9269@command{guix system list-generations} command lists the system
067a2e2d
CM
9270generations available on disk. It is also possible to roll back the
9271system via the commands @command{guix system roll-back} and
9272@command{guix system switch-generation}.
9273
9c332294
JL
9274Although the @command{guix system reconfigure} command will not modify
9275previous generations, you must take care when the current generation is not
067a2e2d
CM
9276the latest (e.g., after invoking @command{guix system roll-back}), since
9277the operation might overwrite a later generation (@pxref{Invoking guix
9278system}).
b81e1947 9279
5d94ac51
LC
9280@unnumberedsubsubsec The Programming Interface
9281
cf4a9129
LC
9282At the Scheme level, the bulk of an @code{operating-system} declaration
9283is instantiated with the following monadic procedure (@pxref{The Store
9284Monad}):
b81e1947 9285
cf4a9129
LC
9286@deffn {Monadic Procedure} operating-system-derivation os
9287Return a derivation that builds @var{os}, an @code{operating-system}
9288object (@pxref{Derivations}).
b81e1947 9289
cf4a9129
LC
9290The output of the derivation is a single directory that refers to all
9291the packages, configuration files, and other supporting files needed to
9292instantiate @var{os}.
9293@end deffn
b81e1947 9294
5d94ac51
LC
9295This procedure is provided by the @code{(gnu system)} module. Along
9296with @code{(gnu services)} (@pxref{Services}), this module contains the
9297guts of GuixSD. Make sure to visit it!
9298
9299
7313a52e
LC
9300@node operating-system Reference
9301@subsection @code{operating-system} Reference
9302
9303This section summarizes all the options available in
9304@code{operating-system} declarations (@pxref{Using the Configuration
9305System}).
9306
9307@deftp {Data Type} operating-system
9308This is the data type representing an operating system configuration.
9309By that, we mean all the global system configuration, not per-user
9310configuration (@pxref{Using the Configuration System}).
9311
9312@table @asis
9313@item @code{kernel} (default: @var{linux-libre})
fbb25e56 9314The package object of the operating system kernel to use@footnote{Currently
7313a52e
LC
9315only the Linux-libre kernel is supported. In the future, it will be
9316possible to use the GNU@tie{}Hurd.}.
9317
ee2a6304
LC
9318@item @code{kernel-arguments} (default: @code{'()})
9319List of strings or gexps representing additional arguments to pass on
1068f26b 9320the command-line of the kernel---e.g., @code{("console=ttyS0")}.
ee2a6304 9321
7313a52e 9322@item @code{bootloader}
74e64724 9323The system bootloader configuration object. @xref{Bootloader Configuration}.
7313a52e 9324
bc499b11 9325@item @code{initrd-modules} (default: @code{%base-initrd-modules})
e32171ee
JD
9326@cindex initrd
9327@cindex initial RAM disk
bc499b11
LC
9328The list of Linux kernel modules that need to be available in the
9329initial RAM disk. @xref{Initial RAM Disk}.
9330
9331@item @code{initrd} (default: @code{base-initrd})
9332A monadic procedure that returns an initial RAM disk for the Linux
9333kernel. This field is provided to support low-level customization and
9334should rarely be needed for casual use. @xref{Initial RAM Disk}.
7313a52e 9335
f34c56be
LC
9336@item @code{firmware} (default: @var{%base-firmware})
9337@cindex firmware
9338List of firmware packages loadable by the operating system kernel.
9339
52db41af
EB
9340The default includes firmware needed for Atheros- and Broadcom-based
9341WiFi devices (Linux-libre modules @code{ath9k} and @code{b43-open},
9342respectively). @xref{Hardware Considerations}, for more info on
9343supported hardware.
f34c56be 9344
7313a52e
LC
9345@item @code{host-name}
9346The host name.
9347
9348@item @code{hosts-file}
9349@cindex hosts file
24e02c28 9350A file-like object (@pxref{G-Expressions, file-like objects}) for use as
7313a52e 9351@file{/etc/hosts} (@pxref{Host Names,,, libc, The GNU C Library
24e02c28 9352Reference Manual}). The default is a file with entries for
7313a52e
LC
9353@code{localhost} and @var{host-name}.
9354
9355@item @code{mapped-devices} (default: @code{'()})
9356A list of mapped devices. @xref{Mapped Devices}.
9357
9358@item @code{file-systems}
9359A list of file systems. @xref{File Systems}.
9360
9361@item @code{swap-devices} (default: @code{'()})
9362@cindex swap devices
a4ca4362
CM
9363A list of strings identifying devices or files to be used for ``swap
9364space'' (@pxref{Memory Concepts,,, libc, The GNU C Library Reference
9365Manual}). For example, @code{'("/dev/sda3")} or @code{'("/swapfile")}.
9366It is possible to specify a swap file in a file system on a mapped
9367device, provided that the necessary device mapping and file system are
9368also specified. @xref{Mapped Devices} and @ref{File Systems}.
7313a52e 9369
bf87f38a 9370@item @code{users} (default: @code{%base-user-accounts})
7313a52e
LC
9371@itemx @code{groups} (default: @var{%base-groups})
9372List of user accounts and groups. @xref{User Accounts}.
9373
45f62117
LC
9374If the @code{users} list lacks a user account with UID@tie{}0, a
9375``root'' account with UID@tie{}0 is automatically added.
9376
7313a52e 9377@item @code{skeletons} (default: @code{(default-skeletons)})
e9dffec1
LC
9378A list target file name/file-like object tuples (@pxref{G-Expressions,
9379file-like objects}). These are the skeleton files that will be added to
9380the home directory of newly-created user accounts.
7313a52e
LC
9381
9382For instance, a valid value may look like this:
9383
9384@example
e9dffec1
LC
9385`((".bashrc" ,(plain-file "bashrc" "echo Hello\n"))
9386 (".guile" ,(plain-file "guile"
9387 "(use-modules (ice-9 readline))
9388 (activate-readline)")))
7313a52e
LC
9389@end example
9390
9391@item @code{issue} (default: @var{%default-issue})
9392A string denoting the contents of the @file{/etc/issue} file, which is
1068f26b 9393displayed when users log in on a text console.
7313a52e
LC
9394
9395@item @code{packages} (default: @var{%base-packages})
9396The set of packages installed in the global profile, which is accessible
9397at @file{/run/current-system/profile}.
9398
1068f26b 9399The default set includes core utilities and it is good practice to
7313a52e
LC
9400install non-core utilities in user profiles (@pxref{Invoking guix
9401package}).
9402
9403@item @code{timezone}
9404A timezone identifying string---e.g., @code{"Europe/Paris"}.
9405
17c20385
LC
9406You can run the @command{tzselect} command to find out which timezone
9407string corresponds to your region. Choosing an invalid timezone name
9408causes @command{guix system} to fail.
9409
598e19dc
LC
9410@item @code{locale} (default: @code{"en_US.utf8"})
9411The name of the default locale (@pxref{Locale Names,,, libc, The GNU C
9412Library Reference Manual}). @xref{Locales}, for more information.
9413
9414@item @code{locale-definitions} (default: @var{%default-locale-definitions})
9415The list of locale definitions to be compiled and that may be used at
9416run time. @xref{Locales}.
7313a52e 9417
34760ae7
LC
9418@item @code{locale-libcs} (default: @code{(list @var{glibc})})
9419The list of GNU@tie{}libc packages whose locale data and tools are used
9420to build the locale definitions. @xref{Locales}, for compatibility
9421considerations that justify this option.
9422
996ed739 9423@item @code{name-service-switch} (default: @var{%default-nss})
1068f26b 9424Configuration of the libc name service switch (NSS)---a
996ed739
LC
9425@code{<name-service-switch>} object. @xref{Name Service Switch}, for
9426details.
9427
7313a52e 9428@item @code{services} (default: @var{%base-services})
28d939af 9429A list of service objects denoting system services. @xref{Services}.
7313a52e
LC
9430
9431@item @code{pam-services} (default: @code{(base-pam-services)})
9432@cindex PAM
9433@cindex pluggable authentication modules
9434Linux @dfn{pluggable authentication module} (PAM) services.
9435@c FIXME: Add xref to PAM services section.
9436
9437@item @code{setuid-programs} (default: @var{%setuid-programs})
9438List of string-valued G-expressions denoting setuid programs.
9439@xref{Setuid Programs}.
9440
f5a9ffa0
AK
9441@item @code{sudoers-file} (default: @var{%sudoers-specification})
9442@cindex sudoers file
84765839
LC
9443The contents of the @file{/etc/sudoers} file as a file-like object
9444(@pxref{G-Expressions, @code{local-file} and @code{plain-file}}).
7313a52e
LC
9445
9446This file specifies which users can use the @command{sudo} command, what
9447they are allowed to do, and what privileges they may gain. The default
9448is that only @code{root} and members of the @code{wheel} group may use
9449@code{sudo}.
9450
9451@end table
9452@end deftp
9453
cf4a9129
LC
9454@node File Systems
9455@subsection File Systems
b81e1947 9456
cf4a9129 9457The list of file systems to be mounted is specified in the
1068f26b 9458@code{file-systems} field of the operating system declaration
cf4a9129
LC
9459(@pxref{Using the Configuration System}). Each file system is declared
9460using the @code{file-system} form, like this:
b81e1947
LC
9461
9462@example
cf4a9129
LC
9463(file-system
9464 (mount-point "/home")
9465 (device "/dev/sda3")
9466 (type "ext4"))
b81e1947
LC
9467@end example
9468
cf4a9129
LC
9469As usual, some of the fields are mandatory---those shown in the example
9470above---while others can be omitted. These are described below.
b81e1947 9471
cf4a9129
LC
9472@deftp {Data Type} file-system
9473Objects of this type represent file systems to be mounted. They
9474contain the following members:
5ff3c4b8 9475
cf4a9129
LC
9476@table @asis
9477@item @code{type}
9478This is a string specifying the type of the file system---e.g.,
9479@code{"ext4"}.
5ff3c4b8 9480
cf4a9129
LC
9481@item @code{mount-point}
9482This designates the place where the file system is to be mounted.
b81e1947 9483
cf4a9129 9484@item @code{device}
a5acc17a
LC
9485This names the ``source'' of the file system. It can be one of three
9486things: a file system label, a file system UUID, or the name of a
9487@file{/dev} node. Labels and UUIDs offer a way to refer to file
9488systems without having to hard-code their actual device
9489name@footnote{Note that, while it is tempting to use
9490@file{/dev/disk/by-uuid} and similar device names to achieve the same
9491result, this is not recommended: These special device nodes are created
9492by the udev daemon and may be unavailable at the time the device is
9493mounted.}.
401c53c4 9494
a5acc17a
LC
9495@findex file-system-label
9496File system labels are created using the @code{file-system-label}
9497procedure, UUIDs are created using @code{uuid}, and @file{/dev} node are
9498plain strings. Here's an example of a file system referred to by its
9499label, as shown by the @command{e2label} command:
401c53c4 9500
a5acc17a
LC
9501@example
9502(file-system
9503 (mount-point "/home")
9504 (type "ext4")
9505 (device (file-system-label "my-home")))
9506@end example
da7cabd4 9507
a5acc17a
LC
9508@findex uuid
9509UUIDs are converted from their string representation (as shown by the
0767f6a6
LC
9510@command{tune2fs -l} command) using the @code{uuid} form@footnote{The
9511@code{uuid} form expects 16-byte UUIDs as defined in
9512@uref{https://tools.ietf.org/html/rfc4122, RFC@tie{}4122}. This is the
9513form of UUID used by the ext2 family of file systems and others, but it
9514is different from ``UUIDs'' found in FAT file systems, for instance.},
9515like this:
661a1d79
LC
9516
9517@example
9518(file-system
9519 (mount-point "/home")
9520 (type "ext4")
661a1d79
LC
9521 (device (uuid "4dab5feb-d176-45de-b287-9b0a6e4c01cb")))
9522@end example
9523
a5acc17a 9524When the source of a file system is a mapped device (@pxref{Mapped
5f86a66e 9525Devices}), its @code{device} field @emph{must} refer to the mapped
a5acc17a
LC
9526device name---e.g., @file{"/dev/mapper/root-partition"}.
9527This is required so that
5f86a66e
LC
9528the system knows that mounting the file system depends on having the
9529corresponding device mapping established.
9530
cf4a9129
LC
9531@item @code{flags} (default: @code{'()})
9532This is a list of symbols denoting mount flags. Recognized flags
2c071ce9
LC
9533include @code{read-only}, @code{bind-mount}, @code{no-dev} (disallow
9534access to special files), @code{no-suid} (ignore setuid and setgid
9535bits), and @code{no-exec} (disallow program execution.)
da7cabd4 9536
cf4a9129
LC
9537@item @code{options} (default: @code{#f})
9538This is either @code{#f}, or a string denoting mount options.
da7cabd4 9539
be21979d
LC
9540@item @code{mount?} (default: @code{#t})
9541This value indicates whether to automatically mount the file system when
9542the system is brought up. When set to @code{#f}, the file system gets
9543an entry in @file{/etc/fstab} (read by the @command{mount} command) but
9544is not automatically mounted.
9545
cf4a9129
LC
9546@item @code{needed-for-boot?} (default: @code{#f})
9547This Boolean value indicates whether the file system is needed when
9548booting. If that is true, then the file system is mounted when the
9549initial RAM disk (initrd) is loaded. This is always the case, for
9550instance, for the root file system.
da7cabd4 9551
cf4a9129
LC
9552@item @code{check?} (default: @code{#t})
9553This Boolean indicates whether the file system needs to be checked for
9554errors before being mounted.
f9cc8971 9555
4e469051
LC
9556@item @code{create-mount-point?} (default: @code{#f})
9557When true, the mount point is created if it does not exist yet.
9558
e51710d1 9559@item @code{dependencies} (default: @code{'()})
13fb1bd9
LC
9560This is a list of @code{<file-system>} or @code{<mapped-device>} objects
9561representing file systems that must be mounted or mapped devices that
9562must be opened before (and unmounted or closed after) this one.
e51710d1
LC
9563
9564As an example, consider a hierarchy of mounts: @file{/sys/fs/cgroup} is
9565a dependency of @file{/sys/fs/cgroup/cpu} and
9566@file{/sys/fs/cgroup/memory}.
9567
13fb1bd9
LC
9568Another example is a file system that depends on a mapped device, for
9569example for an encrypted partition (@pxref{Mapped Devices}).
cf4a9129
LC
9570@end table
9571@end deftp
da7cabd4 9572
a69576ea
LC
9573The @code{(gnu system file-systems)} exports the following useful
9574variables.
9575
9576@defvr {Scheme Variable} %base-file-systems
9577These are essential file systems that are required on normal systems,
cc0e575a 9578such as @var{%pseudo-terminal-file-system} and @var{%immutable-store} (see
3392ce5d
LC
9579below.) Operating system declarations should always contain at least
9580these.
a69576ea
LC
9581@end defvr
9582
7f239fd3
LC
9583@defvr {Scheme Variable} %pseudo-terminal-file-system
9584This is the file system to be mounted as @file{/dev/pts}. It supports
9585@dfn{pseudo-terminals} created @i{via} @code{openpty} and similar
9586functions (@pxref{Pseudo-Terminals,,, libc, The GNU C Library Reference
9587Manual}). Pseudo-terminals are used by terminal emulators such as
9588@command{xterm}.
9589@end defvr
9590
db17ae5c
LC
9591@defvr {Scheme Variable} %shared-memory-file-system
9592This file system is mounted as @file{/dev/shm} and is used to support
9593memory sharing across processes (@pxref{Memory-mapped I/O,
9594@code{shm_open},, libc, The GNU C Library Reference Manual}).
9595@end defvr
9596
3392ce5d
LC
9597@defvr {Scheme Variable} %immutable-store
9598This file system performs a read-only ``bind mount'' of
9599@file{/gnu/store}, making it read-only for all the users including
9600@code{root}. This prevents against accidental modification by software
9601running as @code{root} or by system administrators.
9602
9603The daemon itself is still able to write to the store: it remounts it
9604read-write in its own ``name space.''
9605@end defvr
9606
a69576ea
LC
9607@defvr {Scheme Variable} %binary-format-file-system
9608The @code{binfmt_misc} file system, which allows handling of arbitrary
9609executable file types to be delegated to user space. This requires the
9610@code{binfmt.ko} kernel module to be loaded.
9611@end defvr
9612
9613@defvr {Scheme Variable} %fuse-control-file-system
9614The @code{fusectl} file system, which allows unprivileged users to mount
9615and unmount user-space FUSE file systems. This requires the
9616@code{fuse.ko} kernel module to be loaded.
9617@end defvr
9618
510f9d86
LC
9619@node Mapped Devices
9620@subsection Mapped Devices
9621
9622@cindex device mapping
9623@cindex mapped devices
9624The Linux kernel has a notion of @dfn{device mapping}: a block device,
9625such as a hard disk partition, can be @dfn{mapped} into another device,
97c8aef1 9626usually in @code{/dev/mapper/},
510f9d86
LC
9627with additional processing over the data that flows through
9628it@footnote{Note that the GNU@tie{}Hurd makes no difference between the
9629concept of a ``mapped device'' and that of a file system: both boil down
9630to @emph{translating} input/output operations made on a file to
9631operations on its backing store. Thus, the Hurd implements mapped
9632devices, like file systems, using the generic @dfn{translator} mechanism
9633(@pxref{Translators,,, hurd, The GNU Hurd Reference Manual}).}. A
9634typical example is encryption device mapping: all writes to the mapped
9635device are encrypted, and all reads are deciphered, transparently.
97c8aef1
AE
9636Guix extends this notion by considering any device or set of devices that
9637are @dfn{transformed} in some way to create a new device; for instance,
9638RAID devices are obtained by @dfn{assembling} several other devices, such
9639as hard disks or partitions, into a new one that behaves as one partition.
9640Other examples, not yet implemented, are LVM logical volumes.
510f9d86 9641
97c8aef1
AE
9642Mapped devices are declared using the @code{mapped-device} form,
9643defined as follows; for examples, see below.
510f9d86
LC
9644
9645@deftp {Data Type} mapped-device
9646Objects of this type represent device mappings that will be made when
9647the system boots up.
9648
9cb426b8
LC
9649@table @code
9650@item source
97c8aef1
AE
9651This is either a string specifying the name of the block device to be mapped,
9652such as @code{"/dev/sda3"}, or a list of such strings when several devices
9653need to be assembled for creating a new one.
510f9d86 9654
9cb426b8 9655@item target
97c8aef1
AE
9656This string specifies the name of the resulting mapped device. For
9657kernel mappers such as encrypted devices of type @code{luks-device-mapping},
9658specifying @code{"my-partition"} leads to the creation of
510f9d86 9659the @code{"/dev/mapper/my-partition"} device.
97c8aef1
AE
9660For RAID devices of type @code{raid-device-mapping}, the full device name
9661such as @code{"/dev/md0"} needs to be given.
510f9d86 9662
9cb426b8 9663@item type
510f9d86
LC
9664This must be a @code{mapped-device-kind} object, which specifies how
9665@var{source} is mapped to @var{target}.
9666@end table
9667@end deftp
9668
9669@defvr {Scheme Variable} luks-device-mapping
9670This defines LUKS block device encryption using the @command{cryptsetup}
1068f26b 9671command from the package with the same name. It relies on the
510f9d86
LC
9672@code{dm-crypt} Linux kernel module.
9673@end defvr
9674
97c8aef1
AE
9675@defvr {Scheme Variable} raid-device-mapping
9676This defines a RAID device, which is assembled using the @code{mdadm}
9677command from the package with the same name. It requires a Linux kernel
9678module for the appropriate RAID level to be loaded, such as @code{raid456}
9679for RAID-4, RAID-5 or RAID-6, or @code{raid10} for RAID-10.
9680@end defvr
9681
9682@cindex disk encryption
9683@cindex LUKS
9684The following example specifies a mapping from @file{/dev/sda3} to
9685@file{/dev/mapper/home} using LUKS---the
ddf1cd51 9686@url{https://gitlab.com/cryptsetup/cryptsetup,Linux Unified Key Setup}, a
97c8aef1
AE
9687standard mechanism for disk encryption.
9688The @file{/dev/mapper/home}
9689device can then be used as the @code{device} of a @code{file-system}
9690declaration (@pxref{File Systems}).
9691
9692@example
9693(mapped-device
9694 (source "/dev/sda3")
9695 (target "home")
9696 (type luks-device-mapping))
9697@end example
9698
9699Alternatively, to become independent of device numbering, one may obtain
9700the LUKS UUID (@dfn{unique identifier}) of the source device by a
9701command like:
9702
9703@example
9704cryptsetup luksUUID /dev/sda3
9705@end example
9706
9707and use it as follows:
9708
9709@example
9710(mapped-device
9711 (source (uuid "cb67fc72-0d54-4c88-9d4b-b225f30b0f44"))
9712 (target "home")
9713 (type luks-device-mapping))
9714@end example
9715
a4ca4362
CM
9716@cindex swap encryption
9717It is also desirable to encrypt swap space, since swap space may contain
9718sensitive data. One way to accomplish that is to use a swap file in a
9719file system on a device mapped via LUKS encryption. In this way, the
9720swap file is encrypted because the entire device is encrypted.
9721@xref{Preparing for Installation,,Disk Partitioning}, for an example.
9722
97c8aef1
AE
9723A RAID device formed of the partitions @file{/dev/sda1} and @file{/dev/sdb1}
9724may be declared as follows:
9725
9726@example
9727(mapped-device
9728 (source (list "/dev/sda1" "/dev/sdb1"))
9729 (target "/dev/md0")
9730 (type raid-device-mapping))
9731@end example
9732
9733The @file{/dev/md0} device can then be used as the @code{device} of a
9734@code{file-system} declaration (@pxref{File Systems}).
9735Note that the RAID level need not be given; it is chosen during the
9736initial creation and formatting of the RAID device and is determined
9737automatically later.
9738
9739
cf4a9129
LC
9740@node User Accounts
9741@subsection User Accounts
ee85f3db 9742
e32171ee
JD
9743@cindex users
9744@cindex accounts
9745@cindex user accounts
9bea87a5
LC
9746User accounts and groups are entirely managed through the
9747@code{operating-system} declaration. They are specified with the
9748@code{user-account} and @code{user-group} forms:
ee85f3db 9749
cf4a9129
LC
9750@example
9751(user-account
9752 (name "alice")
9753 (group "users")
24e752c0
LC
9754 (supplementary-groups '("wheel" ;allow use of sudo, etc.
9755 "audio" ;sound card
9756 "video" ;video devices such as webcams
9757 "cdrom")) ;the good ol' CD-ROM
cf4a9129
LC
9758 (comment "Bob's sister")
9759 (home-directory "/home/alice"))
9760@end example
25083588 9761
9bea87a5
LC
9762When booting or upon completion of @command{guix system reconfigure},
9763the system ensures that only the user accounts and groups specified in
9764the @code{operating-system} declaration exist, and with the specified
9765properties. Thus, account or group creations or modifications made by
9766directly invoking commands such as @command{useradd} are lost upon
9767reconfiguration or reboot. This ensures that the system remains exactly
9768as declared.
9769
cf4a9129
LC
9770@deftp {Data Type} user-account
9771Objects of this type represent user accounts. The following members may
9772be specified:
ee85f3db 9773
cf4a9129
LC
9774@table @asis
9775@item @code{name}
9776The name of the user account.
ee85f3db 9777
cf4a9129 9778@item @code{group}
e32171ee 9779@cindex groups
cf4a9129
LC
9780This is the name (a string) or identifier (a number) of the user group
9781this account belongs to.
ee85f3db 9782
cf4a9129
LC
9783@item @code{supplementary-groups} (default: @code{'()})
9784Optionally, this can be defined as a list of group names that this
9785account belongs to.
ee85f3db 9786
cf4a9129
LC
9787@item @code{uid} (default: @code{#f})
9788This is the user ID for this account (a number), or @code{#f}. In the
9789latter case, a number is automatically chosen by the system when the
9790account is created.
ee85f3db 9791
cf4a9129 9792@item @code{comment} (default: @code{""})
1068f26b 9793A comment about the account, such as the account owner's full name.
c8c871d1 9794
cf4a9129
LC
9795@item @code{home-directory}
9796This is the name of the home directory for the account.
ee85f3db 9797
eb56ee02
LC
9798@item @code{create-home-directory?} (default: @code{#t})
9799Indicates whether the home directory of this account should be created
9800if it does not exist yet.
9801
cf4a9129
LC
9802@item @code{shell} (default: Bash)
9803This is a G-expression denoting the file name of a program to be used as
9804the shell (@pxref{G-Expressions}).
ee85f3db 9805
cf4a9129
LC
9806@item @code{system?} (default: @code{#f})
9807This Boolean value indicates whether the account is a ``system''
9808account. System accounts are sometimes treated specially; for instance,
9809graphical login managers do not list them.
ee85f3db 9810
1bd4e6db 9811@anchor{user-account-password}
cf4a9129 9812@item @code{password} (default: @code{#f})
eb59595c
LC
9813You would normally leave this field to @code{#f}, initialize user
9814passwords as @code{root} with the @command{passwd} command, and then let
9bea87a5
LC
9815users change it with @command{passwd}. Passwords set with
9816@command{passwd} are of course preserved across reboot and
9817reconfiguration.
eb59595c
LC
9818
9819If you @emph{do} want to have a preset password for an account, then
9820this field must contain the encrypted password, as a string.
5d1f1177
LC
9821@xref{crypt,,, libc, The GNU C Library Reference Manual}, for more information
9822on password encryption, and @ref{Encryption,,, guile, GNU Guile Reference
eb59595c 9823Manual}, for information on Guile's @code{crypt} procedure.
c8c871d1 9824
cf4a9129
LC
9825@end table
9826@end deftp
ee85f3db 9827
e32171ee 9828@cindex groups
cf4a9129 9829User group declarations are even simpler:
ee85f3db 9830
cf4a9129
LC
9831@example
9832(user-group (name "students"))
9833@end example
ee85f3db 9834
cf4a9129
LC
9835@deftp {Data Type} user-group
9836This type is for, well, user groups. There are just a few fields:
af8a56b8 9837
cf4a9129
LC
9838@table @asis
9839@item @code{name}
1068f26b 9840The name of the group.
ee85f3db 9841
cf4a9129
LC
9842@item @code{id} (default: @code{#f})
9843The group identifier (a number). If @code{#f}, a new number is
9844automatically allocated when the group is created.
ee85f3db 9845
c8fa3426
LC
9846@item @code{system?} (default: @code{#f})
9847This Boolean value indicates whether the group is a ``system'' group.
9848System groups have low numerical IDs.
9849
cf4a9129
LC
9850@item @code{password} (default: @code{#f})
9851What, user groups can have a password? Well, apparently yes. Unless
1068f26b 9852@code{#f}, this field specifies the password of the group.
ee85f3db 9853
cf4a9129
LC
9854@end table
9855@end deftp
401c53c4 9856
cf4a9129
LC
9857For convenience, a variable lists all the basic user groups one may
9858expect:
401c53c4 9859
cf4a9129
LC
9860@defvr {Scheme Variable} %base-groups
9861This is the list of basic user groups that users and/or packages expect
9862to be present on the system. This includes groups such as ``root'',
9863``wheel'', and ``users'', as well as groups used to control access to
9864specific devices such as ``audio'', ``disk'', and ``cdrom''.
9865@end defvr
401c53c4 9866
bf87f38a
LC
9867@defvr {Scheme Variable} %base-user-accounts
9868This is the list of basic system accounts that programs may expect to
9869find on a GNU/Linux system, such as the ``nobody'' account.
9870
9871Note that the ``root'' account is not included here. It is a
9872special-case and is automatically added whether or not it is specified.
9873@end defvr
9874
598e19dc
LC
9875@node Locales
9876@subsection Locales
9877
9878@cindex locale
9879A @dfn{locale} defines cultural conventions for a particular language
9880and region of the world (@pxref{Locales,,, libc, The GNU C Library
9881Reference Manual}). Each locale has a name that typically has the form
b2636518 9882@code{@var{language}_@var{territory}.@var{codeset}}---e.g.,
598e19dc
LC
9883@code{fr_LU.utf8} designates the locale for the French language, with
9884cultural conventions from Luxembourg, and using the UTF-8 encoding.
9885
9886@cindex locale definition
9887Usually, you will want to specify the default locale for the machine
9888using the @code{locale} field of the @code{operating-system} declaration
9889(@pxref{operating-system Reference, @code{locale}}).
9890
f5582b2c
LC
9891The selected locale is automatically added to the @dfn{locale
9892definitions} known to the system if needed, with its codeset inferred
9893from its name---e.g., @code{bo_CN.utf8} will be assumed to use the
9894@code{UTF-8} codeset. Additional locale definitions can be specified in
9895the @code{locale-definitions} slot of @code{operating-system}---this is
9896useful, for instance, if the codeset could not be inferred from the
9897locale name. The default set of locale definitions includes some widely
9898used locales, but not all the available locales, in order to save space.
9899
9900For instance, to add the North Frisian locale for Germany, the value of
9901that field may be:
598e19dc
LC
9902
9903@example
9904(cons (locale-definition
9905 (name "fy_DE.utf8") (source "fy_DE"))
9906 %default-locale-definitions)
9907@end example
9908
9909Likewise, to save space, one might want @code{locale-definitions} to
9910list only the locales that are actually used, as in:
9911
9912@example
9913(list (locale-definition
9914 (name "ja_JP.eucjp") (source "ja_JP")
9915 (charset "EUC-JP")))
9916@end example
9917
5c3c1427
LC
9918@vindex LOCPATH
9919The compiled locale definitions are available at
46bd6edd
LC
9920@file{/run/current-system/locale/X.Y}, where @code{X.Y} is the libc
9921version, which is the default location where the GNU@tie{}libc provided
9922by Guix looks for locale data. This can be overridden using the
9923@code{LOCPATH} environment variable (@pxref{locales-and-locpath,
5c3c1427
LC
9924@code{LOCPATH} and locale packages}).
9925
598e19dc
LC
9926The @code{locale-definition} form is provided by the @code{(gnu system
9927locale)} module. Details are given below.
9928
9929@deftp {Data Type} locale-definition
9930This is the data type of a locale definition.
9931
9932@table @asis
9933
9934@item @code{name}
9935The name of the locale. @xref{Locale Names,,, libc, The GNU C Library
9936Reference Manual}, for more information on locale names.
9937
9938@item @code{source}
9939The name of the source for that locale. This is typically the
9940@code{@var{language}_@var{territory}} part of the locale name.
9941
9942@item @code{charset} (default: @code{"UTF-8"})
9943The ``character set'' or ``code set'' for that locale,
9944@uref{http://www.iana.org/assignments/character-sets, as defined by
9945IANA}.
9946
9947@end table
9948@end deftp
9949
9950@defvr {Scheme Variable} %default-locale-definitions
1068f26b 9951A list of commonly used UTF-8 locales, used as the default
b2636518 9952value of the @code{locale-definitions} field of @code{operating-system}
598e19dc 9953declarations.
b2636518
LC
9954
9955@cindex locale name
9956@cindex normalized codeset in locale names
9957These locale definitions use the @dfn{normalized codeset} for the part
9958that follows the dot in the name (@pxref{Using gettextized software,
9959normalized codeset,, libc, The GNU C Library Reference Manual}). So for
9960instance it has @code{uk_UA.utf8} but @emph{not}, say,
9961@code{uk_UA.UTF-8}.
598e19dc 9962@end defvr
401c53c4 9963
34760ae7
LC
9964@subsubsection Locale Data Compatibility Considerations
9965
9966@cindex incompatibility, of locale data
9967@code{operating-system} declarations provide a @code{locale-libcs} field
9968to specify the GNU@tie{}libc packages that are used to compile locale
9969declarations (@pxref{operating-system Reference}). ``Why would I
9970care?'', you may ask. Well, it turns out that the binary format of
9971locale data is occasionally incompatible from one libc version to
9972another.
9973
9974@c See <https://sourceware.org/ml/libc-alpha/2015-09/msg00575.html>
9975@c and <https://lists.gnu.org/archive/html/guix-devel/2015-08/msg00737.html>.
9976For instance, a program linked against libc version 2.21 is unable to
9977read locale data produced with libc 2.22; worse, that program
9978@emph{aborts} instead of simply ignoring the incompatible locale
9979data@footnote{Versions 2.23 and later of GNU@tie{}libc will simply skip
9980the incompatible locale data, which is already an improvement.}.
9981Similarly, a program linked against libc 2.22 can read most, but not
201fff9e 9982all, of the locale data from libc 2.21 (specifically, @code{LC_COLLATE}
34760ae7
LC
9983data is incompatible); thus calls to @code{setlocale} may fail, but
9984programs will not abort.
9985
9986The ``problem'' in GuixSD is that users have a lot of freedom: They can
9987choose whether and when to upgrade software in their profiles, and might
9988be using a libc version different from the one the system administrator
9989used to build the system-wide locale data.
9990
9991Fortunately, unprivileged users can also install their own locale data
9992and define @var{GUIX_LOCPATH} accordingly (@pxref{locales-and-locpath,
9993@code{GUIX_LOCPATH} and locale packages}).
9994
9995Still, it is best if the system-wide locale data at
9996@file{/run/current-system/locale} is built for all the libc versions
9997actually in use on the system, so that all the programs can access
9998it---this is especially crucial on a multi-user system. To do that, the
9999administrator can specify several libc packages in the
10000@code{locale-libcs} field of @code{operating-system}:
10001
10002@example
10003(use-package-modules base)
10004
10005(operating-system
10006 ;; @dots{}
10007 (locale-libcs (list glibc-2.21 (canonical-package glibc))))
10008@end example
10009
10010This example would lead to a system containing locale definitions for
10011both libc 2.21 and the current version of libc in
10012@file{/run/current-system/locale}.
10013
10014
cf4a9129
LC
10015@node Services
10016@subsection Services
401c53c4 10017
cf4a9129
LC
10018@cindex system services
10019An important part of preparing an @code{operating-system} declaration is
10020listing @dfn{system services} and their configuration (@pxref{Using the
10021Configuration System}). System services are typically daemons launched
10022when the system boots, or other actions needed at that time---e.g.,
d8b94dbd
LC
10023configuring network access.
10024
e8b652d4
LC
10025GuixSD has a broad definition of ``service'' (@pxref{Service
10026Composition}), but many services are managed by the GNU@tie{}Shepherd
10027(@pxref{Shepherd Services}). On a running system, the @command{herd}
10028command allows you to list the available services, show their status,
10029start and stop them, or do other specific operations (@pxref{Jump
10030Start,,, shepherd, The GNU Shepherd Manual}). For example:
d8b94dbd
LC
10031
10032@example
dd17bc38 10033# herd status
d8b94dbd
LC
10034@end example
10035
10036The above command, run as @code{root}, lists the currently defined
dd17bc38 10037services. The @command{herd doc} command shows a synopsis of the given
d8b94dbd
LC
10038service:
10039
10040@example
dd17bc38 10041# herd doc nscd
d8b94dbd
LC
10042Run libc's name service cache daemon (nscd).
10043@end example
10044
10045The @command{start}, @command{stop}, and @command{restart} sub-commands
10046have the effect you would expect. For instance, the commands below stop
10047the nscd service and restart the Xorg display server:
10048
10049@example
dd17bc38 10050# herd stop nscd
d8b94dbd 10051Service nscd has been stopped.
dd17bc38 10052# herd restart xorg-server
d8b94dbd
LC
10053Service xorg-server has been stopped.
10054Service xorg-server has been started.
10055@end example
401c53c4 10056
cf4a9129 10057The following sections document the available services, starting with
d8b94dbd
LC
10058the core services, that may be used in an @code{operating-system}
10059declaration.
401c53c4 10060
cf4a9129
LC
10061@menu
10062* Base Services:: Essential system services.
c311089b 10063* Scheduled Job Execution:: The mcron service.
92c03a87 10064* Log Rotation:: The rottlog service.
cf4a9129
LC
10065* Networking Services:: Network setup, SSH daemon, etc.
10066* X Window:: Graphical display.
f2ec23d1 10067* Printing Services:: Local and remote printer support.
fe1a39d3 10068* Desktop Services:: D-Bus and desktop services.
8cd1e8e8 10069* Sound Services:: ALSA and Pulseaudio services.
065225a4 10070* Database Services:: SQL databases, key-value stores, etc.
d8c18af8 10071* Mail Services:: IMAP, POP3, SMTP, and all that.
78cef99b 10072* Messaging Services:: Messaging services.
b6d2930d 10073* Telephony Services:: Telephony services.
730ed6ec 10074* Monitoring Services:: Monitoring services.
859e367d 10075* Kerberos Services:: Kerberos services.
58724c48 10076* Web Services:: Web servers.
1115f140 10077* Certificate Services:: TLS certificates via Let's Encrypt.
ba69e8f7 10078* DNS Services:: DNS daemons.
2be1b471 10079* VPN Services:: VPN daemons.
eb419bc9 10080* Network File System:: NFS related services.
a7cf4eb6 10081* Continuous Integration:: The Cuirass service.
69390e29 10082* Power Management Services:: Extending battery life.
06465d2b 10083* Audio Services:: The MPD.
e6051057 10084* Virtualization Services:: Virtualization services.
05f1cb3c 10085* Version Control Services:: Providing remote access to Git repositories.
a76acfd3 10086* Game Services:: Game servers.
dbc6d370 10087* Miscellaneous Services:: Other services.
cf4a9129 10088@end menu
401c53c4 10089
cf4a9129
LC
10090@node Base Services
10091@subsubsection Base Services
a1ba8475 10092
cf4a9129
LC
10093The @code{(gnu services base)} module provides definitions for the basic
10094services that one expects from the system. The services exported by
10095this module are listed below.
401c53c4 10096
cf4a9129 10097@defvr {Scheme Variable} %base-services
31771497
LC
10098This variable contains a list of basic services (@pxref{Service Types
10099and Services}, for more information on service objects) one would
cf4a9129 10100expect from the system: a login service (mingetty) on each tty, syslogd,
1068f26b 10101the libc name service cache daemon (nscd), the udev device manager, and
cf4a9129 10102more.
401c53c4 10103
cf4a9129
LC
10104This is the default value of the @code{services} field of
10105@code{operating-system} declarations. Usually, when customizing a
10106system, you will want to append services to @var{%base-services}, like
10107this:
401c53c4 10108
cf4a9129 10109@example
fa1e31b8 10110(cons* (avahi-service) (lsh-service) %base-services)
cf4a9129
LC
10111@end example
10112@end defvr
401c53c4 10113
387e1754
LC
10114@defvr {Scheme Variable} special-files-service-type
10115This is the service that sets up ``special files'' such as
10116@file{/bin/sh}; an instance of it is part of @code{%base-services}.
10117
10118The value associated with @code{special-files-service-type} services
10119must be a list of tuples where the first element is the ``special file''
10120and the second element is its target. By default it is:
10121
10122@cindex @file{/bin/sh}
10123@cindex @file{sh}, in @file{/bin}
10124@example
10125`(("/bin/sh" ,(file-append @var{bash} "/bin/sh")))
10126@end example
10127
10128@cindex @file{/usr/bin/env}
10129@cindex @file{env}, in @file{/usr/bin}
10130If you want to add, say, @code{/usr/bin/env} to your system, you can
10131change it to:
10132
10133@example
10134`(("/bin/sh" ,(file-append @var{bash} "/bin/sh"))
10135 ("/usr/bin/env" ,(file-append @var{coreutils} "/bin/env")))
10136@end example
10137
10138Since this is part of @code{%base-services}, you can use
10139@code{modify-services} to customize the set of special files
10140(@pxref{Service Reference, @code{modify-services}}). But the simple way
10141to add a special file is @i{via} the @code{extra-special-file} procedure
10142(see below.)
10143@end defvr
10144
10145@deffn {Scheme Procedure} extra-special-file @var{file} @var{target}
10146Use @var{target} as the ``special file'' @var{file}.
10147
10148For example, adding the following lines to the @code{services} field of
10149your operating system declaration leads to a @file{/usr/bin/env}
10150symlink:
10151
10152@example
10153(extra-special-file "/usr/bin/env"
10154 (file-append coreutils "/bin/env"))
10155@end example
10156@end deffn
10157
be1c2c54 10158@deffn {Scheme Procedure} host-name-service @var{name}
cf4a9129
LC
10159Return a service that sets the host name to @var{name}.
10160@end deffn
401c53c4 10161
317d3b47
DC
10162@deffn {Scheme Procedure} login-service @var{config}
10163Return a service to run login according to @var{config}, a
10164@code{<login-configuration>} object, which specifies the message of the day,
10165among other things.
10166@end deffn
10167
10168@deftp {Data Type} login-configuration
10169This is the data type representing the configuration of login.
10170
10171@table @asis
10172
10173@item @code{motd}
e32171ee 10174@cindex message of the day
317d3b47
DC
10175A file-like object containing the ``message of the day''.
10176
10177@item @code{allow-empty-passwords?} (default: @code{#t})
10178Allow empty passwords by default so that first-time users can log in when
10179the 'root' account has just been created.
10180
10181@end table
10182@end deftp
10183
66e4f01c
LC
10184@deffn {Scheme Procedure} mingetty-service @var{config}
10185Return a service to run mingetty according to @var{config}, a
10186@code{<mingetty-configuration>} object, which specifies the tty to run, among
10187other things.
cf4a9129 10188@end deffn
401c53c4 10189
66e4f01c
LC
10190@deftp {Data Type} mingetty-configuration
10191This is the data type representing the configuration of Mingetty, which
9ee4c9ab 10192provides the default implementation of virtual console log-in.
66e4f01c
LC
10193
10194@table @asis
10195
10196@item @code{tty}
10197The name of the console this Mingetty runs on---e.g., @code{"tty1"}.
10198
66e4f01c
LC
10199@item @code{auto-login} (default: @code{#f})
10200When true, this field must be a string denoting the user name under
f9b9a033 10201which the system automatically logs in. When it is @code{#f}, a
66e4f01c
LC
10202user name and password must be entered to log in.
10203
10204@item @code{login-program} (default: @code{#f})
10205This must be either @code{#f}, in which case the default log-in program
10206is used (@command{login} from the Shadow tool suite), or a gexp denoting
10207the name of the log-in program.
10208
10209@item @code{login-pause?} (default: @code{#f})
10210When set to @code{#t} in conjunction with @var{auto-login}, the user
10211will have to press a key before the log-in shell is launched.
10212
10213@item @code{mingetty} (default: @var{mingetty})
10214The Mingetty package to use.
10215
10216@end table
10217@end deftp
10218
9ee4c9ab
LF
10219@deffn {Scheme Procedure} agetty-service @var{config}
10220Return a service to run agetty according to @var{config}, an
10221@code{<agetty-configuration>} object, which specifies the tty to run,
10222among other things.
10223@end deffn
10224
10225@deftp {Data Type} agetty-configuration
10226This is the data type representing the configuration of agetty, which
10227implements virtual and serial console log-in. See the @code{agetty(8)}
10228man page for more information.
10229
10230@table @asis
10231
10232@item @code{tty}
10233The name of the console this agetty runs on, as a string---e.g.,
5a9902c8
DM
10234@code{"ttyS0"}. This argument is optional, it will default to
10235a reasonable default serial port used by the kernel Linux.
10236
10237For this, if there is a value for an option @code{agetty.tty} in the kernel
10238command line, agetty will extract the device name of the serial port
10239from it and use that.
10240
10241If not and if there is a value for an option @code{console} with a tty in
10242the Linux command line, agetty will extract the device name of the
10243serial port from it and use that.
10244
10245In both cases, agetty will leave the other serial device settings
10246(baud rate etc.) alone---in the hope that Linux pinned them to the
10247correct values.
9ee4c9ab
LF
10248
10249@item @code{baud-rate} (default: @code{#f})
10250A string containing a comma-separated list of one or more baud rates, in
10251descending order.
10252
10253@item @code{term} (default: @code{#f})
10254A string containing the value used for the @code{TERM} environment
10255variable.
10256
10257@item @code{eight-bits?} (default: @code{#f})
10258When @code{#t}, the tty is assumed to be 8-bit clean, and parity detection is
10259disabled.
10260
10261@item @code{auto-login} (default: @code{#f})
10262When passed a login name, as a string, the specified user will be logged
10263in automatically without prompting for their login name or password.
10264
10265@item @code{no-reset?} (default: @code{#f})
10266When @code{#t}, don't reset terminal cflags (control modes).
10267
10268@item @code{host} (default: @code{#f})
10269This accepts a string containing the "login_host", which will be written
10270into the @file{/var/run/utmpx} file.
10271
10272@item @code{remote?} (default: @code{#f})
10273When set to @code{#t} in conjunction with @var{host}, this will add an
10274@code{-r} fakehost option to the command line of the login program
10275specified in @var{login-program}.
10276
10277@item @code{flow-control?} (default: @code{#f})
10278When set to @code{#t}, enable hardware (RTS/CTS) flow control.
10279
10280@item @code{no-issue?} (default: @code{#f})
10281When set to @code{#t}, the contents of the @file{/etc/issue} file will
10282not be displayed before presenting the login prompt.
10283
10284@item @code{init-string} (default: @code{#f})
10285This accepts a string that will be sent to the tty or modem before
10286sending anything else. It can be used to initialize a modem.
10287
10288@item @code{no-clear?} (default: @code{#f})
10289When set to @code{#t}, agetty will not clear the screen before showing
10290the login prompt.
10291
10292@item @code{login-program} (default: (file-append shadow "/bin/login"))
10293This must be either a gexp denoting the name of a log-in program, or
10294unset, in which case the default value is the @command{login} from the
10295Shadow tool suite.
10296
10297@item @code{local-line} (default: @code{#f})
10298Control the CLOCAL line flag. This accepts one of three symbols as
10299arguments, @code{'auto}, @code{'always}, or @code{'never}. If @code{#f},
10300the default value chosen by agetty is @code{'auto}.
10301
10302@item @code{extract-baud?} (default: @code{#f})
10303When set to @code{#t}, instruct agetty to try to extract the baud rate
10304from the status messages produced by certain types of modems.
10305
10306@item @code{skip-login?} (default: @code{#f})
10307When set to @code{#t}, do not prompt the user for a login name. This
10308can be used with @var{login-program} field to use non-standard login
10309systems.
10310
10311@item @code{no-newline?} (default: @code{#f})
10312When set to @code{#t}, do not print a newline before printing the
10313@file{/etc/issue} file.
10314
10315@c Is this dangerous only when used with login-program, or always?
10316@item @code{login-options} (default: @code{#f})
10317This option accepts a string containing options that are passed to the
10318login program. When used with the @var{login-program}, be aware that a
10319malicious user could try to enter a login name containing embedded
10320options that could be parsed by the login program.
10321
10322@item @code{login-pause} (default: @code{#f})
10323When set to @code{#t}, wait for any key before showing the login prompt.
10324This can be used in conjunction with @var{auto-login} to save memory by
10325lazily spawning shells.
10326
10327@item @code{chroot} (default: @code{#f})
10328Change root to the specified directory. This option accepts a directory
10329path as a string.
10330
10331@item @code{hangup?} (default: @code{#f})
10332Use the Linux system call @code{vhangup} to do a virtual hangup of the
10333specified terminal.
10334
10335@item @code{keep-baud?} (default: @code{#f})
10336When set to @code{#t}, try to keep the existing baud rate. The baud
10337rates from @var{baud-rate} are used when agetty receives a @key{BREAK}
10338character.
10339
10340@item @code{timeout} (default: @code{#f})
10341When set to an integer value, terminate if no user name could be read
10342within @var{timeout} seconds.
10343
10344@item @code{detect-case?} (default: @code{#f})
10345When set to @code{#t}, turn on support for detecting an uppercase-only
10346terminal. This setting will detect a login name containing only
10347uppercase letters as indicating an uppercase-only terminal and turn on
10348some upper-to-lower case conversions. Note that this will not support
10349Unicode characters.
10350
10351@item @code{wait-cr?} (default: @code{#f})
10352When set to @code{#t}, wait for the user or modem to send a
10353carriage-return or linefeed character before displaying
10354@file{/etc/issue} or login prompt. This is typically used with the
10355@var{init-string} option.
10356
10357@item @code{no-hints?} (default: @code{#f})
10358When set to @code{#t}, do not print hints about Num, Caps, and Scroll
10359locks.
10360
10361@item @code{no-hostname?} (default: @code{#f})
10362By default, the hostname is printed. When this option is set to
10363@code{#t}, no hostname will be shown at all.
10364
10365@item @code{long-hostname?} (default: @code{#f})
10366By default, the hostname is only printed until the first dot. When this
10367option is set to @code{#t}, the fully qualified hostname by
10368@code{gethostname} or @code{getaddrinfo} is shown.
10369
10370@item @code{erase-characters} (default: @code{#f})
10371This option accepts a string of additional characters that should be
10372interpreted as backspace when the user types their login name.
10373
10374@item @code{kill-characters} (default: @code{#f})
10375This option accepts a string that should be interpreted to mean "ignore
10376all previous characters" (also called a "kill" character) when the types
10377their login name.
10378
10379@item @code{chdir} (default: @code{#f})
10380This option accepts, as a string, a directory path that will be changed
10381to before login.
10382
10383@item @code{delay} (default: @code{#f})
10384This options accepts, as an integer, the number of seconds to sleep
10385before opening the tty and displaying the login prompt.
10386
10387@item @code{nice} (default: @code{#f})
10388This option accepts, as an integer, the nice value with which to run the
10389@command{login} program.
10390
10391@item @code{extra-options} (default: @code{'()})
10392This option provides an "escape hatch" for the user to provide arbitrary
10393command-line arguments to @command{agetty} as a list of strings.
10394
10395@end table
10396@end deftp
10397
46ec2707
DC
10398@deffn {Scheme Procedure} kmscon-service-type @var{config}
10399Return a service to run @uref{https://www.freedesktop.org/wiki/Software/kmscon,kmscon}
10400according to @var{config}, a @code{<kmscon-configuration>} object, which
10401specifies the tty to run, among other things.
10402@end deffn
10403
10404@deftp {Data Type} kmscon-configuration
10405This is the data type representing the configuration of Kmscon, which
9ee4c9ab 10406implements virtual console log-in.
46ec2707
DC
10407
10408@table @asis
10409
10410@item @code{virtual-terminal}
10411The name of the console this Kmscon runs on---e.g., @code{"tty1"}.
10412
10413@item @code{login-program} (default: @code{#~(string-append #$shadow "/bin/login")})
10414A gexp denoting the name of the log-in program. The default log-in program is
10415@command{login} from the Shadow tool suite.
10416
10417@item @code{login-arguments} (default: @code{'("-p")})
10418A list of arguments to pass to @command{login}.
10419
10420@item @code{hardware-acceleration?} (default: #f)
10421Whether to use hardware acceleration.
10422
10423@item @code{kmscon} (default: @var{kmscon})
10424The Kmscon package to use.
10425
10426@end table
10427@end deftp
10428
6454b333
LC
10429@cindex name service cache daemon
10430@cindex nscd
be1c2c54 10431@deffn {Scheme Procedure} nscd-service [@var{config}] [#:glibc glibc] @
4aee6e60 10432 [#:name-services '()]
1068f26b 10433Return a service that runs the libc name service cache daemon (nscd) with the
b893f1ae
LC
10434given @var{config}---an @code{<nscd-configuration>} object. @xref{Name
10435Service Switch}, for an example.
cf4a9129 10436@end deffn
401c53c4 10437
6454b333
LC
10438@defvr {Scheme Variable} %nscd-default-configuration
10439This is the default @code{<nscd-configuration>} value (see below) used
1068f26b 10440by @code{nscd-service}. It uses the caches defined by
6454b333
LC
10441@var{%nscd-default-caches}; see below.
10442@end defvr
10443
10444@deftp {Data Type} nscd-configuration
1068f26b 10445This is the data type representing the name service cache daemon (nscd)
6454b333
LC
10446configuration.
10447
10448@table @asis
10449
b893f1ae
LC
10450@item @code{name-services} (default: @code{'()})
10451List of packages denoting @dfn{name services} that must be visible to
10452the nscd---e.g., @code{(list @var{nss-mdns})}.
10453
10454@item @code{glibc} (default: @var{glibc})
10455Package object denoting the GNU C Library providing the @command{nscd}
10456command.
10457
6454b333 10458@item @code{log-file} (default: @code{"/var/log/nscd.log"})
1068f26b 10459Name of the nscd log file. This is where debugging output goes when
6454b333
LC
10460@code{debug-level} is strictly positive.
10461
10462@item @code{debug-level} (default: @code{0})
1068f26b 10463Integer denoting the debugging levels. Higher numbers mean that more
6454b333
LC
10464debugging output is logged.
10465
10466@item @code{caches} (default: @var{%nscd-default-caches})
10467List of @code{<nscd-cache>} objects denoting things to be cached; see
10468below.
10469
10470@end table
10471@end deftp
10472
10473@deftp {Data Type} nscd-cache
10474Data type representing a cache database of nscd and its parameters.
10475
10476@table @asis
10477
10478@item @code{database}
10479This is a symbol representing the name of the database to be cached.
10480Valid values are @code{passwd}, @code{group}, @code{hosts}, and
10481@code{services}, which designate the corresponding NSS database
10482(@pxref{NSS Basics,,, libc, The GNU C Library Reference Manual}).
10483
10484@item @code{positive-time-to-live}
10485@itemx @code{negative-time-to-live} (default: @code{20})
10486A number representing the number of seconds during which a positive or
10487negative lookup result remains in cache.
10488
10489@item @code{check-files?} (default: @code{#t})
10490Whether to check for updates of the files corresponding to
10491@var{database}.
10492
10493For instance, when @var{database} is @code{hosts}, setting this flag
10494instructs nscd to check for updates in @file{/etc/hosts} and to take
10495them into account.
10496
10497@item @code{persistent?} (default: @code{#t})
10498Whether the cache should be stored persistently on disk.
10499
10500@item @code{shared?} (default: @code{#t})
10501Whether the cache should be shared among users.
10502
10503@item @code{max-database-size} (default: 32@tie{}MiB)
10504Maximum size in bytes of the database cache.
10505
10506@c XXX: 'suggested-size' and 'auto-propagate?' seem to be expert
10507@c settings, so leave them out.
10508
10509@end table
10510@end deftp
10511
10512@defvr {Scheme Variable} %nscd-default-caches
10513List of @code{<nscd-cache>} objects used by default by
1068f26b 10514@code{nscd-configuration} (see above).
6454b333
LC
10515
10516It enables persistent and aggressive caching of service and host name
10517lookups. The latter provides better host name lookup performance,
10518resilience in the face of unreliable name servers, and also better
10519privacy---often the result of host name lookups is in local cache, so
10520external name servers do not even need to be queried.
10521@end defvr
10522
ec2e2f6c 10523@anchor{syslog-configuration-type}
e32171ee
JD
10524@cindex syslog
10525@cindex logging
ec2e2f6c
DC
10526@deftp {Data Type} syslog-configuration
10527This data type represents the configuration of the syslog daemon.
6454b333 10528
ec2e2f6c
DC
10529@table @asis
10530@item @code{syslogd} (default: @code{#~(string-append #$inetutils "/libexec/syslogd")})
10531The syslog daemon to use.
10532
10533@item @code{config-file} (default: @code{%default-syslog.conf})
10534The syslog configuration file to use.
10535
10536@end table
10537@end deftp
10538
10539@anchor{syslog-service}
e32171ee 10540@cindex syslog
ec2e2f6c
DC
10541@deffn {Scheme Procedure} syslog-service @var{config}
10542Return a service that runs a syslog daemon according to @var{config}.
44abcb28
LC
10543
10544@xref{syslogd invocation,,, inetutils, GNU Inetutils}, for more
10545information on the configuration file syntax.
cf4a9129 10546@end deffn
401c53c4 10547
0adfe95a
LC
10548@anchor{guix-configuration-type}
10549@deftp {Data Type} guix-configuration
10550This data type represents the configuration of the Guix build daemon.
10551@xref{Invoking guix-daemon}, for more information.
10552
10553@table @asis
10554@item @code{guix} (default: @var{guix})
10555The Guix package to use.
401c53c4 10556
0adfe95a
LC
10557@item @code{build-group} (default: @code{"guixbuild"})
10558Name of the group for build user accounts.
401c53c4 10559
0adfe95a
LC
10560@item @code{build-accounts} (default: @code{10})
10561Number of build user accounts to create.
401c53c4 10562
0adfe95a 10563@item @code{authorize-key?} (default: @code{#t})
e32171ee 10564@cindex substitutes, authorization thereof
5b58c28b
LC
10565Whether to authorize the substitute keys listed in
10566@code{authorized-keys}---by default that of @code{hydra.gnu.org}
0adfe95a
LC
10567(@pxref{Substitutes}).
10568
5b58c28b
LC
10569@vindex %default-authorized-guix-keys
10570@item @code{authorized-keys} (default: @var{%default-authorized-guix-keys})
10571The list of authorized key files for archive imports, as a list of
10572string-valued gexps (@pxref{Invoking guix archive}). By default, it
10573contains that of @code{hydra.gnu.org} (@pxref{Substitutes}).
10574
0adfe95a
LC
10575@item @code{use-substitutes?} (default: @code{#t})
10576Whether to use substitutes.
10577
b0b9f6e0
LC
10578@item @code{substitute-urls} (default: @var{%default-substitute-urls})
10579The list of URLs where to look for substitutes by default.
10580
3bee4b61
LC
10581@item @code{max-silent-time} (default: @code{0})
10582@itemx @code{timeout} (default: @code{0})
10583The number of seconds of silence and the number of seconds of activity,
10584respectively, after which a build process times out. A value of zero
10585disables the timeout.
10586
f4596f76
LC
10587@item @code{log-compression} (default: @code{'bzip2})
10588The type of compression used for build logs---one of @code{gzip},
10589@code{bzip2}, or @code{none}.
10590
0adfe95a
LC
10591@item @code{extra-options} (default: @code{'()})
10592List of extra command-line options for @command{guix-daemon}.
10593
dc0ef095
LC
10594@item @code{log-file} (default: @code{"/var/log/guix-daemon.log"})
10595File where @command{guix-daemon}'s standard output and standard error
10596are written.
10597
93d32da9
LF
10598@item @code{http-proxy} (default: @code{#f})
10599The HTTP proxy used for downloading fixed-output derivations and
10600substitutes.
10601
b191f0a6
LF
10602@item @code{tmpdir} (default: @code{#f})
10603A directory path where the @command{guix-daemon} will perform builds.
10604
0adfe95a
LC
10605@end table
10606@end deftp
10607
10608@deffn {Scheme Procedure} guix-service @var{config}
10609Return a service that runs the Guix build daemon according to
10610@var{config}.
cf4a9129 10611@end deffn
a1ba8475 10612
6e644cfd 10613@deffn {Scheme Procedure} udev-service [#:udev @var{eudev} #:rules @code{'()}]
cf4a9129 10614Run @var{udev}, which populates the @file{/dev} directory dynamically.
6e644cfd
MC
10615udev rules can be provided as a list of files through the @var{rules}
10616variable. The procedures @var{udev-rule} and @var{file->udev-rule} from
10617@code{(gnu services base)} simplify the creation of such rule files.
10618
10619@deffn {Scheme Procedure} udev-rule [@var{file-name} @var{contents}]
10620Return a udev-rule file named @var{file-name} containing the rules
10621defined by the @var{contents} literal.
e0c1d080
RW
10622
10623In the following example, a rule for a USB device is defined to be
6e644cfd
MC
10624stored in the file @file{90-usb-thing.rules}. The rule runs a script
10625upon detecting a USB device with a given product identifier.
e0c1d080
RW
10626
10627@example
10628(define %example-udev-rule
6e644cfd
MC
10629 (udev-rule
10630 "90-usb-thing.rules"
10631 (string-append "ACTION==\"add\", SUBSYSTEM==\"usb\", "
10632 "ATTR@{product@}==\"Example\", "
10633 "RUN+=\"/path/to/script\"")))
10634@end example
10635@end deffn
10636
10637Here we show how the default @var{udev-service} can be extended with it.
10638
10639@example
10640(operating-system
10641 ;; @dots{}
10642 (services
10643 (modify-services %desktop-services
10644 (udev-service-type config =>
10645 (udev-configuration (inherit config)
10646 (rules (append (udev-configuration-rules config)
10647 (list %example-udev-rule))))))))
10648@end example
10649
10650@deffn {Scheme Procedure} file->udev-rule [@var{file-name} @var{file}]
10651Return a udev file named @var{file-name} containing the rules defined
10652within @var{file}, a file-like object.
10653
10654The following example showcases how we can use an existing rule file.
10655
10656@example
10657(use-modules (guix download) ;for url-fetch
10658 (guix packages) ;for origin
10659 ;; @dots{})
10660
10661(define %android-udev-rules
10662 (file->udev-rule
10663 "51-android-udev.rules"
10664 (let ((version "20170910"))
10665 (origin
10666 (method url-fetch)
10667 (uri (string-append "https://raw.githubusercontent.com/M0Rf30/"
10668 "android-udev-rules/" version "/51-android.rules"))
10669 (sha256
10670 (base32 "0lmmagpyb6xsq6zcr2w1cyx9qmjqmajkvrdbhjx32gqf1d9is003"))))))
10671@end example
10672@end deffn
10673
10674Additionally, Guix package definitions can be included in @var{rules} in
10675order to extend the udev rules with the definitions found under their
10676@file{lib/udev/rules.d} sub-directory. In lieu of the previous
10677@var{file->udev-rule} example, we could have used the
10678@var{android-udev-rules} package which exists in Guix in the @code{(gnu
10679packages android)} module.
10680
10681The following example shows how to use the @var{android-udev-rules}
10682package so that the Android tool @command{adb} can detect devices
10683without root privileges. It also details how to create the
10684@code{adbusers} group, which is required for the proper functioning of
10685the rules defined within the @var{android-udev-rules} package. To
10686create such a group, we must define it both as part of the
10687@var{supplementary-groups} of our @var{user-account} declaration, as
10688well as in the @var{groups} field of the @var{operating-system} record.
10689
10690@example
10691(use-modules (gnu packages android) ;for android-udev-rules
10692 (gnu system shadow) ;for user-group
10693 ;; @dots{})
e0c1d080
RW
10694
10695(operating-system
10696 ;; @dots{}
6e644cfd
MC
10697 (users (cons (user-acount
10698 ;; @dots{}
10699 (supplementary-groups
10700 '("adbusers" ;for adb
10701 "wheel" "netdev" "audio" "video"))
10702 ;; @dots{})))
10703
10704 (groups (cons (user-group (system? #t) (name "adbusers"))
10705 %base-groups))
10706
10707 ;; @dots{}
10708
10709 (services
10710 (modify-services %desktop-services
10711 (udev-service-type config =>
10712 (udev-configuration (inherit config)
10713 (rules (cons* android-udev-rules
10714 (udev-configuration-rules config))))))))
e0c1d080 10715@end example
cf4a9129 10716@end deffn
401c53c4 10717
8faaf8d7 10718@defvr {Scheme Variable} urandom-seed-service-type
a535e122 10719Save some entropy in @var{%random-seed-file} to seed @file{/dev/urandom}
9a56cf2b
LF
10720when rebooting. It also tries to seed @file{/dev/urandom} from
10721@file{/dev/hwrng} while booting, if @file{/dev/hwrng} exists and is
10722readable.
8faaf8d7 10723@end defvr
a535e122
LF
10724
10725@defvr {Scheme Variable} %random-seed-file
10726This is the name of the file where some random bytes are saved by
10727@var{urandom-seed-service} to seed @file{/dev/urandom} when rebooting.
10728It defaults to @file{/var/lib/random-seed}.
10729@end defvr
10730
e32171ee
JD
10731@cindex keymap
10732@cindex keyboard
b3d05f48 10733@deffn {Scheme Procedure} console-keymap-service @var{files} ...
dedb8d5e 10734@cindex keyboard layout
b3d05f48
AK
10735Return a service to load console keymaps from @var{files} using
10736@command{loadkeys} command. Most likely, you want to load some default
10737keymap, which can be done like this:
10738
10739@example
10740(console-keymap-service "dvorak")
10741@end example
10742
10743Or, for example, for a Swedish keyboard, you may need to combine
10744the following keymaps:
10745@example
10746(console-keymap-service "se-lat6" "se-fi-lat6")
10747@end example
10748
10749Also you can specify a full file name (or file names) of your keymap(s).
10750See @code{man loadkeys} for details.
10751
5eca9459
AK
10752@end deffn
10753
e32171ee
JD
10754@cindex mouse
10755@cindex gpm
5986e941
LC
10756@defvr {Scheme Variable} gpm-service-type
10757This is the type of the service that runs GPM, the @dfn{general-purpose
10758mouse daemon}, which provides mouse support to the Linux console. GPM
10759allows users to use the mouse in the console, notably to select, copy,
10760and paste text.
10761
10762The value for services of this type must be a @code{gpm-configuration}
10763(see below). This service is not part of @var{%base-services}.
10764@end defvr
10765
10766@deftp {Data Type} gpm-configuration
10767Data type representing the configuration of GPM.
10768
10769@table @asis
10770@item @code{options} (default: @code{%default-gpm-options})
10771Command-line options passed to @command{gpm}. The default set of
10772options instruct @command{gpm} to listen to mouse events on
10773@file{/dev/input/mice}. @xref{Command Line,,, gpm, gpm manual}, for
10774more information.
10775
10776@item @code{gpm} (default: @code{gpm})
10777The GPM package to use.
10778
10779@end table
10780@end deftp
8664cc88 10781
f1e900a3 10782@anchor{guix-publish-service-type}
3d3c5650 10783@deffn {Scheme Variable} guix-publish-service-type
f1e900a3 10784This is the service type for @command{guix publish} (@pxref{Invoking
3d3c5650 10785guix publish}). Its value must be a @code{guix-configuration}
f1e900a3 10786object, as described below.
1c52181f
LC
10787
10788This assumes that @file{/etc/guix} already contains a signing key pair as
10789created by @command{guix archive --generate-key} (@pxref{Invoking guix
10790archive}). If that is not the case, the service will fail to start.
10791@end deffn
10792
f1e900a3
LC
10793@deftp {Data Type} guix-publish-configuration
10794Data type representing the configuration of the @code{guix publish}
10795service.
10796
10797@table @asis
10798@item @code{guix} (default: @code{guix})
10799The Guix package to use.
10800
10801@item @code{port} (default: @code{80})
10802The TCP port to listen for connections.
10803
10804@item @code{host} (default: @code{"localhost"})
10805The host (and thus, network interface) to listen to. Use
10806@code{"0.0.0.0"} to listen on all the network interfaces.
697ddb88
LC
10807
10808@item @code{compression-level} (default: @code{3})
10809The gzip compression level at which substitutes are compressed. Use
10810@code{0} to disable compression altogether, and @code{9} to get the best
10811compression ratio at the expense of increased CPU usage.
10812
10813@item @code{nar-path} (default: @code{"nar"})
10814The URL path at which ``nars'' can be fetched. @xref{Invoking guix
10815publish, @code{--nar-path}}, for details.
a35136cb
LC
10816
10817@item @code{cache} (default: @code{#f})
10818When it is @code{#f}, disable caching and instead generate archives on
10819demand. Otherwise, this should be the name of a directory---e.g.,
10820@code{"/var/cache/guix/publish"}---where @command{guix publish} caches
10821archives and meta-data ready to be sent. @xref{Invoking guix publish,
10822@option{--cache}}, for more information on the tradeoffs involved.
10823
10824@item @code{workers} (default: @code{#f})
10825When it is an integer, this is the number of worker threads used for
10826caching; when @code{#f}, the number of processors is used.
10827@xref{Invoking guix publish, @option{--workers}}, for more information.
10828
10829@item @code{ttl} (default: @code{#f})
d16948bf
TGR
10830When it is an integer, this denotes the @dfn{time-to-live} in seconds
10831of the published archives. @xref{Invoking guix publish, @option{--ttl}},
10832for more information.
f1e900a3
LC
10833@end table
10834@end deftp
10835
b58cbf9a
DC
10836@anchor{rngd-service}
10837@deffn {Scheme Procedure} rngd-service [#:rng-tools @var{rng-tools}] @
10838 [#:device "/dev/hwrng"]
10839Return a service that runs the @command{rngd} program from @var{rng-tools}
10840to add @var{device} to the kernel's entropy pool. The service will fail if
10841@var{device} does not exist.
10842@end deffn
a69576ea 10843
909147e4
RW
10844@anchor{pam-limits-service}
10845@cindex session limits
10846@cindex ulimit
10847@cindex priority
b75e1df6
MC
10848@cindex realtime
10849@cindex jackd
6e644cfd 10850@deffn {Scheme Procedure} pam-limits-service [#:limits @code{'()}]
909147e4
RW
10851
10852Return a service that installs a configuration file for the
10853@uref{http://linux-pam.org/Linux-PAM-html/sag-pam_limits.html,
10854@code{pam_limits} module}. The procedure optionally takes a list of
10855@code{pam-limits-entry} values, which can be used to specify
10856@code{ulimit} limits and nice priority limits to user sessions.
10857
10858The following limits definition sets two hard and soft limits for all
10859login sessions of users in the @code{realtime} group:
10860
10861@example
10862(pam-limits-service
10863 (list
10864 (pam-limits-entry "@@realtime" 'both 'rtprio 99)
10865 (pam-limits-entry "@@realtime" 'both 'memlock 'unlimited)))
10866@end example
10867
10868The first entry increases the maximum realtime priority for
10869non-privileged processes; the second entry lifts any restriction of the
10870maximum address space that can be locked in memory. These settings are
10871commonly used for real-time audio systems.
10872@end deffn
10873
c311089b
LC
10874@node Scheduled Job Execution
10875@subsubsection Scheduled Job Execution
10876
10877@cindex cron
e32171ee 10878@cindex mcron
c311089b
LC
10879@cindex scheduling jobs
10880The @code{(gnu services mcron)} module provides an interface to
10881GNU@tie{}mcron, a daemon to run jobs at scheduled times (@pxref{Top,,,
10882mcron, GNU@tie{}mcron}). GNU@tie{}mcron is similar to the traditional
10883Unix @command{cron} daemon; the main difference is that it is
10884implemented in Guile Scheme, which provides a lot of flexibility when
10885specifying the scheduling of jobs and their actions.
10886
8ac6282c 10887The example below defines an operating system that runs the
c311089b 10888@command{updatedb} (@pxref{Invoking updatedb,,, find, Finding Files})
8ac6282c
LC
10889and the @command{guix gc} commands (@pxref{Invoking guix gc}) daily, as
10890well as the @command{mkid} command on behalf of an unprivileged user
10891(@pxref{mkid invocation,,, idutils, ID Database Utilities}). It uses
10892gexps to introduce job definitions that are passed to mcron
10893(@pxref{G-Expressions}).
c311089b
LC
10894
10895@lisp
10896(use-modules (guix) (gnu) (gnu services mcron))
8ac6282c 10897(use-package-modules base idutils)
c311089b
LC
10898
10899(define updatedb-job
8ac6282c
LC
10900 ;; Run 'updatedb' at 3AM every day. Here we write the
10901 ;; job's action as a Scheme procedure.
c311089b 10902 #~(job '(next-hour '(3))
8ac6282c
LC
10903 (lambda ()
10904 (execl (string-append #$findutils "/bin/updatedb")
10905 "updatedb"
10906 "--prunepaths=/tmp /var/tmp /gnu/store"))))
c311089b
LC
10907
10908(define garbage-collector-job
10909 ;; Collect garbage 5 minutes after midnight every day.
8ac6282c 10910 ;; The job's action is a shell command.
c311089b
LC
10911 #~(job "5 0 * * *" ;Vixie cron syntax
10912 "guix gc -F 1G"))
10913
80d944b7 10914(define idutils-job
8ac6282c
LC
10915 ;; Update the index database as user "charlie" at 12:15PM
10916 ;; and 19:15PM. This runs from the user's home directory.
10917 #~(job '(next-minute-from (next-hour '(12 19)) '(15))
10918 (string-append #$idutils "/bin/mkid src")
10919 #:user "charlie"))
10920
c311089b
LC
10921(operating-system
10922 ;; @dots{}
10923 (services (cons (mcron-service (list garbage-collector-job
8ac6282c
LC
10924 updatedb-job
10925 idutils-job))
c311089b
LC
10926 %base-services)))
10927@end lisp
10928
10929@xref{Guile Syntax, mcron job specifications,, mcron, GNU@tie{}mcron},
10930for more information on mcron job specifications. Below is the
10931reference of the mcron service.
10932
147c5aa5
LC
10933On a running system, you can use the @code{schedule} action of the service to
10934visualize the mcron jobs that will be executed next:
10935
10936@example
10937# herd schedule mcron
10938@end example
10939
10940@noindent
10941The example above lists the next five tasks that will be executed, but you can
10942also specify the number of tasks to display:
10943
10944@example
10945# herd schedule mcron 10
10946@end example
10947
cfbf6de1 10948@deffn {Scheme Procedure} mcron-service @var{jobs} [#:mcron @var{mcron}]
c311089b
LC
10949Return an mcron service running @var{mcron} that schedules @var{jobs}, a
10950list of gexps denoting mcron job specifications.
10951
10952This is a shorthand for:
10953@example
80d944b7
LC
10954(service mcron-service-type
10955 (mcron-configuration (mcron mcron) (jobs jobs)))
c311089b
LC
10956@end example
10957@end deffn
10958
10959@defvr {Scheme Variable} mcron-service-type
10960This is the type of the @code{mcron} service, whose value is an
10961@code{mcron-configuration} object.
10962
10963This service type can be the target of a service extension that provides
10964it additional job specifications (@pxref{Service Composition}). In
80d944b7 10965other words, it is possible to define services that provide additional
c311089b
LC
10966mcron jobs to run.
10967@end defvr
10968
10969@deftp {Data Type} mcron-configuration
10970Data type representing the configuration of mcron.
10971
10972@table @asis
cfbf6de1 10973@item @code{mcron} (default: @var{mcron})
c311089b
LC
10974The mcron package to use.
10975
10976@item @code{jobs}
10977This is a list of gexps (@pxref{G-Expressions}), where each gexp
10978corresponds to an mcron job specification (@pxref{Syntax, mcron job
10979specifications,, mcron, GNU@tie{}mcron}).
10980@end table
10981@end deftp
10982
10983
92c03a87
JN
10984@node Log Rotation
10985@subsubsection Log Rotation
10986
10987@cindex rottlog
10988@cindex log rotation
e32171ee 10989@cindex logging
92c03a87
JN
10990Log files such as those found in @file{/var/log} tend to grow endlessly,
10991so it's a good idea to @dfn{rotate} them once in a while---i.e., archive
10992their contents in separate files, possibly compressed. The @code{(gnu
10993services admin)} module provides an interface to GNU@tie{}Rot[t]log, a
10994log rotation tool (@pxref{Top,,, rottlog, GNU Rot[t]log Manual}).
10995
10996The example below defines an operating system that provides log rotation
81fa2229 10997with the default settings, for commonly encountered log files.
92c03a87
JN
10998
10999@lisp
11000(use-modules (guix) (gnu))
11001(use-service-modules admin mcron)
11002(use-package-modules base idutils)
11003
11004(operating-system
11005 ;; @dots{}
d466b1fc
LC
11006 (services (cons (service rottlog-service-type)
11007 %base-services)))
92c03a87
JN
11008@end lisp
11009
11010@defvr {Scheme Variable} rottlog-service-type
11011This is the type of the Rottlog service, whose value is a
11012@code{rottlog-configuration} object.
11013
254ea3f9
LC
11014Other services can extend this one with new @code{log-rotation} objects
11015(see below), thereby augmenting the set of files to be rotated.
11016
92c03a87
JN
11017This service type can define mcron jobs (@pxref{Scheduled Job
11018Execution}) to run the rottlog service.
11019@end defvr
11020
11021@deftp {Data Type} rottlog-configuration
11022Data type representing the configuration of rottlog.
11023
11024@table @asis
11025@item @code{rottlog} (default: @code{rottlog})
11026The Rottlog package to use.
11027
11028@item @code{rc-file} (default: @code{(file-append rottlog "/etc/rc")})
11029The Rottlog configuration file to use (@pxref{Mandatory RC Variables,,,
11030rottlog, GNU Rot[t]log Manual}).
11031
81fa2229
LC
11032@item @code{rotations} (default: @code{%default-rotations})
11033A list of @code{log-rotation} objects as defined below.
92c03a87 11034
81fa2229
LC
11035@item @code{jobs}
11036This is a list of gexps where each gexp corresponds to an mcron job
11037specification (@pxref{Scheduled Job Execution}).
11038@end table
11039@end deftp
11040
11041@deftp {Data Type} log-rotation
11042Data type representing the rotation of a group of log files.
11043
11044Taking an example from the Rottlog manual (@pxref{Period Related File
11045Examples,,, rottlog, GNU Rot[t]log Manual}), a log rotation might be
11046defined like this:
92c03a87
JN
11047
11048@example
81fa2229
LC
11049(log-rotation
11050 (frequency 'daily)
11051 (files '("/var/log/apache/*"))
11052 (options '("storedir apache-archives"
11053 "rotate 6"
11054 "notifempty"
11055 "nocompress")))
92c03a87
JN
11056@end example
11057
81fa2229
LC
11058The list of fields is as follows:
11059
11060@table @asis
11061@item @code{frequency} (default: @code{'weekly})
11062The log rotation frequency, a symbol.
11063
11064@item @code{files}
11065The list of files or file glob patterns to rotate.
11066
11067@item @code{options} (default: @code{'()})
11068The list of rottlog options for this rotation (@pxref{Configuration
11069parameters,,, rottlog, GNU Rot[t]lg Manual}).
11070
11071@item @code{post-rotate} (default: @code{#f})
11072Either @code{#f} or a gexp to execute once the rotation has completed.
92c03a87
JN
11073@end table
11074@end deftp
11075
11076@defvr {Scheme Variable} %default-rotations
11077Specifies weekly rotation of @var{%rotated-files} and
81fa2229 11078a couple of other files.
92c03a87
JN
11079@end defvr
11080
11081@defvr {Scheme Variable} %rotated-files
11082The list of syslog-controlled files to be rotated. By default it is:
11083@code{'("/var/log/messages" "/var/log/secure")}.
11084@end defvr
11085
cf4a9129
LC
11086@node Networking Services
11087@subsubsection Networking Services
401c53c4 11088
fa1e31b8 11089The @code{(gnu services networking)} module provides services to configure
cf4a9129 11090the network interface.
a1ba8475 11091
a023cca8 11092@cindex DHCP, networking service
be1c2c54 11093@deffn {Scheme Procedure} dhcp-client-service [#:dhcp @var{isc-dhcp}]
a023cca8
LC
11094Return a service that runs @var{dhcp}, a Dynamic Host Configuration
11095Protocol (DHCP) client, on all the non-loopback network interfaces.
11096@end deffn
11097
f1104d90
CM
11098@deffn {Scheme Procedure} dhcpd-service-type
11099This type defines a service that runs a DHCP daemon. To create a
11100service of this type, you must supply a @code{<dhcpd-configuration>}.
11101For example:
11102
11103@example
11104(service dhcpd-service-type
11105 (dhcpd-configuration
11106 (config-file (local-file "my-dhcpd.conf"))
11107 (interfaces '("enp0s25"))))
11108@end example
11109@end deffn
11110
11111@deftp {Data Type} dhcpd-configuration
11112@table @asis
11113@item @code{package} (default: @code{isc-dhcp})
11114The package that provides the DHCP daemon. This package is expected to
11115provide the daemon at @file{sbin/dhcpd} relative to its output
11116directory. The default package is the
11117@uref{http://www.isc.org/products/DHCP, ISC's DHCP server}.
11118@item @code{config-file} (default: @code{#f})
11119The configuration file to use. This is required. It will be passed to
11120@code{dhcpd} via its @code{-cf} option. This may be any ``file-like''
11121object (@pxref{G-Expressions, file-like objects}). See @code{man
11122dhcpd.conf} for details on the configuration file syntax.
11123@item @code{version} (default: @code{"4"})
11124The DHCP version to use. The ISC DHCP server supports the values ``4'',
11125``6'', and ``4o6''. These correspond to the @code{dhcpd} program
11126options @code{-4}, @code{-6}, and @code{-4o6}. See @code{man dhcpd} for
11127details.
11128@item @code{run-directory} (default: @code{"/run/dhcpd"})
11129The run directory to use. At service activation time, this directory
11130will be created if it does not exist.
11131@item @code{pid-file} (default: @code{"/run/dhcpd/dhcpd.pid"})
11132The PID file to use. This corresponds to the @code{-pf} option of
11133@code{dhcpd}. See @code{man dhcpd} for details.
11134@item @code{interfaces} (default: @code{'()})
11135The names of the network interfaces on which dhcpd should listen for
11136broadcasts. If this list is not empty, then its elements (which must be
11137strings) will be appended to the @code{dhcpd} invocation when starting
11138the daemon. It may not be necessary to explicitly specify any
11139interfaces here; see @code{man dhcpd} for details.
11140@end table
11141@end deftp
11142
8de3e4b3
LC
11143@defvr {Scheme Variable} static-networking-service-type
11144This is the type for statically-configured network interfaces.
11145@c TODO Document <static-networking> data structures.
11146@end defvr
11147
be1c2c54 11148@deffn {Scheme Procedure} static-networking-service @var{interface} @var{ip} @
52ee4d85 11149 [#:netmask #f] [#:gateway #f] [#:name-servers @code{'()}] @
db8ed7ce 11150 [#:requirement @code{'(udev)}]
cf4a9129 11151Return a service that starts @var{interface} with address @var{ip}. If
1f9803c2 11152@var{netmask} is true, use it as the network mask. If @var{gateway} is true,
db8ed7ce
MB
11153it must be a string specifying the default network gateway. @var{requirement}
11154can be used to declare a dependency on another service before configuring the
11155interface.
8de3e4b3
LC
11156
11157This procedure can be called several times, one for each network
11158interface of interest. Behind the scenes what it does is extend
11159@code{static-networking-service-type} with additional network interfaces
11160to handle.
cf4a9129 11161@end deffn
8b315a6d 11162
b7d0c494 11163@cindex wicd
e32171ee
JD
11164@cindex wireless
11165@cindex WiFi
87f40011 11166@cindex network management
be1c2c54 11167@deffn {Scheme Procedure} wicd-service [#:wicd @var{wicd}]
87f40011
LC
11168Return a service that runs @url{https://launchpad.net/wicd,Wicd}, a network
11169management daemon that aims to simplify wired and wireless networking.
11170
11171This service adds the @var{wicd} package to the global profile, providing
11172several commands to interact with the daemon and configure networking:
11173@command{wicd-client}, a graphical user interface, and the @command{wicd-cli}
11174and @command{wicd-curses} user interfaces.
b7d0c494
MW
11175@end deffn
11176
d94e81db
DM
11177@cindex ModemManager
11178
11179@defvr {Scheme Variable} modem-manager-service-type
11180This is the service type for the
11181@uref{https://wiki.gnome.org/Projects/ModemManager, ModemManager}
11182service. The value for this service type is a
11183@code{modem-manager-configuration} record.
11184
11185This service is part of @code{%desktop-services} (@pxref{Desktop
11186Services}).
11187@end defvr
11188
11189@deftp {Data Type} modem-manager-configuration
11190Data type representing the configuration of ModemManager.
11191
11192@table @asis
11193@item @code{modem-manager} (default: @code{modem-manager})
11194The ModemManager package to use.
11195
11196@end table
11197@end deftp
11198
c0a9589d 11199@cindex NetworkManager
b726096b
CB
11200
11201@defvr {Scheme Variable} network-manager-service-type
11202This is the service type for the
11203@uref{https://wiki.gnome.org/Projects/NetworkManager, NetworkManager}
11204service. The value for this service type is a
11205@code{network-manager-configuration} record.
4110fbc6
LC
11206
11207This service is part of @code{%desktop-services} (@pxref{Desktop
11208Services}).
b726096b
CB
11209@end defvr
11210
11211@deftp {Data Type} network-manager-configuration
11212Data type representing the configuration of NetworkManager.
11213
11214@table @asis
11215@item @code{network-manager} (default: @code{network-manager})
11216The NetworkManager package to use.
11217
11218@item @code{dns} (default: @code{"default"})
11219Processing mode for DNS, which affects how NetworkManager uses the
11220@code{resolv.conf} configuration file.
11221
11222@table @samp
11223@item default
11224NetworkManager will update @code{resolv.conf} to reflect the nameservers
11225provided by currently active connections.
11226
11227@item dnsmasq
11228NetworkManager will run @code{dnsmasq} as a local caching nameserver,
11229using a "split DNS" configuration if you are connected to a VPN, and
11230then update @code{resolv.conf} to point to the local nameserver.
11231
11232@item none
11233NetworkManager will not modify @code{resolv.conf}.
11234@end table
11235
94d2a250
LC
11236@item @code{vpn-plugins} (default: @code{'()})
11237This is the list of available plugins for virtual private networks
11238(VPNs). An example of this is the @code{network-manager-openvpn}
11239package, which allows NetworkManager to manage VPNs @i{via} OpenVPN.
11240
b726096b
CB
11241@end table
11242@end deftp
c0a9589d 11243
76192896 11244@cindex Connman
34d60c49
MO
11245@deffn {Scheme Variable} connman-service-type
11246This is the service type to run @url{https://01.org/connman,Connman},
11247a network connection manager.
11248
11249Its value must be an
11250@code{connman-configuration} record as in this example:
11251
11252@example
11253(service connman-service-type
11254 (connman-configuration
11255 (disable-vpn? #t)))
11256@end example
11257
11258See below for details about @code{connman-configuration}.
76192896
EF
11259@end deffn
11260
34d60c49
MO
11261@deftp {Data Type} connman-configuration
11262Data Type representing the configuration of connman.
11263
11264@table @asis
11265@item @code{connman} (default: @var{connman})
11266The connman package to use.
11267
11268@item @code{disable-vpn?} (default: @code{#f})
11269When true, enable connman's vpn plugin.
11270@end table
11271@end deftp
11272
2cccbc2a 11273@cindex WPA Supplicant
cbf1024e
LC
11274@defvr {Scheme Variable} wpa-supplicant-service-type
11275This is the service type to run @url{https://w1.fi/wpa_supplicant/,WPA
2cccbc2a 11276supplicant}, an authentication daemon required to authenticate against
cbf1024e 11277encrypted WiFi or ethernet networks. It is configured to listen for
2cccbc2a 11278requests on D-Bus.
cbf1024e
LC
11279
11280The value of this service is the @code{wpa-supplicant} package to use.
11281Thus, it can be instantiated like this:
11282
11283@lisp
3d3c5650 11284(use-modules (gnu services networking))
cbf1024e 11285
3d3c5650 11286(service wpa-supplicant-service-type)
cbf1024e
LC
11287@end lisp
11288@end defvr
2cccbc2a 11289
e32171ee
JD
11290@cindex NTP
11291@cindex real time clock
be1c2c54 11292@deffn {Scheme Procedure} ntp-service [#:ntp @var{ntp}] @
dc0322b5
LC
11293 [#:servers @var{%ntp-servers}] @
11294 [#:allow-large-adjustment? #f]
63854bcb
LC
11295Return a service that runs the daemon from @var{ntp}, the
11296@uref{http://www.ntp.org, Network Time Protocol package}. The daemon will
11297keep the system clock synchronized with that of @var{servers}.
dc0322b5
LC
11298@var{allow-large-adjustment?} determines whether @command{ntpd} is allowed to
11299make an initial adjustment of more than 1,000 seconds.
63854bcb
LC
11300@end deffn
11301
11302@defvr {Scheme Variable} %ntp-servers
11303List of host names used as the default NTP servers.
11304@end defvr
11305
16718b67
EF
11306@cindex OpenNTPD
11307@deffn {Scheme Procedure} openntpd-service-type
11308Run the @command{ntpd}, the Network Time Protocol (NTP) daemon, as implemented
11309by @uref{http://www.openntpd.org, OpenNTPD}. The daemon will keep the system
11310clock synchronized with that of the given servers.
11311
11312@example
11313(service
11314 openntpd-service-type
11315 (openntpd-configuration
11316 (listen-on '("127.0.0.1" "::1"))
11317 (sensor '("udcf0 correction 70000"))
11318 (constraint-from '("www.gnu.org"))
11319 (constraints-from '("https://www.google.com/"))
11320 (allow-large-adjustment? #t)))
11321
11322@end example
11323@end deffn
11324
11325@deftp {Data Type} openntpd-configuration
11326@table @asis
11327@item @code{openntpd} (default: @code{(file-append openntpd "/sbin/ntpd")})
11328The openntpd executable to use.
11329@item @code{listen-on} (default: @code{'("127.0.0.1" "::1")})
11330A list of local IP addresses or hostnames the ntpd daemon should listen on.
11331@item @code{query-from} (default: @code{'()})
11332A list of local IP address the ntpd daemon should use for outgoing queries.
11333@item @code{sensor} (default: @code{'()})
11334Specify a list of timedelta sensor devices ntpd should use. @code{ntpd}
11335will listen to each sensor that acutally exists and ignore non-existant ones.
11336See @uref{https://man.openbsd.org/ntpd.conf, upstream documentation} for more
11337information.
11338@item @code{server} (default: @var{%ntp-servers})
11339Specify a list of IP addresses or hostnames of NTP servers to synchronize to.
11340@item @code{servers} (default: @code{'()})
11341Specify a list of IP addresses or hostnames of NTP pools to synchronize to.
11342@item @code{constraint-from} (default: @code{'()})
11343@code{ntpd} can be configured to query the ‘Date’ from trusted HTTPS servers via TLS.
11344This time information is not used for precision but acts as an authenticated
11345constraint, thereby reducing the impact of unauthenticated NTP
11346man-in-the-middle attacks.
11347Specify a list of URLs, IP addresses or hostnames of HTTPS servers to provide
11348a constraint.
11349@item @code{constraints-from} (default: @code{'()})
11350As with constraint from, specify a list of URLs, IP addresses or hostnames of
11351HTTPS servers to provide a constraint. Should the hostname resolve to multiple
11352IP addresses, @code{ntpd} will calculate a median constraint from all of them.
11353@item @code{allow-large-adjustment?} (default: @code{#f})
11354Determines if @code{ntpd} is allowed to make an initial adjustment of more
11355than 180 seconds.
11356@end table
11357@end deftp
11358
9260b9d1
TD
11359@cindex inetd
11360@deffn {Scheme variable} inetd-service-type
11361This service runs the @command{inetd} (@pxref{inetd invocation,,,
11362inetutils, GNU Inetutils}) daemon. @command{inetd} listens for
11363connections on internet sockets, and lazily starts the specified server
11364program when a connection is made on one of these sockets.
11365
11366The value of this service is an @code{inetd-configuration} object. The
11367following example configures the @command{inetd} daemon to provide the
11368built-in @command{echo} service, as well as an smtp service which
11369forwards smtp traffic over ssh to a server @code{smtp-server} behind a
11370gateway @code{hostname}:
11371
11372@example
11373(service
11374 inetd-service-type
11375 (inetd-configuration
11376 (entries (list
11377 (inetd-entry
11378 (name "echo")
11379 (socket-type 'stream)
11380 (protocol "tcp")
11381 (wait? #f)
11382 (user "root"))
11383 (inetd-entry
11384 (node "127.0.0.1")
11385 (name "smtp")
11386 (socket-type 'stream)
11387 (protocol "tcp")
11388 (wait? #f)
11389 (user "root")
11390 (program (file-append openssh "/bin/ssh"))
11391 (arguments
11392 '("ssh" "-qT" "-i" "/path/to/ssh_key"
11393 "-W" "smtp-server:25" "user@@hostname")))))
11394@end example
11395
11396See below for more details about @code{inetd-configuration}.
11397@end deffn
11398
11399@deftp {Data Type} inetd-configuration
11400Data type representing the configuration of @command{inetd}.
11401
11402@table @asis
11403@item @code{program} (default: @code{(file-append inetutils "/libexec/inetd")})
11404The @command{inetd} executable to use.
11405
11406@item @code{entries} (default: @code{'()})
11407A list of @command{inetd} service entries. Each entry should be created
11408by the @code{inetd-entry} constructor.
11409@end table
11410@end deftp
11411
11412@deftp {Data Type} inetd-entry
11413Data type representing an entry in the @command{inetd} configuration.
11414Each entry corresponds to a socket where @command{inetd} will listen for
11415requests.
11416
11417@table @asis
11418@item @code{node} (default: @code{#f})
11419Optional string, a comma-separated list of local addresses
11420@command{inetd} should use when listening for this service.
11421@xref{Configuration file,,, inetutils, GNU Inetutils} for a complete
11422description of all options.
11423@item @code{name}
11424A string, the name must correspond to an entry in @code{/etc/services}.
11425@item @code{socket-type}
11426One of @code{'stream}, @code{'dgram}, @code{'raw}, @code{'rdm} or
11427@code{'seqpacket}.
11428@item @code{protocol}
11429A string, must correspond to an entry in @code{/etc/protocols}.
11430@item @code{wait?} (default: @code{#t})
11431Whether @command{inetd} should wait for the server to exit before
11432listening to new service requests.
11433@item @code{user}
11434A string containing the user (and, optionally, group) name of the user
11435as whom the server should run. The group name can be specified in a
11436suffix, separated by a colon or period, i.e. @code{"user"},
11437@code{"user:group"} or @code{"user.group"}.
11438@item @code{program} (default: @code{"internal"})
11439The server program which will serve the requests, or @code{"internal"}
11440if @command{inetd} should use a built-in service.
11441@item @code{arguments} (default: @code{'()})
11442A list strings or file-like objects, which are the server program's
11443arguments, starting with the zeroth argument, i.e. the name of the
11444program itself. For @command{inetd}'s internal services, this entry
11445must be @code{'()} or @code{'("internal")}.
11446@end table
11447
11448@xref{Configuration file,,, inetutils, GNU Inetutils} for a more
11449detailed discussion of each configuration field.
11450@end deftp
11451
e32171ee 11452@cindex Tor
375c6108
LC
11453@deffn {Scheme Procedure} tor-service [@var{config-file}] [#:tor @var{tor}]
11454Return a service to run the @uref{https://torproject.org, Tor} anonymous
11455networking daemon.
8b315a6d 11456
375c6108 11457The daemon runs as the @code{tor} unprivileged user. It is passed
6331bde7
LC
11458@var{config-file}, a file-like object, with an additional @code{User tor} line
11459and lines for hidden services added via @code{tor-hidden-service}. Run
11460@command{man tor} for information about the configuration file.
11461@end deffn
11462
24a8ef3b 11463@cindex hidden service
6331bde7
LC
11464@deffn {Scheme Procedure} tor-hidden-service @var{name} @var{mapping}
11465Define a new Tor @dfn{hidden service} called @var{name} and implementing
11466@var{mapping}. @var{mapping} is a list of port/host tuples, such as:
11467
11468@example
24a8ef3b
LC
11469 '((22 "127.0.0.1:22")
11470 (80 "127.0.0.1:8080"))
6331bde7
LC
11471@end example
11472
11473In this example, port 22 of the hidden service is mapped to local port 22, and
11474port 80 is mapped to local port 8080.
11475
6629099a
LC
11476This creates a @file{/var/lib/tor/hidden-services/@var{name}} directory, where
11477the @file{hostname} file contains the @code{.onion} host name for the hidden
6331bde7
LC
11478service.
11479
11480See @uref{https://www.torproject.org/docs/tor-hidden-service.html.en, the Tor
11481project's documentation} for more information.
cf4a9129 11482@end deffn
8b315a6d 11483
9db7e9be
OP
11484The @code{(gnu services rsync)} module provides the following services:
11485
11486You might want an rsync daemon if you have files that you want available
11487so anyone (or just yourself) can download existing files or upload new
11488files.
11489
11490@deffn {Scheme Variable} rsync-service-type
11491This is the type for the @uref{https://rsync.samba.org, rsync} rsync daemon,
11492@command{rsync-configuration} record as in this example:
11493
11494@example
11495(service rsync-service-type)
11496@end example
11497
11498See below for details about @code{rsync-configuration}.
11499@end deffn
11500
11501@deftp {Data Type} rsync-configuration
11502Data type representing the configuration for @code{rsync-service}.
11503
11504@table @asis
11505@item @code{package} (default: @var{rsync})
11506@code{rsync} package to use.
11507
11508@item @code{port-number} (default: @code{873})
11509TCP port on which @command{rsync} listens for incoming connections. If port
11510is less than @code{1024} @command{rsync} needs to be started as the
11511@code{root} user and group.
11512
11513@item @code{pid-file} (default: @code{"/var/run/rsyncd/rsyncd.pid"})
11514Name of the file where @command{rsync} writes its PID.
11515
11516@item @code{lock-file} (default: @code{"/var/run/rsyncd/rsyncd.lock"})
11517Name of the file where @command{rsync} writes its lock file.
11518
11519@item @code{log-file} (default: @code{"/var/log/rsyncd.log"})
11520Name of the file where @command{rsync} writes its log file.
11521
11522@item @code{use-chroot?} (default: @var{#t})
11523Whether to use chroot for @command{rsync} shared directory.
11524
11525@item @code{share-path} (default: @file{/srv/rsync})
11526Location of the @command{rsync} shared directory.
11527
11528@item @code{share-comment} (default: @code{"Rsync share"})
11529Comment of the @command{rsync} shared directory.
11530
11531@item @code{read-only?} (default: @var{#f})
11532Read-write permissions to shared directory.
11533
11534@item @code{timeout} (default: @code{300})
11535I/O timeout in seconds.
11536
11537@item @code{user} (default: @var{"root"})
11538Owner of the @code{rsync} process.
11539
11540@item @code{group} (default: @var{"root"})
11541Group of the @code{rsync} process.
11542
11543@item @code{uid} (default: @var{"rsyncd"})
11544User name or user ID that file transfers to and from that module should take
11545place as when the daemon was run as @code{root}.
11546
11547@item @code{gid} (default: @var{"rsyncd"})
11548Group name or group ID that will be used when accessing the module.
11549
11550@end table
11551@end deftp
11552
71b0601a 11553Furthermore, @code{(gnu services ssh)} provides the following services.
e32171ee
JD
11554@cindex SSH
11555@cindex SSH server
8b315a6d 11556
be1c2c54 11557@deffn {Scheme Procedure} lsh-service [#:host-key "/etc/lsh/host-key"] @
5833bf33 11558 [#:daemonic? #t] [#:interfaces '()] [#:port-number 22] @
cf4a9129
LC
11559 [#:allow-empty-passwords? #f] [#:root-login? #f] @
11560 [#:syslog-output? #t] [#:x11-forwarding? #t] @
11561 [#:tcp/ip-forwarding? #t] [#:password-authentication? #t] @
21cc905a 11562 [#:public-key-authentication? #t] [#:initialize? #t]
cf4a9129
LC
11563Run the @command{lshd} program from @var{lsh} to listen on port @var{port-number}.
11564@var{host-key} must designate a file containing the host key, and readable
11565only by root.
72e25e35 11566
5833bf33
DP
11567When @var{daemonic?} is true, @command{lshd} will detach from the
11568controlling terminal and log its output to syslogd, unless one sets
11569@var{syslog-output?} to false. Obviously, it also makes lsh-service
11570depend on existence of syslogd service. When @var{pid-file?} is true,
11571@command{lshd} writes its PID to the file called @var{pid-file}.
11572
cf4a9129
LC
11573When @var{initialize?} is true, automatically create the seed and host key
11574upon service activation if they do not exist yet. This may take long and
11575require interaction.
8b315a6d 11576
20dd519c
LC
11577When @var{initialize?} is false, it is up to the user to initialize the
11578randomness generator (@pxref{lsh-make-seed,,, lsh, LSH Manual}), and to create
11579a key pair with the private key stored in file @var{host-key} (@pxref{lshd
11580basics,,, lsh, LSH Manual}).
11581
cf4a9129
LC
11582When @var{interfaces} is empty, lshd listens for connections on all the
11583network interfaces; otherwise, @var{interfaces} must be a list of host names
11584or addresses.
9bf3c1a7 11585
20dd519c
LC
11586@var{allow-empty-passwords?} specifies whether to accept log-ins with empty
11587passwords, and @var{root-login?} specifies whether to accept log-ins as
cf4a9129 11588root.
4af2447e 11589
cf4a9129
LC
11590The other options should be self-descriptive.
11591@end deffn
4af2447e 11592
e32171ee
JD
11593@cindex SSH
11594@cindex SSH server
d8f31281
LC
11595@deffn {Scheme Variable} openssh-service-type
11596This is the type for the @uref{http://www.openssh.org, OpenSSH} secure
11597shell daemon, @command{sshd}. Its value must be an
11598@code{openssh-configuration} record as in this example:
11599
11600@example
11601(service openssh-service-type
11602 (openssh-configuration
11603 (x11-forwarding? #t)
4892eb7c
LC
11604 (permit-root-login 'without-password)
11605 (authorized-keys
11606 `(("alice" ,(local-file "alice.pub"))
11607 ("bob" ,(local-file "bob.pub"))))))
d8f31281
LC
11608@end example
11609
11610See below for details about @code{openssh-configuration}.
1398a438
LC
11611
11612This service can be extended with extra authorized keys, as in this
11613example:
11614
11615@example
11616(service-extension openssh-service-type
11617 (const `(("charlie"
11618 ,(local-file "charlie.pub")))))
11619@end example
86d8f6d3
JL
11620@end deffn
11621
d8f31281
LC
11622@deftp {Data Type} openssh-configuration
11623This is the configuration record for OpenSSH's @command{sshd}.
11624
11625@table @asis
11626@item @code{pid-file} (default: @code{"/var/run/sshd.pid"})
11627Name of the file where @command{sshd} writes its PID.
11628
11629@item @code{port-number} (default: @code{22})
11630TCP port on which @command{sshd} listens for incoming connections.
11631
11632@item @code{permit-root-login} (default: @code{#f})
11633This field determines whether and when to allow logins as root. If
11634@code{#f}, root logins are disallowed; if @code{#t}, they are allowed.
11635If it's the symbol @code{'without-password}, then root logins are
11636permitted but not with password-based authentication.
11637
11638@item @code{allow-empty-passwords?} (default: @code{#f})
11639When true, users with empty passwords may log in. When false, they may
11640not.
11641
11642@item @code{password-authentication?} (default: @code{#t})
11643When true, users may log in with their password. When false, they have
11644other authentication methods.
11645
11646@item @code{public-key-authentication?} (default: @code{#t})
11647When true, users may log in using public key authentication. When
11648false, users have to use other authentication method.
11649
11650Authorized public keys are stored in @file{~/.ssh/authorized_keys}.
11651This is used only by protocol version 2.
11652
d8f31281
LC
11653@item @code{x11-forwarding?} (default: @code{#f})
11654When true, forwarding of X11 graphical client connections is
11655enabled---in other words, @command{ssh} options @option{-X} and
11656@option{-Y} will work.
11657
5b682390
EB
11658@item @code{allow-agent-forwarding?} (default: @code{#t})
11659Whether to allow agent forwarding.
11660
11661@item @code{allow-tcp-forwarding?} (default: @code{#t})
11662Whether to allow TCP forwarding.
11663
11664@item @code{gateway-ports?} (default: @code{#f})
11665Whether to allow gateway ports.
11666
563c5d42
CL
11667@item @code{challenge-response-authentication?} (default: @code{#f})
11668Specifies whether challenge response authentication is allowed (e.g. via
11669PAM).
11670
11671@item @code{use-pam?} (default: @code{#t})
11672Enables the Pluggable Authentication Module interface. If set to
11673@code{#t}, this will enable PAM authentication using
11674@code{challenge-response-authentication?} and
11675@code{password-authentication?}, in addition to PAM account and session
11676module processing for all authentication types.
11677
11678Because PAM challenge response authentication usually serves an
11679equivalent role to password authentication, you should disable either
11680@code{challenge-response-authentication?} or
11681@code{password-authentication?}.
f895dce4
CL
11682
11683@item @code{print-last-log?} (default: @code{#t})
11684Specifies whether @command{sshd} should print the date and time of the
11685last user login when a user logs in interactively.
12723370
CL
11686
11687@item @code{subsystems} (default: @code{'(("sftp" "internal-sftp"))})
11688Configures external subsystems (e.g. file transfer daemon).
11689
11690This is a list of two-element lists, each of which containing the
11691subsystem name and a command (with optional arguments) to execute upon
11692subsystem request.
11693
11694The command @command{internal-sftp} implements an in-process SFTP
11695server. Alternately, one can specify the @command{sftp-server} command:
11696@example
11697(service openssh-service-type
11698 (openssh-configuration
11699 (subsystems
4892eb7c 11700 `(("sftp" ,(file-append openssh "/libexec/sftp-server"))))))
12723370 11701@end example
4892eb7c 11702
985934cb
MC
11703@item @code{accepted-environment} (default: @code{'()})
11704List of strings describing which environment variables may be exported.
11705
11706Each string gets on its own line. See the @code{AcceptEnv} option in
11707@code{man sshd_config}.
11708
11709This example allows ssh-clients to export the @code{COLORTERM} variable.
11710It is set by terminal emulators, which support colors. You can use it in
11711your shell's ressource file to enable colors for the prompt and commands
11712if this variable is set.
11713
11714@example
11715(service openssh-service-type
11716 (openssh-configuration
11717 (accepted-environment '("COLORTERM"))))
11718@end example
11719
4892eb7c
LC
11720@item @code{authorized-keys} (default: @code{'()})
11721@cindex authorized keys, SSH
11722@cindex SSH authorized keys
11723This is the list of authorized keys. Each element of the list is a user
11724name followed by one or more file-like objects that represent SSH public
11725keys. For example:
11726
11727@example
11728(openssh-configuration
11729 (authorized-keys
11730 `(("rekado" ,(local-file "rekado.pub"))
11731 ("chris" ,(local-file "chris.pub"))
11732 ("root" ,(local-file "rekado.pub") ,(local-file "chris.pub")))))
11733@end example
11734
11735@noindent
11736registers the specified public keys for user accounts @code{rekado},
11737@code{chris}, and @code{root}.
11738
1398a438
LC
11739Additional authorized keys can be specified @i{via}
11740@code{service-extension}.
11741
4892eb7c
LC
11742Note that this does @emph{not} interfere with the use of
11743@file{~/.ssh/authorized_keys}.
d8f31281
LC
11744@end table
11745@end deftp
11746
71b0601a
DC
11747@deffn {Scheme Procedure} dropbear-service [@var{config}]
11748Run the @uref{https://matt.ucc.asn.au/dropbear/dropbear.html,Dropbear SSH
11749daemon} with the given @var{config}, a @code{<dropbear-configuration>}
11750object.
11751
11752For example, to specify a Dropbear service listening on port 1234, add
11753this call to the operating system's @code{services} field:
11754
11755@example
11756(dropbear-service (dropbear-configuration
11757 (port-number 1234)))
11758@end example
11759@end deffn
11760
11761@deftp {Data Type} dropbear-configuration
11762This data type represents the configuration of a Dropbear SSH daemon.
11763
11764@table @asis
11765@item @code{dropbear} (default: @var{dropbear})
11766The Dropbear package to use.
11767
11768@item @code{port-number} (default: 22)
11769The TCP port where the daemon waits for incoming connections.
11770
11771@item @code{syslog-output?} (default: @code{#t})
11772Whether to enable syslog output.
11773
11774@item @code{pid-file} (default: @code{"/var/run/dropbear.pid"})
11775File name of the daemon's PID file.
11776
11777@item @code{root-login?} (default: @code{#f})
11778Whether to allow @code{root} logins.
11779
11780@item @code{allow-empty-passwords?} (default: @code{#f})
11781Whether to allow empty passwords.
11782
11783@item @code{password-authentication?} (default: @code{#t})
11784Whether to enable password-based authentication.
11785@end table
11786@end deftp
11787
fa0c1d61
LC
11788@defvr {Scheme Variable} %facebook-host-aliases
11789This variable contains a string for use in @file{/etc/hosts}
11790(@pxref{Host Names,,, libc, The GNU C Library Reference Manual}). Each
11791line contains a entry that maps a known server name of the Facebook
11792on-line service---e.g., @code{www.facebook.com}---to the local
11793host---@code{127.0.0.1} or its IPv6 equivalent, @code{::1}.
11794
11795This variable is typically used in the @code{hosts-file} field of an
7313a52e
LC
11796@code{operating-system} declaration (@pxref{operating-system Reference,
11797@file{/etc/hosts}}):
fa0c1d61
LC
11798
11799@example
11800(use-modules (gnu) (guix))
11801
11802(operating-system
11803 (host-name "mymachine")
11804 ;; ...
11805 (hosts-file
11806 ;; Create a /etc/hosts file with aliases for "localhost"
11807 ;; and "mymachine", as well as for Facebook servers.
24e02c28
LC
11808 (plain-file "hosts"
11809 (string-append (local-host-aliases host-name)
11810 %facebook-host-aliases))))
fa0c1d61
LC
11811@end example
11812
11813This mechanism can prevent programs running locally, such as Web
11814browsers, from accessing Facebook.
11815@end defvr
11816
965a7332
LC
11817The @code{(gnu services avahi)} provides the following definition.
11818
be1c2c54 11819@deffn {Scheme Procedure} avahi-service [#:avahi @var{avahi}] @
965a7332
LC
11820 [#:host-name #f] [#:publish? #t] [#:ipv4? #t] @
11821 [#:ipv6? #t] [#:wide-area? #f] @
c8695f32 11822 [#:domains-to-browse '()] [#:debug? #f]
965a7332
LC
11823Return a service that runs @command{avahi-daemon}, a system-wide
11824mDNS/DNS-SD responder that allows for service discovery and
cc9c1f39
LC
11825"zero-configuration" host name lookups (see @uref{http://avahi.org/}), and
11826extends the name service cache daemon (nscd) so that it can resolve
11827@code{.local} host names using
1065bed9
LC
11828@uref{http://0pointer.de/lennart/projects/nss-mdns/, nss-mdns}. Additionally,
11829add the @var{avahi} package to the system profile so that commands such as
11830@command{avahi-browse} are directly usable.
965a7332
LC
11831
11832If @var{host-name} is different from @code{#f}, use that as the host name to
11833publish for this machine; otherwise, use the machine's actual host name.
11834
11835When @var{publish?} is true, publishing of host names and services is allowed;
11836in particular, avahi-daemon will publish the machine's host name and IP
11837address via mDNS on the local network.
11838
11839When @var{wide-area?} is true, DNS-SD over unicast DNS is enabled.
11840
11841Boolean values @var{ipv4?} and @var{ipv6?} determine whether to use IPv4/IPv6
11842sockets.
11843@end deffn
11844
c32d02fe
SB
11845@deffn {Scheme Variable} openvswitch-service-type
11846This is the type of the @uref{http://www.openvswitch.org, Open vSwitch}
11847service, whose value should be an @code{openvswitch-configuration}
11848object.
11849@end deffn
11850
11851@deftp {Data Type} openvswitch-configuration
11852Data type representing the configuration of Open vSwitch, a multilayer
11853virtual switch which is designed to enable massive network automation
11854through programmatic extension.
11855
11856@table @asis
11857@item @code{package} (default: @var{openvswitch})
11858Package object of the Open vSwitch.
11859
11860@end table
11861@end deftp
965a7332 11862
cf4a9129
LC
11863@node X Window
11864@subsubsection X Window
68ad877c 11865
e32171ee
JD
11866@cindex X11
11867@cindex X Window System
65c0f436 11868@cindex login manager
cf4a9129
LC
11869Support for the X Window graphical display system---specifically
11870Xorg---is provided by the @code{(gnu services xorg)} module. Note that
11871there is no @code{xorg-service} procedure. Instead, the X server is
65c0f436
LC
11872started by the @dfn{login manager}, by default SLiM.
11873
11874@cindex window manager
11875To use X11, you must install at least one @dfn{window manager}---for
11876example the @code{windowmaker} or @code{openbox} packages---preferably
11877by adding it to the @code{packages} field of your operating system
11878definition (@pxref{operating-system Reference, system-wide packages}).
4af2447e 11879
b37f86d7
LC
11880@defvr {Scheme Variable} slim-service-type
11881This is the type for the SLiM graphical login manager for X11.
11882
11883@cindex session types (X11)
11884@cindex X11 session types
11885SLiM looks for @dfn{session types} described by the @file{.desktop} files in
11886@file{/run/current-system/profile/share/xsessions} and allows users to
11887choose a session from the log-in screen using @kbd{F1}. Packages such
11888as @code{xfce}, @code{sawfish}, and @code{ratpoison} provide
11889@file{.desktop} files; adding them to the system-wide set of packages
11890automatically makes them available at the log-in screen.
11891
11892In addition, @file{~/.xsession} files are honored. When available,
11893@file{~/.xsession} must be an executable that starts a window manager
11894and/or other X clients.
11895@end defvr
11896
11897@deftp {Data Type} slim-configuration
11898Data type representing the configuration of @code{slim-service-type}.
11899
11900@table @asis
11901@item @code{allow-empty-passwords?} (default: @code{#t})
11902Whether to allow logins with empty passwords.
11903
11904@item @code{auto-login?} (default: @code{#f})
11905@itemx @code{default-user} (default: @code{""})
11906When @code{auto-login?} is false, SLiM presents a log-in screen.
11907
11908When @code{auto-login?} is true, SLiM logs in directly as
11909@code{default-user}.
11910
11911@item @code{theme} (default: @code{%default-slim-theme})
11912@itemx @code{theme-name} (default: @code{%default-slim-theme-name})
11913The graphical theme to use and its name.
11914
65c0f436
LC
11915@item @code{auto-login-session} (default: @code{#f})
11916If true, this must be the name of the executable to start as the default
11917session---e.g., @code{(file-append windowmaker "/bin/windowmaker")}.
11918
11919If false, a session described by one of the available @file{.desktop}
11920files in @code{/run/current-system/profile} and @code{~/.guix-profile}
11921will be used.
11922
11923@quotation Note
11924You must install at least one window manager in the system profile or in
11925your user profile. Failing to do that, if @code{auto-login-session} is
11926false, you will be unable to log in.
11927@end quotation
b37f86d7
LC
11928
11929@item @code{startx} (default: @code{(xorg-start-command)})
11930The command used to start the X11 graphical server.
11931
11932@item @code{xauth} (default: @code{xauth})
11933The XAuth package to use.
11934
11935@item @code{shepherd} (default: @code{shepherd})
11936The Shepherd package used when invoking @command{halt} and
11937@command{reboot}.
11938
736e45a2
DM
11939@item @code{sessreg} (default: @code{sessreg})
11940The sessreg package used in order to register the session.
11941
b37f86d7
LC
11942@item @code{slim} (default: @code{slim})
11943The SLiM package to use.
11944@end table
11945@end deftp
11946
11947@defvr {Scheme Variable} %default-theme
11948@defvrx {Scheme Variable} %default-theme-name
11949The default SLiM theme and its name.
11950@end defvr
11951
11952
935644c0
DC
11953@deftp {Data Type} sddm-configuration
11954This is the data type representing the sddm service configuration.
11955
11956@table @asis
11957@item @code{display-server} (default: "x11")
11958Select display server to use for the greeter. Valid values are "x11"
11959or "wayland".
11960
11961@item @code{numlock} (default: "on")
11962Valid values are "on", "off" or "none".
11963
11964@item @code{halt-command} (default @code{#~(string-apppend #$shepherd "/sbin/halt")})
11965Command to run when halting.
11966
11967@item @code{reboot-command} (default @code{#~(string-append #$shepherd "/sbin/reboot")})
11968Command to run when rebooting.
11969
11970@item @code{theme} (default "maldives")
11971Theme to use. Default themes provided by SDDM are "elarun" or "maldives".
11972
11973@item @code{themes-directory} (default "/run/current-system/profile/share/sddm/themes")
11974Directory to look for themes.
11975
11976@item @code{faces-directory} (default "/run/current-system/profile/share/sddm/faces")
11977Directory to look for faces.
11978
11979@item @code{default-path} (default "/run/current-system/profile/bin")
11980Default PATH to use.
11981
11982@item @code{minimum-uid} (default 1000)
11983Minimum UID to display in SDDM.
11984
11985@item @code{maximum-uid} (default 2000)
11986Maximum UID to display in SDDM
11987
11988@item @code{remember-last-user?} (default #t)
11989Remember last user.
11990
11991@item @code{remember-last-session?} (default #t)
11992Remember last session.
11993
11994@item @code{hide-users} (default "")
11995Usernames to hide from SDDM greeter.
11996
11997@item @code{hide-shells} (default @code{#~(string-append #$shadow "/sbin/nologin")})
11998Users with shells listed will be hidden from the SDDM greeter.
11999
12000@item @code{session-command} (default @code{#~(string-append #$sddm "/share/sddm/scripts/wayland-session")})
12001Script to run before starting a wayland session.
12002
12003@item @code{sessions-directory} (default "/run/current-system/profile/share/wayland-sessions")
12004Directory to look for desktop files starting wayland sessions.
12005
12006@item @code{xorg-server-path} (default @code{xorg-start-command})
12007Path to xorg-server.
12008
12009@item @code{xauth-path} (default @code{#~(string-append #$xauth "/bin/xauth")})
12010Path to xauth.
12011
12012@item @code{xephyr-path} (default @code{#~(string-append #$xorg-server "/bin/Xephyr")})
12013Path to Xephyr.
12014
12015@item @code{xdisplay-start} (default @code{#~(string-append #$sddm "/share/sddm/scripts/Xsetup")})
12016Script to run after starting xorg-server.
12017
12018@item @code{xdisplay-stop} (default @code{#~(string-append #$sddm "/share/sddm/scripts/Xstop")})
12019Script to run before stopping xorg-server.
12020
9b557bea 12021@item @code{xsession-command} (default: @code{xinitrc})
935644c0
DC
12022Script to run before starting a X session.
12023
12024@item @code{xsessions-directory} (default: "/run/current-system/profile/share/xsessions")
12025Directory to look for desktop files starting X sessions.
12026
12027@item @code{minimum-vt} (default: 7)
12028Minimum VT to use.
12029
12030@item @code{xserver-arguments} (default "-nolisten tcp")
12031Arguments to pass to xorg-server.
12032
12033@item @code{auto-login-user} (default "")
12034User to use for auto-login.
12035
12036@item @code{auto-login-session} (default "")
12037Desktop file to use for auto-login.
12038
12039@item @code{relogin?} (default #f)
12040Relogin after logout.
12041
12042@end table
12043@end deftp
12044
e32171ee 12045@cindex login manager
b37f86d7 12046@cindex X11 login
935644c0
DC
12047@deffn {Scheme Procedure} sddm-service config
12048Return a service that spawns the SDDM graphical login manager for config of
12049type @code{<sddm-configuration>}.
12050
12051@example
12052 (sddm-service (sddm-configuration
12053 (auto-login-user "Alice")
12054 (auto-login-session "xfce.desktop")))
12055@end example
12056@end deffn
12057
be1c2c54 12058@deffn {Scheme Procedure} xorg-start-command [#:guile] @
d344f5a5
LC
12059 [#:modules %default-xorg-modules] @
12060 [#:fonts %default-xorg-fonts] @
12061 [#:configuration-file (xorg-configuration-file @dots{})] @
12062 [#:xorg-server @var{xorg-server}]
12063Return a @code{startx} script in which @var{modules}, a list of X module
12064packages, and @var{fonts}, a list of X font directories, are available. See
12065@code{xorg-wrapper} for more details on the arguments. The result should be
12066used in place of @code{startx}.
d1cdd7ba
LC
12067
12068Usually the X server is started by a login manager.
12069@end deffn
12070
be1c2c54 12071@deffn {Scheme Procedure} xorg-configuration-file @
d344f5a5
LC
12072 [#:modules %default-xorg-modules] @
12073 [#:fonts %default-xorg-fonts] @
12422c9d 12074 [#:drivers '()] [#:resolutions '()] [#:extra-config '()]
d1cdd7ba
LC
12075Return a configuration file for the Xorg server containing search paths for
12076all the common drivers.
f703413e 12077
d344f5a5
LC
12078@var{modules} must be a list of @dfn{module packages} loaded by the Xorg
12079server---e.g., @code{xf86-video-vesa}, @code{xf86-input-keyboard}, and so on.
12080@var{fonts} must be a list of font directories to add to the server's
12081@dfn{font path}.
12082
f703413e
LC
12083@var{drivers} must be either the empty list, in which case Xorg chooses a
12084graphics driver automatically, or a list of driver names that will be tried in
d344f5a5 12085this order---e.g., @code{("modesetting" "vesa")}.
d2e59637
LC
12086
12087Likewise, when @var{resolutions} is the empty list, Xorg chooses an
12088appropriate screen resolution; otherwise, it must be a list of
12089resolutions---e.g., @code{((1024 768) (640 480))}.
12422c9d
LC
12090
12091Last, @var{extra-config} is a list of strings or objects appended to the
d344f5a5
LC
12092configuration file. It is used to pass extra text to be
12093added verbatim to the configuration file.
136a1e8b
JL
12094
12095@cindex keymap
12096@cindex keyboard layout
12097This procedure is especially useful to configure a different keyboard layout
12098than the default US keymap. For instance, to use the ``bépo'' keymap by
12099default on the display manager:
12100
12101@example
12102(define bepo-evdev
12103 "Section \"InputClass\"
12104 Identifier \"evdev keyboard catchall\"
12105 Driver \"evdev\"
12106 MatchIsKeyboard \"on\"
12107 Option \"xkb_layout\" \"fr\"
12108 Option \"xkb_variant\" \"bepo\"
12109EndSection")
12110
12111(operating-system
12112 ...
12113 (services
12114 (modify-services %desktop-services
12115 (slim-service-type config =>
12116 (slim-configuration
12117 (inherit config)
12118 (startx (xorg-start-command
12119 #:configuration-file
12120 (xorg-configuration-file
12121 #:extra-config
12122 (list bepo-evdev)))))))))
12123@end example
12124
12125The @code{MatchIsKeyboard} line specifies that we only apply the configuration
12126to keyboards. Without this line, other devices such as touchpad may not work
12127correctly because they will be attached to the wrong driver. In this example,
12128the user typically used @code{setxkbmap fr bepo} to set their favorite keymap
12129once logged in. The first argument corresponds to the layout, while the second
12130argument corresponds to the variant. The @code{xkb_variant} line can be omitted
12131to select the default variant.
f703413e 12132@end deffn
4af2447e 12133
5481887d 12134@deffn {Scheme Procedure} screen-locker-service @var{package} [@var{program}]
d64e1746 12135Add @var{package}, a package for a screen locker or screen saver whose
6726282b
LC
12136command is @var{program}, to the set of setuid programs and add a PAM entry
12137for it. For example:
12138
12139@lisp
12140(screen-locker-service xlockmore "xlock")
12141@end lisp
12142
12143makes the good ol' XlockMore usable.
12144@end deffn
12145
12146
f2ec23d1
AW
12147@node Printing Services
12148@subsubsection Printing Services
12149
de322a5d 12150@cindex printer support with CUPS
f2ec23d1
AW
12151The @code{(gnu services cups)} module provides a Guix service definition
12152for the CUPS printing service. To add printer support to a GuixSD
12153system, add a @code{cups-service} to the operating system definition:
12154
12155@deffn {Scheme Variable} cups-service-type
12156The service type for the CUPS print server. Its value should be a valid
3d3c5650
LC
12157CUPS configuration (see below). To use the default settings, simply
12158write:
f2ec23d1 12159@example
3d3c5650 12160(service cups-service-type)
f2ec23d1
AW
12161@end example
12162@end deffn
12163
12164The CUPS configuration controls the basic things about your CUPS
12165installation: what interfaces it listens on, what to do if a print job
12166fails, how much logging to do, and so on. To actually add a printer,
12167you have to visit the @url{http://localhost:631} URL, or use a tool such
12168as GNOME's printer configuration services. By default, configuring a
12169CUPS service will generate a self-signed certificate if needed, for
12170secure connections to the print server.
12171
de322a5d 12172Suppose you want to enable the Web interface of CUPS and also add
d2a7170d 12173support for Epson printers @i{via} the @code{escpr} package and for HP
8e189596 12174printers @i{via} the @code{hplip-minimal} package. You can do that directly,
d2a7170d 12175like this (you need to use the @code{(gnu packages cups)} module):
f2ec23d1
AW
12176
12177@example
12178(service cups-service-type
12179 (cups-configuration
de322a5d
LC
12180 (web-interface? #t)
12181 (extensions
8e189596 12182 (list cups-filters escpr hplip-minimal))))
f2ec23d1
AW
12183@end example
12184
8e189596
EF
12185Note: If you wish to use the Qt5 based GUI which comes with the hplip
12186package then it is suggested that you install the @code{hplip} package,
12187either in your OS configuration file or as your user.
12188
f2ec23d1
AW
12189The available configuration parameters follow. Each parameter
12190definition is preceded by its type; for example, @samp{string-list foo}
12191indicates that the @code{foo} parameter should be specified as a list of
12192strings. There is also a way to specify the configuration as a string,
12193if you have an old @code{cupsd.conf} file that you want to port over
12194from some other system; see the end for more details.
12195
12196@c The following documentation was initially generated by
12197@c (generate-documentation) in (gnu services cups). Manually maintained
12198@c documentation is better, so we shouldn't hesitate to edit below as
12199@c needed. However if the change you want to make to this documentation
12200@c can be done in an automated way, it's probably easier to change
12201@c (generate-documentation) than to make it below and have to deal with
12202@c the churn as CUPS updates.
12203
12204
12205Available @code{cups-configuration} fields are:
12206
12207@deftypevr {@code{cups-configuration} parameter} package cups
12208The CUPS package.
12209@end deftypevr
12210
12211@deftypevr {@code{cups-configuration} parameter} package-list extensions
12212Drivers and other extensions to the CUPS package.
12213@end deftypevr
12214
12215@deftypevr {@code{cups-configuration} parameter} files-configuration files-configuration
12216Configuration of where to write logs, what directories to use for print
12217spools, and related privileged configuration parameters.
12218
12219Available @code{files-configuration} fields are:
12220
12221@deftypevr {@code{files-configuration} parameter} log-location access-log
12222Defines the access log filename. Specifying a blank filename disables
12223access log generation. The value @code{stderr} causes log entries to be
12224sent to the standard error file when the scheduler is running in the
12225foreground, or to the system log daemon when run in the background. The
12226value @code{syslog} causes log entries to be sent to the system log
12227daemon. The server name may be included in filenames using the string
12228@code{%s}, as in @code{/var/log/cups/%s-access_log}.
12229
12230Defaults to @samp{"/var/log/cups/access_log"}.
12231@end deftypevr
12232
12233@deftypevr {@code{files-configuration} parameter} file-name cache-dir
12234Where CUPS should cache data.
12235
12236Defaults to @samp{"/var/cache/cups"}.
12237@end deftypevr
12238
12239@deftypevr {@code{files-configuration} parameter} string config-file-perm
12240Specifies the permissions for all configuration files that the scheduler
12241writes.
12242
12243Note that the permissions for the printers.conf file are currently
12244masked to only allow access from the scheduler user (typically root).
12245This is done because printer device URIs sometimes contain sensitive
12246authentication information that should not be generally known on the
12247system. There is no way to disable this security feature.
12248
12249Defaults to @samp{"0640"}.
12250@end deftypevr
12251
12252@deftypevr {@code{files-configuration} parameter} log-location error-log
12253Defines the error log filename. Specifying a blank filename disables
12254access log generation. The value @code{stderr} causes log entries to be
12255sent to the standard error file when the scheduler is running in the
12256foreground, or to the system log daemon when run in the background. The
12257value @code{syslog} causes log entries to be sent to the system log
12258daemon. The server name may be included in filenames using the string
12259@code{%s}, as in @code{/var/log/cups/%s-error_log}.
12260
12261Defaults to @samp{"/var/log/cups/error_log"}.
12262@end deftypevr
12263
12264@deftypevr {@code{files-configuration} parameter} string fatal-errors
12265Specifies which errors are fatal, causing the scheduler to exit. The
12266kind strings are:
12267
12268@table @code
12269@item none
12270No errors are fatal.
12271
12272@item all
12273All of the errors below are fatal.
12274
12275@item browse
12276Browsing initialization errors are fatal, for example failed connections
12277to the DNS-SD daemon.
12278
12279@item config
12280Configuration file syntax errors are fatal.
12281
12282@item listen
12283Listen or Port errors are fatal, except for IPv6 failures on the
12284loopback or @code{any} addresses.
12285
12286@item log
12287Log file creation or write errors are fatal.
12288
12289@item permissions
12290Bad startup file permissions are fatal, for example shared TLS
12291certificate and key files with world-read permissions.
12292@end table
12293
12294Defaults to @samp{"all -browse"}.
12295@end deftypevr
12296
12297@deftypevr {@code{files-configuration} parameter} boolean file-device?
12298Specifies whether the file pseudo-device can be used for new printer
12299queues. The URI @uref{file:///dev/null} is always allowed.
12300
12301Defaults to @samp{#f}.
12302@end deftypevr
12303
12304@deftypevr {@code{files-configuration} parameter} string group
12305Specifies the group name or ID that will be used when executing external
12306programs.
12307
12308Defaults to @samp{"lp"}.
12309@end deftypevr
12310
12311@deftypevr {@code{files-configuration} parameter} string log-file-perm
12312Specifies the permissions for all log files that the scheduler writes.
12313
12314Defaults to @samp{"0644"}.
12315@end deftypevr
12316
12317@deftypevr {@code{files-configuration} parameter} log-location page-log
12318Defines the page log filename. Specifying a blank filename disables
12319access log generation. The value @code{stderr} causes log entries to be
12320sent to the standard error file when the scheduler is running in the
12321foreground, or to the system log daemon when run in the background. The
12322value @code{syslog} causes log entries to be sent to the system log
12323daemon. The server name may be included in filenames using the string
12324@code{%s}, as in @code{/var/log/cups/%s-page_log}.
12325
12326Defaults to @samp{"/var/log/cups/page_log"}.
12327@end deftypevr
12328
12329@deftypevr {@code{files-configuration} parameter} string remote-root
12330Specifies the username that is associated with unauthenticated accesses
12331by clients claiming to be the root user. The default is @code{remroot}.
12332
12333Defaults to @samp{"remroot"}.
12334@end deftypevr
12335
12336@deftypevr {@code{files-configuration} parameter} file-name request-root
12337Specifies the directory that contains print jobs and other HTTP request
12338data.
12339
12340Defaults to @samp{"/var/spool/cups"}.
12341@end deftypevr
12342
12343@deftypevr {@code{files-configuration} parameter} sandboxing sandboxing
12344Specifies the level of security sandboxing that is applied to print
12345filters, backends, and other child processes of the scheduler; either
12346@code{relaxed} or @code{strict}. This directive is currently only
12347used/supported on macOS.
12348
12349Defaults to @samp{strict}.
12350@end deftypevr
12351
12352@deftypevr {@code{files-configuration} parameter} file-name server-keychain
12353Specifies the location of TLS certificates and private keys. CUPS will
12354look for public and private keys in this directory: a @code{.crt} files
12355for PEM-encoded certificates and corresponding @code{.key} files for
12356PEM-encoded private keys.
12357
12358Defaults to @samp{"/etc/cups/ssl"}.
12359@end deftypevr
12360
12361@deftypevr {@code{files-configuration} parameter} file-name server-root
12362Specifies the directory containing the server configuration files.
12363
12364Defaults to @samp{"/etc/cups"}.
12365@end deftypevr
12366
12367@deftypevr {@code{files-configuration} parameter} boolean sync-on-close?
12368Specifies whether the scheduler calls fsync(2) after writing
12369configuration or state files.
12370
12371Defaults to @samp{#f}.
12372@end deftypevr
12373
12374@deftypevr {@code{files-configuration} parameter} space-separated-string-list system-group
12375Specifies the group(s) to use for @code{@@SYSTEM} group authentication.
12376@end deftypevr
12377
12378@deftypevr {@code{files-configuration} parameter} file-name temp-dir
12379Specifies the directory where temporary files are stored.
12380
12381Defaults to @samp{"/var/spool/cups/tmp"}.
12382@end deftypevr
12383
12384@deftypevr {@code{files-configuration} parameter} string user
12385Specifies the user name or ID that is used when running external
12386programs.
12387
12388Defaults to @samp{"lp"}.
12389@end deftypevr
12390@end deftypevr
12391
12392@deftypevr {@code{cups-configuration} parameter} access-log-level access-log-level
12393Specifies the logging level for the AccessLog file. The @code{config}
12394level logs when printers and classes are added, deleted, or modified and
12395when configuration files are accessed or updated. The @code{actions}
12396level logs when print jobs are submitted, held, released, modified, or
12397canceled, and any of the conditions for @code{config}. The @code{all}
12398level logs all requests.
12399
12400Defaults to @samp{actions}.
12401@end deftypevr
12402
12403@deftypevr {@code{cups-configuration} parameter} boolean auto-purge-jobs?
12404Specifies whether to purge job history data automatically when it is no
12405longer required for quotas.
12406
12407Defaults to @samp{#f}.
12408@end deftypevr
12409
12410@deftypevr {@code{cups-configuration} parameter} browse-local-protocols browse-local-protocols
12411Specifies which protocols to use for local printer sharing.
12412
12413Defaults to @samp{dnssd}.
12414@end deftypevr
12415
12416@deftypevr {@code{cups-configuration} parameter} boolean browse-web-if?
12417Specifies whether the CUPS web interface is advertised.
12418
12419Defaults to @samp{#f}.
12420@end deftypevr
12421
12422@deftypevr {@code{cups-configuration} parameter} boolean browsing?
12423Specifies whether shared printers are advertised.
12424
12425Defaults to @samp{#f}.
12426@end deftypevr
12427
12428@deftypevr {@code{cups-configuration} parameter} string classification
12429Specifies the security classification of the server. Any valid banner
12430name can be used, including "classified", "confidential", "secret",
12431"topsecret", and "unclassified", or the banner can be omitted to disable
12432secure printing functions.
12433
12434Defaults to @samp{""}.
12435@end deftypevr
12436
12437@deftypevr {@code{cups-configuration} parameter} boolean classify-override?
12438Specifies whether users may override the classification (cover page) of
12439individual print jobs using the @code{job-sheets} option.
12440
12441Defaults to @samp{#f}.
12442@end deftypevr
12443
12444@deftypevr {@code{cups-configuration} parameter} default-auth-type default-auth-type
12445Specifies the default type of authentication to use.
12446
12447Defaults to @samp{Basic}.
12448@end deftypevr
12449
12450@deftypevr {@code{cups-configuration} parameter} default-encryption default-encryption
12451Specifies whether encryption will be used for authenticated requests.
12452
12453Defaults to @samp{Required}.
12454@end deftypevr
12455
12456@deftypevr {@code{cups-configuration} parameter} string default-language
12457Specifies the default language to use for text and web content.
12458
12459Defaults to @samp{"en"}.
12460@end deftypevr
12461
12462@deftypevr {@code{cups-configuration} parameter} string default-paper-size
12463Specifies the default paper size for new print queues. @samp{"Auto"}
12464uses a locale-specific default, while @samp{"None"} specifies there is
12465no default paper size. Specific size names are typically
12466@samp{"Letter"} or @samp{"A4"}.
12467
12468Defaults to @samp{"Auto"}.
12469@end deftypevr
12470
12471@deftypevr {@code{cups-configuration} parameter} string default-policy
12472Specifies the default access policy to use.
12473
12474Defaults to @samp{"default"}.
12475@end deftypevr
12476
12477@deftypevr {@code{cups-configuration} parameter} boolean default-shared?
12478Specifies whether local printers are shared by default.
12479
12480Defaults to @samp{#t}.
12481@end deftypevr
12482
12483@deftypevr {@code{cups-configuration} parameter} non-negative-integer dirty-clean-interval
12484Specifies the delay for updating of configuration and state files, in
12485seconds. A value of 0 causes the update to happen as soon as possible,
12486typically within a few milliseconds.
12487
12488Defaults to @samp{30}.
12489@end deftypevr
12490
12491@deftypevr {@code{cups-configuration} parameter} error-policy error-policy
12492Specifies what to do when an error occurs. Possible values are
12493@code{abort-job}, which will discard the failed print job;
12494@code{retry-job}, which will retry the job at a later time;
12495@code{retry-this-job}, which retries the failed job immediately; and
12496@code{stop-printer}, which stops the printer.
12497
12498Defaults to @samp{stop-printer}.
12499@end deftypevr
12500
12501@deftypevr {@code{cups-configuration} parameter} non-negative-integer filter-limit
12502Specifies the maximum cost of filters that are run concurrently, which
12503can be used to minimize disk, memory, and CPU resource problems. A
12504limit of 0 disables filter limiting. An average print to a
12505non-PostScript printer needs a filter limit of about 200. A PostScript
12506printer needs about half that (100). Setting the limit below these
12507thresholds will effectively limit the scheduler to printing a single job
12508at any time.
12509
12510Defaults to @samp{0}.
12511@end deftypevr
12512
12513@deftypevr {@code{cups-configuration} parameter} non-negative-integer filter-nice
12514Specifies the scheduling priority of filters that are run to print a
12515job. The nice value ranges from 0, the highest priority, to 19, the
12516lowest priority.
12517
12518Defaults to @samp{0}.
12519@end deftypevr
12520
12521@deftypevr {@code{cups-configuration} parameter} host-name-lookups host-name-lookups
12522Specifies whether to do reverse lookups on connecting clients. The
12523@code{double} setting causes @code{cupsd} to verify that the hostname
12524resolved from the address matches one of the addresses returned for that
12525hostname. Double lookups also prevent clients with unregistered
12526addresses from connecting to your server. Only set this option to
12527@code{#t} or @code{double} if absolutely required.
12528
12529Defaults to @samp{#f}.
12530@end deftypevr
12531
12532@deftypevr {@code{cups-configuration} parameter} non-negative-integer job-kill-delay
12533Specifies the number of seconds to wait before killing the filters and
12534backend associated with a canceled or held job.
12535
12536Defaults to @samp{30}.
12537@end deftypevr
12538
12539@deftypevr {@code{cups-configuration} parameter} non-negative-integer job-retry-interval
12540Specifies the interval between retries of jobs in seconds. This is
12541typically used for fax queues but can also be used with normal print
12542queues whose error policy is @code{retry-job} or
12543@code{retry-current-job}.
12544
12545Defaults to @samp{30}.
12546@end deftypevr
12547
12548@deftypevr {@code{cups-configuration} parameter} non-negative-integer job-retry-limit
12549Specifies the number of retries that are done for jobs. This is
12550typically used for fax queues but can also be used with normal print
12551queues whose error policy is @code{retry-job} or
12552@code{retry-current-job}.
12553
12554Defaults to @samp{5}.
12555@end deftypevr
12556
12557@deftypevr {@code{cups-configuration} parameter} boolean keep-alive?
12558Specifies whether to support HTTP keep-alive connections.
12559
12560Defaults to @samp{#t}.
12561@end deftypevr
12562
12563@deftypevr {@code{cups-configuration} parameter} non-negative-integer keep-alive-timeout
12564Specifies how long an idle client connection remains open, in seconds.
12565
12566Defaults to @samp{30}.
12567@end deftypevr
12568
12569@deftypevr {@code{cups-configuration} parameter} non-negative-integer limit-request-body
12570Specifies the maximum size of print files, IPP requests, and HTML form
12571data. A limit of 0 disables the limit check.
12572
12573Defaults to @samp{0}.
12574@end deftypevr
12575
12576@deftypevr {@code{cups-configuration} parameter} multiline-string-list listen
12577Listens on the specified interfaces for connections. Valid values are
12578of the form @var{address}:@var{port}, where @var{address} is either an
12579IPv6 address enclosed in brackets, an IPv4 address, or @code{*} to
12580indicate all addresses. Values can also be file names of local UNIX
12581domain sockets. The Listen directive is similar to the Port directive
12582but allows you to restrict access to specific interfaces or networks.
12583@end deftypevr
12584
12585@deftypevr {@code{cups-configuration} parameter} non-negative-integer listen-back-log
12586Specifies the number of pending connections that will be allowed. This
12587normally only affects very busy servers that have reached the MaxClients
12588limit, but can also be triggered by large numbers of simultaneous
12589connections. When the limit is reached, the operating system will
12590refuse additional connections until the scheduler can accept the pending
12591ones.
12592
12593Defaults to @samp{128}.
12594@end deftypevr
12595
12596@deftypevr {@code{cups-configuration} parameter} location-access-control-list location-access-controls
12597Specifies a set of additional access controls.
12598
12599Available @code{location-access-controls} fields are:
12600
12601@deftypevr {@code{location-access-controls} parameter} file-name path
12602Specifies the URI path to which the access control applies.
12603@end deftypevr
12604
12605@deftypevr {@code{location-access-controls} parameter} access-control-list access-controls
12606Access controls for all access to this path, in the same format as the
12607@code{access-controls} of @code{operation-access-control}.
12608
12609Defaults to @samp{()}.
12610@end deftypevr
12611
12612@deftypevr {@code{location-access-controls} parameter} method-access-control-list method-access-controls
12613Access controls for method-specific access to this path.
12614
12615Defaults to @samp{()}.
12616
12617Available @code{method-access-controls} fields are:
12618
12619@deftypevr {@code{method-access-controls} parameter} boolean reverse?
12620If @code{#t}, apply access controls to all methods except the listed
12621methods. Otherwise apply to only the listed methods.
12622
12623Defaults to @samp{#f}.
12624@end deftypevr
12625
12626@deftypevr {@code{method-access-controls} parameter} method-list methods
12627Methods to which this access control applies.
12628
12629Defaults to @samp{()}.
12630@end deftypevr
12631
12632@deftypevr {@code{method-access-controls} parameter} access-control-list access-controls
12633Access control directives, as a list of strings. Each string should be
12634one directive, such as "Order allow,deny".
12635
12636Defaults to @samp{()}.
12637@end deftypevr
12638@end deftypevr
12639@end deftypevr
12640
12641@deftypevr {@code{cups-configuration} parameter} non-negative-integer log-debug-history
12642Specifies the number of debugging messages that are retained for logging
12643if an error occurs in a print job. Debug messages are logged regardless
12644of the LogLevel setting.
12645
12646Defaults to @samp{100}.
12647@end deftypevr
12648
12649@deftypevr {@code{cups-configuration} parameter} log-level log-level
12650Specifies the level of logging for the ErrorLog file. The value
12651@code{none} stops all logging while @code{debug2} logs everything.
12652
12653Defaults to @samp{info}.
12654@end deftypevr
12655
12656@deftypevr {@code{cups-configuration} parameter} log-time-format log-time-format
12657Specifies the format of the date and time in the log files. The value
12658@code{standard} logs whole seconds while @code{usecs} logs microseconds.
12659
12660Defaults to @samp{standard}.
12661@end deftypevr
12662
12663@deftypevr {@code{cups-configuration} parameter} non-negative-integer max-clients
12664Specifies the maximum number of simultaneous clients that are allowed by
12665the scheduler.
12666
12667Defaults to @samp{100}.
12668@end deftypevr
12669
12670@deftypevr {@code{cups-configuration} parameter} non-negative-integer max-clients-per-host
12671Specifies the maximum number of simultaneous clients that are allowed
12672from a single address.
12673
12674Defaults to @samp{100}.
12675@end deftypevr
12676
12677@deftypevr {@code{cups-configuration} parameter} non-negative-integer max-copies
12678Specifies the maximum number of copies that a user can print of each
12679job.
12680
12681Defaults to @samp{9999}.
12682@end deftypevr
12683
12684@deftypevr {@code{cups-configuration} parameter} non-negative-integer max-hold-time
12685Specifies the maximum time a job may remain in the @code{indefinite}
12686hold state before it is canceled. A value of 0 disables cancellation of
12687held jobs.
12688
12689Defaults to @samp{0}.
12690@end deftypevr
12691
12692@deftypevr {@code{cups-configuration} parameter} non-negative-integer max-jobs
12693Specifies the maximum number of simultaneous jobs that are allowed. Set
12694to 0 to allow an unlimited number of jobs.
12695
12696Defaults to @samp{500}.
12697@end deftypevr
12698
12699@deftypevr {@code{cups-configuration} parameter} non-negative-integer max-jobs-per-printer
12700Specifies the maximum number of simultaneous jobs that are allowed per
12701printer. A value of 0 allows up to MaxJobs jobs per printer.
12702
12703Defaults to @samp{0}.
12704@end deftypevr
12705
12706@deftypevr {@code{cups-configuration} parameter} non-negative-integer max-jobs-per-user
12707Specifies the maximum number of simultaneous jobs that are allowed per
12708user. A value of 0 allows up to MaxJobs jobs per user.
12709
12710Defaults to @samp{0}.
12711@end deftypevr
12712
12713@deftypevr {@code{cups-configuration} parameter} non-negative-integer max-job-time
12714Specifies the maximum time a job may take to print before it is
12715canceled, in seconds. Set to 0 to disable cancellation of "stuck" jobs.
12716
12717Defaults to @samp{10800}.
12718@end deftypevr
12719
12720@deftypevr {@code{cups-configuration} parameter} non-negative-integer max-log-size
12721Specifies the maximum size of the log files before they are rotated, in
12722bytes. The value 0 disables log rotation.
12723
12724Defaults to @samp{1048576}.
12725@end deftypevr
12726
12727@deftypevr {@code{cups-configuration} parameter} non-negative-integer multiple-operation-timeout
12728Specifies the maximum amount of time to allow between files in a
12729multiple file print job, in seconds.
12730
12731Defaults to @samp{300}.
12732@end deftypevr
12733
12734@deftypevr {@code{cups-configuration} parameter} string page-log-format
12735Specifies the format of PageLog lines. Sequences beginning with percent
12736(@samp{%}) characters are replaced with the corresponding information,
12737while all other characters are copied literally. The following percent
12738sequences are recognized:
12739
12740@table @samp
12741@item %%
12742insert a single percent character
12743
12744@item %@{name@}
12745insert the value of the specified IPP attribute
12746
12747@item %C
12748insert the number of copies for the current page
12749
12750@item %P
12751insert the current page number
12752
12753@item %T
12754insert the current date and time in common log format
12755
12756@item %j
12757insert the job ID
12758
12759@item %p
12760insert the printer name
12761
12762@item %u
12763insert the username
12764@end table
12765
12766A value of the empty string disables page logging. The string @code{%p
12767%u %j %T %P %C %@{job-billing@} %@{job-originating-host-name@}
12768%@{job-name@} %@{media@} %@{sides@}} creates a page log with the
12769standard items.
12770
12771Defaults to @samp{""}.
12772@end deftypevr
12773
12774@deftypevr {@code{cups-configuration} parameter} environment-variables environment-variables
12775Passes the specified environment variable(s) to child processes; a list
12776of strings.
12777
12778Defaults to @samp{()}.
12779@end deftypevr
12780
12781@deftypevr {@code{cups-configuration} parameter} policy-configuration-list policies
12782Specifies named access control policies.
12783
12784Available @code{policy-configuration} fields are:
12785
12786@deftypevr {@code{policy-configuration} parameter} string name
12787Name of the policy.
12788@end deftypevr
12789
12790@deftypevr {@code{policy-configuration} parameter} string job-private-access
12791Specifies an access list for a job's private values. @code{@@ACL} maps
12792to the printer's requesting-user-name-allowed or
12793requesting-user-name-denied values. @code{@@OWNER} maps to the job's
12794owner. @code{@@SYSTEM} maps to the groups listed for the
12795@code{system-group} field of the @code{files-config} configuration,
12796which is reified into the @code{cups-files.conf(5)} file. Other
12797possible elements of the access list include specific user names, and
12798@code{@@@var{group}} to indicate members of a specific group. The
12799access list may also be simply @code{all} or @code{default}.
12800
12801Defaults to @samp{"@@OWNER @@SYSTEM"}.
12802@end deftypevr
12803
12804@deftypevr {@code{policy-configuration} parameter} string job-private-values
12805Specifies the list of job values to make private, or @code{all},
12806@code{default}, or @code{none}.
12807
12808Defaults to @samp{"job-name job-originating-host-name
12809job-originating-user-name phone"}.
12810@end deftypevr
12811
12812@deftypevr {@code{policy-configuration} parameter} string subscription-private-access
12813Specifies an access list for a subscription's private values.
12814@code{@@ACL} maps to the printer's requesting-user-name-allowed or
12815requesting-user-name-denied values. @code{@@OWNER} maps to the job's
12816owner. @code{@@SYSTEM} maps to the groups listed for the
12817@code{system-group} field of the @code{files-config} configuration,
12818which is reified into the @code{cups-files.conf(5)} file. Other
12819possible elements of the access list include specific user names, and
12820@code{@@@var{group}} to indicate members of a specific group. The
12821access list may also be simply @code{all} or @code{default}.
12822
12823Defaults to @samp{"@@OWNER @@SYSTEM"}.
12824@end deftypevr
12825
12826@deftypevr {@code{policy-configuration} parameter} string subscription-private-values
12827Specifies the list of job values to make private, or @code{all},
12828@code{default}, or @code{none}.
12829
12830Defaults to @samp{"notify-events notify-pull-method notify-recipient-uri
12831notify-subscriber-user-name notify-user-data"}.
12832@end deftypevr
12833
12834@deftypevr {@code{policy-configuration} parameter} operation-access-control-list access-controls
12835Access control by IPP operation.
12836
12837Defaults to @samp{()}.
12838@end deftypevr
12839@end deftypevr
12840
12841@deftypevr {@code{cups-configuration} parameter} boolean-or-non-negative-integer preserve-job-files
12842Specifies whether job files (documents) are preserved after a job is
12843printed. If a numeric value is specified, job files are preserved for
12844the indicated number of seconds after printing. Otherwise a boolean
12845value applies indefinitely.
12846
12847Defaults to @samp{86400}.
12848@end deftypevr
12849
12850@deftypevr {@code{cups-configuration} parameter} boolean-or-non-negative-integer preserve-job-history
12851Specifies whether the job history is preserved after a job is printed.
12852If a numeric value is specified, the job history is preserved for the
12853indicated number of seconds after printing. If @code{#t}, the job
12854history is preserved until the MaxJobs limit is reached.
12855
12856Defaults to @samp{#t}.
12857@end deftypevr
12858
12859@deftypevr {@code{cups-configuration} parameter} non-negative-integer reload-timeout
12860Specifies the amount of time to wait for job completion before
12861restarting the scheduler.
12862
12863Defaults to @samp{30}.
12864@end deftypevr
12865
12866@deftypevr {@code{cups-configuration} parameter} string rip-cache
12867Specifies the maximum amount of memory to use when converting documents
12868into bitmaps for a printer.
12869
12870Defaults to @samp{"128m"}.
12871@end deftypevr
12872
12873@deftypevr {@code{cups-configuration} parameter} string server-admin
12874Specifies the email address of the server administrator.
12875
12876Defaults to @samp{"root@@localhost.localdomain"}.
12877@end deftypevr
12878
12879@deftypevr {@code{cups-configuration} parameter} host-name-list-or-* server-alias
12880The ServerAlias directive is used for HTTP Host header validation when
12881clients connect to the scheduler from external interfaces. Using the
12882special name @code{*} can expose your system to known browser-based DNS
12883rebinding attacks, even when accessing sites through a firewall. If the
12884auto-discovery of alternate names does not work, we recommend listing
12885each alternate name with a ServerAlias directive instead of using
12886@code{*}.
12887
12888Defaults to @samp{*}.
12889@end deftypevr
12890
12891@deftypevr {@code{cups-configuration} parameter} string server-name
12892Specifies the fully-qualified host name of the server.
12893
12894Defaults to @samp{"localhost"}.
12895@end deftypevr
12896
12897@deftypevr {@code{cups-configuration} parameter} server-tokens server-tokens
12898Specifies what information is included in the Server header of HTTP
12899responses. @code{None} disables the Server header. @code{ProductOnly}
12900reports @code{CUPS}. @code{Major} reports @code{CUPS 2}. @code{Minor}
12901reports @code{CUPS 2.0}. @code{Minimal} reports @code{CUPS 2.0.0}.
12902@code{OS} reports @code{CUPS 2.0.0 (@var{uname})} where @var{uname} is
12903the output of the @code{uname} command. @code{Full} reports @code{CUPS
129042.0.0 (@var{uname}) IPP/2.0}.
12905
12906Defaults to @samp{Minimal}.
12907@end deftypevr
12908
12909@deftypevr {@code{cups-configuration} parameter} string set-env
12910Set the specified environment variable to be passed to child processes.
12911
12912Defaults to @samp{"variable value"}.
12913@end deftypevr
12914
12915@deftypevr {@code{cups-configuration} parameter} multiline-string-list ssl-listen
12916Listens on the specified interfaces for encrypted connections. Valid
12917values are of the form @var{address}:@var{port}, where @var{address} is
12918either an IPv6 address enclosed in brackets, an IPv4 address, or
12919@code{*} to indicate all addresses.
12920
12921Defaults to @samp{()}.
12922@end deftypevr
12923
12924@deftypevr {@code{cups-configuration} parameter} ssl-options ssl-options
12925Sets encryption options. By default, CUPS only supports encryption
12926using TLS v1.0 or higher using known secure cipher suites. The
12927@code{AllowRC4} option enables the 128-bit RC4 cipher suites, which are
12928required for some older clients that do not implement newer ones. The
12929@code{AllowSSL3} option enables SSL v3.0, which is required for some
12930older clients that do not support TLS v1.0.
12931
12932Defaults to @samp{()}.
12933@end deftypevr
12934
12935@deftypevr {@code{cups-configuration} parameter} boolean strict-conformance?
12936Specifies whether the scheduler requires clients to strictly adhere to
12937the IPP specifications.
12938
12939Defaults to @samp{#f}.
12940@end deftypevr
12941
12942@deftypevr {@code{cups-configuration} parameter} non-negative-integer timeout
12943Specifies the HTTP request timeout, in seconds.
12944
12945Defaults to @samp{300}.
12946
12947@end deftypevr
12948
12949@deftypevr {@code{cups-configuration} parameter} boolean web-interface?
12950Specifies whether the web interface is enabled.
12951
12952Defaults to @samp{#f}.
12953@end deftypevr
12954
12955At this point you're probably thinking ``oh dear, Guix manual, I like
12956you but you can stop already with the configuration options''. Indeed.
12957However, one more point: it could be that you have an existing
12958@code{cupsd.conf} that you want to use. In that case, you can pass an
12959@code{opaque-cups-configuration} as the configuration of a
12960@code{cups-service-type}.
12961
12962Available @code{opaque-cups-configuration} fields are:
12963
12964@deftypevr {@code{opaque-cups-configuration} parameter} package cups
12965The CUPS package.
12966@end deftypevr
12967
12968@deftypevr {@code{opaque-cups-configuration} parameter} string cupsd.conf
12969The contents of the @code{cupsd.conf}, as a string.
12970@end deftypevr
12971
12972@deftypevr {@code{opaque-cups-configuration} parameter} string cups-files.conf
12973The contents of the @code{cups-files.conf} file, as a string.
12974@end deftypevr
12975
12976For example, if your @code{cupsd.conf} and @code{cups-files.conf} are in
12977strings of the same name, you could instantiate a CUPS service like
12978this:
12979
12980@example
12981(service cups-service-type
12982 (opaque-cups-configuration
12983 (cupsd.conf cupsd.conf)
12984 (cups-files.conf cups-files.conf)))
12985@end example
12986
12987
fe1a39d3
LC
12988@node Desktop Services
12989@subsubsection Desktop Services
aa4ed923 12990
fe1a39d3
LC
12991The @code{(gnu services desktop)} module provides services that are
12992usually useful in the context of a ``desktop'' setup---that is, on a
12993machine running a graphical display server, possibly with graphical user
7a2413e4 12994interfaces, etc. It also defines services that provide specific desktop
431703ff 12995environments like GNOME, XFCE or MATE.
aa4ed923 12996
4467be21
LC
12997To simplify things, the module defines a variable containing the set of
12998services that users typically expect on a machine with a graphical
12999environment and networking:
13000
13001@defvr {Scheme Variable} %desktop-services
13002This is a list of services that builds upon @var{%base-services} and
1068f26b 13003adds or adjusts services for a typical ``desktop'' setup.
4467be21
LC
13004
13005In particular, it adds a graphical login manager (@pxref{X Window,
063c6082 13006@code{slim-service}}), screen lockers, a network management tool
4110fbc6 13007(@pxref{Networking Services, @code{network-manager-service-type}}), energy and color
063c6082
AW
13008management services, the @code{elogind} login and seat manager, the
13009Polkit privilege service, the GeoClue location service, the
13010AccountsService daemon that allows authorized users change system
13011passwords, an NTP client (@pxref{Networking Services}), the Avahi
13012daemon, and has the name service switch service configured to be able to
13013use @code{nss-mdns} (@pxref{Name Service Switch, mDNS}).
4467be21
LC
13014@end defvr
13015
13016The @var{%desktop-services} variable can be used as the @code{services}
13017field of an @code{operating-system} declaration (@pxref{operating-system
13018Reference, @code{services}}).
13019
431703ff 13020Additionally, the @code{gnome-desktop-service},
e9d271ed
EF
13021@code{xfce-desktop-service}, @code{mate-desktop-service} and
13022@code{enlightenment-desktop-service-type} procedures can add GNOME, XFCE, MATE
13023and/or Enlightenment to a system. To ``add GNOME'' means that system-level
13024services like the backlight adjustment helpers and the power management
13025utilities are added to the system, extending @code{polkit} and @code{dbus}
7a2413e4
AW
13026appropriately, allowing GNOME to operate with elevated privileges on a
13027limited number of special-purpose system interfaces. Additionally,
13028adding a service made by @code{gnome-desktop-service} adds the GNOME
13029metapackage to the system profile. Likewise, adding the XFCE service
13030not only adds the @code{xfce} metapackage to the system profile, but it
13031also gives the Thunar file manager the ability to open a ``root-mode''
13032file management window, if the user authenticates using the
13033administrator's password via the standard polkit graphical interface.
431703ff 13034To ``add MATE'' means that @code{polkit} and @code{dbus} are extended
13035appropriately, allowing MATE to operate with elevated privileges on a
13036limited number of special-purpose system interfaces. Additionally,
13037adding a service made by @code{mate-desktop-service} adds the MATE
e9d271ed
EF
13038metapackage to the system profile. ``Adding ENLIGHTENMENT'' means that
13039@code{dbus} is extended appropriately, and several of Enlightenment's binaries
13040are set as setuid, allowing Enlightenment's screen locker and other
13041functionality to work as expetected.
7a2413e4 13042
3853f86f
RH
13043The desktop environments in Guix use the Xorg display server by
13044default. If you'd like to use the newer display server protocol
13045called Wayland, you need to use the @code{sddm-service} instead of the
13046@code{slim-service} for the graphical login manager. You should then
75538328
RH
13047select the ``GNOME (Wayland)'' session in SDDM. Alternatively you can
13048also try starting GNOME on Wayland manually from a TTY with the
13049command ``XDG_SESSION_TYPE=wayland exec dbus-run-session
13050gnome-session``. Currently only GNOME has support for Wayland.
3853f86f 13051
7a2413e4
AW
13052@deffn {Scheme Procedure} gnome-desktop-service
13053Return a service that adds the @code{gnome} package to the system
13054profile, and extends polkit with the actions from
13055@code{gnome-settings-daemon}.
13056@end deffn
13057
13058@deffn {Scheme Procedure} xfce-desktop-service
13059Return a service that adds the @code{xfce} package to the system profile,
5741e3e5 13060and extends polkit with the ability for @code{thunar} to manipulate the
7a2413e4
AW
13061file system as root from within a user session, after the user has
13062authenticated with the administrator's password.
13063@end deffn
13064
431703ff 13065@deffn {Scheme Procedure} mate-desktop-service
13066Return a service that adds the @code{mate} package to the system
13067profile, and extends polkit with the actions from
13068@code{mate-settings-daemon}.
13069@end deffn
13070
e9d271ed
EF
13071@deffn {Scheme Procedure} enlightenment-desktop-service-type
13072Return a service that adds the @code{enlightenment} package to the system
13073profile, and extends dbus with actions from @code{efl}.
13074@end deffn
13075
13076@deftp {Data Type} enlightenment-desktop-service-configuration
13077@table @asis
13078@item @code{enlightenment} (default @code{enlightenment})
13079The enlightenment package to use.
13080@end table
13081@end deftp
13082
431703ff 13083Because the GNOME, XFCE and MATE desktop services pull in so many packages,
7017d874 13084the default @code{%desktop-services} variable doesn't include any of
1c27f72f 13085them by default. To add GNOME, XFCE or MATE, just @code{cons} them onto
7a2413e4
AW
13086@code{%desktop-services} in the @code{services} field of your
13087@code{operating-system}:
13088
13089@example
13090(use-modules (gnu))
13091(use-service-modules desktop)
13092(operating-system
13093 ...
13094 ;; cons* adds items to the list given as its last argument.
13095 (services (cons* (gnome-desktop-service)
13096 (xfce-desktop-service)
13097 %desktop-services))
13098 ...)
13099@end example
13100
13101These desktop environments will then be available as options in the
13102graphical login window.
13103
13104The actual service definitions included in @code{%desktop-services} and
13105provided by @code{(gnu services dbus)} and @code{(gnu services desktop)}
13106are described below.
4467be21 13107
0adfe95a 13108@deffn {Scheme Procedure} dbus-service [#:dbus @var{dbus}] [#:services '()]
fe1a39d3
LC
13109Return a service that runs the ``system bus'', using @var{dbus}, with
13110support for @var{services}.
aa4ed923 13111
fe1a39d3
LC
13112@uref{http://dbus.freedesktop.org/, D-Bus} is an inter-process communication
13113facility. Its system bus is used to allow system services to communicate
1068f26b 13114and to be notified of system-wide events.
aa4ed923 13115
fe1a39d3
LC
13116@var{services} must be a list of packages that provide an
13117@file{etc/dbus-1/system.d} directory containing additional D-Bus configuration
13118and policy files. For example, to allow avahi-daemon to use the system bus,
13119@var{services} must be equal to @code{(list avahi)}.
aa4ed923
AK
13120@end deffn
13121
0adfe95a 13122@deffn {Scheme Procedure} elogind-service [#:config @var{config}]
4650a77e 13123Return a service that runs the @code{elogind} login and
acc2ab65 13124seat management daemon. @uref{https://github.com/elogind/elogind,
4650a77e
AW
13125Elogind} exposes a D-Bus interface that can be used to know which users
13126are logged in, know what kind of sessions they have open, suspend the
13127system, inhibit system suspend, reboot the system, and other tasks.
13128
13129Elogind handles most system-level power events for a computer, for
13130example suspending the system when a lid is closed, or shutting it down
13131when the power button is pressed.
13132
13133The @var{config} keyword argument specifies the configuration for
1068f26b 13134elogind, and should be the result of an @code{(elogind-configuration
4650a77e
AW
13135(@var{parameter} @var{value})...)} invocation. Available parameters and
13136their default values are:
13137
13138@table @code
13139@item kill-user-processes?
13140@code{#f}
13141@item kill-only-users
13142@code{()}
13143@item kill-exclude-users
13144@code{("root")}
13145@item inhibit-delay-max-seconds
13146@code{5}
13147@item handle-power-key
13148@code{poweroff}
13149@item handle-suspend-key
13150@code{suspend}
13151@item handle-hibernate-key
13152@code{hibernate}
13153@item handle-lid-switch
13154@code{suspend}
13155@item handle-lid-switch-docked
13156@code{ignore}
13157@item power-key-ignore-inhibited?
13158@code{#f}
13159@item suspend-key-ignore-inhibited?
13160@code{#f}
13161@item hibernate-key-ignore-inhibited?
13162@code{#f}
13163@item lid-switch-ignore-inhibited?
13164@code{#t}
13165@item holdoff-timeout-seconds
13166@code{30}
13167@item idle-action
13168@code{ignore}
13169@item idle-action-seconds
13170@code{(* 30 60)}
13171@item runtime-directory-size-percent
13172@code{10}
13173@item runtime-directory-size
13174@code{#f}
13175@item remove-ipc?
13176@code{#t}
13177@item suspend-state
13178@code{("mem" "standby" "freeze")}
13179@item suspend-mode
13180@code{()}
13181@item hibernate-state
13182@code{("disk")}
13183@item hibernate-mode
13184@code{("platform" "shutdown")}
13185@item hybrid-sleep-state
13186@code{("disk")}
13187@item hybrid-sleep-mode
13188@code{("suspend" "platform" "shutdown")}
13189@end table
13190@end deffn
13191
063c6082
AW
13192@deffn {Scheme Procedure} accountsservice-service @
13193 [#:accountsservice @var{accountsservice}]
13194Return a service that runs AccountsService, a system service that can
13195list available accounts, change their passwords, and so on.
13196AccountsService integrates with PolicyKit to enable unprivileged users
13197to acquire the capability to modify their system configuration.
13198@uref{https://www.freedesktop.org/wiki/Software/AccountsService/, the
13199accountsservice web site} for more information.
13200
13201The @var{accountsservice} keyword argument is the @code{accountsservice}
13202package to expose as a service.
13203@end deffn
13204
be1c2c54 13205@deffn {Scheme Procedure} polkit-service @
4650a77e 13206 [#:polkit @var{polkit}]
222e3319
LC
13207Return a service that runs the
13208@uref{http://www.freedesktop.org/wiki/Software/polkit/, Polkit privilege
13209management service}, which allows system administrators to grant access to
13210privileged operations in a structured way. By querying the Polkit service, a
13211privileged system component can know when it should grant additional
13212capabilities to ordinary users. For example, an ordinary user can be granted
13213the capability to suspend the system if the user is logged in locally.
4650a77e
AW
13214@end deffn
13215
be1c2c54 13216@deffn {Scheme Procedure} upower-service [#:upower @var{upower}] @
be234128
AW
13217 [#:watts-up-pro? #f] @
13218 [#:poll-batteries? #t] @
13219 [#:ignore-lid? #f] @
13220 [#:use-percentage-for-policy? #f] @
13221 [#:percentage-low 10] @
13222 [#:percentage-critical 3] @
13223 [#:percentage-action 2] @
13224 [#:time-low 1200] @
13225 [#:time-critical 300] @
13226 [#:time-action 120] @
13227 [#:critical-power-action 'hybrid-sleep]
13228Return a service that runs @uref{http://upower.freedesktop.org/,
13229@command{upowerd}}, a system-wide monitor for power consumption and battery
13230levels, with the given configuration settings. It implements the
13231@code{org.freedesktop.UPower} D-Bus interface, and is notably used by
13232GNOME.
13233@end deffn
13234
2b9e0a94
LC
13235@deffn {Scheme Procedure} udisks-service [#:udisks @var{udisks}]
13236Return a service for @uref{http://udisks.freedesktop.org/docs/latest/,
13237UDisks}, a @dfn{disk management} daemon that provides user interfaces with
13238notifications and ways to mount/unmount disks. Programs that talk to UDisks
13239include the @command{udisksctl} command, part of UDisks, and GNOME Disks.
13240@end deffn
13241
be1c2c54 13242@deffn {Scheme Procedure} colord-service [#:colord @var{colord}]
7ce597ff
AW
13243Return a service that runs @command{colord}, a system service with a D-Bus
13244interface to manage the color profiles of input and output devices such as
13245screens and scanners. It is notably used by the GNOME Color Manager graphical
13246tool. See @uref{http://www.freedesktop.org/software/colord/, the colord web
13247site} for more information.
13248@end deffn
13249
cee32ee4 13250@deffn {Scheme Procedure} geoclue-application name [#:allowed? #t] [#:system? #f] [#:users '()]
1068f26b 13251Return a configuration allowing an application to access GeoClue
cee32ee4
AW
13252location data. @var{name} is the Desktop ID of the application, without
13253the @code{.desktop} part. If @var{allowed?} is true, the application
13254will have access to location information by default. The boolean
1068f26b 13255@var{system?} value indicates whether an application is a system component
cee32ee4
AW
13256or not. Finally @var{users} is a list of UIDs of all users for which
13257this application is allowed location info access. An empty users list
13258means that all users are allowed.
13259@end deffn
13260
13261@defvr {Scheme Variable} %standard-geoclue-applications
13262The standard list of well-known GeoClue application configurations,
1068f26b
AE
13263granting authority to the GNOME date-and-time utility to ask for the
13264current location in order to set the time zone, and allowing the
13265IceCat and Epiphany web browsers to request location information.
13266IceCat and Epiphany both query the user before allowing a web page to
cee32ee4
AW
13267know the user's location.
13268@end defvr
13269
be1c2c54 13270@deffn {Scheme Procedure} geoclue-service [#:colord @var{colord}] @
cee32ee4
AW
13271 [#:whitelist '()] @
13272 [#:wifi-geolocation-url "https://location.services.mozilla.com/v1/geolocate?key=geoclue"] @
13273 [#:submit-data? #f]
13274 [#:wifi-submission-url "https://location.services.mozilla.com/v1/submit?key=geoclue"] @
13275 [#:submission-nick "geoclue"] @
13276 [#:applications %standard-geoclue-applications]
13277Return a service that runs the GeoClue location service. This service
13278provides a D-Bus interface to allow applications to request access to a
13279user's physical location, and optionally to add information to online
13280location databases. See
13281@uref{https://wiki.freedesktop.org/www/Software/GeoClue/, the GeoClue
13282web site} for more information.
13283@end deffn
13284
b9f67d6d
MC
13285@deffn {Scheme Procedure} bluetooth-service [#:bluez @var{bluez}] @
13286 [@w{#:auto-enable? #f}]
13287Return a service that runs the @command{bluetoothd} daemon, which
13288manages all the Bluetooth devices and provides a number of D-Bus
13289interfaces. When AUTO-ENABLE? is true, the bluetooth controller is
13290powered automatically at boot, which can be useful when using a
13291bluetooth keyboard or mouse.
922e21f4
SB
13292
13293Users need to be in the @code{lp} group to access the D-Bus service.
13294@end deffn
13295
8cd1e8e8
OP
13296@node Sound Services
13297@subsubsection Sound Services
13298
13299@cindex sound support
13300@cindex ALSA
13301@cindex PulseAudio, sound support
13302
6d91a469
SB
13303The @code{(gnu services sound)} module provides a service to configure the
13304Advanced Linux Sound Architecture (ALSA) system, which making PulseAudio the
13305prefered ALSA output driver.
8cd1e8e8
OP
13306
13307@deffn {Scheme Variable} alsa-service-type
6d91a469
SB
13308This is the type for the @uref{https://alsa-project.org/, Advanced Linux Sound
13309Architecture} (ALSA) system, which generates the @file{/etc/asound.conf}
13310configuration file. The value for this type is a @command{alsa-configuration}
13311record as in this example:
8cd1e8e8
OP
13312
13313@example
13314(service alsa-service-type)
13315@end example
13316
13317See below for details about @code{alsa-configuration}.
13318@end deffn
13319
13320@deftp {Data Type} alsa-configuration
13321Data type representing the configuration for @code{alsa-service}.
13322
13323@table @asis
1e3861eb
OP
13324@item @code{alsa-plugins} (default: @var{alsa-plugins})
13325@code{alsa-plugins} package to use.
13326
8cd1e8e8
OP
13327@item @code{pulseaudio?} (default: @var{#t})
13328Whether ALSA applications should transparently be made to use the
13329@uref{http://www.pulseaudio.org/, PulseAudio} sound server.
13330
13331Using PulseAudio allows you to run several sound-producing applications
13332at the same time and to individual control them @i{via}
13333@command{pavucontrol}, among other things.
13334
13335@item @code{extra-options} (default: @var{""})
6d91a469 13336String to append to the @file{/etc/asound.conf} file.
8cd1e8e8
OP
13337
13338@end table
13339@end deftp
13340
6d91a469
SB
13341Individual users who want to override the system configuration of ALSA can do
13342it with the @file{~/.asoundrc} file:
13343
13344@example
13345# In guix, we have to specify the absolute path for plugins.
13346pcm_type.jack @{
13347 lib "/home/alice/.guix-profile/lib/alsa-lib/libasound_module_pcm_jack.so"
13348@}
13349
13350# Routing ALSA to jack:
13351# <http://jackaudio.org/faq/routing_alsa.html>.
13352pcm.rawjack @{
13353 type jack
13354 playback_ports @{
13355 0 system:playback_1
13356 1 system:playback_2
13357 @}
13358
13359 capture_ports @{
13360 0 system:capture_1
13361 1 system:capture_2
13362 @}
13363@}
13364
13365pcm.!default @{
13366 type plug
13367 slave @{
13368 pcm "rawjack"
13369 @}
13370@}
13371@end example
13372
13373See @uref{https://www.alsa-project.org/main/index.php/Asoundrc} for the
13374details.
13375
13376
105369a4
DT
13377@node Database Services
13378@subsubsection Database Services
13379
e32171ee
JD
13380@cindex database
13381@cindex SQL
6575183b 13382The @code{(gnu services databases)} module provides the following services.
105369a4 13383
be1c2c54 13384@deffn {Scheme Procedure} postgresql-service [#:postgresql postgresql] @
2d3d5cc5 13385 [#:config-file] [#:data-directory ``/var/lib/postgresql/data''] @
0d57a50a 13386 [#:port 5432] [#:locale ``en_US.utf8''] [#:extension-packages '()]
105369a4
DT
13387Return a service that runs @var{postgresql}, the PostgreSQL database
13388server.
13389
e05b780a
CB
13390The PostgreSQL daemon loads its runtime configuration from @var{config-file},
13391creates a database cluster with @var{locale} as the default
13392locale, stored in @var{data-directory}. It then listens on @var{port}.
0d57a50a
JL
13393
13394@cindex postgresql extension-packages
13395Additional extensions are loaded from packages listed in
13396@var{extension-packages}. Extensions are available at runtime. For instance,
13397to create a geographic database using the @code{postgis} extension, a user can
13398configure the postgresql-service as in this example:
13399
13400@cindex postgis
13401@example
13402(use-package-modules databases geo)
13403
13404(operating-system
13405 ...
13406 ;; postgresql is required to run `psql' but postgis is not required for
13407 ;; proper operation.
13408 (packages (cons* postgresql %base-packages))
13409 (services
13410 (cons*
13411 (postgresql-service #:extension-packages (list postgis))
13412 %base-services)))
13413@end example
13414
13415Then the extension becomes visible and you can initialise an empty geographic
13416database in this way:
13417
13418@example
13419psql -U postgres
13420> create database postgistest;
13421> \connect postgistest;
13422> create extension postgis;
13423> create extension postgis_topology;
13424@end example
13425
13426There is no need to add this field for contrib extensions such as hstore or
13427dblink as they are already loadable by postgresql. This field is only
13428required to add extensions provided by other packages.
105369a4 13429@end deffn
fe1a39d3 13430
6575183b
SB
13431@deffn {Scheme Procedure} mysql-service [#:config (mysql-configuration)]
13432Return a service that runs @command{mysqld}, the MySQL or MariaDB
13433database server.
13434
13435The optional @var{config} argument specifies the configuration for
c940b8e6 13436@command{mysqld}, which should be a @code{<mysql-configuration>} object.
6575183b
SB
13437@end deffn
13438
13439@deftp {Data Type} mysql-configuration
13440Data type representing the configuration of @var{mysql-service}.
13441
13442@table @asis
13443@item @code{mysql} (default: @var{mariadb})
13444Package object of the MySQL database server, can be either @var{mariadb}
13445or @var{mysql}.
13446
7414de0a 13447For MySQL, a temporary root password will be displayed at activation time.
6575183b 13448For MariaDB, the root password is empty.
4b41febf
CB
13449
13450@item @code{port} (default: @code{3306})
13451TCP port on which the database server listens for incoming connections.
6575183b
SB
13452@end table
13453@end deftp
13454
119fdd0d
CB
13455@defvr {Scheme Variable} memcached-service-type
13456This is the service type for the @uref{https://memcached.org/,
13457Memcached} service, which provides a distributed in memory cache. The
13458value for the service type is a @code{memcached-configuration} object.
13459@end defvr
13460
13461@example
13462(service memcached-service-type)
13463@end example
13464
13465@deftp {Data Type} memcached-configuration
13466Data type representing the configuration of memcached.
13467
13468@table @asis
13469@item @code{memcached} (default: @code{memcached})
13470The Memcached package to use.
13471
13472@item @code{interfaces} (default: @code{'("0.0.0.0")})
13473Network interfaces on which to listen.
13474
13475@item @code{tcp-port} (default: @code{11211})
13476Port on which to accept connections on,
13477
13478@item @code{udp-port} (default: @code{11211})
13479Port on which to accept UDP connections on, a value of 0 will disable
13480listening on a UDP socket.
13481
13482@item @code{additional-options} (default: @code{'()})
13483Additional command line options to pass to @code{memcached}.
13484@end table
13485@end deftp
13486
5266ff71
CB
13487@defvr {Scheme Variable} mongodb-service-type
13488This is the service type for @uref{https://www.mongodb.com/, MongoDB}.
13489The value for the service type is a @code{mongodb-configuration} object.
13490@end defvr
13491
13492@example
13493(service mongodb-service-type)
13494@end example
13495
13496@deftp {Data Type} mongodb-configuration
13497Data type representing the configuration of mongodb.
13498
13499@table @asis
13500@item @code{mongodb} (default: @code{mongodb})
13501The MongoDB package to use.
13502
13503@item @code{config-file} (default: @code{%default-mongodb-configuration-file})
13504The configuration file for MongoDB.
13505
13506@item @code{data-directory} (default: @code{"/var/lib/mongodb"})
13507This value is used to create the directory, so that it exists and is
13508owned by the mongodb user. It should match the data-directory which
13509MongoDB is configured to use through the configuration file.
13510@end table
13511@end deftp
13512
67cadaca
CB
13513@defvr {Scheme Variable} redis-service-type
13514This is the service type for the @uref{https://redis.io/, Redis}
13515key/value store, whose value is a @code{redis-configuration} object.
13516@end defvr
13517
13518@deftp {Data Type} redis-configuration
13519Data type representing the configuration of redis.
13520
13521@table @asis
13522@item @code{redis} (default: @code{redis})
13523The Redis package to use.
13524
13525@item @code{bind} (default: @code{"127.0.0.1"})
13526Network interface on which to listen.
13527
13528@item @code{port} (default: @code{6379})
13529Port on which to accept connections on, a value of 0 will disable
9fc221b5 13530listening on a TCP socket.
67cadaca
CB
13531
13532@item @code{working-directory} (default: @code{"/var/lib/redis"})
13533Directory in which to store the database and related files.
13534@end table
13535@end deftp
13536
d8c18af8
AW
13537@node Mail Services
13538@subsubsection Mail Services
13539
e32171ee
JD
13540@cindex mail
13541@cindex email
d8c18af8 13542The @code{(gnu services mail)} module provides Guix service definitions
f88371e8
SB
13543for email services: IMAP, POP3, and LMTP servers, as well as mail
13544transport agents (MTAs). Lots of acronyms! These services are detailed
13545in the subsections below.
d8c18af8 13546
f88371e8 13547@subsubheading Dovecot Service
d8c18af8
AW
13548
13549@deffn {Scheme Procedure} dovecot-service [#:config (dovecot-configuration)]
13550Return a service that runs the Dovecot IMAP/POP3/LMTP mail server.
13551@end deffn
13552
1068f26b 13553By default, Dovecot does not need much configuration; the default
d8c18af8
AW
13554configuration object created by @code{(dovecot-configuration)} will
13555suffice if your mail is delivered to @code{~/Maildir}. A self-signed
13556certificate will be generated for TLS-protected connections, though
13557Dovecot will also listen on cleartext ports by default. There are a
1068f26b 13558number of options, though, which mail administrators might need to change,
d8c18af8
AW
13559and as is the case with other services, Guix allows the system
13560administrator to specify these parameters via a uniform Scheme interface.
13561
13562For example, to specify that mail is located at @code{maildir~/.mail},
13563one would instantiate the Dovecot service like this:
13564
13565@example
13566(dovecot-service #:config
13567 (dovecot-configuration
13568 (mail-location "maildir:~/.mail")))
13569@end example
13570
13571The available configuration parameters follow. Each parameter
13572definition is preceded by its type; for example, @samp{string-list foo}
13573indicates that the @code{foo} parameter should be specified as a list of
13574strings. There is also a way to specify the configuration as a string,
13575if you have an old @code{dovecot.conf} file that you want to port over
13576from some other system; see the end for more details.
13577
13578@c The following documentation was initially generated by
13579@c (generate-documentation) in (gnu services mail). Manually maintained
13580@c documentation is better, so we shouldn't hesitate to edit below as
13581@c needed. However if the change you want to make to this documentation
13582@c can be done in an automated way, it's probably easier to change
13583@c (generate-documentation) than to make it below and have to deal with
13584@c the churn as dovecot updates.
13585
13586Available @code{dovecot-configuration} fields are:
13587
13588@deftypevr {@code{dovecot-configuration} parameter} package dovecot
13589The dovecot package.
13590@end deftypevr
13591
13592@deftypevr {@code{dovecot-configuration} parameter} comma-separated-string-list listen
1068f26b
AE
13593A list of IPs or hosts where to listen for connections. @samp{*}
13594listens on all IPv4 interfaces, @samp{::} listens on all IPv6
d8c18af8
AW
13595interfaces. If you want to specify non-default ports or anything more
13596complex, customize the address and port fields of the
13597@samp{inet-listener} of the specific services you are interested in.
13598@end deftypevr
13599
13600@deftypevr {@code{dovecot-configuration} parameter} protocol-configuration-list protocols
13601List of protocols we want to serve. Available protocols include
13602@samp{imap}, @samp{pop3}, and @samp{lmtp}.
13603
13604Available @code{protocol-configuration} fields are:
13605
13606@deftypevr {@code{protocol-configuration} parameter} string name
13607The name of the protocol.
13608@end deftypevr
13609
13610@deftypevr {@code{protocol-configuration} parameter} string auth-socket-path
1068f26b 13611UNIX socket path to the master authentication server to find users.
d8c18af8 13612This is used by imap (for shared users) and lda.
1068f26b 13613It defaults to @samp{"/var/run/dovecot/auth-userdb"}.
d8c18af8
AW
13614@end deftypevr
13615
13616@deftypevr {@code{protocol-configuration} parameter} space-separated-string-list mail-plugins
13617Space separated list of plugins to load.
13618@end deftypevr
13619
13620@deftypevr {@code{protocol-configuration} parameter} non-negative-integer mail-max-userip-connections
13621Maximum number of IMAP connections allowed for a user from each IP
13622address. NOTE: The username is compared case-sensitively.
13623Defaults to @samp{10}.
13624@end deftypevr
13625
13626@end deftypevr
13627
13628@deftypevr {@code{dovecot-configuration} parameter} service-configuration-list services
13629List of services to enable. Available services include @samp{imap},
13630@samp{imap-login}, @samp{pop3}, @samp{pop3-login}, @samp{auth}, and
13631@samp{lmtp}.
13632
13633Available @code{service-configuration} fields are:
13634
13635@deftypevr {@code{service-configuration} parameter} string kind
13636The service kind. Valid values include @code{director},
13637@code{imap-login}, @code{pop3-login}, @code{lmtp}, @code{imap},
13638@code{pop3}, @code{auth}, @code{auth-worker}, @code{dict},
13639@code{tcpwrap}, @code{quota-warning}, or anything else.
13640@end deftypevr
13641
13642@deftypevr {@code{service-configuration} parameter} listener-configuration-list listeners
1068f26b 13643Listeners for the service. A listener is either a
d8c18af8
AW
13644@code{unix-listener-configuration}, a @code{fifo-listener-configuration}, or
13645an @code{inet-listener-configuration}.
13646Defaults to @samp{()}.
13647
13648Available @code{unix-listener-configuration} fields are:
13649
eba56076
CL
13650@deftypevr {@code{unix-listener-configuration} parameter} string path
13651Path to the file, relative to @code{base-dir} field. This is also used as
13652the section name.
d8c18af8
AW
13653@end deftypevr
13654
13655@deftypevr {@code{unix-listener-configuration} parameter} string mode
13656The access mode for the socket.
13657Defaults to @samp{"0600"}.
13658@end deftypevr
13659
13660@deftypevr {@code{unix-listener-configuration} parameter} string user
f9b9a033 13661The user to own the socket.
d8c18af8
AW
13662Defaults to @samp{""}.
13663@end deftypevr
13664
13665@deftypevr {@code{unix-listener-configuration} parameter} string group
13666The group to own the socket.
13667Defaults to @samp{""}.
13668@end deftypevr
13669
13670
13671Available @code{fifo-listener-configuration} fields are:
13672
eba56076
CL
13673@deftypevr {@code{fifo-listener-configuration} parameter} string path
13674Path to the file, relative to @code{base-dir} field. This is also used as
13675the section name.
d8c18af8
AW
13676@end deftypevr
13677
13678@deftypevr {@code{fifo-listener-configuration} parameter} string mode
13679The access mode for the socket.
13680Defaults to @samp{"0600"}.
13681@end deftypevr
13682
13683@deftypevr {@code{fifo-listener-configuration} parameter} string user
f9b9a033 13684The user to own the socket.
d8c18af8
AW
13685Defaults to @samp{""}.
13686@end deftypevr
13687
13688@deftypevr {@code{fifo-listener-configuration} parameter} string group
13689The group to own the socket.
13690Defaults to @samp{""}.
13691@end deftypevr
13692
13693
13694Available @code{inet-listener-configuration} fields are:
13695
13696@deftypevr {@code{inet-listener-configuration} parameter} string protocol
13697The protocol to listen for.
13698@end deftypevr
13699
13700@deftypevr {@code{inet-listener-configuration} parameter} string address
13701The address on which to listen, or empty for all addresses.
13702Defaults to @samp{""}.
13703@end deftypevr
13704
13705@deftypevr {@code{inet-listener-configuration} parameter} non-negative-integer port
13706The port on which to listen.
13707@end deftypevr
13708
13709@deftypevr {@code{inet-listener-configuration} parameter} boolean ssl?
13710Whether to use SSL for this service; @samp{yes}, @samp{no}, or
13711@samp{required}.
13712Defaults to @samp{#t}.
13713@end deftypevr
13714
13715@end deftypevr
13716
13717@deftypevr {@code{service-configuration} parameter} non-negative-integer service-count
13718Number of connections to handle before starting a new process.
13719Typically the only useful values are 0 (unlimited) or 1. 1 is more
13720secure, but 0 is faster. <doc/wiki/LoginProcess.txt>.
13721Defaults to @samp{1}.
13722@end deftypevr
13723
13724@deftypevr {@code{service-configuration} parameter} non-negative-integer process-min-avail
13725Number of processes to always keep waiting for more connections.
13726Defaults to @samp{0}.
13727@end deftypevr
13728
13729@deftypevr {@code{service-configuration} parameter} non-negative-integer vsz-limit
13730If you set @samp{service-count 0}, you probably need to grow
13731this.
13732Defaults to @samp{256000000}.
13733@end deftypevr
13734
13735@end deftypevr
13736
13737@deftypevr {@code{dovecot-configuration} parameter} dict-configuration dict
13738Dict configuration, as created by the @code{dict-configuration}
13739constructor.
13740
13741Available @code{dict-configuration} fields are:
13742
13743@deftypevr {@code{dict-configuration} parameter} free-form-fields entries
13744A list of key-value pairs that this dict should hold.
13745Defaults to @samp{()}.
13746@end deftypevr
13747
13748@end deftypevr
13749
13750@deftypevr {@code{dovecot-configuration} parameter} passdb-configuration-list passdbs
1068f26b 13751A list of passdb configurations, each one created by the
d8c18af8
AW
13752@code{passdb-configuration} constructor.
13753
13754Available @code{passdb-configuration} fields are:
13755
13756@deftypevr {@code{passdb-configuration} parameter} string driver
13757The driver that the passdb should use. Valid values include
13758@samp{pam}, @samp{passwd}, @samp{shadow}, @samp{bsdauth}, and
13759@samp{static}.
13760Defaults to @samp{"pam"}.
13761@end deftypevr
13762
deb36188
CL
13763@deftypevr {@code{passdb-configuration} parameter} space-separated-string-list args
13764Space separated list of arguments to the passdb driver.
13765Defaults to @samp{""}.
d8c18af8
AW
13766@end deftypevr
13767
13768@end deftypevr
13769
13770@deftypevr {@code{dovecot-configuration} parameter} userdb-configuration-list userdbs
13771List of userdb configurations, each one created by the
13772@code{userdb-configuration} constructor.
13773
13774Available @code{userdb-configuration} fields are:
13775
13776@deftypevr {@code{userdb-configuration} parameter} string driver
13777The driver that the userdb should use. Valid values include
13778@samp{passwd} and @samp{static}.
13779Defaults to @samp{"passwd"}.
13780@end deftypevr
13781
deb36188
CL
13782@deftypevr {@code{userdb-configuration} parameter} space-separated-string-list args
13783Space separated list of arguments to the userdb driver.
13784Defaults to @samp{""}.
d8c18af8
AW
13785@end deftypevr
13786
13787@deftypevr {@code{userdb-configuration} parameter} free-form-args override-fields
13788Override fields from passwd.
13789Defaults to @samp{()}.
13790@end deftypevr
13791
13792@end deftypevr
13793
13794@deftypevr {@code{dovecot-configuration} parameter} plugin-configuration plugin-configuration
13795Plug-in configuration, created by the @code{plugin-configuration}
13796constructor.
13797@end deftypevr
13798
13799@deftypevr {@code{dovecot-configuration} parameter} list-of-namespace-configuration namespaces
13800List of namespaces. Each item in the list is created by the
13801@code{namespace-configuration} constructor.
13802
13803Available @code{namespace-configuration} fields are:
13804
13805@deftypevr {@code{namespace-configuration} parameter} string name
13806Name for this namespace.
13807@end deftypevr
13808
13809@deftypevr {@code{namespace-configuration} parameter} string type
13810Namespace type: @samp{private}, @samp{shared} or @samp{public}.
13811Defaults to @samp{"private"}.
13812@end deftypevr
13813
13814@deftypevr {@code{namespace-configuration} parameter} string separator
13815Hierarchy separator to use. You should use the same separator for
13816all namespaces or some clients get confused. @samp{/} is usually a good
13817one. The default however depends on the underlying mail storage
13818format.
13819Defaults to @samp{""}.
13820@end deftypevr
13821
13822@deftypevr {@code{namespace-configuration} parameter} string prefix
13823Prefix required to access this namespace. This needs to be
13824different for all namespaces. For example @samp{Public/}.
13825Defaults to @samp{""}.
13826@end deftypevr
13827
13828@deftypevr {@code{namespace-configuration} parameter} string location
1068f26b 13829Physical location of the mailbox. This is in the same format as
d8c18af8
AW
13830mail_location, which is also the default for it.
13831Defaults to @samp{""}.
13832@end deftypevr
13833
13834@deftypevr {@code{namespace-configuration} parameter} boolean inbox?
13835There can be only one INBOX, and this setting defines which
13836namespace has it.
13837Defaults to @samp{#f}.
13838@end deftypevr
13839
13840@deftypevr {@code{namespace-configuration} parameter} boolean hidden?
13841If namespace is hidden, it's not advertised to clients via NAMESPACE
13842extension. You'll most likely also want to set @samp{list? #f}. This is mostly
13843useful when converting from another server with different namespaces
13844which you want to deprecate but still keep working. For example you can
13845create hidden namespaces with prefixes @samp{~/mail/}, @samp{~%u/mail/}
13846and @samp{mail/}.
13847Defaults to @samp{#f}.
13848@end deftypevr
13849
13850@deftypevr {@code{namespace-configuration} parameter} boolean list?
1068f26b
AE
13851Show the mailboxes under this namespace with the LIST command. This
13852makes the namespace visible for clients that do not support the NAMESPACE
d8c18af8
AW
13853extension. The special @code{children} value lists child mailboxes, but
13854hides the namespace prefix.
13855Defaults to @samp{#t}.
13856@end deftypevr
13857
13858@deftypevr {@code{namespace-configuration} parameter} boolean subscriptions?
13859Namespace handles its own subscriptions. If set to @code{#f}, the
13860parent namespace handles them. The empty prefix should always have this
1068f26b 13861as @code{#t}).
d8c18af8
AW
13862Defaults to @samp{#t}.
13863@end deftypevr
13864
13865@deftypevr {@code{namespace-configuration} parameter} mailbox-configuration-list mailboxes
13866List of predefined mailboxes in this namespace.
13867Defaults to @samp{()}.
13868
13869Available @code{mailbox-configuration} fields are:
13870
13871@deftypevr {@code{mailbox-configuration} parameter} string name
13872Name for this mailbox.
13873@end deftypevr
13874
13875@deftypevr {@code{mailbox-configuration} parameter} string auto
13876@samp{create} will automatically create this mailbox.
13877@samp{subscribe} will both create and subscribe to the mailbox.
13878Defaults to @samp{"no"}.
13879@end deftypevr
13880
13881@deftypevr {@code{mailbox-configuration} parameter} space-separated-string-list special-use
13882List of IMAP @code{SPECIAL-USE} attributes as specified by RFC 6154.
13883Valid values are @code{\All}, @code{\Archive}, @code{\Drafts},
13884@code{\Flagged}, @code{\Junk}, @code{\Sent}, and @code{\Trash}.
13885Defaults to @samp{()}.
13886@end deftypevr
13887
13888@end deftypevr
13889
13890@end deftypevr
13891
13892@deftypevr {@code{dovecot-configuration} parameter} file-name base-dir
13893Base directory where to store runtime data.
13894Defaults to @samp{"/var/run/dovecot/"}.
13895@end deftypevr
13896
13897@deftypevr {@code{dovecot-configuration} parameter} string login-greeting
13898Greeting message for clients.
13899Defaults to @samp{"Dovecot ready."}.
13900@end deftypevr
13901
13902@deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list login-trusted-networks
13903List of trusted network ranges. Connections from these IPs are
13904allowed to override their IP addresses and ports (for logging and for
13905authentication checks). @samp{disable-plaintext-auth} is also ignored
1068f26b 13906for these networks. Typically you would specify your IMAP proxy servers
d8c18af8
AW
13907here.
13908Defaults to @samp{()}.
13909@end deftypevr
13910
13911@deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list login-access-sockets
13912List of login access check sockets (e.g. tcpwrap).
13913Defaults to @samp{()}.
13914@end deftypevr
13915
13916@deftypevr {@code{dovecot-configuration} parameter} boolean verbose-proctitle?
13917Show more verbose process titles (in ps). Currently shows user name
1068f26b
AE
13918and IP address. Useful for seeing who is actually using the IMAP
13919processes (e.g. shared mailboxes or if the same uid is used for multiple
d8c18af8
AW
13920accounts).
13921Defaults to @samp{#f}.
13922@end deftypevr
13923
13924@deftypevr {@code{dovecot-configuration} parameter} boolean shutdown-clients?
13925Should all processes be killed when Dovecot master process shuts down.
13926Setting this to @code{#f} means that Dovecot can be upgraded without
13927forcing existing client connections to close (although that could also
1068f26b 13928be a problem if the upgrade is e.g. due to a security fix).
d8c18af8
AW
13929Defaults to @samp{#t}.
13930@end deftypevr
13931
13932@deftypevr {@code{dovecot-configuration} parameter} non-negative-integer doveadm-worker-count
13933If non-zero, run mail commands via this many connections to doveadm
13934server, instead of running them directly in the same process.
13935Defaults to @samp{0}.
13936@end deftypevr
13937
13938@deftypevr {@code{dovecot-configuration} parameter} string doveadm-socket-path
13939UNIX socket or host:port used for connecting to doveadm server.
13940Defaults to @samp{"doveadm-server"}.
13941@end deftypevr
13942
13943@deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list import-environment
13944List of environment variables that are preserved on Dovecot startup
13945and passed down to all of its child processes. You can also give
13946key=value pairs to always set specific settings.
13947@end deftypevr
13948
13949@deftypevr {@code{dovecot-configuration} parameter} boolean disable-plaintext-auth?
13950Disable LOGIN command and all other plaintext authentications unless
13951SSL/TLS is used (LOGINDISABLED capability). Note that if the remote IP
13952matches the local IP (i.e. you're connecting from the same computer),
13953the connection is considered secure and plaintext authentication is
13954allowed. See also ssl=required setting.
13955Defaults to @samp{#t}.
13956@end deftypevr
13957
13958@deftypevr {@code{dovecot-configuration} parameter} non-negative-integer auth-cache-size
13959Authentication cache size (e.g. @samp{#e10e6}). 0 means it's disabled.
13960Note that bsdauth, PAM and vpopmail require @samp{cache-key} to be set
13961for caching to be used.
13962Defaults to @samp{0}.
13963@end deftypevr
13964
13965@deftypevr {@code{dovecot-configuration} parameter} string auth-cache-ttl
13966Time to live for cached data. After TTL expires the cached record
13967is no longer used, *except* if the main database lookup returns internal
13968failure. We also try to handle password changes automatically: If
13969user's previous authentication was successful, but this one wasn't, the
13970cache isn't used. For now this works only with plaintext
13971authentication.
13972Defaults to @samp{"1 hour"}.
13973@end deftypevr
13974
13975@deftypevr {@code{dovecot-configuration} parameter} string auth-cache-negative-ttl
13976TTL for negative hits (user not found, password mismatch).
139770 disables caching them completely.
13978Defaults to @samp{"1 hour"}.
13979@end deftypevr
13980
13981@deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list auth-realms
13982List of realms for SASL authentication mechanisms that need them.
13983You can leave it empty if you don't want to support multiple realms.
13984Many clients simply use the first one listed here, so keep the default
13985realm first.
13986Defaults to @samp{()}.
13987@end deftypevr
13988
13989@deftypevr {@code{dovecot-configuration} parameter} string auth-default-realm
13990Default realm/domain to use if none was specified. This is used for
13991both SASL realms and appending @@domain to username in plaintext
13992logins.
13993Defaults to @samp{""}.
13994@end deftypevr
13995
13996@deftypevr {@code{dovecot-configuration} parameter} string auth-username-chars
13997List of allowed characters in username. If the user-given username
13998contains a character not listed in here, the login automatically fails.
13999This is just an extra check to make sure user can't exploit any
14000potential quote escaping vulnerabilities with SQL/LDAP databases. If
14001you want to allow all characters, set this value to empty.
14002Defaults to @samp{"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890.-_@@"}.
14003@end deftypevr
14004
14005@deftypevr {@code{dovecot-configuration} parameter} string auth-username-translation
14006Username character translations before it's looked up from
14007databases. The value contains series of from -> to characters. For
14008example @samp{#@@/@@} means that @samp{#} and @samp{/} characters are
14009translated to @samp{@@}.
14010Defaults to @samp{""}.
14011@end deftypevr
14012
14013@deftypevr {@code{dovecot-configuration} parameter} string auth-username-format
14014Username formatting before it's looked up from databases. You can
14015use the standard variables here, e.g. %Lu would lowercase the username,
14016%n would drop away the domain if it was given, or @samp{%n-AT-%d} would
14017change the @samp{@@} into @samp{-AT-}. This translation is done after
14018@samp{auth-username-translation} changes.
14019Defaults to @samp{"%Lu"}.
14020@end deftypevr
14021
14022@deftypevr {@code{dovecot-configuration} parameter} string auth-master-user-separator
14023If you want to allow master users to log in by specifying the master
14024username within the normal username string (i.e. not using SASL
14025mechanism's support for it), you can specify the separator character
14026here. The format is then <username><separator><master username>.
14027UW-IMAP uses @samp{*} as the separator, so that could be a good
14028choice.
14029Defaults to @samp{""}.
14030@end deftypevr
14031
14032@deftypevr {@code{dovecot-configuration} parameter} string auth-anonymous-username
14033Username to use for users logging in with ANONYMOUS SASL
14034mechanism.
14035Defaults to @samp{"anonymous"}.
14036@end deftypevr
14037
14038@deftypevr {@code{dovecot-configuration} parameter} non-negative-integer auth-worker-max-count
14039Maximum number of dovecot-auth worker processes. They're used to
14040execute blocking passdb and userdb queries (e.g. MySQL and PAM).
14041They're automatically created and destroyed as needed.
14042Defaults to @samp{30}.
14043@end deftypevr
14044
14045@deftypevr {@code{dovecot-configuration} parameter} string auth-gssapi-hostname
14046Host name to use in GSSAPI principal names. The default is to use
14047the name returned by gethostname(). Use @samp{$ALL} (with quotes) to
14048allow all keytab entries.
14049Defaults to @samp{""}.
14050@end deftypevr
14051
14052@deftypevr {@code{dovecot-configuration} parameter} string auth-krb5-keytab
14053Kerberos keytab to use for the GSSAPI mechanism. Will use the
8b499030 14054system default (usually @file{/etc/krb5.keytab}) if not specified. You may
d8c18af8
AW
14055need to change the auth service to run as root to be able to read this
14056file.
14057Defaults to @samp{""}.
14058@end deftypevr
14059
14060@deftypevr {@code{dovecot-configuration} parameter} boolean auth-use-winbind?
14061Do NTLM and GSS-SPNEGO authentication using Samba's winbind daemon
14062and @samp{ntlm-auth} helper.
14063<doc/wiki/Authentication/Mechanisms/Winbind.txt>.
14064Defaults to @samp{#f}.
14065@end deftypevr
14066
14067@deftypevr {@code{dovecot-configuration} parameter} file-name auth-winbind-helper-path
14068Path for Samba's @samp{ntlm-auth} helper binary.
14069Defaults to @samp{"/usr/bin/ntlm_auth"}.
14070@end deftypevr
14071
14072@deftypevr {@code{dovecot-configuration} parameter} string auth-failure-delay
14073Time to delay before replying to failed authentications.
14074Defaults to @samp{"2 secs"}.
14075@end deftypevr
14076
14077@deftypevr {@code{dovecot-configuration} parameter} boolean auth-ssl-require-client-cert?
14078Require a valid SSL client certificate or the authentication
14079fails.
14080Defaults to @samp{#f}.
14081@end deftypevr
14082
14083@deftypevr {@code{dovecot-configuration} parameter} boolean auth-ssl-username-from-cert?
14084Take the username from client's SSL certificate, using
14085@code{X509_NAME_get_text_by_NID()} which returns the subject's DN's
14086CommonName.
14087Defaults to @samp{#f}.
14088@end deftypevr
14089
14090@deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list auth-mechanisms
14091List of wanted authentication mechanisms. Supported mechanisms are:
14092@samp{plain}, @samp{login}, @samp{digest-md5}, @samp{cram-md5},
14093@samp{ntlm}, @samp{rpa}, @samp{apop}, @samp{anonymous}, @samp{gssapi},
14094@samp{otp}, @samp{skey}, and @samp{gss-spnego}. NOTE: See also
14095@samp{disable-plaintext-auth} setting.
14096@end deftypevr
14097
14098@deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list director-servers
14099List of IPs or hostnames to all director servers, including ourself.
14100Ports can be specified as ip:port. The default port is the same as what
14101director service's @samp{inet-listener} is using.
14102Defaults to @samp{()}.
14103@end deftypevr
14104
14105@deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list director-mail-servers
14106List of IPs or hostnames to all backend mail servers. Ranges are
14107allowed too, like 10.0.0.10-10.0.0.30.
14108Defaults to @samp{()}.
14109@end deftypevr
14110
14111@deftypevr {@code{dovecot-configuration} parameter} string director-user-expire
14112How long to redirect users to a specific server after it no longer
14113has any connections.
14114Defaults to @samp{"15 min"}.
14115@end deftypevr
14116
d8c18af8
AW
14117@deftypevr {@code{dovecot-configuration} parameter} string director-username-hash
14118How the username is translated before being hashed. Useful values
14119include %Ln if user can log in with or without @@domain, %Ld if mailboxes
14120are shared within domain.
14121Defaults to @samp{"%Lu"}.
14122@end deftypevr
14123
14124@deftypevr {@code{dovecot-configuration} parameter} string log-path
14125Log file to use for error messages. @samp{syslog} logs to syslog,
14126@samp{/dev/stderr} logs to stderr.
14127Defaults to @samp{"syslog"}.
14128@end deftypevr
14129
14130@deftypevr {@code{dovecot-configuration} parameter} string info-log-path
14131Log file to use for informational messages. Defaults to
14132@samp{log-path}.
14133Defaults to @samp{""}.
14134@end deftypevr
14135
14136@deftypevr {@code{dovecot-configuration} parameter} string debug-log-path
14137Log file to use for debug messages. Defaults to
14138@samp{info-log-path}.
14139Defaults to @samp{""}.
14140@end deftypevr
14141
14142@deftypevr {@code{dovecot-configuration} parameter} string syslog-facility
14143Syslog facility to use if you're logging to syslog. Usually if you
14144don't want to use @samp{mail}, you'll use local0..local7. Also other
14145standard facilities are supported.
14146Defaults to @samp{"mail"}.
14147@end deftypevr
14148
14149@deftypevr {@code{dovecot-configuration} parameter} boolean auth-verbose?
14150Log unsuccessful authentication attempts and the reasons why they
14151failed.
14152Defaults to @samp{#f}.
14153@end deftypevr
14154
14155@deftypevr {@code{dovecot-configuration} parameter} boolean auth-verbose-passwords?
14156In case of password mismatches, log the attempted password. Valid
14157values are no, plain and sha1. sha1 can be useful for detecting brute
14158force password attempts vs. user simply trying the same password over
14159and over again. You can also truncate the value to n chars by appending
14160":n" (e.g. sha1:6).
14161Defaults to @samp{#f}.
14162@end deftypevr
14163
14164@deftypevr {@code{dovecot-configuration} parameter} boolean auth-debug?
14165Even more verbose logging for debugging purposes. Shows for example
14166SQL queries.
14167Defaults to @samp{#f}.
14168@end deftypevr
14169
14170@deftypevr {@code{dovecot-configuration} parameter} boolean auth-debug-passwords?
14171In case of password mismatches, log the passwords and used scheme so
14172the problem can be debugged. Enabling this also enables
14173@samp{auth-debug}.
14174Defaults to @samp{#f}.
14175@end deftypevr
14176
14177@deftypevr {@code{dovecot-configuration} parameter} boolean mail-debug?
14178Enable mail process debugging. This can help you figure out why
14179Dovecot isn't finding your mails.
14180Defaults to @samp{#f}.
14181@end deftypevr
14182
14183@deftypevr {@code{dovecot-configuration} parameter} boolean verbose-ssl?
14184Show protocol level SSL errors.
14185Defaults to @samp{#f}.
14186@end deftypevr
14187
14188@deftypevr {@code{dovecot-configuration} parameter} string log-timestamp
14189Prefix for each line written to log file. % codes are in
14190strftime(3) format.
14191Defaults to @samp{"\"%b %d %H:%M:%S \""}.
14192@end deftypevr
14193
14194@deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list login-log-format-elements
14195List of elements we want to log. The elements which have a
14196non-empty variable value are joined together to form a comma-separated
14197string.
14198@end deftypevr
14199
14200@deftypevr {@code{dovecot-configuration} parameter} string login-log-format
14201Login log format. %s contains @samp{login-log-format-elements}
14202string, %$ contains the data we want to log.
14203Defaults to @samp{"%$: %s"}.
14204@end deftypevr
14205
14206@deftypevr {@code{dovecot-configuration} parameter} string mail-log-prefix
14207Log prefix for mail processes. See doc/wiki/Variables.txt for list
14208of possible variables you can use.
90d8923b 14209Defaults to @samp{"\"%s(%u)<%@{pid@}><%@{session@}>: \""}.
d8c18af8
AW
14210@end deftypevr
14211
14212@deftypevr {@code{dovecot-configuration} parameter} string deliver-log-format
14213Format to use for logging mail deliveries. You can use variables:
14214@table @code
14215@item %$
14216Delivery status message (e.g. @samp{saved to INBOX})
14217@item %m
14218Message-ID
14219@item %s
14220Subject
14221@item %f
14222From address
14223@item %p
14224Physical size
14225@item %w
14226Virtual size.
14227@end table
14228Defaults to @samp{"msgid=%m: %$"}.
14229@end deftypevr
14230
14231@deftypevr {@code{dovecot-configuration} parameter} string mail-location
14232Location for users' mailboxes. The default is empty, which means
14233that Dovecot tries to find the mailboxes automatically. This won't work
14234if the user doesn't yet have any mail, so you should explicitly tell
14235Dovecot the full location.
14236
14237If you're using mbox, giving a path to the INBOX
14238file (e.g. /var/mail/%u) isn't enough. You'll also need to tell Dovecot
14239where the other mailboxes are kept. This is called the "root mail
14240directory", and it must be the first path given in the
14241@samp{mail-location} setting.
14242
14243There are a few special variables you can use, eg.:
14244
14245@table @samp
14246@item %u
14247username
14248@item %n
14249user part in user@@domain, same as %u if there's no domain
14250@item %d
14251domain part in user@@domain, empty if there's no domain
14252@item %h
14253home director
14254@end table
14255
14256See doc/wiki/Variables.txt for full list. Some examples:
14257@table @samp
14258@item maildir:~/Maildir
14259@item mbox:~/mail:INBOX=/var/mail/%u
14260@item mbox:/var/mail/%d/%1n/%n:INDEX=/var/indexes/%d/%1n/%
14261@end table
14262Defaults to @samp{""}.
14263@end deftypevr
14264
14265@deftypevr {@code{dovecot-configuration} parameter} string mail-uid
14266System user and group used to access mails. If you use multiple,
14267userdb can override these by returning uid or gid fields. You can use
14268either numbers or names. <doc/wiki/UserIds.txt>.
14269Defaults to @samp{""}.
14270@end deftypevr
14271
14272@deftypevr {@code{dovecot-configuration} parameter} string mail-gid
14273
14274Defaults to @samp{""}.
14275@end deftypevr
14276
14277@deftypevr {@code{dovecot-configuration} parameter} string mail-privileged-group
14278Group to enable temporarily for privileged operations. Currently
14279this is used only with INBOX when either its initial creation or
14280dotlocking fails. Typically this is set to "mail" to give access to
14281/var/mail.
14282Defaults to @samp{""}.
14283@end deftypevr
14284
14285@deftypevr {@code{dovecot-configuration} parameter} string mail-access-groups
14286Grant access to these supplementary groups for mail processes.
14287Typically these are used to set up access to shared mailboxes. Note
14288that it may be dangerous to set these if users can create
14289symlinks (e.g. if "mail" group is set here, ln -s /var/mail ~/mail/var
14290could allow a user to delete others' mailboxes, or ln -s
14291/secret/shared/box ~/mail/mybox would allow reading it).
14292Defaults to @samp{""}.
14293@end deftypevr
14294
14295@deftypevr {@code{dovecot-configuration} parameter} boolean mail-full-filesystem-access?
8f65585b 14296Allow full file system access to clients. There's no access checks
d8c18af8
AW
14297other than what the operating system does for the active UID/GID. It
14298works with both maildir and mboxes, allowing you to prefix mailboxes
14299names with e.g. /path/ or ~user/.
14300Defaults to @samp{#f}.
14301@end deftypevr
14302
14303@deftypevr {@code{dovecot-configuration} parameter} boolean mmap-disable?
14304Don't use mmap() at all. This is required if you store indexes to
8f65585b 14305shared file systems (NFS or clustered file system).
d8c18af8
AW
14306Defaults to @samp{#f}.
14307@end deftypevr
14308
14309@deftypevr {@code{dovecot-configuration} parameter} boolean dotlock-use-excl?
14310Rely on @samp{O_EXCL} to work when creating dotlock files. NFS
14311supports @samp{O_EXCL} since version 3, so this should be safe to use
14312nowadays by default.
14313Defaults to @samp{#t}.
14314@end deftypevr
14315
14316@deftypevr {@code{dovecot-configuration} parameter} string mail-fsync
14317When to use fsync() or fdatasync() calls:
14318@table @code
14319@item optimized
14320Whenever necessary to avoid losing important data
14321@item always
14322Useful with e.g. NFS when write()s are delayed
14323@item never
14324Never use it (best performance, but crashes can lose data).
14325@end table
14326Defaults to @samp{"optimized"}.
14327@end deftypevr
14328
14329@deftypevr {@code{dovecot-configuration} parameter} boolean mail-nfs-storage?
14330Mail storage exists in NFS. Set this to yes to make Dovecot flush
14331NFS caches whenever needed. If you're using only a single mail server
14332this isn't needed.
14333Defaults to @samp{#f}.
14334@end deftypevr
14335
14336@deftypevr {@code{dovecot-configuration} parameter} boolean mail-nfs-index?
14337Mail index files also exist in NFS. Setting this to yes requires
14338@samp{mmap-disable? #t} and @samp{fsync-disable? #f}.
14339Defaults to @samp{#f}.
14340@end deftypevr
14341
14342@deftypevr {@code{dovecot-configuration} parameter} string lock-method
14343Locking method for index files. Alternatives are fcntl, flock and
14344dotlock. Dotlocking uses some tricks which may create more disk I/O
14345than other locking methods. NFS users: flock doesn't work, remember to
14346change @samp{mmap-disable}.
14347Defaults to @samp{"fcntl"}.
14348@end deftypevr
14349
14350@deftypevr {@code{dovecot-configuration} parameter} file-name mail-temp-dir
14351Directory in which LDA/LMTP temporarily stores incoming mails >128
14352kB.
14353Defaults to @samp{"/tmp"}.
14354@end deftypevr
14355
14356@deftypevr {@code{dovecot-configuration} parameter} non-negative-integer first-valid-uid
14357Valid UID range for users. This is mostly to make sure that users can't
14358log in as daemons or other system users. Note that denying root logins is
14359hardcoded to dovecot binary and can't be done even if @samp{first-valid-uid}
14360is set to 0.
14361Defaults to @samp{500}.
14362@end deftypevr
14363
14364@deftypevr {@code{dovecot-configuration} parameter} non-negative-integer last-valid-uid
14365
14366Defaults to @samp{0}.
14367@end deftypevr
14368
14369@deftypevr {@code{dovecot-configuration} parameter} non-negative-integer first-valid-gid
14370Valid GID range for users. Users having non-valid GID as primary group ID
14371aren't allowed to log in. If user belongs to supplementary groups with
14372non-valid GIDs, those groups are not set.
14373Defaults to @samp{1}.
14374@end deftypevr
14375
14376@deftypevr {@code{dovecot-configuration} parameter} non-negative-integer last-valid-gid
14377
14378Defaults to @samp{0}.
14379@end deftypevr
14380
14381@deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mail-max-keyword-length
14382Maximum allowed length for mail keyword name. It's only forced when
14383trying to create new keywords.
14384Defaults to @samp{50}.
14385@end deftypevr
14386
14387@deftypevr {@code{dovecot-configuration} parameter} colon-separated-file-name-list valid-chroot-dirs
14388List of directories under which chrooting is allowed for mail
14389processes (i.e. /var/mail will allow chrooting to /var/mail/foo/bar
14390too). This setting doesn't affect @samp{login-chroot}
14391@samp{mail-chroot} or auth chroot settings. If this setting is empty,
14392"/./" in home dirs are ignored. WARNING: Never add directories here
14393which local users can modify, that may lead to root exploit. Usually
14394this should be done only if you don't allow shell access for users.
14395<doc/wiki/Chrooting.txt>.
14396Defaults to @samp{()}.
14397@end deftypevr
14398
14399@deftypevr {@code{dovecot-configuration} parameter} string mail-chroot
14400Default chroot directory for mail processes. This can be overridden
14401for specific users in user database by giving /./ in user's home
14402directory (e.g. /home/./user chroots into /home). Note that usually
14403there is no real need to do chrooting, Dovecot doesn't allow users to
14404access files outside their mail directory anyway. If your home
14405directories are prefixed with the chroot directory, append "/." to
14406@samp{mail-chroot}. <doc/wiki/Chrooting.txt>.
14407Defaults to @samp{""}.
14408@end deftypevr
14409
14410@deftypevr {@code{dovecot-configuration} parameter} file-name auth-socket-path
14411UNIX socket path to master authentication server to find users.
14412This is used by imap (for shared users) and lda.
14413Defaults to @samp{"/var/run/dovecot/auth-userdb"}.
14414@end deftypevr
14415
14416@deftypevr {@code{dovecot-configuration} parameter} file-name mail-plugin-dir
14417Directory where to look up mail plugins.
14418Defaults to @samp{"/usr/lib/dovecot"}.
14419@end deftypevr
14420
14421@deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list mail-plugins
14422List of plugins to load for all services. Plugins specific to IMAP,
14423LDA, etc. are added to this list in their own .conf files.
14424Defaults to @samp{()}.
14425@end deftypevr
14426
14427@deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mail-cache-min-mail-count
14428The minimum number of mails in a mailbox before updates are done to
14429cache file. This allows optimizing Dovecot's behavior to do less disk
14430writes at the cost of more disk reads.
14431Defaults to @samp{0}.
14432@end deftypevr
14433
14434@deftypevr {@code{dovecot-configuration} parameter} string mailbox-idle-check-interval
14435When IDLE command is running, mailbox is checked once in a while to
14436see if there are any new mails or other changes. This setting defines
14437the minimum time to wait between those checks. Dovecot can also use
14438dnotify, inotify and kqueue to find out immediately when changes
14439occur.
14440Defaults to @samp{"30 secs"}.
14441@end deftypevr
14442
14443@deftypevr {@code{dovecot-configuration} parameter} boolean mail-save-crlf?
14444Save mails with CR+LF instead of plain LF. This makes sending those
14445mails take less CPU, especially with sendfile() syscall with Linux and
14446FreeBSD. But it also creates a bit more disk I/O which may just make it
14447slower. Also note that if other software reads the mboxes/maildirs,
14448they may handle the extra CRs wrong and cause problems.
14449Defaults to @samp{#f}.
14450@end deftypevr
14451
14452@deftypevr {@code{dovecot-configuration} parameter} boolean maildir-stat-dirs?
14453By default LIST command returns all entries in maildir beginning
14454with a dot. Enabling this option makes Dovecot return only entries
14455which are directories. This is done by stat()ing each entry, so it
14456causes more disk I/O.
14457 (For systems setting struct @samp{dirent->d_type} this check is free
14458and it's done always regardless of this setting).
14459Defaults to @samp{#f}.
14460@end deftypevr
14461
14462@deftypevr {@code{dovecot-configuration} parameter} boolean maildir-copy-with-hardlinks?
14463When copying a message, do it with hard links whenever possible.
14464This makes the performance much better, and it's unlikely to have any
14465side effects.
14466Defaults to @samp{#t}.
14467@end deftypevr
14468
14469@deftypevr {@code{dovecot-configuration} parameter} boolean maildir-very-dirty-syncs?
14470Assume Dovecot is the only MUA accessing Maildir: Scan cur/
14471directory only when its mtime changes unexpectedly or when we can't find
14472the mail otherwise.
14473Defaults to @samp{#f}.
14474@end deftypevr
14475
14476@deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list mbox-read-locks
14477Which locking methods to use for locking mbox. There are four
14478available:
14479
14480@table @code
14481@item dotlock
14482Create <mailbox>.lock file. This is the oldest and most NFS-safe
14483solution. If you want to use /var/mail/ like directory, the users will
14484need write access to that directory.
14485@item dotlock-try
14486Same as dotlock, but if it fails because of permissions or because there
14487isn't enough disk space, just skip it.
14488@item fcntl
14489Use this if possible. Works with NFS too if lockd is used.
14490@item flock
a01ad638 14491May not exist in all systems. Doesn't work with NFS.
d8c18af8
AW
14492@item lockf
14493May not exist in all systems. Doesn't work with NFS.
14494@end table
14495
14496You can use multiple locking methods; if you do the order they're declared
14497in is important to avoid deadlocks if other MTAs/MUAs are using multiple
14498locking methods as well. Some operating systems don't allow using some of
14499them simultaneously.
14500@end deftypevr
14501
14502@deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list mbox-write-locks
14503
14504@end deftypevr
14505
14506@deftypevr {@code{dovecot-configuration} parameter} string mbox-lock-timeout
14507Maximum time to wait for lock (all of them) before aborting.
14508Defaults to @samp{"5 mins"}.
14509@end deftypevr
14510
14511@deftypevr {@code{dovecot-configuration} parameter} string mbox-dotlock-change-timeout
14512If dotlock exists but the mailbox isn't modified in any way,
14513override the lock file after this much time.
14514Defaults to @samp{"2 mins"}.
14515@end deftypevr
14516
14517@deftypevr {@code{dovecot-configuration} parameter} boolean mbox-dirty-syncs?
14518When mbox changes unexpectedly we have to fully read it to find out
14519what changed. If the mbox is large this can take a long time. Since
14520the change is usually just a newly appended mail, it'd be faster to
14521simply read the new mails. If this setting is enabled, Dovecot does
14522this but still safely fallbacks to re-reading the whole mbox file
14523whenever something in mbox isn't how it's expected to be. The only real
14524downside to this setting is that if some other MUA changes message
14525flags, Dovecot doesn't notice it immediately. Note that a full sync is
14526done with SELECT, EXAMINE, EXPUNGE and CHECK commands.
14527Defaults to @samp{#t}.
14528@end deftypevr
14529
14530@deftypevr {@code{dovecot-configuration} parameter} boolean mbox-very-dirty-syncs?
14531Like @samp{mbox-dirty-syncs}, but don't do full syncs even with SELECT,
14532EXAMINE, EXPUNGE or CHECK commands. If this is set,
14533@samp{mbox-dirty-syncs} is ignored.
14534Defaults to @samp{#f}.
14535@end deftypevr
14536
14537@deftypevr {@code{dovecot-configuration} parameter} boolean mbox-lazy-writes?
14538Delay writing mbox headers until doing a full write sync (EXPUNGE
14539and CHECK commands and when closing the mailbox). This is especially
14540useful for POP3 where clients often delete all mails. The downside is
14541that our changes aren't immediately visible to other MUAs.
14542Defaults to @samp{#t}.
14543@end deftypevr
14544
14545@deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mbox-min-index-size
14546If mbox size is smaller than this (e.g. 100k), don't write index
14547files. If an index file already exists it's still read, just not
14548updated.
14549Defaults to @samp{0}.
14550@end deftypevr
14551
14552@deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mdbox-rotate-size
14553Maximum dbox file size until it's rotated.
28c03b45 14554Defaults to @samp{10000000}.
d8c18af8
AW
14555@end deftypevr
14556
14557@deftypevr {@code{dovecot-configuration} parameter} string mdbox-rotate-interval
14558Maximum dbox file age until it's rotated. Typically in days. Day
14559begins from midnight, so 1d = today, 2d = yesterday, etc. 0 = check
14560disabled.
14561Defaults to @samp{"1d"}.
14562@end deftypevr
14563
14564@deftypevr {@code{dovecot-configuration} parameter} boolean mdbox-preallocate-space?
14565When creating new mdbox files, immediately preallocate their size to
14566@samp{mdbox-rotate-size}. This setting currently works only in Linux
8f65585b 14567with some file systems (ext4, xfs).
d8c18af8
AW
14568Defaults to @samp{#f}.
14569@end deftypevr
14570
14571@deftypevr {@code{dovecot-configuration} parameter} string mail-attachment-dir
14572sdbox and mdbox support saving mail attachments to external files,
14573which also allows single instance storage for them. Other backends
14574don't support this for now.
14575
14576WARNING: This feature hasn't been tested much yet. Use at your own risk.
14577
14578Directory root where to store mail attachments. Disabled, if empty.
14579Defaults to @samp{""}.
14580@end deftypevr
14581
14582@deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mail-attachment-min-size
14583Attachments smaller than this aren't saved externally. It's also
14584possible to write a plugin to disable saving specific attachments
14585externally.
14586Defaults to @samp{128000}.
14587@end deftypevr
14588
14589@deftypevr {@code{dovecot-configuration} parameter} string mail-attachment-fs
8f65585b 14590File system backend to use for saving attachments:
d8c18af8
AW
14591@table @code
14592@item posix
14593No SiS done by Dovecot (but this might help FS's own deduplication)
14594@item sis posix
14595SiS with immediate byte-by-byte comparison during saving
14596@item sis-queue posix
14597SiS with delayed comparison and deduplication.
14598@end table
14599Defaults to @samp{"sis posix"}.
14600@end deftypevr
14601
14602@deftypevr {@code{dovecot-configuration} parameter} string mail-attachment-hash
14603Hash format to use in attachment filenames. You can add any text and
14604variables: @code{%@{md4@}}, @code{%@{md5@}}, @code{%@{sha1@}},
14605@code{%@{sha256@}}, @code{%@{sha512@}}, @code{%@{size@}}. Variables can be
14606truncated, e.g. @code{%@{sha256:80@}} returns only first 80 bits.
14607Defaults to @samp{"%@{sha1@}"}.
14608@end deftypevr
14609
14610@deftypevr {@code{dovecot-configuration} parameter} non-negative-integer default-process-limit
14611
14612Defaults to @samp{100}.
14613@end deftypevr
14614
14615@deftypevr {@code{dovecot-configuration} parameter} non-negative-integer default-client-limit
14616
14617Defaults to @samp{1000}.
14618@end deftypevr
14619
14620@deftypevr {@code{dovecot-configuration} parameter} non-negative-integer default-vsz-limit
14621Default VSZ (virtual memory size) limit for service processes.
14622This is mainly intended to catch and kill processes that leak memory
14623before they eat up everything.
14624Defaults to @samp{256000000}.
14625@end deftypevr
14626
14627@deftypevr {@code{dovecot-configuration} parameter} string default-login-user
14628Login user is internally used by login processes. This is the most
14629untrusted user in Dovecot system. It shouldn't have access to anything
14630at all.
14631Defaults to @samp{"dovenull"}.
14632@end deftypevr
14633
14634@deftypevr {@code{dovecot-configuration} parameter} string default-internal-user
14635Internal user is used by unprivileged processes. It should be
14636separate from login user, so that login processes can't disturb other
14637processes.
14638Defaults to @samp{"dovecot"}.
14639@end deftypevr
14640
14641@deftypevr {@code{dovecot-configuration} parameter} string ssl?
14642SSL/TLS support: yes, no, required. <doc/wiki/SSL.txt>.
14643Defaults to @samp{"required"}.
14644@end deftypevr
14645
14646@deftypevr {@code{dovecot-configuration} parameter} string ssl-cert
14647PEM encoded X.509 SSL/TLS certificate (public key).
14648Defaults to @samp{"</etc/dovecot/default.pem"}.
14649@end deftypevr
14650
14651@deftypevr {@code{dovecot-configuration} parameter} string ssl-key
14652PEM encoded SSL/TLS private key. The key is opened before
14653dropping root privileges, so keep the key file unreadable by anyone but
14654root.
14655Defaults to @samp{"</etc/dovecot/private/default.pem"}.
14656@end deftypevr
14657
14658@deftypevr {@code{dovecot-configuration} parameter} string ssl-key-password
14659If key file is password protected, give the password here.
14660Alternatively give it when starting dovecot with -p parameter. Since
14661this file is often world-readable, you may want to place this setting
14662instead to a different.
14663Defaults to @samp{""}.
14664@end deftypevr
14665
14666@deftypevr {@code{dovecot-configuration} parameter} string ssl-ca
14667PEM encoded trusted certificate authority. Set this only if you
14668intend to use @samp{ssl-verify-client-cert? #t}. The file should
14669contain the CA certificate(s) followed by the matching
14670CRL(s). (e.g. @samp{ssl-ca </etc/ssl/certs/ca.pem}).
14671Defaults to @samp{""}.
14672@end deftypevr
14673
14674@deftypevr {@code{dovecot-configuration} parameter} boolean ssl-require-crl?
14675Require that CRL check succeeds for client certificates.
14676Defaults to @samp{#t}.
14677@end deftypevr
14678
14679@deftypevr {@code{dovecot-configuration} parameter} boolean ssl-verify-client-cert?
14680Request client to send a certificate. If you also want to require
14681it, set @samp{auth-ssl-require-client-cert? #t} in auth section.
14682Defaults to @samp{#f}.
14683@end deftypevr
14684
14685@deftypevr {@code{dovecot-configuration} parameter} string ssl-cert-username-field
14686Which field from certificate to use for username. commonName and
14687x500UniqueIdentifier are the usual choices. You'll also need to set
14688@samp{auth-ssl-username-from-cert? #t}.
14689Defaults to @samp{"commonName"}.
14690@end deftypevr
14691
28c03b45
TGR
14692@deftypevr {@code{dovecot-configuration} parameter} string ssl-min-protocol
14693Minimum SSL protocol version to accept.
14694Defaults to @samp{"TLSv1"}.
d8c18af8
AW
14695@end deftypevr
14696
14697@deftypevr {@code{dovecot-configuration} parameter} string ssl-cipher-list
14698SSL ciphers to use.
28c03b45 14699Defaults to @samp{"ALL:!kRSA:!SRP:!kDHd:!DSS:!aNULL:!eNULL:!EXPORT:!DES:!3DES:!MD5:!PSK:!RC4:!ADH:!LOW@@STRENGTH"}.
d8c18af8
AW
14700@end deftypevr
14701
14702@deftypevr {@code{dovecot-configuration} parameter} string ssl-crypto-device
14703SSL crypto device to use, for valid values run "openssl engine".
14704Defaults to @samp{""}.
14705@end deftypevr
14706
14707@deftypevr {@code{dovecot-configuration} parameter} string postmaster-address
14708Address to use when sending rejection mails.
66329c23
AW
14709%d expands to recipient domain.
14710Defaults to @samp{"postmaster@@%d"}.
d8c18af8
AW
14711@end deftypevr
14712
14713@deftypevr {@code{dovecot-configuration} parameter} string hostname
14714Hostname to use in various parts of sent mails (e.g. in Message-Id)
14715and in LMTP replies. Default is the system's real hostname@@domain.
14716Defaults to @samp{""}.
14717@end deftypevr
14718
14719@deftypevr {@code{dovecot-configuration} parameter} boolean quota-full-tempfail?
14720If user is over quota, return with temporary failure instead of
14721bouncing the mail.
14722Defaults to @samp{#f}.
14723@end deftypevr
14724
14725@deftypevr {@code{dovecot-configuration} parameter} file-name sendmail-path
14726Binary to use for sending mails.
14727Defaults to @samp{"/usr/sbin/sendmail"}.
14728@end deftypevr
14729
14730@deftypevr {@code{dovecot-configuration} parameter} string submission-host
14731If non-empty, send mails via this SMTP host[:port] instead of
14732sendmail.
14733Defaults to @samp{""}.
14734@end deftypevr
14735
14736@deftypevr {@code{dovecot-configuration} parameter} string rejection-subject
14737Subject: header to use for rejection mails. You can use the same
14738variables as for @samp{rejection-reason} below.
14739Defaults to @samp{"Rejected: %s"}.
14740@end deftypevr
14741
14742@deftypevr {@code{dovecot-configuration} parameter} string rejection-reason
14743Human readable error message for rejection mails. You can use
14744variables:
14745
14746@table @code
14747@item %n
14748CRLF
14749@item %r
14750reason
14751@item %s
14752original subject
14753@item %t
14754recipient
14755@end table
14756Defaults to @samp{"Your message to <%t> was automatically rejected:%n%r"}.
14757@end deftypevr
14758
14759@deftypevr {@code{dovecot-configuration} parameter} string recipient-delimiter
14760Delimiter character between local-part and detail in email
14761address.
14762Defaults to @samp{"+"}.
14763@end deftypevr
14764
14765@deftypevr {@code{dovecot-configuration} parameter} string lda-original-recipient-header
14766Header where the original recipient address (SMTP's RCPT TO:
14767address) is taken from if not available elsewhere. With dovecot-lda -a
14768parameter overrides this. A commonly used header for this is
14769X-Original-To.
14770Defaults to @samp{""}.
14771@end deftypevr
14772
14773@deftypevr {@code{dovecot-configuration} parameter} boolean lda-mailbox-autocreate?
14774Should saving a mail to a nonexistent mailbox automatically create
14775it?.
14776Defaults to @samp{#f}.
14777@end deftypevr
14778
14779@deftypevr {@code{dovecot-configuration} parameter} boolean lda-mailbox-autosubscribe?
14780Should automatically created mailboxes be also automatically
14781subscribed?.
14782Defaults to @samp{#f}.
14783@end deftypevr
14784
14785@deftypevr {@code{dovecot-configuration} parameter} non-negative-integer imap-max-line-length
14786Maximum IMAP command line length. Some clients generate very long
14787command lines with huge mailboxes, so you may need to raise this if you
14788get "Too long argument" or "IMAP command line too large" errors
14789often.
14790Defaults to @samp{64000}.
14791@end deftypevr
14792
14793@deftypevr {@code{dovecot-configuration} parameter} string imap-logout-format
14794IMAP logout format string:
14795@table @code
14796@item %i
14797total number of bytes read from client
14798@item %o
14799total number of bytes sent to client.
14800@end table
28c03b45 14801See @file{doc/wiki/Variables.txt} for a list of all the variables you can use.
90d8923b 14802Defaults 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@}"}.
d8c18af8
AW
14803@end deftypevr
14804
14805@deftypevr {@code{dovecot-configuration} parameter} string imap-capability
14806Override the IMAP CAPABILITY response. If the value begins with '+',
14807add the given capabilities on top of the defaults (e.g. +XFOO XBAR).
14808Defaults to @samp{""}.
14809@end deftypevr
14810
14811@deftypevr {@code{dovecot-configuration} parameter} string imap-idle-notify-interval
14812How long to wait between "OK Still here" notifications when client
14813is IDLEing.
14814Defaults to @samp{"2 mins"}.
14815@end deftypevr
14816
14817@deftypevr {@code{dovecot-configuration} parameter} string imap-id-send
14818ID field names and values to send to clients. Using * as the value
14819makes Dovecot use the default value. The following fields have default
14820values currently: name, version, os, os-version, support-url,
14821support-email.
14822Defaults to @samp{""}.
14823@end deftypevr
14824
14825@deftypevr {@code{dovecot-configuration} parameter} string imap-id-log
14826ID fields sent by client to log. * means everything.
14827Defaults to @samp{""}.
14828@end deftypevr
14829
14830@deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list imap-client-workarounds
14831Workarounds for various client bugs:
14832
14833@table @code
14834@item delay-newmail
14835Send EXISTS/RECENT new mail notifications only when replying to NOOP and
14836CHECK commands. Some clients ignore them otherwise, for example OSX
14837Mail (<v2.1). Outlook Express breaks more badly though, without this it
14838may show user "Message no longer in server" errors. Note that OE6
14839still breaks even with this workaround if synchronization is set to
14840"Headers Only".
14841
14842@item tb-extra-mailbox-sep
14843Thunderbird gets somehow confused with LAYOUT=fs (mbox and dbox) and
14844adds extra @samp{/} suffixes to mailbox names. This option causes Dovecot to
14845ignore the extra @samp{/} instead of treating it as invalid mailbox name.
14846
14847@item tb-lsub-flags
14848Show \Noselect flags for LSUB replies with LAYOUT=fs (e.g. mbox).
14849This makes Thunderbird realize they aren't selectable and show them
14850greyed out, instead of only later giving "not selectable" popup error.
14851@end table
14852Defaults to @samp{()}.
14853@end deftypevr
14854
14855@deftypevr {@code{dovecot-configuration} parameter} string imap-urlauth-host
14856Host allowed in URLAUTH URLs sent by client. "*" allows all.
14857Defaults to @samp{""}.
14858@end deftypevr
14859
14860
14861Whew! Lots of configuration options. The nice thing about it though is
14862that GuixSD has a complete interface to Dovecot's configuration
14863language. This allows not only a nice way to declare configurations,
14864but also offers reflective capabilities as well: users can write code to
14865inspect and transform configurations from within Scheme.
14866
14867However, it could be that you just want to get a @code{dovecot.conf} up
14868and running. In that case, you can pass an
7414de0a 14869@code{opaque-dovecot-configuration} as the @code{#:config} parameter to
d8c18af8
AW
14870@code{dovecot-service}. As its name indicates, an opaque configuration
14871does not have easy reflective capabilities.
14872
14873Available @code{opaque-dovecot-configuration} fields are:
14874
14875@deftypevr {@code{opaque-dovecot-configuration} parameter} package dovecot
14876The dovecot package.
14877@end deftypevr
14878
14879@deftypevr {@code{opaque-dovecot-configuration} parameter} string string
14880The contents of the @code{dovecot.conf}, as a string.
14881@end deftypevr
14882
14883For example, if your @code{dovecot.conf} is just the empty string, you
14884could instantiate a dovecot service like this:
14885
14886@example
14887(dovecot-service #:config
14888 (opaque-dovecot-configuration
14889 (string "")))
14890@end example
14891
f88371e8
SB
14892@subsubheading OpenSMTPD Service
14893
14894@deffn {Scheme Variable} opensmtpd-service-type
14895This is the type of the @uref{https://www.opensmtpd.org, OpenSMTPD}
14896service, whose value should be an @code{opensmtpd-configuration} object
14897as in this example:
14898
14899@example
14900(service opensmtpd-service-type
14901 (opensmtpd-configuration
14902 (config-file (local-file "./my-smtpd.conf"))))
14903@end example
14904@end deffn
14905
14906@deftp {Data Type} opensmtpd-configuration
9fc221b5 14907Data type representing the configuration of opensmtpd.
f88371e8
SB
14908
14909@table @asis
14910@item @code{package} (default: @var{opensmtpd})
14911Package object of the OpenSMTPD SMTP server.
14912
14913@item @code{config-file} (default: @var{%default-opensmtpd-file})
14914File-like object of the OpenSMTPD configuration file to use. By default
14915it listens on the loopback network interface, and allows for mail from
14916users and daemons on the local machine, as well as permitting email to
14917remote servers. Run @command{man smtpd.conf} for more information.
14918
14919@end table
14920@end deftp
859e367d 14921
82ccc499
CZ
14922@subsubheading Exim Service
14923
63422bbb
CZ
14924@cindex mail transfer agent (MTA)
14925@cindex MTA (mail transfer agent)
14926@cindex SMTP
14927
82ccc499 14928@deffn {Scheme Variable} exim-service-type
63422bbb
CZ
14929This is the type of the @uref{https://exim.org, Exim} mail transfer
14930agent (MTA), whose value should be an @code{exim-configuration} object
14931as in this example:
82ccc499
CZ
14932
14933@example
14934(service exim-service-type
14935 (exim-configuration
63422bbb 14936 (config-file (local-file "./my-exim.conf"))))
82ccc499
CZ
14937@end example
14938@end deffn
14939
63422bbb
CZ
14940In order to use an @code{exim-service-type} service you must also have a
14941@code{mail-aliases-service-type} service present in your
14942@code{operating-system} (even if it has no aliases).
14943
82ccc499
CZ
14944@deftp {Data Type} exim-configuration
14945Data type representing the configuration of exim.
14946
14947@table @asis
14948@item @code{package} (default: @var{exim})
14949Package object of the Exim server.
14950
14951@item @code{config-file} (default: @code{#f})
14952File-like object of the Exim configuration file to use. If its value is
14953@code{#f} then use the default configuration file from the package
14954provided in @code{package}. The resulting configuration file is loaded
14955after setting the @code{exim_user} and @code{exim_group} configuration
14956variables.
14957
82ccc499
CZ
14958@end table
14959@end deftp
14960
63422bbb
CZ
14961@subsubheading Mail Aliases Service
14962
14963@cindex email aliases
14964@cindex aliases, for email addresses
14965
14966@deffn {Scheme Variable} mail-aliases-service-type
14967This is the type of the service which provides @code{/etc/aliases},
14968specifying how to deliver mail to users on this system.
14969
14970@example
14971(service mail-aliases-service-type
14972 '(("postmaster" "bob")
14973 ("bob" "bob@@example.com" "bob@@example2.com")))
14974@end example
14975@end deffn
14976
14977The configuration for a @code{mail-aliases-service-type} service is an
14978association list denoting how to deliver mail that comes to this
14979system. Each entry is of the form @code{(alias addresses ...)}, with
14980@code{alias} specifying the local alias and @code{addresses} specifying
14981where to deliver this user's mail.
14982
14983The aliases aren't required to exist as users on the local system. In
14984the above example, there doesn't need to be a @code{postmaster} entry in
14985the @code{operating-system}'s @code{user-accounts} in order to deliver
14986the @code{postmaster} mail to @code{bob} (which subsequently would
14987deliver mail to @code{bob@@example.com} and @code{bob@@example2.com}).
14988
78cef99b
CL
14989@node Messaging Services
14990@subsubsection Messaging Services
14991
14992@cindex messaging
14993@cindex jabber
14994@cindex XMPP
14995The @code{(gnu services messaging)} module provides Guix service
14996definitions for messaging services: currently only Prosody is supported.
14997
14998@subsubheading Prosody Service
14999
15000@deffn {Scheme Variable} prosody-service-type
7459cb93 15001This is the type for the @uref{https://prosody.im, Prosody XMPP
78cef99b
CL
15002communication server}. Its value must be a @code{prosody-configuration}
15003record as in this example:
15004
15005@example
15006(service prosody-service-type
15007 (prosody-configuration
5cc6dcd7 15008 (modules-enabled (cons "groups" "mam" %default-modules-enabled))
78cef99b
CL
15009 (int-components
15010 (list
15011 (int-component-configuration
15012 (hostname "conference.example.net")
15013 (plugin "muc")
15014 (mod-muc (mod-muc-configuration)))))
15015 (virtualhosts
15016 (list
15017 (virtualhost-configuration
15018 (domain "example.net"))))))
15019@end example
15020
15021See below for details about @code{prosody-configuration}.
15022
15023@end deffn
15024
15025By default, Prosody does not need much configuration. Only one
15026@code{virtualhosts} field is needed: it specifies the domain you wish
15027Prosody to serve.
15028
5cc6dcd7
CL
15029You can perform various sanity checks on the generated configuration
15030with the @code{prosodyctl check} command.
15031
15032Prosodyctl will also help you to import certificates from the
15033@code{letsencrypt} directory so that the @code{prosody} user can access
15034them. See @url{https://prosody.im/doc/letsencrypt}.
78cef99b
CL
15035
15036@example
5cc6dcd7 15037prosodyctl --root cert import /etc/letsencrypt/live
78cef99b
CL
15038@end example
15039
15040The available configuration parameters follow. Each parameter
15041definition is preceded by its type; for example, @samp{string-list foo}
15042indicates that the @code{foo} parameter should be specified as a list of
15043strings. Types starting with @code{maybe-} denote parameters that won't
15044show up in @code{prosody.cfg.lua} when their value is @code{'disabled}.
15045
15046There is also a way to specify the configuration as a string, if you
15047have an old @code{prosody.cfg.lua} file that you want to port over from
15048some other system; see the end for more details.
15049
bdcf0e6f
CL
15050The @code{file-object} type designates either a file-like object
15051(@pxref{G-Expressions, file-like objects}) or a file name.
15052
78cef99b
CL
15053@c The following documentation was initially generated by
15054@c (generate-documentation) in (gnu services messaging). Manually maintained
15055@c documentation is better, so we shouldn't hesitate to edit below as
15056@c needed. However if the change you want to make to this documentation
15057@c can be done in an automated way, it's probably easier to change
15058@c (generate-documentation) than to make it below and have to deal with
15059@c the churn as Prosody updates.
15060
15061Available @code{prosody-configuration} fields are:
15062
15063@deftypevr {@code{prosody-configuration} parameter} package prosody
15064The Prosody package.
15065@end deftypevr
15066
15067@deftypevr {@code{prosody-configuration} parameter} file-name data-path
15068Location of the Prosody data storage directory. See
7459cb93 15069@url{https://prosody.im/doc/configure}.
78cef99b
CL
15070Defaults to @samp{"/var/lib/prosody"}.
15071@end deftypevr
15072
bdcf0e6f 15073@deftypevr {@code{prosody-configuration} parameter} file-object-list plugin-paths
78cef99b 15074Additional plugin directories. They are searched in all the specified
7459cb93 15075paths in order. See @url{https://prosody.im/doc/plugins_directory}.
78cef99b
CL
15076Defaults to @samp{()}.
15077@end deftypevr
15078
5cc6dcd7
CL
15079@deftypevr {@code{prosody-configuration} parameter} file-name certificates
15080Every virtual host and component needs a certificate so that clients and
15081servers can securely verify its identity. Prosody will automatically load
15082certificates/keys from the directory specified here.
15083Defaults to @samp{"/etc/prosody/certs"}.
15084@end deftypevr
15085
78cef99b
CL
15086@deftypevr {@code{prosody-configuration} parameter} string-list admins
15087This is a list of accounts that are admins for the server. Note that you
7459cb93
TGR
15088must create the accounts separately. See @url{https://prosody.im/doc/admins} and
15089@url{https://prosody.im/doc/creating_accounts}.
78cef99b
CL
15090Example: @code{(admins '("user1@@example.com" "user2@@example.net"))}
15091Defaults to @samp{()}.
15092@end deftypevr
15093
15094@deftypevr {@code{prosody-configuration} parameter} boolean use-libevent?
15095Enable use of libevent for better performance under high load. See
7459cb93 15096@url{https://prosody.im/doc/libevent}.
78cef99b
CL
15097Defaults to @samp{#f}.
15098@end deftypevr
15099
15100@deftypevr {@code{prosody-configuration} parameter} module-list modules-enabled
15101This is the list of modules Prosody will load on startup. It looks for
15102@code{mod_modulename.lua} in the plugins folder, so make sure that exists too.
19ff1f26 15103Documentation on modules can be found at:
7459cb93 15104@url{https://prosody.im/doc/modules}.
19ff1f26 15105Defaults to @samp{("roster" "saslauth" "tls" "dialback" "disco" "carbons" "private" "blocklist" "vcard" "version" "uptime" "time" "ping" "pep" "register" "admin_adhoc")}.
78cef99b
CL
15106@end deftypevr
15107
15108@deftypevr {@code{prosody-configuration} parameter} string-list modules-disabled
15109@samp{"offline"}, @samp{"c2s"} and @samp{"s2s"} are auto-loaded, but
15110should you want to disable them then add them to this list.
15111Defaults to @samp{()}.
15112@end deftypevr
15113
bdcf0e6f 15114@deftypevr {@code{prosody-configuration} parameter} file-object groups-file
78cef99b
CL
15115Path to a text file where the shared groups are defined. If this path is
15116empty then @samp{mod_groups} does nothing. See
7459cb93 15117@url{https://prosody.im/doc/modules/mod_groups}.
78cef99b
CL
15118Defaults to @samp{"/var/lib/prosody/sharedgroups.txt"}.
15119@end deftypevr
15120
15121@deftypevr {@code{prosody-configuration} parameter} boolean allow-registration?
15122Disable account creation by default, for security. See
7459cb93 15123@url{https://prosody.im/doc/creating_accounts}.
78cef99b
CL
15124Defaults to @samp{#f}.
15125@end deftypevr
15126
15127@deftypevr {@code{prosody-configuration} parameter} maybe-ssl-configuration ssl
15128These are the SSL/TLS-related settings. Most of them are disabled so to
15129use Prosody's defaults. If you do not completely understand these options, do
15130not add them to your config, it is easy to lower the security of your server
7459cb93 15131using them. See @url{https://prosody.im/doc/advanced_ssl_config}.
78cef99b
CL
15132
15133Available @code{ssl-configuration} fields are:
15134
15135@deftypevr {@code{ssl-configuration} parameter} maybe-string protocol
15136This determines what handshake to use.
15137@end deftypevr
15138
5cc6dcd7
CL
15139@deftypevr {@code{ssl-configuration} parameter} maybe-file-name key
15140Path to your private key file.
78cef99b
CL
15141@end deftypevr
15142
5cc6dcd7
CL
15143@deftypevr {@code{ssl-configuration} parameter} maybe-file-name certificate
15144Path to your certificate file.
78cef99b
CL
15145@end deftypevr
15146
bdcf0e6f 15147@deftypevr {@code{ssl-configuration} parameter} file-object capath
78cef99b
CL
15148Path to directory containing root certificates that you wish Prosody to
15149trust when verifying the certificates of remote servers.
15150Defaults to @samp{"/etc/ssl/certs"}.
15151@end deftypevr
15152
bdcf0e6f 15153@deftypevr {@code{ssl-configuration} parameter} maybe-file-object cafile
78cef99b
CL
15154Path to a file containing root certificates that you wish Prosody to trust.
15155Similar to @code{capath} but with all certificates concatenated together.
15156@end deftypevr
15157
15158@deftypevr {@code{ssl-configuration} parameter} maybe-string-list verify
15159A list of verification options (these mostly map to OpenSSL's
15160@code{set_verify()} flags).
15161@end deftypevr
15162
15163@deftypevr {@code{ssl-configuration} parameter} maybe-string-list options
15164A list of general options relating to SSL/TLS. These map to OpenSSL's
15165@code{set_options()}. For a full list of options available in LuaSec, see the
15166LuaSec source.
15167@end deftypevr
15168
15169@deftypevr {@code{ssl-configuration} parameter} maybe-non-negative-integer depth
15170How long a chain of certificate authorities to check when looking for a
15171trusted root certificate.
15172@end deftypevr
15173
15174@deftypevr {@code{ssl-configuration} parameter} maybe-string ciphers
15175An OpenSSL cipher string. This selects what ciphers Prosody will offer to
15176clients, and in what order.
15177@end deftypevr
15178
15179@deftypevr {@code{ssl-configuration} parameter} maybe-file-name dhparam
15180A path to a file containing parameters for Diffie-Hellman key exchange. You
15181can create such a file with:
15182@code{openssl dhparam -out /etc/prosody/certs/dh-2048.pem 2048}
15183@end deftypevr
15184
15185@deftypevr {@code{ssl-configuration} parameter} maybe-string curve
15186Curve for Elliptic curve Diffie-Hellman. Prosody's default is
15187@samp{"secp384r1"}.
15188@end deftypevr
15189
15190@deftypevr {@code{ssl-configuration} parameter} maybe-string-list verifyext
15191A list of "extra" verification options.
15192@end deftypevr
15193
15194@deftypevr {@code{ssl-configuration} parameter} maybe-string password
15195Password for encrypted private keys.
15196@end deftypevr
15197
15198@end deftypevr
15199
15200@deftypevr {@code{prosody-configuration} parameter} boolean c2s-require-encryption?
15201Whether to force all client-to-server connections to be encrypted or not.
7459cb93 15202See @url{https://prosody.im/doc/modules/mod_tls}.
78cef99b
CL
15203Defaults to @samp{#f}.
15204@end deftypevr
15205
e30038da
CL
15206@deftypevr {@code{prosody-configuration} parameter} string-list disable-sasl-mechanisms
15207Set of mechanisms that will never be offered. See
15208@url{https://prosody.im/doc/modules/mod_saslauth}.
19ff1f26 15209Defaults to @samp{("DIGEST-MD5")}.
e30038da
CL
15210@end deftypevr
15211
78cef99b
CL
15212@deftypevr {@code{prosody-configuration} parameter} boolean s2s-require-encryption?
15213Whether to force all server-to-server connections to be encrypted or not.
7459cb93 15214See @url{https://prosody.im/doc/modules/mod_tls}.
78cef99b
CL
15215Defaults to @samp{#f}.
15216@end deftypevr
15217
15218@deftypevr {@code{prosody-configuration} parameter} boolean s2s-secure-auth?
15219Whether to require encryption and certificate authentication. This
15220provides ideal security, but requires servers you communicate with to support
15221encryption AND present valid, trusted certificates. See
7459cb93 15222@url{https://prosody.im/doc/s2s#security}.
78cef99b
CL
15223Defaults to @samp{#f}.
15224@end deftypevr
15225
15226@deftypevr {@code{prosody-configuration} parameter} string-list s2s-insecure-domains
15227Many servers don't support encryption or have invalid or self-signed
15228certificates. You can list domains here that will not be required to
15229authenticate using certificates. They will be authenticated using DNS. See
7459cb93 15230@url{https://prosody.im/doc/s2s#security}.
78cef99b
CL
15231Defaults to @samp{()}.
15232@end deftypevr
15233
15234@deftypevr {@code{prosody-configuration} parameter} string-list s2s-secure-domains
15235Even if you leave @code{s2s-secure-auth?} disabled, you can still require
15236valid certificates for some domains by specifying a list here. See
7459cb93 15237@url{https://prosody.im/doc/s2s#security}.
78cef99b
CL
15238Defaults to @samp{()}.
15239@end deftypevr
15240
15241@deftypevr {@code{prosody-configuration} parameter} string authentication
15242Select the authentication backend to use. The default provider stores
15243passwords in plaintext and uses Prosody's configured data storage to store the
15244authentication data. If you do not trust your server please see
7459cb93 15245@url{https://prosody.im/doc/modules/mod_auth_internal_hashed} for information
78cef99b 15246about using the hashed backend. See also
7459cb93 15247@url{https://prosody.im/doc/authentication}
78cef99b
CL
15248Defaults to @samp{"internal_plain"}.
15249@end deftypevr
15250
15251@deftypevr {@code{prosody-configuration} parameter} maybe-string log
15252Set logging options. Advanced logging configuration is not yet supported
7459cb93 15253by the GuixSD Prosody Service. See @url{https://prosody.im/doc/logging}.
78cef99b
CL
15254Defaults to @samp{"*syslog"}.
15255@end deftypevr
15256
15257@deftypevr {@code{prosody-configuration} parameter} file-name pidfile
7459cb93 15258File to write pid in. See @url{https://prosody.im/doc/modules/mod_posix}.
78cef99b
CL
15259Defaults to @samp{"/var/run/prosody/prosody.pid"}.
15260@end deftypevr
15261
1f6f1a07
CL
15262@deftypevr {@code{prosody-configuration} parameter} maybe-non-negative-integer http-max-content-size
15263Maximum allowed size of the HTTP body (in bytes).
15264@end deftypevr
15265
f59de6be
CL
15266@deftypevr {@code{prosody-configuration} parameter} maybe-string http-external-url
15267Some modules expose their own URL in various ways. This URL is built
15268from the protocol, host and port used. If Prosody sits behind a proxy, the
15269public URL will be @code{http-external-url} instead. See
15270@url{https://prosody.im/doc/http#external_url}.
15271@end deftypevr
15272
78cef99b
CL
15273@deftypevr {@code{prosody-configuration} parameter} virtualhost-configuration-list virtualhosts
15274A host in Prosody is a domain on which user accounts can be created. For
15275example if you want your users to have addresses like
15276@samp{"john.smith@@example.com"} then you need to add a host
15277@samp{"example.com"}. All options in this list will apply only to this host.
15278
15279Note: the name "virtual" host is used in configuration to avoid confusion with
15280the actual physical host that Prosody is installed on. A single Prosody
15281instance can serve many domains, each one defined as a VirtualHost entry in
15282Prosody's configuration. Conversely a server that hosts a single domain would
15283have just one VirtualHost entry.
15284
7459cb93 15285See @url{https://prosody.im/doc/configure#virtual_host_settings}.
78cef99b
CL
15286
15287Available @code{virtualhost-configuration} fields are:
15288
e30038da 15289all 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:
78cef99b
CL
15290@deftypevr {@code{virtualhost-configuration} parameter} string domain
15291Domain you wish Prosody to serve.
15292@end deftypevr
15293
15294@end deftypevr
15295
15296@deftypevr {@code{prosody-configuration} parameter} int-component-configuration-list int-components
15297Components are extra services on a server which are available to clients,
15298usually on a subdomain of the main server (such as
15299@samp{"mycomponent.example.com"}). Example components might be chatroom
15300servers, user directories, or gateways to other protocols.
15301
15302Internal components are implemented with Prosody-specific plugins. To add an
15303internal component, you simply fill the hostname field, and the plugin you wish
15304to use for the component.
15305
7459cb93 15306See @url{https://prosody.im/doc/components}.
78cef99b
CL
15307Defaults to @samp{()}.
15308
15309Available @code{int-component-configuration} fields are:
15310
e30038da 15311all 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:
78cef99b
CL
15312@deftypevr {@code{int-component-configuration} parameter} string hostname
15313Hostname of the component.
15314@end deftypevr
15315
15316@deftypevr {@code{int-component-configuration} parameter} string plugin
15317Plugin you wish to use for the component.
15318@end deftypevr
15319
15320@deftypevr {@code{int-component-configuration} parameter} maybe-mod-muc-configuration mod-muc
15321Multi-user chat (MUC) is Prosody's module for allowing you to create
15322hosted chatrooms/conferences for XMPP users.
15323
15324General information on setting up and using multi-user chatrooms can be found
7459cb93 15325in the "Chatrooms" documentation (@url{https://prosody.im/doc/chatrooms}),
78cef99b
CL
15326which you should read if you are new to XMPP chatrooms.
15327
7459cb93 15328See also @url{https://prosody.im/doc/modules/mod_muc}.
78cef99b
CL
15329
15330Available @code{mod-muc-configuration} fields are:
15331
15332@deftypevr {@code{mod-muc-configuration} parameter} string name
15333The name to return in service discovery responses.
15334Defaults to @samp{"Prosody Chatrooms"}.
15335@end deftypevr
15336
15337@deftypevr {@code{mod-muc-configuration} parameter} string-or-boolean restrict-room-creation
15338If @samp{#t}, this will only allow admins to create new chatrooms.
15339Otherwise anyone can create a room. The value @samp{"local"} restricts room
15340creation to users on the service's parent domain. E.g. @samp{user@@example.com}
15341can create rooms on @samp{rooms.example.com}. The value @samp{"admin"}
15342restricts to service administrators only.
15343Defaults to @samp{#f}.
15344@end deftypevr
15345
15346@deftypevr {@code{mod-muc-configuration} parameter} non-negative-integer max-history-messages
15347Maximum number of history messages that will be sent to the member that has
15348just joined the room.
15349Defaults to @samp{20}.
15350@end deftypevr
15351
15352@end deftypevr
15353
15354@end deftypevr
15355
15356@deftypevr {@code{prosody-configuration} parameter} ext-component-configuration-list ext-components
15357External components use XEP-0114, which most standalone components
15358support. To add an external component, you simply fill the hostname field. See
7459cb93 15359@url{https://prosody.im/doc/components}.
78cef99b
CL
15360Defaults to @samp{()}.
15361
15362Available @code{ext-component-configuration} fields are:
15363
e30038da 15364all 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:
78cef99b
CL
15365@deftypevr {@code{ext-component-configuration} parameter} string component-secret
15366Password which the component will use to log in.
15367@end deftypevr
15368
15369@deftypevr {@code{ext-component-configuration} parameter} string hostname
15370Hostname of the component.
15371@end deftypevr
15372
15373@end deftypevr
15374
15375@deftypevr {@code{prosody-configuration} parameter} non-negative-integer-list component-ports
15376Port(s) Prosody listens on for component connections.
19ff1f26 15377Defaults to @samp{(5347)}.
78cef99b
CL
15378@end deftypevr
15379
15380@deftypevr {@code{prosody-configuration} parameter} string component-interface
15381Interface Prosody listens on for component connections.
15382Defaults to @samp{"127.0.0.1"}.
15383@end deftypevr
15384
274b9500
CL
15385@deftypevr {@code{prosody-configuration} parameter} maybe-raw-content raw-content
15386Raw content that will be added to the configuration file.
15387@end deftypevr
15388
78cef99b
CL
15389It could be that you just want to get a @code{prosody.cfg.lua}
15390up and running. In that case, you can pass an
15391@code{opaque-prosody-configuration} record as the value of
15392@code{prosody-service-type}. As its name indicates, an opaque configuration
15393does not have easy reflective capabilities.
15394Available @code{opaque-prosody-configuration} fields are:
15395
15396@deftypevr {@code{opaque-prosody-configuration} parameter} package prosody
15397The prosody package.
15398@end deftypevr
15399
15400@deftypevr {@code{opaque-prosody-configuration} parameter} string prosody.cfg.lua
15401The contents of the @code{prosody.cfg.lua} to use.
15402@end deftypevr
15403
15404For example, if your @code{prosody.cfg.lua} is just the empty
15405string, you could instantiate a prosody service like this:
15406
15407@example
15408(service prosody-service-type
15409 (opaque-prosody-configuration
15410 (prosody.cfg.lua "")))
15411@end example
15412
bdcf0e6f
CL
15413@c end of Prosody auto-generated documentation
15414
f2bee421
LC
15415@subsubheading BitlBee Service
15416
37af37dc
LC
15417@cindex IRC (Internet Relay Chat)
15418@cindex IRC gateway
f2bee421
LC
15419@url{http://bitlbee.org,BitlBee} is a gateway that provides an IRC
15420interface to a variety of messaging protocols such as XMPP.
15421
37af37dc
LC
15422@defvr {Scheme Variable} bitlbee-service-type
15423This is the service type for the @url{http://bitlbee.org,BitlBee} IRC
15424gateway daemon. Its value is a @code{bitlbee-configuration} (see
15425below).
f2bee421 15426
37af37dc
LC
15427To have BitlBee listen on port 6667 on localhost, add this line to your
15428services:
15429
15430@example
15431(service bitlbee-service-type)
15432@end example
15433@end defvr
15434
15435@deftp {Data Type} bitlbee-configuration
15436This is the configuration for BitlBee, with the following fields:
15437
15438@table @asis
15439@item @code{interface} (default: @code{"127.0.0.1"})
15440@itemx @code{port} (default: @code{6667})
15441Listen on the network interface corresponding to the IP address
15442specified in @var{interface}, on @var{port}.
15443
15444When @var{interface} is @code{127.0.0.1}, only local clients can
15445connect; when it is @code{0.0.0.0}, connections can come from any
15446networking interface.
15447
15448@item @code{package} (default: @code{bitlbee})
15449The BitlBee package to use.
15450
36d619e8
PAR
15451@item @code{plugins} (default: @code{'()})
15452List of plugin packages to use---e.g., @code{bitlbee-discord}.
15453
37af37dc
LC
15454@item @code{extra-settings} (default: @code{""})
15455Configuration snippet added as-is to the BitlBee configuration file.
15456@end table
15457@end deftp
f2bee421 15458
b6d2930d 15459
15460@node Telephony Services
15461@subsubsection Telephony Services
15462
15463@cindex Murmur (VoIP server)
15464@cindex VoIP server
15465This section describes how to set up and run a Murmur server. Murmur is
15466the server of the @uref{https://mumble.info, Mumble} voice-over-IP
15467(VoIP) suite.
15468
15469@deftp {Data Type} murmur-configuration
15470The service type for the Murmur server. An example configuration can
15471look like this:
15472
15473@example
15474(service murmur-service-type
15475 (murmur-configuration
15476 (welcome-text
15477 "Welcome to this Mumble server running on GuixSD!")
15478 (cert-required? #t) ;disallow text password logins
15479 (ssl-cert "/etc/letsencrypt/live/mumble.example.com/fullchain.pem")
15480 (ssl-key "/etc/letsencrypt/live/mumble.example.com/privkey.pem")))
15481@end example
15482
15483After reconfiguring your system, you can manually set the murmur @code{SuperUser}
15484password with the command that is printed during the activation phase.
15485
15486It is recommended to register a normal Mumble user account
15487and grant it admin or moderator rights.
15488You can use the @code{mumble} client to
15489login as new normal user, register yourself, and log out.
15490For the next step login with the name @code{SuperUser} use
15491the @code{SuperUser} password that you set previously,
15492and grant your newly registered mumble user administrator or moderator
15493rights and create some channels.
15494
15495Available @code{murmur-configuration} fields are:
15496
15497@table @asis
15498@item @code{package} (default: @code{mumble})
15499Package that contains @code{bin/murmurd}.
15500
15501@item @code{user} (default: @code{"murmur"})
15502User who will run the Murmur server.
15503
15504@item @code{group} (default: @code{"murmur"})
15505Group of the user who will run the murmur server.
15506
15507@item @code{port} (default: @code{64738})
15508Port on which the server will listen.
15509
15510@item @code{welcome-text} (default: @code{""})
15511Welcome text sent to clients when they connect.
15512
15513@item @code{server-password} (default: @code{""})
15514Password the clients have to enter in order to connect.
15515
15516@item @code{max-users} (default: @code{100})
15517Maximum of users that can be connected to the server at once.
15518
15519@item @code{max-user-bandwidth} (default: @code{#f})
15520Maximum voice traffic a user can send per second.
15521
15522@item @code{database-file} (default: @code{"/var/lib/murmur/db.sqlite"})
15523File name of the sqlite database.
15524The service's user will become the owner of the directory.
15525
15526@item @code{log-file} (default: @code{"/var/log/murmur/murmur.log"})
15527File name of the log file.
15528The service's user will become the owner of the directory.
15529
15530@item @code{autoban-attempts} (default: @code{10})
15531Maximum number of logins a user can make in @code{autoban-timeframe}
15532without getting auto banned for @code{autoban-time}.
15533
15534@item @code{autoban-timeframe} (default: @code{120})
15535Timeframe for autoban in seconds.
15536
15537@item @code{autoban-time} (default: @code{300})
15538Amount of time in seconds for which a client gets banned
15539when violating the autoban limits.
15540
15541@item @code{opus-threshold} (default: @code{100})
15542Percentage of clients that need to support opus
15543before switching over to opus audio codec.
15544
15545@item @code{channel-nesting-limit} (default: @code{10})
15546How deep channels can be nested at maximum.
15547
15548@item @code{channelname-regex} (default: @code{#f})
15549A string in from of a Qt regular expression that channel names must conform to.
15550
15551@item @code{username-regex} (default: @code{#f})
15552A string in from of a Qt regular expression that user names must conform to.
15553
15554@item @code{text-message-length} (default: @code{5000})
15555Maximum size in bytes that a user can send in one text chat message.
15556
15557@item @code{image-message-length} (default: @code{(* 128 1024)})
15558Maximum size in bytes that a user can send in one image message.
15559
15560@item @code{cert-required?} (default: @code{#f})
15561If it is set to @code{#t} clients that use weak password authentification
15562will not be accepted. Users must have completed the certificate wizard to join.
15563
15564@item @code{remember-channel?} (defualt @code{#f})
15565Should murmur remember the last channel each user was in when they disconnected
15566and put them into the remembered channel when they rejoin.
15567
15568@item @code{allow-html?} (default: @code{#f})
15569Should html be allowed in text messages, user comments, and channel descriptions.
15570
15571@item @code{allow-ping?} (default: @code{#f})
15572Setting to true exposes the current user count, the maximum user count, and
15573the server's maximum bandwidth per client to unauthenticated users. In the
15574Mumble client, this information is shown in the Connect dialog.
15575
15576Disabling this setting will prevent public listing of the server.
15577
15578@item @code{bonjour?} (default: @code{#f})
15579Should the server advertise itself in the local network through the bonjour protocol.
15580
15581@item @code{send-version?} (default: @code{#f})
15582Should the murmur server version be exposed in ping requests.
15583
15584@item @code{log-days} (default: @code{31})
15585Murmur also stores logs in the database, which are accessible via RPC.
15586The default is 31 days of months, but you can set this setting to 0 to keep logs forever,
15587or -1 to disable logging to the database.
15588
15589@item @code{obfuscate-ips?} (default @code{#t})
15590Should logged ips be obfuscated to protect the privacy of users.
15591
15592@item @code{ssl-cert} (default: @code{#f})
15593File name of the SSL/TLS certificate used for encrypted connections.
15594
15595@example
15596(ssl-cert "/etc/letsencrypt/live/example.com/fullchain.pem")
15597@end example
15598@item @code{ssl-key} (default: @code{#f})
15599Filepath to the ssl private key used for encrypted connections.
15600@example
15601(ssl-key "/etc/letsencrypt/live/example.com/privkey.pem")
15602@end example
15603
15604@item @code{ssl-dh-params} (default: @code{#f})
15605File name of a PEM-encoded file with Diffie-Hellman parameters
15606for the SSL/TLS encryption. Alternatively you set it to
15607@code{"@@ffdhe2048"}, @code{"@@ffdhe3072"}, @code{"@@ffdhe4096"}, @code{"@@ffdhe6144"}
15608or @code{"@@ffdhe8192"} to use bundled parameters from RFC 7919.
15609
15610@item @code{ssl-ciphers} (default: @code{#f})
15611The @code{ssl-ciphers} option chooses the cipher suites to make available for use
15612in SSL/TLS.
15613
15614This option is specified using
15615@uref{https://www.openssl.org/docs/apps/ciphers.html#CIPHER-LIST-FORMAT,
15616OpenSSL cipher list notation}.
15617
15618It is recommended that you try your cipher string using 'openssl ciphers <string>'
15619before setting it here, to get a feel for which cipher suites you will get.
15620After setting this option, it is recommend that you inspect your Murmur log
15621to ensure that Murmur is using the cipher suites that you expected it to.
15622
15623Note: Changing this option may impact the backwards compatibility of your
15624Murmur server, and can remove the ability for older Mumble clients to be able
15625to connect to it.
15626
15627@item @code{public-registration} (default: @code{#f})
15628Must be a @code{<murmur-public-registration-configuration>} record or @code{#f}.
15629
15630You can optionally register your server in the public server list that the
15631@code{mumble} client shows on startup.
15632You cannot register your server if you have set a @code{server-password},
15633or set @code{allow-ping} to @code{#f}.
15634
15635It might take a few hours until it shows up in the public list.
15636
15637@item @code{file} (default: @code{#f})
15638Optional alternative override for this configuration.
15639@end table
15640@end deftp
15641
15642@deftp {Data Type} murmur-public-registration-configuration
15643Configuration for public registration of a murmur service.
15644
15645@table @asis
15646@item @code{name}
15647This is a display name for your server. Not to be confused with the hostname.
15648
15649@item @code{password}
15650A password to identify your registration.
15651Subsequent updates will need the same password. Don't lose your password.
15652
15653@item @code{url}
15654This should be a @code{http://} or @code{https://} link to your web
15655site.
15656
15657@item @code{hostname} (default: @code{#f})
15658By default your server will be listed by its IP address.
15659If it is set your server will be linked by this host name instead.
15660@end table
15661@end deftp
15662
15663
15664
730ed6ec
CB
15665@node Monitoring Services
15666@subsubsection Monitoring Services
15667
15668@subsubheading Tailon Service
15669
15670@uref{https://tailon.readthedocs.io/, Tailon} is a web application for
15671viewing and searching log files.
15672
15673The following example will configure the service with default values.
15674By default, Tailon can be accessed on port 8080 (@code{http://localhost:8080}).
15675
15676@example
15677(service tailon-service-type)
15678@end example
15679
15680The following example customises more of the Tailon configuration,
15681adding @command{sed} to the list of allowed commands.
15682
15683@example
15684(service tailon-service-type
15685 (tailon-configuration
15686 (config-file
15687 (tailon-configuration-file
15688 (allowed-commands '("tail" "grep" "awk" "sed"))))))
15689@end example
15690
15691
15692@deftp {Data Type} tailon-configuration
15693Data type representing the configuration of Tailon.
15694This type has the following parameters:
15695
15696@table @asis
15697@item @code{config-file} (default: @code{(tailon-configuration-file)})
15698The configuration file to use for Tailon. This can be set to a
15699@dfn{tailon-configuration-file} record value, or any gexp
15700(@pxref{G-Expressions}).
15701
15702For example, to instead use a local file, the @code{local-file} function
15703can be used:
15704
15705@example
15706(service tailon-service-type
15707 (tailon-configuration
15708 (config-file (local-file "./my-tailon.conf"))))
15709@end example
15710
15711@item @code{package} (default: @code{tailon})
15712The tailon package to use.
15713
15714@end table
15715@end deftp
15716
15717@deftp {Data Type} tailon-configuration-file
15718Data type representing the configuration options for Tailon.
15719This type has the following parameters:
15720
15721@table @asis
15722@item @code{files} (default: @code{(list "/var/log")})
15723List of files to display. The list can include strings for a single file
15724or directory, or a list, where the first item is the name of a
15725subsection, and the remaining items are the files or directories in that
15726subsection.
15727
15728@item @code{bind} (default: @code{"localhost:8080"})
15729Address and port to which Tailon should bind on.
15730
15731@item @code{relative-root} (default: @code{#f})
15732URL path to use for Tailon, set to @code{#f} to not use a path.
15733
15734@item @code{allow-transfers?} (default: @code{#t})
15735Allow downloading the log files in the web interface.
15736
15737@item @code{follow-names?} (default: @code{#t})
15738Allow tailing of not-yet existent files.
15739
15740@item @code{tail-lines} (default: @code{200})
15741Number of lines to read initially from each file.
15742
15743@item @code{allowed-commands} (default: @code{(list "tail" "grep" "awk")})
15744Commands to allow running. By default, @code{sed} is disabled.
15745
15746@item @code{debug?} (default: @code{#f})
15747Set @code{debug?} to @code{#t} to show debug messages.
15748
f2d8e7f7
CB
15749@item @code{wrap-lines} (default: @code{#t})
15750Initial line wrapping state in the web interface. Set to @code{#t} to
15751initially wrap lines (the default), or to @code{#f} to initially not
15752wrap lines.
15753
91fdc8a5
CB
15754@item @code{http-auth} (default: @code{#f})
15755HTTP authentication type to use. Set to @code{#f} to disable
15756authentication (the default). Supported values are @code{"digest"} or
15757@code{"basic"}.
15758
15759@item @code{users} (default: @code{#f})
15760If HTTP authentication is enabled (see @code{http-auth}), access will be
15761restricted to the credentials provided here. To configure users, use a
15762list of pairs, where the first element of the pair is the username, and
15763the 2nd element of the pair is the password.
15764
15765@example
15766(tailon-configuration-file
15767 (http-auth "basic")
15768 (users '(("user1" . "password1")
15769 ("user2" . "password2"))))
15770@end example
15771
730ed6ec
CB
15772@end table
15773@end deftp
15774
15775
693b52df
SB
15776@subsubheading Darkstat Service
15777@cindex darkstat
15778Darkstat is a packet sniffer that captures network traffic, calculates
15779statistics about usage, and serves reports over HTTP.
15780
15781@defvar {Scheme Variable} darkstat-service-type
15782This is the service type for the
15783@uref{https://unix4lyfe.org/darkstat/, darkstat}
15784service, its value must be a @code{darkstat-configuration} record as in
15785this example:
15786
15787@example
15788(service darkstat-service-type
15789 (darkstat-configuration
15790 (interface "eno1")))
15791@end example
15792@end defvar
15793
15794@deftp {Data Type} darkstat-configuration
15795Data type representing the configuration of @command{darkstat}.
15796
15797@table @asis
15798@item @code{package} (default: @code{darkstat})
15799The darkstat package to use.
15800
15801@item @code{interface}
15802Capture traffic on the specified network interface.
15803
15804@item @code{port} (default: @code{"667"})
15805Bind the web interface to the specified port.
15806
15807@item @code{bind-address} (default: @code{"127.0.0.1"})
15808Bind the web interface to the specified address.
15809
15810@item @code{base} (default: @code{"/"})
15811Specify the path of the base URL. This can be useful if
15812@command{darkstat} is accessed via a reverse proxy.
15813
15814@end table
15815@end deftp
15816
a33652ee
GB
15817@subsubheading Prometheus Node Exporter Service
15818
15819@cindex prometheus-node-exporter
15820The Prometheus ``node exporter'' makes hardware and operating system statistics
9c2427ab 15821provided by the Linux kernel available for the Prometheus monitoring system.
a33652ee 15822This service should be deployed on all physical nodes and virtual machines,
9c2427ab 15823where monitoring these statistics is desirable.
a33652ee 15824
9c2427ab 15825@defvar {Scheme variable} prometheus-node-exporter-service-type
a33652ee
GB
15826This is the service type for the
15827@uref{https://github.com/prometheus/node_exporter/, prometheus-node-exporter}
15828service, its value must be a @code{prometheus-node-exporter-configuration}
15829record as in this example:
15830
15831@example
15832(service prometheus-node-exporter-service-type
15833 (prometheus-node-exporter-configuration
15834 (web-listen-address ":9100")))
15835@end example
15836@end defvar
15837
15838@deftp {Data Type} prometheus-node-exporter-configuration
15839Data type representing the configuration of @command{node_exporter}.
15840
15841@table @asis
15842@item @code{package} (default: @code{go-github-com-prometheus-node-exporter})
15843The prometheus-node-exporter package to use.
15844
15845@item @code{web-listen-address} (default: @code{":9100"})
15846Bind the web interface to the specified address.
15847
15848@end table
15849@end deftp
693b52df 15850
859e367d
JD
15851@node Kerberos Services
15852@subsubsection Kerberos Services
15853@cindex Kerberos
15854
df31e36a 15855The @code{(gnu services kerberos)} module provides services relating to
859e367d
JD
15856the authentication protocol @dfn{Kerberos}.
15857
8e3f813f
JD
15858@subsubheading Krb5 Service
15859
15860Programs using a Kerberos client library normally
15861expect a configuration file in @file{/etc/krb5.conf}.
15862This service generates such a file from a definition provided in the
15863operating system declaration.
15864It does not cause any daemon to be started.
15865
15866No ``keytab'' files are provided by this service---you must explicitly create them.
15867This service is known to work with the MIT client library, @code{mit-krb5}.
15868Other implementations have not been tested.
15869
15870@defvr {Scheme Variable} krb5-service-type
15871A service type for Kerberos 5 clients.
15872@end defvr
15873
15874@noindent
15875Here is an example of its use:
15876@lisp
15877(service krb5-service-type
15878 (krb5-configuration
15879 (default-realm "EXAMPLE.COM")
15880 (allow-weak-crypto? #t)
15881 (realms (list
15882 (krb5-realm
15883 (name "EXAMPLE.COM")
15884 (admin-server "groucho.example.com")
15885 (kdc "karl.example.com"))
15886 (krb5-realm
15887 (name "ARGRX.EDU")
15888 (admin-server "kerb-admin.argrx.edu")
15889 (kdc "keys.argrx.edu"))))))
15890@end lisp
15891
15892@noindent
15893This example provides a Kerberos@tie{}5 client configuration which:
15894@itemize
15895@item Recognizes two realms, @i{viz:} ``EXAMPLE.COM'' and ``ARGRX.EDU'', both
15896of which have distinct administration servers and key distribution centers;
15897@item Will default to the realm ``EXAMPLE.COM'' if the realm is not explicitly
15898specified by clients;
15899@item Accepts services which only support encryption types known to be weak.
15900@end itemize
15901
15902The @code{krb5-realm} and @code{krb5-configuration} types have many fields.
15903Only the most commonly used ones are described here.
15904For a full list, and more detailed explanation of each, see the MIT
15905@uref{http://web.mit.edu/kerberos/krb5-devel/doc/admin/conf_files/krb5_conf.html,,krb5.conf}
15906documentation.
15907
15908
15909@deftp {Data Type} krb5-realm
15910@cindex realm, kerberos
15911@table @asis
15912@item @code{name}
15913This field is a string identifying the name of the realm.
15914A common convention is to use the fully qualified DNS name of your organization,
15915converted to upper case.
15916
15917@item @code{admin-server}
15918This field is a string identifying the host where the administration server is
15919running.
15920
15921@item @code{kdc}
15922This field is a string identifying the key distribution center
15923for the realm.
15924@end table
15925@end deftp
15926
15927@deftp {Data Type} krb5-configuration
15928
15929@table @asis
15930@item @code{allow-weak-crypto?} (default: @code{#f})
15931If this flag is @code{#t} then services which only offer encryption algorithms
15932known to be weak will be accepted.
15933
15934@item @code{default-realm} (default: @code{#f})
15935This field should be a string identifying the default Kerberos
15936realm for the client.
15937You should set this field to the name of your Kerberos realm.
15938If this value is @code{#f}
15939then a realm must be specified with every Kerberos principal when invoking programs
15940such as @command{kinit}.
15941
15942@item @code{realms}
15943This should be a non-empty list of @code{krb5-realm} objects, which clients may
15944access.
15945Normally, one of them will have a @code{name} field matching the @code{default-realm}
15946field.
15947@end table
15948@end deftp
15949
15950
859e367d
JD
15951@subsubheading PAM krb5 Service
15952@cindex pam-krb5
15953
df31e36a 15954The @code{pam-krb5} service allows for login authentication and password
859e367d
JD
15955management via Kerberos.
15956You will need this service if you want PAM enabled applications to authenticate
15957users using Kerberos.
15958
15959@defvr {Scheme Variable} pam-krb5-service-type
15960A service type for the Kerberos 5 PAM module.
15961@end defvr
15962
15963@deftp {Data Type} pam-krb5-configuration
15964Data type representing the configuration of the Kerberos 5 PAM module
15965This type has the following parameters:
15966@table @asis
15967@item @code{pam-krb5} (default: @code{pam-krb5})
15968The pam-krb5 package to use.
15969
15970@item @code{minimum-uid} (default: @code{1000})
15971The smallest user ID for which Kerberos authentications should be attempted.
15972Local accounts with lower values will silently fail to authenticate.
15973@end table
15974@end deftp
15975
15976
58724c48
DT
15977@node Web Services
15978@subsubsection Web Services
15979
e32171ee
JD
15980@cindex web
15981@cindex www
15982@cindex HTTP
d067e4ba
CB
15983The @code{(gnu services web)} module provides the Apache HTTP Server,
15984the nginx web server, and also a fastcgi wrapper daemon.
15985
15986@subsubheading Apache HTTP Server
15987
15988@deffn {Scheme Variable} httpd-service-type
15989Service type for the @uref{https://httpd.apache.org/,Apache HTTP} server
15990(@dfn{httpd}). The value for this service type is a
15991@code{https-configuration} record.
15992
15993A simple example configuration is given below.
15994
15995@example
15996(service httpd-service-type
15997 (httpd-configuration
15998 (config
15999 (httpd-config-file
16000 (server-name "www.example.com")
16001 (document-root "/srv/http/www.example.com")))))
16002@end example
16003
16004Other services can also extend the @code{httpd-service-type} to add to
16005the configuration.
16006
16007@example
16008(simple-service 'my-extra-server httpd-service-type
16009 (list
16010 (httpd-virtualhost
16011 "*:80"
16012 (list (string-append
16013 "ServerName "www.example.com
16014 DocumentRoot \"/srv/http/www.example.com\"")))))
16015@end example
16016@end deffn
16017
16018The details for the @code{httpd-configuration}, @code{httpd-module},
16019@code{httpd-config-file} and @code{httpd-virtualhost} record types are
16020given below.
16021
16022@deffn {Data Type} httpd-configuration
16023This data type represents the configuration for the httpd service.
16024
16025@table @asis
16026@item @code{package} (default: @code{httpd})
16027The httpd package to use.
16028
16029@item @code{pid-file} (default: @code{"/var/run/httpd"})
16030The pid file used by the shepherd-service.
16031
16032@item @code{config} (default: @code{(httpd-config-file)})
16033The configuration file to use with the httpd service. The default value
16034is a @code{httpd-config-file} record, but this can also be a different
16035G-expression that generates a file, for example a @code{plain-file}. A
16036file outside of the store can also be specified through a string.
16037
16038@end table
16039@end deffn
16040
16041@deffn {Data Type} httpd-module
16042This data type represents a module for the httpd service.
16043
16044@table @asis
16045@item @code{name}
16046The name of the module.
16047
16048@item @code{file}
16049The file for the module. This can be relative to the httpd package being
16050used, the absolute location of a file, or a G-expression for a file
16051within the store, for example @code{(file-append mod-wsgi
16052"/modules/mod_wsgi.so")}.
16053
16054@end table
16055@end deffn
16056
16057@deffn {Data Type} httpd-config-file
16058This data type represents a configuration file for the httpd service.
16059
16060@table @asis
16061@item @code{modules} (default: @code{%default-httpd-modules})
16062The modules to load. Additional modules can be added here, or loaded by
16063additional configuration.
16064
16065@item @code{server-root} (default: @code{httpd})
16066The @code{ServerRoot} in the configuration file, defaults to the httpd
16067package. Directives including @code{Include} and @code{LoadModule} are
16068taken as relative to the server root.
16069
16070@item @code{server-name} (default: @code{#f})
16071The @code{ServerName} in the configuration file, used to specify the
16072request scheme, hostname and port that the server uses to identify
16073itself.
16074
16075This doesn't need to be set in the server config, and can be specifyed
16076in virtual hosts. The default is @code{#f} to not specify a
16077@code{ServerName}.
16078
16079@item @code{document-root} (default: @code{"/srv/http"})
16080The @code{DocumentRoot} from which files will be served.
16081
16082@item @code{listen} (default: @code{'("80")})
16083The list of values for the @code{Listen} directives in the config
16084file. The value should be a list of strings, when each string can
16085specify the port number to listen on, and optionally the IP address and
16086protocol to use.
16087
16088@item @code{pid-file} (default: @code{"/var/run/httpd"})
16089The @code{PidFile} to use. This should match the @code{pid-file} set in
16090the @code{httpd-configuration} so that the Shepherd service is
16091configured correctly.
16092
16093@item @code{error-log} (default: @code{"/var/log/httpd/error_log"})
16094The @code{ErrorLog} to which the server will log errors.
16095
16096@item @code{user} (default: @code{"httpd"})
16097The @code{User} which the server will answer requests as.
16098
16099@item @code{group} (default: @code{"httpd"})
16100The @code{Group} which the server will answer requests as.
16101
16102@item @code{extra-config} (default: @code{(list "TypesConfig etc/httpd/mime.types")})
16103A flat list of strings and G-expressions which will be added to the end
16104of the configuration file.
16105
16106Any values which the service is extended with will be appended to this
16107list.
16108
16109@end table
16110@end deffn
16111
16112@deffn {Data Type} httpd-virtualhost
16113This data type represents a virtualhost configuration block for the httpd service.
16114
16115These should be added to the extra-config for the httpd-service.
16116
16117@example
16118(simple-service 'my-extra-server httpd-service-type
16119 (list
16120 (httpd-virtualhost
16121 "*:80"
16122 (list (string-append
16123 "ServerName "www.example.com
16124 DocumentRoot \"/srv/http/www.example.com\"")))))
16125@end example
16126
16127@table @asis
16128@item @code{addresses-and-ports}
16129The addresses and ports for the @code{VirtualHost} directive.
16130
16131@item @code{contents}
16132The contents of the @code{VirtualHost} directive, this should be a list
16133of strings and G-expressions.
16134
16135@end table
16136@end deffn
16137
16138@subsubheading NGINX
58724c48 16139
39fc3004
CB
16140@deffn {Scheme Variable} nginx-service-type
16141Service type for the @uref{https://nginx.org/,NGinx} web server. The
16142value for this service type is a @code{<nginx-configuration>} record.
5a10cd47 16143
39fc3004 16144A simple example configuration is given below.
58724c48 16145
39fc3004
CB
16146@example
16147(service nginx-service-type
16148 (nginx-configuration
fb1cba68 16149 (server-blocks
39fc3004
CB
16150 (list (nginx-server-configuration
16151 (server-name '("www.example.com"))
c48aa70a 16152 (root "/srv/http/www.example.com"))))))
39fc3004 16153@end example
d338237d 16154
39fc3004
CB
16155In addition to adding server blocks to the service configuration
16156directly, this service can be extended by other services to add server
16157blocks, as in this example:
d338237d
JL
16158
16159@example
16160(simple-service 'my-extra-server nginx-service-type
16161 (list (nginx-server-configuration
4d14808a
OP
16162 (root "/srv/http/extra-website")
16163 (try-files (list "$uri" "$uri/index.html")))))
d338237d
JL
16164@end example
16165@end deffn
16166
39fc3004
CB
16167At startup, @command{nginx} has not yet read its configuration file, so
16168it uses a default file to log error messages. If it fails to load its
16169configuration file, that is where error messages are logged. After the
16170configuration file is loaded, the default error log file changes as per
16171configuration. In our case, startup error messages can be found in
16172@file{/var/run/nginx/logs/error.log}, and after configuration in
16173@file{/var/log/nginx/error.log}. The second location can be changed
16174with the @var{log-directory} configuration option.
16175
16176@deffn {Data Type} nginx-configuration
16177This data type represents the configuration for NGinx. Some
16178configuration can be done through this and the other provided record
16179types, or alternatively, a config file can be provided.
16180
16181@table @asis
16182@item @code{nginx} (default: @code{nginx})
16183The nginx package to use.
16184
16185@item @code{log-directory} (default: @code{"/var/log/nginx"})
16186The directory to which NGinx will write log files.
16187
16188@item @code{run-directory} (default: @code{"/var/run/nginx"})
16189The directory in which NGinx will create a pid file, and write temporary
16190files.
16191
fb1cba68 16192@item @code{server-blocks} (default: @code{'()})
39fc3004
CB
16193A list of @dfn{server blocks} to create in the generated configuration
16194file, the elements should be of type
16195@code{<nginx-server-configuration>}.
16196
16197The following example would setup NGinx to serve @code{www.example.com}
16198from the @code{/srv/http/www.example.com} directory, without using
16199HTTPS.
16200@example
16201(service nginx-service-type
16202 (nginx-configuration
fb1cba68 16203 (server-blocks
39fc3004
CB
16204 (list (nginx-server-configuration
16205 (server-name '("www.example.com"))
c48aa70a 16206 (root "/srv/http/www.example.com"))))))
39fc3004
CB
16207@end example
16208
c2a59a92 16209@item @code{upstream-blocks} (default: @code{'()})
39fc3004
CB
16210A list of @dfn{upstream blocks} to create in the generated configuration
16211file, the elements should be of type
16212@code{<nginx-upstream-configuration>}.
16213
c2a59a92 16214Configuring upstreams through the @code{upstream-blocks} can be useful
39fc3004
CB
16215when combined with @code{locations} in the
16216@code{<nginx-server-configuration>} records. The following example
16217creates a server configuration with one location configuration, that
16218will proxy requests to a upstream configuration, which will handle
16219requests with two servers.
16220
16221@example
16222(service
16223 nginx-service-type
16224 (nginx-configuration
fb1cba68 16225 (server-blocks
39fc3004
CB
16226 (list (nginx-server-configuration
16227 (server-name '("www.example.com"))
16228 (root "/srv/http/www.example.com")
39fc3004
CB
16229 (locations
16230 (list
16231 (nginx-location-configuration
16232 (uri "/path1")
16233 (body '("proxy_pass http://server-proxy;"))))))))
c2a59a92 16234 (upstream-blocks
39fc3004
CB
16235 (list (nginx-upstream-configuration
16236 (name "server-proxy")
16237 (servers (list "server1.example.com"
16238 "server2.example.com")))))))
16239@end example
16240
352a5b63
TGR
16241@item @code{file} (default: @code{#f})
16242If a configuration @var{file} is provided, this will be used, rather than
39fc3004 16243generating a configuration file from the provided @code{log-directory},
c2a59a92 16244@code{run-directory}, @code{server-blocks} and @code{upstream-blocks}. For
fb1cba68
OP
16245proper operation, these arguments should match what is in @var{file} to ensure
16246that the directories are created when the service is activated.
39fc3004
CB
16247
16248This can be useful if you have an existing configuration file, or it's
16249not possible to do what is required through the other parts of the
16250nginx-configuration record.
16251
2881f852
CB
16252@item @code{server-names-hash-bucket-size} (default: @code{#f})
16253Bucket size for the server names hash tables, defaults to @code{#f} to
16254use the size of the processors cache line.
16255
16256@item @code{server-names-hash-bucket-max-size} (default: @code{#f})
16257Maximum bucket size for the server names hash tables.
16258
25e071ea
CB
16259@item @code{extra-content} (default: @code{""})
16260Extra content for the @code{http} block. Should be string or a string
16261valued G-expression.
16262
39fc3004
CB
16263@end table
16264@end deffn
16265
3b9b12ef
JL
16266@deftp {Data Type} nginx-server-configuration
16267Data type representing the configuration of an nginx server block.
8c00b838
JL
16268This type has the following parameters:
16269
16270@table @asis
8b223cea
CL
16271@item @code{listen} (default: @code{'("80" "443 ssl")})
16272Each @code{listen} directive sets the address and port for IP, or the
16273path for a UNIX-domain socket on which the server will accept requests.
16274Both address and port, or only address or only port can be specified.
16275An address may also be a hostname, for example:
8c00b838 16276
8b223cea
CL
16277@example
16278'("127.0.0.1:8000" "127.0.0.1" "8000" "*:8000" "localhost:8000")
16279@end example
8c00b838
JL
16280
16281@item @code{server-name} (default: @code{(list 'default)})
3b9b12ef
JL
16282A list of server names this server represents. @code{'default} represents the
16283default server for connections matching no other server.
8c00b838
JL
16284
16285@item @code{root} (default: @code{"/srv/http"})
16286Root of the website nginx will serve.
16287
9c557a69
CB
16288@item @code{locations} (default: @code{'()})
16289A list of @dfn{nginx-location-configuration} or
16290@dfn{nginx-named-location-configuration} records to use within this
16291server block.
16292
8c00b838
JL
16293@item @code{index} (default: @code{(list "index.html")})
16294Index files to look for when clients ask for a directory. If it cannot be found,
16295Nginx will send the list of files in the directory.
16296
4d14808a
OP
16297@item @code{try-files} (default: @code{'()})
16298A list of files whose existence is checked in the specified order.
16299@code{nginx} will use the first file it finds to process the request.
16300
c48aa70a 16301@item @code{ssl-certificate} (default: @code{#f})
8c00b838
JL
16302Where to find the certificate for secure connections. Set it to @code{#f} if
16303you don't have a certificate or you don't want to use HTTPS.
16304
c48aa70a 16305@item @code{ssl-certificate-key} (default: @code{#f})
8c00b838
JL
16306Where to find the private key for secure connections. Set it to @code{#f} if
16307you don't have a key or you don't want to use HTTPS.
16308
16309@item @code{server-tokens?} (default: @code{#f})
16310Whether the server should add its configuration to response.
16311
b05e8ee1
CL
16312@item @code{raw-content} (default: @code{'()})
16313A list of raw lines added to the server block.
16314
8c00b838
JL
16315@end table
16316@end deftp
16317
a88d41d1
CB
16318@deftp {Data Type} nginx-upstream-configuration
16319Data type representing the configuration of an nginx @code{upstream}
16320block. This type has the following parameters:
16321
16322@table @asis
16323@item @code{name}
16324Name for this group of servers.
16325
16326@item @code{servers}
16327Specify the addresses of the servers in the group. The address can be
16328specified as a IP address (e.g. @samp{127.0.0.1}), domain name
16329(e.g. @samp{backend1.example.com}) or a path to a UNIX socket using the
16330prefix @samp{unix:}. For addresses using an IP address or domain name,
16331the default port is 80, and a different port can be specified
16332explicitly.
16333
16334@end table
16335@end deftp
16336
16337@deftp {Data Type} nginx-location-configuration
16338Data type representing the configuration of an nginx @code{location}
16339block. This type has the following parameters:
16340
16341@table @asis
16342@item @code{uri}
16343URI which this location block matches.
16344
16345@anchor{nginx-location-configuration body}
16346@item @code{body}
7baf6615
AE
16347Body of the location block, specified as a list of strings. This can contain
16348many
a88d41d1
CB
16349configuration directives. For example, to pass requests to a upstream
16350server group defined using an @code{nginx-upstream-configuration} block,
7baf6615
AE
16351the following directive would be specified in the body @samp{(list "proxy_pass
16352http://upstream-name;")}.
a88d41d1
CB
16353
16354@end table
16355@end deftp
16356
16357@deftp {Data Type} nginx-named-location-configuration
16358Data type representing the configuration of an nginx named location
16359block. Named location blocks are used for request redirection, and not
16360used for regular request processing. This type has the following
16361parameters:
16362
16363@table @asis
16364@item @code{name}
16365Name to identify this location block.
16366
16367@item @code{body}
16368@xref{nginx-location-configuration body}, as the body for named location
16369blocks can be used in a similar way to the
16370@code{nginx-location-configuration body}. One restriction is that the
16371body of a named location block cannot contain location blocks.
16372
16373@end table
16374@end deftp
16375
a5130d10
AW
16376@cindex fastcgi
16377@cindex fcgiwrap
16378FastCGI is an interface between the front-end and the back-end of a web
16379service. It is a somewhat legacy facility; new web services should
16380generally just talk HTTP between the front-end and the back-end.
16381However there are a number of back-end services such as PHP or the
16382optimized HTTP Git repository access that use FastCGI, so we have
16383support for it in Guix.
16384
16385To use FastCGI, you configure the front-end web server (e.g., nginx) to
16386dispatch some subset of its requests to the fastcgi backend, which
16387listens on a local TCP or UNIX socket. There is an intermediary
16388@code{fcgiwrap} program that sits between the actual backend process and
16389the web server. The front-end indicates which backend program to run,
16390passing that information to the @code{fcgiwrap} process.
16391
16392@defvr {Scheme Variable} fcgiwrap-service-type
16393A service type for the @code{fcgiwrap} FastCGI proxy.
16394@end defvr
16395
16396@deftp {Data Type} fcgiwrap-configuration
16397Data type representing the configuration of the @code{fcgiwrap} serice.
16398This type has the following parameters:
16399@table @asis
16400@item @code{package} (default: @code{fcgiwrap})
16401The fcgiwrap package to use.
16402
16403@item @code{socket} (default: @code{tcp:127.0.0.1:9000})
16404The socket on which the @code{fcgiwrap} process should listen, as a
16405string. Valid @var{socket} values include
16406@code{unix:@var{/path/to/unix/socket}},
16407@code{tcp:@var{dot.ted.qu.ad}:@var{port}} and
16408@code{tcp6:[@var{ipv6_addr}]:port}.
16409
16410@item @code{user} (default: @code{fcgiwrap})
16411@itemx @code{group} (default: @code{fcgiwrap})
16412The user and group names, as strings, under which to run the
16413@code{fcgiwrap} process. The @code{fastcgi} service will ensure that if
16414the user asks for the specific user or group names @code{fcgiwrap} that
16415the corresponding user and/or group is present on the system.
16416
16417It is possible to configure a FastCGI-backed web service to pass HTTP
16418authentication information from the front-end to the back-end, and to
16419allow @code{fcgiwrap} to run the back-end process as a corresponding
16420local user. To enable this capability on the back-end., run
16421@code{fcgiwrap} as the @code{root} user and group. Note that this
16422capability also has to be configured on the front-end as well.
16423@end table
16424@end deftp
16425
64bae723 16426@cindex php-fpm
16427PHP-FPM (FastCGI Process Manager) is an alternative PHP FastCGI implementation
16428with some additional features useful for sites of any size.
16429
16430These features include:
16431@itemize @bullet
16432@item Adaptive process spawning
16433@item Basic statistics (similar to Apache's mod_status)
16434@item Advanced process management with graceful stop/start
16435@item Ability to start workers with different uid/gid/chroot/environment
16436and different php.ini (replaces safe_mode)
16437@item Stdout & stderr logging
16438@item Emergency restart in case of accidental opcode cache destruction
16439@item Accelerated upload support
16440@item Support for a "slowlog"
16441@item Enhancements to FastCGI, such as fastcgi_finish_request() -
16442a special function to finish request & flush all data while continuing to do
16443something time-consuming (video converting, stats processing, etc.)
16444@end itemize
16445... and much more.
16446
16447@defvr {Scheme Variable} php-fpm-service-type
16448A Service type for @code{php-fpm}.
16449@end defvr
16450
16451@deftp {Data Type} php-fpm-configuration
16452Data Type for php-fpm service configuration.
16453@table @asis
16454@item @code{php} (default: @code{php})
16455The php package to use.
16456@item @code{socket} (default: @code{(string-append "/var/run/php" (version-major (package-version php)) "-fpm.sock")})
16457The address on which to accept FastCGI requests. Valid syntaxes are:
16458@table @asis
16459@item @code{"ip.add.re.ss:port"}
16460Listen on a TCP socket to a specific address on a specific port.
16461@item @code{"port"}
16462Listen on a TCP socket to all addresses on a specific port.
16463@item @code{"/path/to/unix/socket"}
16464Listen on a unix socket.
16465@end table
16466
16467@item @code{user} (default: @code{php-fpm})
16468User who will own the php worker processes.
16469@item @code{group} (default: @code{php-fpm})
16470Group of the worker processes.
16471@item @code{socket-user} (default: @code{php-fpm})
16472User who can speak to the php-fpm socket.
16473@item @code{socket-group} (default: @code{php-fpm})
16474Group that can speak to the php-fpm socket.
16475@item @code{pid-file} (default: @code{(string-append "/var/run/php" (version-major (package-version php)) "-fpm.pid")})
16476The process id of the php-fpm process is written to this file
16477once the service has started.
16478@item @code{log-file} (default: @code{(string-append "/var/log/php" (version-major (package-version php)) "-fpm.log")})
16479Log for the php-fpm master process.
16480@item @code{process-manager} (default: @code{(php-fpm-dynamic-process-manager-configuration)})
16481Detailed settings for the php-fpm process manager.
16482Must be either:
16483@table @asis
16484@item @code{<php-fpm-dynamic-process-manager-configuration>}
16485@item @code{<php-fpm-static-process-manager-configuration>}
16486@item @code{<php-fpm-on-demand-process-manager-configuration>}
16487@end table
16488@item @code{display-errors} (default @code{#f})
11e01891 16489Determines whether php errors and warning should be sent to clients
64bae723 16490and displayed in their browsers.
16491This is useful for local php development, but a security risk for public sites,
16492as error messages can reveal passwords and personal data.
16493@item @code{workers-logfile} (default @code{(string-append "/var/log/php" (version-major (package-version php)) "-fpm.www.log")})
16494This file will log the @code{stderr} outputs of php worker processes.
16495Can be set to @code{#f} to disable logging.
16496@item @code{file} (default @code{#f})
16497An optional override of the whole configuration.
16498You can use the @code{mixed-text-file} function or an absolute filepath for it.
16499@end table
16500@end deftp
16501
16502@deftp {Data type} php-fpm-dynamic-process-manager-configuration
16503Data Type for the @code{dynamic} php-fpm process manager. With the
16504@code{dynamic} process manager, spare worker processes are kept around
16505based on it's configured limits.
16506@table @asis
16507@item @code{max-children} (default: @code{5})
16508Maximum of worker processes.
16509@item @code{start-servers} (default: @code{2})
16510How many worker processes should be started on start-up.
16511@item @code{min-spare-servers} (default: @code{1})
16512How many spare worker processes should be kept around at minimum.
16513@item @code{max-spare-servers} (default: @code{3})
16514How many spare worker processes should be kept around at maximum.
16515@end table
16516@end deftp
16517
16518@deftp {Data type} php-fpm-static-process-manager-configuration
16519Data Type for the @code{static} php-fpm process manager. With the
16520@code{static} process manager, an unchanging number of worker processes
16521are created.
16522@table @asis
16523@item @code{max-children} (default: @code{5})
16524Maximum of worker processes.
16525@end table
16526@end deftp
16527
16528@deftp {Data type} php-fpm-on-demand-process-manager-configuration
16529Data Type for the @code{on-demand} php-fpm process manager. With the
16530@code{on-demand} process manager, worker processes are only created as
16531requests arrive.
16532@table @asis
16533@item @code{max-children} (default: @code{5})
16534Maximum of worker processes.
16535@item @code{process-idle-timeout} (default: @code{10})
16536The time in seconds after which a process with no requests is killed.
16537@end table
16538@end deftp
16539
16540
16541@deffn {Scheme Procedure} nginx-php-fpm-location @
16542 [#:nginx-package nginx] @
16543 [socket (string-append "/var/run/php" @
16544 (version-major (package-version php)) @
16545 "-fpm.sock")]
16546A helper function to quickly add php to an @code{nginx-server-configuration}.
16547@end deffn
16548
16549A simple services setup for nginx with php can look like this:
16550@example
16551(services (cons* (dhcp-client-service)
16552 (service php-fpm-service-type)
16553 (service nginx-service-type
16554 (nginx-server-configuration
16555 (server-name '("example.com"))
16556 (root "/srv/http/")
16557 (locations
16558 (list (nginx-php-location)))
16559 (https-port #f)
16560 (ssl-certificate #f)
16561 (ssl-certificate-key #f)))
16562 %base-services))
16563@end example
16564
08da664d
JL
16565@cindex cat-avatar-generator
16566The cat avatar generator is a simple service to demonstrate the use of php-fpm
16567in @code{Nginx}. It is used to generate cat avatar from a seed, for instance
16568the hash of a user's email address.
16569
16570@deffn {Scheme Procedure} cat-avatar-generator-serice @
16571 [#:cache-dir "/var/cache/cat-avatar-generator"] @
16572 [#:package cat-avatar-generator] @
16573 [#:configuration (nginx-server-configuration)]
16574Returns an nginx-server-configuration that inherits @code{configuration}. It
16575extends the nginx configuration to add a server block that serves @code{package},
16576a version of cat-avatar-generator. During execution, cat-avatar-generator will
16577be able to use @code{cache-dir} as its cache directory.
16578@end deffn
16579
16580A simple setup for cat-avatar-generator can look like this:
16581@example
16582(services (cons* (cat-avatar-generator-service
16583 #:configuration
16584 (nginx-server-configuration
16585 (server-name '("example.com"))))
16586 ...
16587 %base-services))
16588@end example
16589
93b83eb3
PAR
16590@subsubheading Hpcguix-web
16591
16592@cindex hpcguix-web
16593The @uref{hpcguix-web, https://github.com/UMCUGenetics/hpcguix-web/}
16594program is a customizable web interface to browse Guix packages,
16595initially designed for users of high-performance computing (HPC)
16596clusters.
16597
16598@defvr {Scheme Variable} hpcguix-web-service-type
16599The service type for @code{hpcguix-web}.
16600@end defvr
16601
16602@deftp {Data Type} hpcguix-web-configuration
16603Data type for the hpcguix-web service configuration.
16604
16605@table @asis
16606@item @code{specs}
16607A gexp (@pxref{G-Expressions}) specifying the hpcguix-web service
16608configuration. The main items available in this spec are:
16609
16610@table @asis
16611@item @code{title-prefix} (default: @code{"hpcguix | "})
16612The page title prefix.
16613
16614@item @code{guix-command} (default: @code{"guix"})
16615The @command{guix} command.
16616
16617@item @code{package-filter-proc} (default: @code{(const #t)})
16618A procedure specifying how to filter packages that are displayed.
16619
16620@item @code{package-page-extension-proc} (default: @code{(const '())})
16621Extension package for @code{hpcguix-web}.
16622
16623@item @code{menu} (default: @code{'()})
16624Additional entry in page @code{menu}.
16625@end table
16626
16627See the hpcguix-web repository for a
16628@uref{https://github.com/UMCUGenetics/hpcguix-web/blob/master/hpcweb-configuration.scm,
16629complete example}.
16630
16631@item @code{package} (default: @code{hpcguix-web})
16632The hpcguix-web package to use.
16633@end table
16634@end deftp
16635
16636A typical hpcguix-web service declaration looks like this:
16637
16638@example
16639(service hpcguix-web-service-type
16640 (hpcguix-web-configuration
16641 (specs
16642 #~(define site-config
16643 (hpcweb-configuration
16644 (title-prefix "Guix-HPC - ")
16645 (menu '(("/about" "ABOUT"))))))))
16646@end example
16647
1115f140
AW
16648@node Certificate Services
16649@subsubsection Certificate Services
16650
16651@cindex Web
16652@cindex HTTP, HTTPS
16653@cindex Let's Encrypt
16654@cindex TLS certificates
16655The @code{(gnu services certbot)} module provides a service to
16656automatically obtain a valid TLS certificate from the Let's Encrypt
16657certificate authority. These certificates can then be used to serve
16658content securely over HTTPS or other TLS-based protocols, with the
16659knowledge that the client will be able to verify the server's
16660authenticity.
16661
16662@url{https://letsencrypt.org/, Let's Encrypt} provides the
16663@code{certbot} tool to automate the certification process. This tool
16664first securely generates a key on the server. It then makes a request
16665to the Let's Encrypt certificate authority (CA) to sign the key. The CA
16666checks that the request originates from the host in question by using a
16667challenge-response protocol, requiring the server to provide its
16668response over HTTP. If that protocol completes successfully, the CA
16669signs the key, resulting in a certificate. That certificate is valid
16670for a limited period of time, and therefore to continue to provide TLS
16671services, the server needs to periodically ask the CA to renew its
16672signature.
16673
16674The certbot service automates this process: the initial key
16675generation, the initial certification request to the Let's Encrypt
16676service, the web server challenge/response integration, writing the
fece75fe
CL
16677certificate to disk, the automated periodic renewals, and the deployment
16678tasks associated with the renewal (e.g. reloading services, copying keys
16679with different permissions).
1115f140 16680
7ab04c17
CL
16681Certbot is run twice a day, at a random minute within the hour. It
16682won't do anything until your certificates are due for renewal or
16683revoked, but running it regularly would give your service a chance of
16684staying online in case a Let's Encrypt-initiated revocation happened for
16685some reason.
16686
65fc1d89
CL
16687By using this service, you agree to the ACME Subscriber Agreement, which
16688can be found there:
16689@url{https://acme-v01.api.letsencrypt.org/directory}.
16690
1115f140 16691@defvr {Scheme Variable} certbot-service-type
c3215d2f
CL
16692A service type for the @code{certbot} Let's Encrypt client. Its value
16693must be a @code{certbot-configuration} record as in this example:
16694
16695@example
fece75fe
CL
16696(define %nginx-deploy-hook
16697 (program-file
16698 "nginx-deploy-hook"
16699 #~(let ((pid (call-with-input-file "/var/run/nginx/pid" read)))
16700 (kill pid SIGHUP))))
16701
c3215d2f
CL
16702(service certbot-service-type
16703 (certbot-configuration
16704 (email "foo@@example.net")
16705 (certificates
16706 (list
16707 (certificate-configuration
fece75fe
CL
16708 (domains '("example.net" "www.example.net"))
16709 (deploy-hook %nginx-deploy-hook))
c3215d2f
CL
16710 (certificate-configuration
16711 (domains '("bar.example.net")))))))
16712@end example
16713
16714See below for details about @code{certbot-configuration}.
1115f140
AW
16715@end defvr
16716
16717@deftp {Data Type} certbot-configuration
0420a293 16718Data type representing the configuration of the @code{certbot} service.
1115f140
AW
16719This type has the following parameters:
16720
16721@table @asis
16722@item @code{package} (default: @code{certbot})
16723The certbot package to use.
16724
16725@item @code{webroot} (default: @code{/var/www})
16726The directory from which to serve the Let's Encrypt challenge/response
16727files.
16728
c3215d2f
CL
16729@item @code{certificates} (default: @code{()})
16730A list of @code{certificates-configuration}s for which to generate
16731certificates and request signatures. Each certificate has a @code{name}
16732and several @code{domains}.
1115f140 16733
65fc1d89
CL
16734@item @code{email}
16735Mandatory email used for registration, recovery contact, and important
16736account notifications.
16737
a2cb2bbc
CL
16738@item @code{rsa-key-size} (default: @code{2048})
16739Size of the RSA key.
16740
1115f140
AW
16741@item @code{default-location} (default: @i{see below})
16742The default @code{nginx-location-configuration}. Because @code{certbot}
16743needs to be able to serve challenges and responses, it needs to be able
16744to run a web server. It does so by extending the @code{nginx} web
16745service with an @code{nginx-server-configuration} listening on the
966fd7b7 16746@var{domains} on port 80, and which has a
1115f140
AW
16747@code{nginx-location-configuration} for the @code{/.well-known/} URI
16748path subspace used by Let's Encrypt. @xref{Web Services}, for more on
16749these nginx configuration data types.
16750
16751Requests to other URL paths will be matched by the
16752@code{default-location}, which if present is added to all
16753@code{nginx-server-configuration}s.
16754
16755By default, the @code{default-location} will issue a redirect from
966fd7b7 16756@code{http://@var{domain}/...} to @code{https://@var{domain}/...}, leaving
1115f140
AW
16757you to define what to serve on your site via @code{https}.
16758
16759Pass @code{#f} to not issue a default location.
16760@end table
16761@end deftp
16762
c3215d2f
CL
16763@deftp {Data Type} certificate-configuration
16764Data type representing the configuration of a certificate.
16765This type has the following parameters:
16766
16767@table @asis
16768@item @code{name} (default: @i{see below})
16769This name is used by Certbot for housekeeping and in file paths; it
16770doesn't affect the content of the certificate itself. To see
16771certificate names, run @code{certbot certificates}.
16772
16773Its default is the first provided domain.
1115f140 16774
c3215d2f
CL
16775@item @code{domains} (default: @code{()})
16776The first domain provided will be the subject CN of the certificate, and
16777all domains will be Subject Alternative Names on the certificate.
16778
fece75fe
CL
16779@item @code{deploy-hook} (default: @code{#f})
16780Command to be run in a shell once for each successfully issued
16781certificate. For this command, the shell variable
16782@code{$RENEWED_LINEAGE} will point to the config live subdirectory (for
16783example, @samp{"/etc/letsencrypt/live/example.com"}) containing the new
16784certificates and keys; the shell variable @code{$RENEWED_DOMAINS} will
16785contain a space-delimited list of renewed certificate domains (for
16786example, @samp{"example.com www.example.com"}.
16787
c3215d2f
CL
16788@end table
16789@end deftp
a88d41d1 16790
c3215d2f
CL
16791For each @code{certificate-configuration}, the certificate is saved to
16792@code{/etc/letsencrypt/live/@var{name}/fullchain.pem} and the key is
16793saved to @code{/etc/letsencrypt/live/@var{name}/privkey.pem}.
ba69e8f7
JL
16794@node DNS Services
16795@subsubsection DNS Services
16796@cindex DNS (domain name system)
16797@cindex domain name system (DNS)
16798
16799The @code{(gnu services dns)} module provides services related to the
16800@dfn{domain name system} (DNS). It provides a server service for hosting
16801an @emph{authoritative} DNS server for multiple zones, slave or master.
97f6e913
SB
16802This service uses @uref{https://www.knot-dns.cz/, Knot DNS}. And also a
16803caching and forwarding DNS server for the LAN, which uses
16804@uref{http://www.thekelleys.org.uk/dnsmasq/doc.html, dnsmasq}.
16805
16806@subsubheading Knot Service
ba69e8f7
JL
16807
16808An example configuration of an authoritative server for two zones, one master
16809and one slave, is:
16810
16811@lisp
16812(define-zone-entries example.org.zone
16813;; Name TTL Class Type Data
16814 ("@@" "" "IN" "A" "127.0.0.1")
16815 ("@@" "" "IN" "NS" "ns")
16816 ("ns" "" "IN" "A" "127.0.0.1"))
16817
16818(define master-zone
16819 (knot-zone-configuration
16820 (domain "example.org")
16821 (zone (zone-file
16822 (origin "example.org")
16823 (entries example.org.zone)))))
16824
16825(define slave-zone
16826 (knot-zone-configuration
16827 (domain "plop.org")
16828 (dnssec-policy "default")
16829 (master (list "plop-master"))))
16830
16831(define plop-master
16832 (knot-remote-configuration
16833 (id "plop-master")
16834 (address (list "208.76.58.171"))))
16835
16836(operating-system
16837 ;; ...
16838 (services (cons* (service knot-service-type
dfb403b0 16839 (knot-configuration
ba69e8f7
JL
16840 (remotes (list plop-master))
16841 (zones (list master-zone slave-zone))))
16842 ;; ...
16843 %base-services)))
16844@end lisp
16845
16846@deffn {Scheme Variable} knot-service-type
16847This is the type for the Knot DNS server.
16848
16849Knot DNS is an authoritative DNS server, meaning that it can serve multiple
16850zones, that is to say domain names you would buy from a registrar. This server
16851is not a resolver, meaning that it can only resolve names for which it is
16852authoritative. This server can be configured to serve zones as a master server
16853or a slave server as a per-zone basis. Slave zones will get their data from
16854masters, and will serve it as an authoritative server. From the point of view
16855of a resolver, there is no difference between master and slave.
16856
16857The following data types are used to configure the Knot DNS server:
16858@end deffn
16859
16860@deftp {Data Type} knot-key-configuration
16861Data type representing a key.
16862This type has the following parameters:
16863
16864@table @asis
16865@item @code{id} (default: @code{""})
16866An identifier for other configuration fields to refer to this key. IDs must
16867be unique and must not be empty.
16868
16869@item @code{algorithm} (default: @code{#f})
16870The algorithm to use. Choose between @code{#f}, @code{'hmac-md5},
16871@code{'hmac-sha1}, @code{'hmac-sha224}, @code{'hmac-sha256}, @code{'hmac-sha384}
16872and @code{'hmac-sha512}.
16873
16874@item @code{secret} (default: @code{""})
16875The secret key itself.
16876
16877@end table
16878@end deftp
16879
16880@deftp {Data Type} knot-acl-configuration
16881Data type representing an Access Control List (ACL) configuration.
16882This type has the following parameters:
16883
16884@table @asis
16885@item @code{id} (default: @code{""})
16886An identifier for ether configuration fields to refer to this key. IDs must be
16887unique and must not be empty.
16888
16889@item @code{address} (default: @code{'()})
16890An ordered list of IP addresses, network subnets, or network ranges represented
16891with strings. The query must match one of them. Empty value means that
16892address match is not required.
16893
16894@item @code{key} (default: @code{'()})
16895An ordered list of references to keys represented with strings. The string
16896must match a key ID defined in a @code{knot-key-configuration}. No key means
16897that a key is not require to match that ACL.
16898
16899@item @code{action} (default: @code{'()})
16900An ordered list of actions that are permitted or forbidden by this ACL. Possible
16901values are lists of zero or more elements from @code{'transfer}, @code{'notify}
16902and @code{'update}.
16903
16904@item @code{deny?} (default: @code{#f})
16905When true, the ACL defines restrictions. Listed actions are forbidden. When
16906false, listed actions are allowed.
16907
16908@end table
16909@end deftp
16910
16911@deftp {Data Type} zone-entry
16912Data type represnting a record entry in a zone file.
16913This type has the following parameters:
16914
16915@table @asis
16916@item @code{name} (default: @code{"@@"})
16917The name of the record. @code{"@@"} refers to the origin of the zone. Names
16918are relative to the origin of the zone. For example, in the @code{example.org}
16919zone, @code{"ns.example.org"} actually refers to @code{ns.example.org.example.org}.
16920Names ending with a dot are absolute, which means that @code{"ns.example.org."}
16921refers to @code{ns.example.org}.
16922
16923@item @code{ttl} (default: @code{""})
16924The Time-To-Live (TTL) of this record. If not set, the default TTL is used.
16925
16926@item @code{class} (default: @code{"IN"})
16927The class of the record. Knot currently supports only @code{"IN"} and
16928partially @code{"CH"}.
16929
16930@item @code{type} (default: @code{"A"})
16931The type of the record. Common types include A (IPv4 address), AAAA (IPv6
16932address), NS (Name Server) and MX (Mail eXchange). Many other types are
16933defined.
16934
16935@item @code{data} (default: @code{""})
16936The data contained in the record. For instance an IP address associated with
16937an A record, or a domain name associated with an NS record. Remember that
16938domain names are relative to the origin unless they end with a dot.
16939
16940@end table
16941@end deftp
16942
16943@deftp {Data Type} zone-file
16944Data type representing the content of a zone file.
16945This type has the following parameters:
16946
16947@table @asis
16948@item @code{entries} (default: @code{'()})
16949The list of entries. The SOA record is taken care of, so you don't need to
16950put it in the list of entries. This list should probably contain an entry
16951for your primary authoritative DNS server. Other than using a list of entries
16952directly, you can use @code{define-zone-entries} to define a object containing
16953the list of entries more easily, that you can later pass to the @code{entries}
16954field of the @code{zone-file}.
16955
16956@item @code{origin} (default: @code{""})
16957The name of your zone. This parameter cannot be empty.
16958
16959@item @code{ns} (default: @code{"ns"})
16960The domain of your primary authoritative DNS server. The name is relative to
16961the origin, unless it ends with a dot. It is mandatory that this primary
16962DNS server corresponds to an NS record in the zone and that it is associated
16963to an IP address in the list of entries.
16964
16965@item @code{mail} (default: @code{"hostmaster"})
16966An email address people can contact you at, as the owner of the zone. This
16967is translated as @code{<mail>@@<origin>}.
16968
16969@item @code{serial} (default: @code{1})
16970The serial number of the zone. As this is used to keep track of changes by
16971both slaves and resolvers, it is mandatory that it @emph{never} decreases.
16972Always increment it when you make a change in your zone.
16973
f3853a25
JL
16974@item @code{refresh} (default: @code{(* 2 24 3600)})
16975The frequency at which slaves will do a zone transfer. This value is a number
16976of seconds. It can be computed by multiplications or with
16977@code{(string->duration)}.
ba69e8f7 16978
f3853a25 16979@item @code{retry} (default: @code{(* 15 60)})
ba69e8f7
JL
16980The period after which a slave will retry to contact its master when it fails
16981to do so a first time.
16982
f3853a25 16983@item @code{expiry} (default: @code{(* 14 24 3600)})
ba69e8f7
JL
16984Default TTL of records. Existing records are considered correct for at most
16985this amount of time. After this period, resolvers will invalidate their cache
16986and check again that it still exists.
16987
f3853a25 16988@item @code{nx} (default: @code{3600})
ba69e8f7
JL
16989Default TTL of inexistant records. This delay is usually short because you want
16990your new domains to reach everyone quickly.
16991
16992@end table
16993@end deftp
16994
16995@deftp {Data Type} knot-remote-configuration
16996Data type representing a remote configuration.
16997This type has the following parameters:
16998
16999@table @asis
17000@item @code{id} (default: @code{""})
17001An identifier for other configuration fields to refer to this remote. IDs must
17002be unique and must not be empty.
17003
17004@item @code{address} (default: @code{'()})
17005An ordered list of destination IP addresses. Addresses are tried in sequence.
17006An optional port can be given with the @@ separator. For instance:
17007@code{(list "1.2.3.4" "2.3.4.5@@53")}. Default port is 53.
17008
17009@item @code{via} (default: @code{'()})
17010An ordered list of source IP addresses. An empty list will have Knot choose
17011an appropriate source IP. An optional port can be given with the @@ separator.
17012The default is to choose at random.
17013
17014@item @code{key} (default: @code{#f})
17015A reference to a key, that is a string containing the identifier of a key
17016defined in a @code{knot-key-configuration} field.
17017
17018@end table
17019@end deftp
17020
17021@deftp {Data Type} knot-keystore-configuration
17022Data type representing a keystore to hold dnssec keys.
17023This type has the following parameters:
17024
17025@table @asis
17026@item @code{id} (default: @code{""})
17027The id of the keystore. It must not be empty.
17028
17029@item @code{backend} (default: @code{'pem})
17030The backend to store the keys in. Can be @code{'pem} or @code{'pkcs11}.
17031
17032@item @code{config} (default: @code{"/var/lib/knot/keys/keys"})
17033The configuration string of the backend. An example for the PKCS#11 is:
17034@code{"pkcs11:token=knot;pin-value=1234 /gnu/store/.../lib/pkcs11/libsofthsm2.so"}.
162a1374 17035For the pem backend, the string reprensents a path in the file system.
ba69e8f7
JL
17036
17037@end table
17038@end deftp
17039
17040@deftp {Data Type} knot-policy-configuration
17041Data type representing a dnssec policy. Knot DNS is able to automatically
17042sign your zones. It can either generate and manage your keys automatically or
17043use keys that you generate.
17044
17045Dnssec is usually implemented using two keys: a Key Signing Key (KSK) that is
17046used to sign the second, and a Zone Signing Key (ZSK) that is used to sign the
17047zone. In order to be trusted, the KSK needs to be present in the parent zone
17048(usually a top-level domain). If your registrar supports dnssec, you will
17049have to send them your KSK's hash so they can add a DS record in their zone.
17050This is not automated and need to be done each time you change your KSK.
17051
17052The policy also defines the lifetime of keys. Usually, ZSK can be changed
17053easily and use weaker cryptographic functions (they use lower parameters) in
17054order to sign records quickly, so they are changed often. The KSK however
17055requires manual interaction with the registrar, so they are changed less often
17056and use stronger parameters because they sign only one record.
17057
17058This type has the following parameters:
17059
17060@table @asis
17061@item @code{id} (default: @code{""})
17062The id of the policy. It must not be empty.
17063
17064@item @code{keystore} (default: @code{"default"})
17065A reference to a keystore, that is a string containing the identifier of a
17066keystore defined in a @code{knot-keystore-configuration} field. The
17067@code{"default"} identifier means the default keystore (a kasp database that
17068was setup by this service).
17069
17070@item @code{manual?} (default: @code{#f})
17071Whether the key management is manual or automatic.
17072
17073@item @code{single-type-signing?} (default: @code{#f})
17074When @code{#t}, use the Single-Type Signing Scheme.
17075
17076@item @code{algorithm} (default: @code{"ecdsap256sha256"})
17077An algorithm of signing keys and issued signatures.
17078
17079@item @code{ksk-size} (default: @code{256})
17080The length of the KSK. Note that this value is correct for the default
17081algorithm, but would be unsecure for other algorithms.
17082
17083@item @code{zsk-size} (default: @code{256})
17084The length of the ZSK. Note that this value is correct for the default
17085algorithm, but would be unsecure for other algorithms.
17086
17087@item @code{dnskey-ttl} (default: @code{'default})
17088The TTL value for DNSKEY records added into zone apex. The special
17089@code{'default} value means same as the zone SOA TTL.
17090
f3853a25 17091@item @code{zsk-lifetime} (default: @code{(* 30 24 3600)})
ba69e8f7
JL
17092The period between ZSK publication and the next rollover initiation.
17093
f3853a25 17094@item @code{propagation-delay} (default: @code{(* 24 3600)})
ba69e8f7
JL
17095An extra delay added for each key rollover step. This value should be high
17096enough to cover propagation of data from the master server to all slaves.
17097
f3853a25 17098@item @code{rrsig-lifetime} (default: @code{(* 14 24 3600)})
ba69e8f7
JL
17099A validity period of newly issued signatures.
17100
f3853a25 17101@item @code{rrsig-refresh} (default: @code{(* 7 24 3600)})
ba69e8f7
JL
17102A period how long before a signature expiration the signature will be refreshed.
17103
17104@item @code{nsec3?} (default: @code{#f})
17105When @code{#t}, NSEC3 will be used instead of NSEC.
17106
17107@item @code{nsec3-iterations} (default: @code{5})
17108The number of additional times the hashing is performed.
17109
17110@item @code{nsec3-salt-length} (default: @code{8})
17111The length of a salt field in octets, which is appended to the original owner
17112name before hashing.
17113
f3853a25 17114@item @code{nsec3-salt-lifetime} (default: @code{(* 30 24 3600)})
ba69e8f7
JL
17115The validity period of newly issued salt field.
17116
17117@end table
17118@end deftp
17119
17120@deftp {Data Type} knot-zone-configuration
17121Data type representing a zone served by Knot.
17122This type has the following parameters:
17123
17124@table @asis
17125@item @code{domain} (default: @code{""})
17126The domain served by this configuration. It must not be empty.
17127
17128@item @code{file} (default: @code{""})
17129The file where this zone is saved. This parameter is ignored by master zones.
17130Empty means default location that depends on the domain name.
17131
17132@item @code{zone} (default: @code{(zone-file)})
17133The content of the zone file. This parameter is ignored by slave zones. It
17134must contain a zone-file record.
17135
17136@item @code{master} (default: @code{'()})
17137A list of master remotes. When empty, this zone is a master. When set, this
17138zone is a slave. This is a list of remotes identifiers.
17139
17140@item @code{ddns-master} (default: @code{#f})
17141The main master. When empty, it defaults to the first master in the list of
17142masters.
17143
17144@item @code{notify} (default: @code{'()})
17145A list of slave remote identifiers.
17146
17147@item @code{acl} (default: @code{'()})
17148A list of acl identifiers.
17149
17150@item @code{semantic-checks?} (default: @code{#f})
17151When set, this adds more semantic checks to the zone.
17152
17153@item @code{disable-any?} (default: @code{#f})
17154When set, this forbids queries of the ANY type.
17155
17156@item @code{zonefile-sync} (default: @code{0})
17157The delay between a modification in memory and on disk. 0 means immediate
17158synchronization.
17159
17160@item @code{serial-policy} (default: @code{'increment})
17161A policy between @code{'increment} and @code{'unixtime}.
17162
17163@end table
17164@end deftp
17165
17166@deftp {Data Type} knot-configuration
17167Data type representing the Knot configuration.
17168This type has the following parameters:
17169
17170@table @asis
17171@item @code{knot} (default: @code{knot})
17172The Knot package.
17173
17174@item @code{run-directory} (default: @code{"/var/run/knot"})
17175The run directory. This directory will be used for pid file and sockets.
17176
17177@item @code{listen-v4} (default: @code{"0.0.0.0"})
17178An ip address on which to listen.
17179
17180@item @code{listen-v6} (default: @code{"::"})
17181An ip address on which to listen.
17182
17183@item @code{listen-port} (default: @code{53})
17184A port on which to listen.
17185
17186@item @code{keys} (default: @code{'()})
17187The list of knot-key-configuration used by this configuration.
17188
17189@item @code{acls} (default: @code{'()})
17190The list of knot-acl-configuration used by this configuration.
17191
17192@item @code{remotes} (default: @code{'()})
17193The list of knot-remote-configuration used by this configuration.
17194
17195@item @code{zones} (default: @code{'()})
17196The list of knot-zone-configuration used by this configuration.
17197
17198@end table
17199@end deftp
17200
97f6e913
SB
17201@subsubheading Dnsmasq Service
17202
17203@deffn {Scheme Variable} dnsmasq-service-type
17204This is the type of the dnsmasq service, whose value should be an
17205@code{dnsmasq-configuration} object as in this example:
17206
17207@example
17208(service dnsmasq-service-type
17209 (dnsmasq-configuration
17210 (no-resolv? #t)
17211 (servers '("192.168.1.1"))))
17212@end example
17213@end deffn
17214
17215@deftp {Data Type} dnsmasq-configuration
17216Data type representing the configuration of dnsmasq.
17217
17218@table @asis
17219@item @code{package} (default: @var{dnsmasq})
17220Package object of the dnsmasq server.
17221
17222@item @code{no-hosts?} (default: @code{#f})
17223When true, don't read the hostnames in /etc/hosts.
17224
17225@item @code{port} (default: @code{53})
17226The port to listen on. Setting this to zero completely disables DNS
17227funtion, leaving only DHCP and/or TFTP.
17228
17229@item @code{local-service?} (default: @code{#t})
17230Accept DNS queries only from hosts whose address is on a local subnet,
17231ie a subnet for which an interface exists on the server.
17232
17233@item @code{listen-addresses} (default: @code{'()})
17234Listen on the given IP addresses.
17235
17236@item @code{resolv-file} (default: @code{"/etc/resolv.conf"})
17237The file to read the IP address of the upstream nameservers from.
17238
17239@item @code{no-resolv?} (default: @code{#f})
17240When true, don't read @var{resolv-file}.
17241
17242@item @code{servers} (default: @code{'()})
17243Specify IP address of upstream servers directly.
17244
17245@item @code{cache-size} (default: @code{150})
17246Set the size of dnsmasq's cache. Setting the cache size to zero
17247disables caching.
17248
c061eb58
SB
17249@item @code{negative-cache?} (default: @code{#t})
17250When false, disable negative caching.
97f6e913
SB
17251
17252@end table
17253@end deftp
1115f140 17254
2be1b471
JL
17255@node VPN Services
17256@subsubsection VPN Services
17257@cindex VPN (virtual private network)
17258@cindex virtual private network (VPN)
17259
17260The @code{(gnu services vpn)} module provides services related to
17261@dfn{virtual private networks} (VPNs). It provides a @emph{client} service for
17262your machine to connect to a VPN, and a @emph{servire} service for your machine
17263to host a VPN. Both services use @uref{https://openvpn.net/, OpenVPN}.
17264
17265@deffn {Scheme Procedure} openvpn-client-service @
17266 [#:config (openvpn-client-configuration)]
17267
17268Return a service that runs @command{openvpn}, a VPN daemon, as a client.
17269@end deffn
17270
17271@deffn {Scheme Procedure} openvpn-server-service @
17272 [#:config (openvpn-server-configuration)]
17273
17274Return a service that runs @command{openvpn}, a VPN daemon, as a server.
17275
17276Both can be run simultaneously.
17277@end deffn
17278
17279@c %automatically generated documentation
17280
17281Available @code{openvpn-client-configuration} fields are:
17282
1c17a863 17283@deftypevr {@code{openvpn-client-configuration} parameter} package openvpn
2be1b471
JL
17284The OpenVPN package.
17285
17286@end deftypevr
17287
1c17a863 17288@deftypevr {@code{openvpn-client-configuration} parameter} string pid-file
2be1b471
JL
17289The OpenVPN pid file.
17290
17291Defaults to @samp{"/var/run/openvpn/openvpn.pid"}.
17292
17293@end deftypevr
17294
1c17a863 17295@deftypevr {@code{openvpn-client-configuration} parameter} proto proto
2be1b471
JL
17296The protocol (UDP or TCP) used to open a channel between clients and
17297servers.
17298
17299Defaults to @samp{udp}.
17300
17301@end deftypevr
17302
1c17a863 17303@deftypevr {@code{openvpn-client-configuration} parameter} dev dev
2be1b471
JL
17304The device type used to represent the VPN connection.
17305
17306Defaults to @samp{tun}.
17307
17308@end deftypevr
17309
1c17a863 17310@deftypevr {@code{openvpn-client-configuration} parameter} string ca
2be1b471
JL
17311The certificate authority to check connections against.
17312
17313Defaults to @samp{"/etc/openvpn/ca.crt"}.
17314
17315@end deftypevr
17316
1c17a863 17317@deftypevr {@code{openvpn-client-configuration} parameter} string cert
2be1b471
JL
17318The certificate of the machine the daemon is running on. It should be
17319signed by the authority given in @code{ca}.
17320
17321Defaults to @samp{"/etc/openvpn/client.crt"}.
17322
17323@end deftypevr
17324
1c17a863 17325@deftypevr {@code{openvpn-client-configuration} parameter} string key
2be1b471
JL
17326The key of the machine the daemon is running on. It must be the key whose
17327certificate is @code{cert}.
17328
17329Defaults to @samp{"/etc/openvpn/client.key"}.
17330
17331@end deftypevr
17332
1c17a863 17333@deftypevr {@code{openvpn-client-configuration} parameter} boolean comp-lzo?
2be1b471
JL
17334Whether to use the lzo compression algorithm.
17335
17336Defaults to @samp{#t}.
17337
17338@end deftypevr
17339
1c17a863 17340@deftypevr {@code{openvpn-client-configuration} parameter} boolean persist-key?
2be1b471
JL
17341Don't re-read key files across SIGUSR1 or --ping-restart.
17342
17343Defaults to @samp{#t}.
17344
17345@end deftypevr
17346
1c17a863 17347@deftypevr {@code{openvpn-client-configuration} parameter} boolean persist-tun?
2be1b471
JL
17348Don't close and reopen TUN/TAP device or run up/down scripts across
17349SIGUSR1 or --ping-restart restarts.
17350
17351Defaults to @samp{#t}.
17352
17353@end deftypevr
17354
1c17a863 17355@deftypevr {@code{openvpn-client-configuration} parameter} number verbosity
2be1b471
JL
17356Verbosity level.
17357
17358Defaults to @samp{3}.
17359
17360@end deftypevr
17361
1c17a863 17362@deftypevr {@code{openvpn-client-configuration} parameter} tls-auth-client tls-auth
2be1b471
JL
17363Add an additional layer of HMAC authentication on top of the TLS control
17364channel to protect against DoS attacks.
17365
17366Defaults to @samp{#f}.
17367
17368@end deftypevr
17369
1c17a863 17370@deftypevr {@code{openvpn-client-configuration} parameter} key-usage verify-key-usage?
2be1b471
JL
17371Whether to check the server certificate has server usage extension.
17372
17373Defaults to @samp{#t}.
17374
17375@end deftypevr
17376
1c17a863 17377@deftypevr {@code{openvpn-client-configuration} parameter} bind bind?
2be1b471
JL
17378Bind to a specific local port number.
17379
17380Defaults to @samp{#f}.
17381
17382@end deftypevr
17383
1c17a863 17384@deftypevr {@code{openvpn-client-configuration} parameter} resolv-retry resolv-retry?
2be1b471
JL
17385Retry resolving server address.
17386
17387Defaults to @samp{#t}.
17388
17389@end deftypevr
17390
1c17a863 17391@deftypevr {@code{openvpn-client-configuration} parameter} openvpn-remote-list remote
2be1b471
JL
17392A list of remote servers to connect to.
17393
17394Defaults to @samp{()}.
17395
17396Available @code{openvpn-remote-configuration} fields are:
17397
1c17a863 17398@deftypevr {@code{openvpn-remote-configuration} parameter} string name
2be1b471
JL
17399Server name.
17400
17401Defaults to @samp{"my-server"}.
17402
17403@end deftypevr
17404
1c17a863 17405@deftypevr {@code{openvpn-remote-configuration} parameter} number port
2be1b471
JL
17406Port number the server listens to.
17407
17408Defaults to @samp{1194}.
17409
17410@end deftypevr
17411
17412@end deftypevr
17413@c %end of automatic openvpn-client documentation
17414
17415@c %automatically generated documentation
17416
17417Available @code{openvpn-server-configuration} fields are:
17418
1c17a863 17419@deftypevr {@code{openvpn-server-configuration} parameter} package openvpn
2be1b471
JL
17420The OpenVPN package.
17421
17422@end deftypevr
17423
1c17a863 17424@deftypevr {@code{openvpn-server-configuration} parameter} string pid-file
2be1b471
JL
17425The OpenVPN pid file.
17426
17427Defaults to @samp{"/var/run/openvpn/openvpn.pid"}.
17428
17429@end deftypevr
17430
1c17a863 17431@deftypevr {@code{openvpn-server-configuration} parameter} proto proto
2be1b471
JL
17432The protocol (UDP or TCP) used to open a channel between clients and
17433servers.
17434
17435Defaults to @samp{udp}.
17436
17437@end deftypevr
17438
1c17a863 17439@deftypevr {@code{openvpn-server-configuration} parameter} dev dev
2be1b471
JL
17440The device type used to represent the VPN connection.
17441
17442Defaults to @samp{tun}.
17443
17444@end deftypevr
17445
1c17a863 17446@deftypevr {@code{openvpn-server-configuration} parameter} string ca
2be1b471
JL
17447The certificate authority to check connections against.
17448
17449Defaults to @samp{"/etc/openvpn/ca.crt"}.
17450
17451@end deftypevr
17452
1c17a863 17453@deftypevr {@code{openvpn-server-configuration} parameter} string cert
2be1b471
JL
17454The certificate of the machine the daemon is running on. It should be
17455signed by the authority given in @code{ca}.
17456
17457Defaults to @samp{"/etc/openvpn/client.crt"}.
17458
17459@end deftypevr
17460
1c17a863 17461@deftypevr {@code{openvpn-server-configuration} parameter} string key
2be1b471
JL
17462The key of the machine the daemon is running on. It must be the key whose
17463certificate is @code{cert}.
17464
17465Defaults to @samp{"/etc/openvpn/client.key"}.
17466
17467@end deftypevr
17468
1c17a863 17469@deftypevr {@code{openvpn-server-configuration} parameter} boolean comp-lzo?
2be1b471
JL
17470Whether to use the lzo compression algorithm.
17471
17472Defaults to @samp{#t}.
17473
17474@end deftypevr
17475
1c17a863 17476@deftypevr {@code{openvpn-server-configuration} parameter} boolean persist-key?
2be1b471
JL
17477Don't re-read key files across SIGUSR1 or --ping-restart.
17478
17479Defaults to @samp{#t}.
17480
17481@end deftypevr
17482
1c17a863 17483@deftypevr {@code{openvpn-server-configuration} parameter} boolean persist-tun?
2be1b471
JL
17484Don't close and reopen TUN/TAP device or run up/down scripts across
17485SIGUSR1 or --ping-restart restarts.
17486
17487Defaults to @samp{#t}.
17488
17489@end deftypevr
17490
1c17a863 17491@deftypevr {@code{openvpn-server-configuration} parameter} number verbosity
2be1b471
JL
17492Verbosity level.
17493
17494Defaults to @samp{3}.
17495
17496@end deftypevr
17497
1c17a863 17498@deftypevr {@code{openvpn-server-configuration} parameter} tls-auth-server tls-auth
2be1b471
JL
17499Add an additional layer of HMAC authentication on top of the TLS control
17500channel to protect against DoS attacks.
17501
17502Defaults to @samp{#f}.
17503
17504@end deftypevr
17505
1c17a863 17506@deftypevr {@code{openvpn-server-configuration} parameter} number port
2be1b471
JL
17507Specifies the port number on which the server listens.
17508
17509Defaults to @samp{1194}.
17510
17511@end deftypevr
17512
1c17a863 17513@deftypevr {@code{openvpn-server-configuration} parameter} ip-mask server
2be1b471
JL
17514An ip and mask specifying the subnet inside the virtual network.
17515
17516Defaults to @samp{"10.8.0.0 255.255.255.0"}.
17517
17518@end deftypevr
17519
1c17a863 17520@deftypevr {@code{openvpn-server-configuration} parameter} cidr6 server-ipv6
2be1b471
JL
17521A CIDR notation specifying the IPv6 subnet inside the virtual network.
17522
17523Defaults to @samp{#f}.
17524
17525@end deftypevr
17526
1c17a863 17527@deftypevr {@code{openvpn-server-configuration} parameter} string dh
2be1b471
JL
17528The Diffie-Hellman parameters file.
17529
17530Defaults to @samp{"/etc/openvpn/dh2048.pem"}.
17531
17532@end deftypevr
17533
1c17a863 17534@deftypevr {@code{openvpn-server-configuration} parameter} string ifconfig-pool-persist
2be1b471
JL
17535The file that records client IPs.
17536
17537Defaults to @samp{"/etc/openvpn/ipp.txt"}.
17538
17539@end deftypevr
17540
1c17a863 17541@deftypevr {@code{openvpn-server-configuration} parameter} gateway redirect-gateway?
2be1b471
JL
17542When true, the server will act as a gateway for its clients.
17543
17544Defaults to @samp{#f}.
17545
17546@end deftypevr
17547
1c17a863 17548@deftypevr {@code{openvpn-server-configuration} parameter} boolean client-to-client?
9fc221b5 17549When true, clients are allowed to talk to each other inside the VPN.
2be1b471
JL
17550
17551Defaults to @samp{#f}.
17552
17553@end deftypevr
17554
1c17a863 17555@deftypevr {@code{openvpn-server-configuration} parameter} keepalive keepalive
2be1b471
JL
17556Causes ping-like messages to be sent back and forth over the link so
17557that each side knows when the other side has gone down. @code{keepalive}
17558requires a pair. The first element is the period of the ping sending,
17559and the second element is the timeout before considering the other side
17560down.
17561
17562@end deftypevr
17563
1c17a863 17564@deftypevr {@code{openvpn-server-configuration} parameter} number max-clients
2be1b471
JL
17565The maximum number of clients.
17566
17567Defaults to @samp{100}.
17568
17569@end deftypevr
17570
1c17a863 17571@deftypevr {@code{openvpn-server-configuration} parameter} string status
2be1b471 17572The status file. This file shows a small report on current connection.
9fc221b5 17573It is truncated and rewritten every minute.
2be1b471
JL
17574
17575Defaults to @samp{"/var/run/openvpn/status"}.
17576
17577@end deftypevr
17578
1c17a863 17579@deftypevr {@code{openvpn-server-configuration} parameter} openvpn-ccd-list client-config-dir
2be1b471
JL
17580The list of configuration for some clients.
17581
17582Defaults to @samp{()}.
17583
17584Available @code{openvpn-ccd-configuration} fields are:
17585
1c17a863 17586@deftypevr {@code{openvpn-ccd-configuration} parameter} string name
2be1b471
JL
17587Client name.
17588
17589Defaults to @samp{"client"}.
17590
17591@end deftypevr
17592
1c17a863 17593@deftypevr {@code{openvpn-ccd-configuration} parameter} ip-mask iroute
2be1b471
JL
17594Client own network
17595
17596Defaults to @samp{#f}.
17597
17598@end deftypevr
17599
1c17a863 17600@deftypevr {@code{openvpn-ccd-configuration} parameter} ip-mask ifconfig-push
2be1b471
JL
17601Client VPN IP.
17602
17603Defaults to @samp{#f}.
17604
17605@end deftypevr
17606
17607@end deftypevr
17608
17609
17610@c %end of automatic openvpn-server documentation
17611
17612
eb419bc9
JD
17613@node Network File System
17614@subsubsection Network File System
17615@cindex NFS
fe1a39d3 17616
eb419bc9
JD
17617The @code{(gnu services nfs)} module provides the following services,
17618which are most commonly used in relation to mounting or exporting
17619directory trees as @dfn{network file systems} (NFS).
d6a07ee6
JD
17620
17621@subsubheading RPC Bind Service
17622@cindex rpcbind
17623
eb419bc9
JD
17624The RPC Bind service provides a facility to map program numbers into
17625universal addresses.
17626Many NFS related services use this facility. Hence it is automatically
17627started when a dependent service starts.
d6a07ee6
JD
17628
17629@defvr {Scheme Variable} rpcbind-service-type
17630A service type for the RPC portmapper daemon.
17631@end defvr
17632
17633
17634@deftp {Data Type} rpcbind-configuration
17635Data type representing the configuration of the RPC Bind Service.
17636This type has the following parameters:
17637@table @asis
17638@item @code{rpcbind} (default: @code{rpcbind})
17639The rpcbind package to use.
17640
17641@item @code{warm-start?} (default: @code{#t})
17642If this parameter is @code{#t}, then the daemon will read a
17643state file on startup thus reloading state information saved by a previous
17644instance.
17645@end table
17646@end deftp
17647
eb419bc9
JD
17648
17649@subsubheading Pipefs Pseudo File System
17650@cindex pipefs
17651@cindex rpc_pipefs
17652
17653The pipefs file system is used to transfer NFS related data
17654between the kernel and user space programs.
17655
17656@defvr {Scheme Variable} pipefs-service-type
17657A service type for the pipefs pseudo file system.
17658@end defvr
17659
17660@deftp {Data Type} pipefs-configuration
17661Data type representing the configuration of the pipefs pseudo file system service.
17662This type has the following parameters:
17663@table @asis
17664@item @code{mount-point} (default: @code{"/var/lib/nfs/rpc_pipefs"})
17665The directory to which the file system is to be attached.
17666@end table
17667@end deftp
17668
17669
17670@subsubheading GSS Daemon Service
17671@cindex GSSD
17672@cindex GSS
17673@cindex global security system
17674
17675The @dfn{global security system} (GSS) daemon provides strong security for RPC
17676based protocols.
17677Before exchanging RPC requests an RPC client must establish a security
17678context. Typically this is done using the Kerberos command @command{kinit}
859e367d 17679or automatically at login time using PAM services (@pxref{Kerberos Services}).
eb419bc9
JD
17680
17681@defvr {Scheme Variable} gss-service-type
17682A service type for the Global Security System (GSS) daemon.
17683@end defvr
17684
17685@deftp {Data Type} gss-configuration
17686Data type representing the configuration of the GSS daemon service.
17687This type has the following parameters:
17688@table @asis
17689@item @code{nfs-utils} (default: @code{nfs-utils})
17690The package in which the @command{rpc.gssd} command is to be found.
17691
17692@item @code{pipefs-directory} (default: @code{"/var/lib/nfs/rpc_pipefs"})
17693The directory where the pipefs file system is mounted.
17694
17695@end table
17696@end deftp
17697
17698
17699@subsubheading IDMAP Daemon Service
17700@cindex idmapd
17701@cindex name mapper
17702
17703The idmap daemon service provides mapping between user IDs and user names.
17704Typically it is required in order to access file systems mounted via NFSv4.
17705
17706@defvr {Scheme Variable} idmap-service-type
17707A service type for the Identity Mapper (IDMAP) daemon.
17708@end defvr
17709
17710@deftp {Data Type} idmap-configuration
17711Data type representing the configuration of the IDMAP daemon service.
17712This type has the following parameters:
17713@table @asis
17714@item @code{nfs-utils} (default: @code{nfs-utils})
17715The package in which the @command{rpc.idmapd} command is to be found.
17716
17717@item @code{pipefs-directory} (default: @code{"/var/lib/nfs/rpc_pipefs"})
17718The directory where the pipefs file system is mounted.
17719
17720@item @code{domain} (default: @code{#f})
17721The local NFSv4 domain name.
17722This must be a string or @code{#f}.
17723If it is @code{#f} then the daemon will use the host's fully qualified domain name.
17724
17725@end table
17726@end deftp
17727
a7cf4eb6
ML
17728@node Continuous Integration
17729@subsubsection Continuous Integration
17730
17731@cindex continuous integration
4bfa256c
CL
17732@uref{https://git.savannah.gnu.org/cgit/guix/guix-cuirass.git, Cuirass} is a
17733continuous integration tool for Guix. It can be used both for development and
17734for providing substitutes to others (@pxref{Substitutes}).
a7cf4eb6
ML
17735
17736The @code{(gnu services cuirass)} module provides the following service.
17737
231eddc8
LC
17738@defvr {Scheme Procedure} cuirass-service-type
17739The type of the Cuirass service. Its value must be a
17740@code{cuirass-configuration} object, as described below.
17741@end defvr
a7cf4eb6 17742
231eddc8
LC
17743To add build jobs, you have to set the @code{specifications} field of
17744the configuration. Here is an example of a service defining a build job
17745based on a specification that can be found in Cuirass source tree. This
17746service polls the Guix repository and builds a subset of the Guix
17747packages, as prescribed in the @file{gnu-system.scm} example spec:
a7cf4eb6
ML
17748
17749@example
8de938d5
LC
17750(let ((spec #~((#:name . "guix")
17751 (#:url . "git://git.savannah.gnu.org/guix.git")
17752 (#:load-path . ".")
66bc1d2a
JN
17753 (#:file . "build-aux/cuirass/gnu-system.scm")
17754 (#:proc . cuirass-jobs)
8de938d5
LC
17755 (#:arguments (subset . "hello"))
17756 (#:branch . "master"))))
231eddc8
LC
17757 (service cuirass-service-type
17758 (cuirass-configuration
9bb98bcf 17759 (specifications #~(list '#$spec)))))
a7cf4eb6
ML
17760@end example
17761
231eddc8 17762While information related to build jobs is located directly in the
a7cf4eb6
ML
17763specifications, global settings for the @command{cuirass} process are
17764accessible in other @code{cuirass-configuration} fields.
17765
17766@deftp {Data Type} cuirass-configuration
17767Data type representing the configuration of Cuirass.
17768
17769@table @asis
b17e326f
LC
17770@item @code{log-file} (default: @code{"/var/log/cuirass.log"})
17771Location of the log file.
17772
463995da 17773@item @code{cache-directory} (default: @code{"/var/cache/cuirass"})
a7cf4eb6
ML
17774Location of the repository cache.
17775
17776@item @code{user} (default: @code{"cuirass"})
17777Owner of the @code{cuirass} process.
17778
17779@item @code{group} (default: @code{"cuirass"})
17780Owner's group of the @code{cuirass} process.
17781
17782@item @code{interval} (default: @code{60})
17783Number of seconds between the poll of the repositories followed by the
17784Cuirass jobs.
17785
17786@item @code{database} (default: @code{"/var/run/cuirass/cuirass.db"})
17787Location of sqlite database which contains the build results and previously
17788added specifications.
17789
1c05aab4 17790@item @code{port} (default: @code{8081})
11b7717d
MO
17791Port number used by the HTTP server.
17792
326f6ef1
JN
17793@item --listen=@var{host}
17794Listen on the network interface for @var{host}. The default is to
17795accept connections from localhost.
17796
8de938d5
LC
17797@item @code{specifications} (default: @code{#~'()})
17798A gexp (@pxref{G-Expressions}) that evaluates to a list of specifications,
17799where a specification is an association list
a7cf4eb6
ML
17800(@pxref{Associations Lists,,, guile, GNU Guile Reference Manual}) whose
17801keys are keywords (@code{#:keyword-example}) as shown in the example
17802above.
17803
17804@item @code{use-substitutes?} (default: @code{#f})
17805This allows using substitutes to avoid building every dependencies of a job
17806from source.
17807
17808@item @code{one-shot?} (default: @code{#f})
17809Only evaluate specifications and build derivations once.
379b6ba5 17810
c800fd56
MO
17811@item @code{fallback?} (default: @code{#f})
17812When substituting a pre-built binary fails, fall back to building
17813packages locally.
17814
379b6ba5
LC
17815@item @code{cuirass} (default: @code{cuirass})
17816The Cuirass package to use.
a7cf4eb6
ML
17817@end table
17818@end deftp
eb419bc9 17819
69390e29
NG
17820@node Power Management Services
17821@subsubsection Power Management Services
bfbf6e1e 17822
69390e29 17823@cindex tlp
bfbf6e1e 17824@cindex power management with TLP
69390e29
NG
17825@subsubheading TLP daemon
17826
bfbf6e1e
MO
17827The @code{(gnu services pm)} module provides a Guix service definition
17828for the Linux power management tool TLP.
17829
17830TLP enables various powersaving modes in userspace and kernel.
17831Contrary to @code{upower-service}, it is not a passive,
17832monitoring tool, as it will apply custom settings each time a new power
17833source is detected. More information can be found at
17834@uref{http://linrunner.de/en/tlp/tlp.html, TLP home page}.
17835
17836@deffn {Scheme Variable} tlp-service-type
17837The service type for the TLP tool. Its value should be a valid
3d3c5650
LC
17838TLP configuration (see below). To use the default settings, simply
17839write:
bfbf6e1e 17840@example
3d3c5650 17841(service tlp-service-type)
bfbf6e1e
MO
17842@end example
17843@end deffn
17844
17845By default TLP does not need much configuration but most TLP parameters
17846can be tweaked using @code{tlp-configuration}.
17847
17848Each parameter definition is preceded by its type; for example,
17849@samp{boolean foo} indicates that the @code{foo} parameter
17850should be specified as a boolean. Types starting with
17851@code{maybe-} denote parameters that won't show up in TLP config file
17852when their value is @code{'disabled}.
17853
17854@c The following documentation was initially generated by
17855@c (generate-tlp-documentation) in (gnu services pm). Manually maintained
17856@c documentation is better, so we shouldn't hesitate to edit below as
17857@c needed. However if the change you want to make to this documentation
17858@c can be done in an automated way, it's probably easier to change
17859@c (generate-documentation) than to make it below and have to deal with
17860@c the churn as TLP updates.
17861
17862Available @code{tlp-configuration} fields are:
17863
17864@deftypevr {@code{tlp-configuration} parameter} package tlp
17865The TLP package.
17866
17867@end deftypevr
17868
17869@deftypevr {@code{tlp-configuration} parameter} boolean tlp-enable?
17870Set to true if you wish to enable TLP.
17871
17872Defaults to @samp{#t}.
17873
17874@end deftypevr
17875
17876@deftypevr {@code{tlp-configuration} parameter} string tlp-default-mode
17877Default mode when no power supply can be detected. Alternatives are AC
17878and BAT.
17879
17880Defaults to @samp{"AC"}.
17881
17882@end deftypevr
17883
17884@deftypevr {@code{tlp-configuration} parameter} non-negative-integer disk-idle-secs-on-ac
17885Number of seconds Linux kernel has to wait after the disk goes idle,
17886before syncing on AC.
17887
17888Defaults to @samp{0}.
17889
17890@end deftypevr
17891
17892@deftypevr {@code{tlp-configuration} parameter} non-negative-integer disk-idle-secs-on-bat
17893Same as @code{disk-idle-ac} but on BAT mode.
17894
17895Defaults to @samp{2}.
17896
17897@end deftypevr
17898
17899@deftypevr {@code{tlp-configuration} parameter} non-negative-integer max-lost-work-secs-on-ac
17900Dirty pages flushing periodicity, expressed in seconds.
17901
17902Defaults to @samp{15}.
17903
17904@end deftypevr
17905
17906@deftypevr {@code{tlp-configuration} parameter} non-negative-integer max-lost-work-secs-on-bat
17907Same as @code{max-lost-work-secs-on-ac} but on BAT mode.
17908
17909Defaults to @samp{60}.
17910
17911@end deftypevr
17912
17913@deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list cpu-scaling-governor-on-ac
17914CPU frequency scaling governor on AC mode. With intel_pstate driver,
17915alternatives are powersave and performance. With acpi-cpufreq driver,
17916alternatives are ondemand, powersave, performance and conservative.
17917
17918Defaults to @samp{disabled}.
17919
17920@end deftypevr
17921
17922@deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list cpu-scaling-governor-on-bat
17923Same as @code{cpu-scaling-governor-on-ac} but on BAT mode.
17924
17925Defaults to @samp{disabled}.
17926
17927@end deftypevr
17928
17929@deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-scaling-min-freq-on-ac
17930Set the min available frequency for the scaling governor on AC.
17931
17932Defaults to @samp{disabled}.
17933
17934@end deftypevr
17935
17936@deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-scaling-max-freq-on-ac
17937Set the max available frequency for the scaling governor on AC.
17938
17939Defaults to @samp{disabled}.
17940
17941@end deftypevr
17942
17943@deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-scaling-min-freq-on-bat
17944Set the min available frequency for the scaling governor on BAT.
17945
17946Defaults to @samp{disabled}.
17947
17948@end deftypevr
17949
17950@deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-scaling-max-freq-on-bat
17951Set the max available frequency for the scaling governor on BAT.
17952
17953Defaults to @samp{disabled}.
17954
17955@end deftypevr
17956
17957@deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-min-perf-on-ac
17958Limit the min P-state to control the power dissipation of the CPU, in AC
17959mode. Values are stated as a percentage of the available performance.
17960
17961Defaults to @samp{disabled}.
17962
17963@end deftypevr
17964
17965@deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-max-perf-on-ac
17966Limit the max P-state to control the power dissipation of the CPU, in AC
17967mode. Values are stated as a percentage of the available performance.
17968
17969Defaults to @samp{disabled}.
17970
17971@end deftypevr
17972
17973@deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-min-perf-on-bat
17974Same as @code{cpu-min-perf-on-ac} on BAT mode.
17975
17976Defaults to @samp{disabled}.
17977
17978@end deftypevr
17979
17980@deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-max-perf-on-bat
17981Same as @code{cpu-max-perf-on-ac} on BAT mode.
17982
17983Defaults to @samp{disabled}.
17984
17985@end deftypevr
17986
17987@deftypevr {@code{tlp-configuration} parameter} maybe-boolean cpu-boost-on-ac?
17988Enable CPU turbo boost feature on AC mode.
17989
17990Defaults to @samp{disabled}.
17991
17992@end deftypevr
17993
17994@deftypevr {@code{tlp-configuration} parameter} maybe-boolean cpu-boost-on-bat?
17995Same as @code{cpu-boost-on-ac?} on BAT mode.
17996
17997Defaults to @samp{disabled}.
17998
17999@end deftypevr
18000
18001@deftypevr {@code{tlp-configuration} parameter} boolean sched-powersave-on-ac?
18002Allow Linux kernel to minimize the number of CPU cores/hyper-threads
18003used under light load conditions.
18004
18005Defaults to @samp{#f}.
18006
18007@end deftypevr
18008
18009@deftypevr {@code{tlp-configuration} parameter} boolean sched-powersave-on-bat?
18010Same as @code{sched-powersave-on-ac?} but on BAT mode.
18011
18012Defaults to @samp{#t}.
18013
18014@end deftypevr
18015
18016@deftypevr {@code{tlp-configuration} parameter} boolean nmi-watchdog?
18017Enable Linux kernel NMI watchdog.
18018
18019Defaults to @samp{#f}.
18020
18021@end deftypevr
18022
18023@deftypevr {@code{tlp-configuration} parameter} maybe-string phc-controls
18024For Linux kernels with PHC patch applied, change CPU voltages. An
18025example value would be @samp{"F:V F:V F:V F:V"}.
18026
18027Defaults to @samp{disabled}.
18028
18029@end deftypevr
18030
18031@deftypevr {@code{tlp-configuration} parameter} string energy-perf-policy-on-ac
18032Set CPU performance versus energy saving policy on AC. Alternatives are
18033performance, normal, powersave.
18034
18035Defaults to @samp{"performance"}.
18036
18037@end deftypevr
18038
18039@deftypevr {@code{tlp-configuration} parameter} string energy-perf-policy-on-bat
18040Same as @code{energy-perf-policy-ac} but on BAT mode.
18041
18042Defaults to @samp{"powersave"}.
18043
18044@end deftypevr
18045
18046@deftypevr {@code{tlp-configuration} parameter} space-separated-string-list disks-devices
18047Hard disk devices.
18048
18049@end deftypevr
18050
18051@deftypevr {@code{tlp-configuration} parameter} space-separated-string-list disk-apm-level-on-ac
18052Hard disk advanced power management level.
18053
18054@end deftypevr
18055
18056@deftypevr {@code{tlp-configuration} parameter} space-separated-string-list disk-apm-level-on-bat
18057Same as @code{disk-apm-bat} but on BAT mode.
18058
18059@end deftypevr
18060
18061@deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list disk-spindown-timeout-on-ac
18062Hard disk spin down timeout. One value has to be specified for each
18063declared hard disk.
18064
18065Defaults to @samp{disabled}.
18066
18067@end deftypevr
18068
18069@deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list disk-spindown-timeout-on-bat
18070Same as @code{disk-spindown-timeout-on-ac} but on BAT mode.
18071
18072Defaults to @samp{disabled}.
18073
18074@end deftypevr
18075
18076@deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list disk-iosched
18077Select IO scheduler for disk devices. One value has to be specified for
18078each declared hard disk. Example alternatives are cfq, deadline and
18079noop.
18080
18081Defaults to @samp{disabled}.
18082
18083@end deftypevr
18084
18085@deftypevr {@code{tlp-configuration} parameter} string sata-linkpwr-on-ac
18086SATA aggressive link power management (ALPM) level. Alternatives are
18087min_power, medium_power, max_performance.
18088
18089Defaults to @samp{"max_performance"}.
18090
18091@end deftypevr
18092
18093@deftypevr {@code{tlp-configuration} parameter} string sata-linkpwr-on-bat
18094Same as @code{sata-linkpwr-ac} but on BAT mode.
18095
18096Defaults to @samp{"min_power"}.
18097
18098@end deftypevr
18099
18100@deftypevr {@code{tlp-configuration} parameter} maybe-string sata-linkpwr-blacklist
18101Exclude specified SATA host devices for link power management.
18102
18103Defaults to @samp{disabled}.
18104
18105@end deftypevr
18106
18107@deftypevr {@code{tlp-configuration} parameter} maybe-on-off-boolean ahci-runtime-pm-on-ac?
18108Enable Runtime Power Management for AHCI controller and disks on AC
18109mode.
18110
18111Defaults to @samp{disabled}.
18112
18113@end deftypevr
18114
18115@deftypevr {@code{tlp-configuration} parameter} maybe-on-off-boolean ahci-runtime-pm-on-bat?
18116Same as @code{ahci-runtime-pm-on-ac} on BAT mode.
18117
18118Defaults to @samp{disabled}.
18119
18120@end deftypevr
18121
18122@deftypevr {@code{tlp-configuration} parameter} non-negative-integer ahci-runtime-pm-timeout
18123Seconds of inactivity before disk is suspended.
18124
18125Defaults to @samp{15}.
18126
18127@end deftypevr
18128
18129@deftypevr {@code{tlp-configuration} parameter} string pcie-aspm-on-ac
18130PCI Express Active State Power Management level. Alternatives are
18131default, performance, powersave.
18132
18133Defaults to @samp{"performance"}.
18134
18135@end deftypevr
18136
18137@deftypevr {@code{tlp-configuration} parameter} string pcie-aspm-on-bat
18138Same as @code{pcie-aspm-ac} but on BAT mode.
18139
18140Defaults to @samp{"powersave"}.
18141
18142@end deftypevr
18143
18144@deftypevr {@code{tlp-configuration} parameter} string radeon-power-profile-on-ac
18145Radeon graphics clock speed level. Alternatives are low, mid, high,
18146auto, default.
18147
18148Defaults to @samp{"high"}.
18149
18150@end deftypevr
18151
18152@deftypevr {@code{tlp-configuration} parameter} string radeon-power-profile-on-bat
18153Same as @code{radeon-power-ac} but on BAT mode.
18154
18155Defaults to @samp{"low"}.
18156
18157@end deftypevr
18158
18159@deftypevr {@code{tlp-configuration} parameter} string radeon-dpm-state-on-ac
18160Radeon dynamic power management method (DPM). Alternatives are battery,
18161performance.
18162
18163Defaults to @samp{"performance"}.
18164
18165@end deftypevr
18166
18167@deftypevr {@code{tlp-configuration} parameter} string radeon-dpm-state-on-bat
18168Same as @code{radeon-dpm-state-ac} but on BAT mode.
18169
18170Defaults to @samp{"battery"}.
18171
18172@end deftypevr
18173
18174@deftypevr {@code{tlp-configuration} parameter} string radeon-dpm-perf-level-on-ac
18175Radeon DPM performance level. Alternatives are auto, low, high.
18176
18177Defaults to @samp{"auto"}.
18178
18179@end deftypevr
18180
18181@deftypevr {@code{tlp-configuration} parameter} string radeon-dpm-perf-level-on-bat
18182Same as @code{radeon-dpm-perf-ac} but on BAT mode.
18183
18184Defaults to @samp{"auto"}.
18185
18186@end deftypevr
18187
18188@deftypevr {@code{tlp-configuration} parameter} on-off-boolean wifi-pwr-on-ac?
18189Wifi power saving mode.
18190
18191Defaults to @samp{#f}.
18192
18193@end deftypevr
18194
18195@deftypevr {@code{tlp-configuration} parameter} on-off-boolean wifi-pwr-on-bat?
18196Same as @code{wifi-power-ac?} but on BAT mode.
18197
18198Defaults to @samp{#t}.
18199
18200@end deftypevr
18201
18202@deftypevr {@code{tlp-configuration} parameter} y-n-boolean wol-disable?
18203Disable wake on LAN.
18204
18205Defaults to @samp{#t}.
18206
18207@end deftypevr
18208
18209@deftypevr {@code{tlp-configuration} parameter} non-negative-integer sound-power-save-on-ac
18210Timeout duration in seconds before activating audio power saving on
18211Intel HDA and AC97 devices. A value of 0 disables power saving.
18212
18213Defaults to @samp{0}.
18214
18215@end deftypevr
18216
18217@deftypevr {@code{tlp-configuration} parameter} non-negative-integer sound-power-save-on-bat
18218Same as @code{sound-powersave-ac} but on BAT mode.
18219
18220Defaults to @samp{1}.
18221
18222@end deftypevr
18223
18224@deftypevr {@code{tlp-configuration} parameter} y-n-boolean sound-power-save-controller?
18225Disable controller in powersaving mode on Intel HDA devices.
18226
18227Defaults to @samp{#t}.
18228
18229@end deftypevr
18230
18231@deftypevr {@code{tlp-configuration} parameter} boolean bay-poweroff-on-bat?
18232Enable optical drive in UltraBay/MediaBay on BAT mode. Drive can be
18233powered on again by releasing (and reinserting) the eject lever or by
18234pressing the disc eject button on newer models.
18235
18236Defaults to @samp{#f}.
18237
18238@end deftypevr
18239
18240@deftypevr {@code{tlp-configuration} parameter} string bay-device
18241Name of the optical drive device to power off.
18242
18243Defaults to @samp{"sr0"}.
18244
18245@end deftypevr
18246
18247@deftypevr {@code{tlp-configuration} parameter} string runtime-pm-on-ac
18248Runtime Power Management for PCI(e) bus devices. Alternatives are on
18249and auto.
18250
18251Defaults to @samp{"on"}.
18252
18253@end deftypevr
18254
18255@deftypevr {@code{tlp-configuration} parameter} string runtime-pm-on-bat
18256Same as @code{runtime-pm-ac} but on BAT mode.
18257
18258Defaults to @samp{"auto"}.
18259
18260@end deftypevr
18261
18262@deftypevr {@code{tlp-configuration} parameter} boolean runtime-pm-all?
18263Runtime Power Management for all PCI(e) bus devices, except blacklisted
18264ones.
18265
18266Defaults to @samp{#t}.
18267
18268@end deftypevr
18269
18270@deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list runtime-pm-blacklist
9fc221b5 18271Exclude specified PCI(e) device addresses from Runtime Power Management.
bfbf6e1e
MO
18272
18273Defaults to @samp{disabled}.
18274
18275@end deftypevr
18276
18277@deftypevr {@code{tlp-configuration} parameter} space-separated-string-list runtime-pm-driver-blacklist
18278Exclude PCI(e) devices assigned to the specified drivers from Runtime
18279Power Management.
18280
18281@end deftypevr
18282
18283@deftypevr {@code{tlp-configuration} parameter} boolean usb-autosuspend?
18284Enable USB autosuspend feature.
18285
18286Defaults to @samp{#t}.
18287
18288@end deftypevr
18289
18290@deftypevr {@code{tlp-configuration} parameter} maybe-string usb-blacklist
18291Exclude specified devices from USB autosuspend.
18292
18293Defaults to @samp{disabled}.
18294
18295@end deftypevr
18296
18297@deftypevr {@code{tlp-configuration} parameter} boolean usb-blacklist-wwan?
18298Exclude WWAN devices from USB autosuspend.
18299
18300Defaults to @samp{#t}.
18301
18302@end deftypevr
18303
18304@deftypevr {@code{tlp-configuration} parameter} maybe-string usb-whitelist
18305Include specified devices into USB autosuspend, even if they are already
18306excluded by the driver or via @code{usb-blacklist-wwan?}.
18307
18308Defaults to @samp{disabled}.
18309
18310@end deftypevr
18311
18312@deftypevr {@code{tlp-configuration} parameter} maybe-boolean usb-autosuspend-disable-on-shutdown?
18313Enable USB autosuspend before shutdown.
18314
18315Defaults to @samp{disabled}.
18316
18317@end deftypevr
18318
18319@deftypevr {@code{tlp-configuration} parameter} boolean restore-device-state-on-startup?
18320Restore radio device state (bluetooth, wifi, wwan) from previous
18321shutdown on system startup.
18322
18323Defaults to @samp{#f}.
18324
18325@end deftypevr
18326
69390e29
NG
18327@cindex thermald
18328@cindex CPU frequency scaling with thermald
18329@subsubheading Thermald daemon
d7fa39cc
CAW
18330
18331The @code{(gnu services pm)} module provides an interface to
18332thermald, a CPU frequency scaling service which helps prevent overheating.
18333
18334@defvr {Scheme Variable} thermald-service-type
18335This is the service type for
18336@uref{https://01.org/linux-thermal-daemon/, thermald}, the Linux
18337Thermal Daemon, which is responsible for controlling the thermal state
18338of processors and preventing overheating.
18339@end defvr
18340
18341@deftp {Data Type} thermald-configuration
18342Data type representing the configuration of @code{thermald-service-type}.
18343
18344@table @asis
18345@item @code{ignore-cpuid-check?} (default: @code{#f})
18346Ignore cpuid check for supported CPU models.
18347
18348@item @code{thermald} (default: @var{thermald})
18349Package object of thermald.
18350
18351@end table
18352@end deftp
18353
06465d2b
PM
18354@node Audio Services
18355@subsubsection Audio Services
18356
18357The @code{(gnu services audio)} module provides a service to start MPD
18358(the Music Player Daemon).
18359
18360@cindex mpd
18361@subsubheading Music Player Daemon
18362
18363The Music Player Daemon (MPD) is a service that can play music while
18364being controlled from the local machine or over the network by a variety
18365of clients.
18366
18367The following example shows how one might run @code{mpd} as user
18368@code{"bob"} on port @code{6666}. It uses pulseaudio for output.
18369
18370@example
18371(service mpd-service-type
18372 (mpd-configuration
18373 (user "bob")
18374 (port "6666")))
18375@end example
18376
18377@defvr {Scheme Variable} mpd-service-type
18378The service type for @command{mpd}
18379@end defvr
18380
18381@deftp {Data Type} mpd-configuration
18382Data type representing the configuration of @command{mpd}.
18383
18384@table @asis
18385@item @code{user} (default: @code{"mpd"})
18386The user to run mpd as.
18387
18388@item @code{music-dir} (default: @code{"~/Music"})
18389The directory to scan for music files.
18390
18391@item @code{playlist-dir} (default: @code{"~/.mpd/playlists"})
18392The directory to store playlists.
18393
06465d2b
PM
18394@item @code{port} (default: @code{"6600"})
18395The port to run mpd on.
18396
18397@item @code{address} (default: @code{"any"})
18398The address that mpd will bind to. To use a Unix domain socket,
18399an absolute path can be specified here.
18400
18401@end table
18402@end deftp
d7fa39cc 18403
e6051057
RM
18404@node Virtualization Services
18405@subsubsection Virtualization services
6738c29f 18406
e6051057 18407The @code{(gnu services virtualization)} module provides services for
6738c29f
LC
18408the libvirt and virtlog daemons, as well as other virtualization-related
18409services.
e6051057
RM
18410
18411@subsubheading Libvirt daemon
18412@code{libvirtd} is the server side daemon component of the libvirt
18413virtualization management system. This daemon runs on host servers
18414and performs required management tasks for virtualized guests.
18415
18416@deffn {Scheme Variable} libvirt-service-type
18417This is the type of the @uref{https://libvirt.org, libvirt daemon}.
18418Its value must be a @code{libvirt-configuration}.
18419
18420@example
18421(service libvirt-service-type
18422 (libvirt-configuration
18423 (unix-sock-group "libvirt")
18424 (tls-port "16555")))
18425@end example
18426@end deffn
18427
18428@c Auto-generated with (generate-libvirt-documentation)
18429Available @code{libvirt-configuration} fields are:
18430
18431@deftypevr {@code{libvirt-configuration} parameter} package libvirt
18432Libvirt package.
18433
18434@end deftypevr
18435
18436@deftypevr {@code{libvirt-configuration} parameter} boolean listen-tls?
18437Flag listening for secure TLS connections on the public TCP/IP port.
18438must set @code{listen} for this to have any effect.
18439
18440It is necessary to setup a CA and issue server certificates before using
18441this capability.
18442
18443Defaults to @samp{#t}.
18444
18445@end deftypevr
18446
18447@deftypevr {@code{libvirt-configuration} parameter} boolean listen-tcp?
18448Listen for unencrypted TCP connections on the public TCP/IP port. must
18449set @code{listen} for this to have any effect.
18450
18451Using the TCP socket requires SASL authentication by default. Only SASL
18452mechanisms which support data encryption are allowed. This is
18453DIGEST_MD5 and GSSAPI (Kerberos5)
18454
18455Defaults to @samp{#f}.
18456
18457@end deftypevr
18458
18459@deftypevr {@code{libvirt-configuration} parameter} string tls-port
18460Port for accepting secure TLS connections This can be a port number, or
18461service name
18462
18463Defaults to @samp{"16514"}.
18464
18465@end deftypevr
18466
18467@deftypevr {@code{libvirt-configuration} parameter} string tcp-port
18468Port for accepting insecure TCP connections This can be a port number,
18469or service name
18470
18471Defaults to @samp{"16509"}.
18472
18473@end deftypevr
18474
18475@deftypevr {@code{libvirt-configuration} parameter} string listen-addr
18476IP address or hostname used for client connections.
18477
18478Defaults to @samp{"0.0.0.0"}.
18479
18480@end deftypevr
18481
18482@deftypevr {@code{libvirt-configuration} parameter} boolean mdns-adv?
18483Flag toggling mDNS advertisement of the libvirt service.
18484
18485Alternatively can disable for all services on a host by stopping the
18486Avahi daemon.
18487
18488Defaults to @samp{#f}.
18489
18490@end deftypevr
18491
18492@deftypevr {@code{libvirt-configuration} parameter} string mdns-name
18493Default mDNS advertisement name. This must be unique on the immediate
18494broadcast network.
18495
18496Defaults to @samp{"Virtualization Host <hostname>"}.
18497
18498@end deftypevr
18499
18500@deftypevr {@code{libvirt-configuration} parameter} string unix-sock-group
18501UNIX domain socket group ownership. This can be used to allow a
18502'trusted' set of users access to management capabilities without
18503becoming root.
18504
18505Defaults to @samp{"root"}.
18506
18507@end deftypevr
18508
18509@deftypevr {@code{libvirt-configuration} parameter} string unix-sock-ro-perms
18510UNIX socket permissions for the R/O socket. This is used for monitoring
18511VM status only.
18512
18513Defaults to @samp{"0777"}.
18514
18515@end deftypevr
18516
18517@deftypevr {@code{libvirt-configuration} parameter} string unix-sock-rw-perms
18518UNIX socket permissions for the R/W socket. Default allows only root.
18519If PolicyKit is enabled on the socket, the default will change to allow
18520everyone (eg, 0777)
18521
18522Defaults to @samp{"0770"}.
18523
18524@end deftypevr
18525
18526@deftypevr {@code{libvirt-configuration} parameter} string unix-sock-admin-perms
18527UNIX socket permissions for the admin socket. Default allows only owner
18528(root), do not change it unless you are sure to whom you are exposing
18529the access to.
18530
18531Defaults to @samp{"0777"}.
18532
18533@end deftypevr
18534
18535@deftypevr {@code{libvirt-configuration} parameter} string unix-sock-dir
18536The directory in which sockets will be found/created.
18537
18538Defaults to @samp{"/var/run/libvirt"}.
18539
18540@end deftypevr
18541
18542@deftypevr {@code{libvirt-configuration} parameter} string auth-unix-ro
18543Authentication scheme for UNIX read-only sockets. By default socket
18544permissions allow anyone to connect
18545
18546Defaults to @samp{"polkit"}.
18547
18548@end deftypevr
18549
18550@deftypevr {@code{libvirt-configuration} parameter} string auth-unix-rw
18551Authentication scheme for UNIX read-write sockets. By default socket
18552permissions only allow root. If PolicyKit support was compiled into
18553libvirt, the default will be to use 'polkit' auth.
18554
18555Defaults to @samp{"polkit"}.
18556
18557@end deftypevr
18558
18559@deftypevr {@code{libvirt-configuration} parameter} string auth-tcp
18560Authentication scheme for TCP sockets. If you don't enable SASL, then
18561all TCP traffic is cleartext. Don't do this outside of a dev/test
18562scenario.
18563
18564Defaults to @samp{"sasl"}.
18565
18566@end deftypevr
18567
18568@deftypevr {@code{libvirt-configuration} parameter} string auth-tls
18569Authentication scheme for TLS sockets. TLS sockets already have
18570encryption provided by the TLS layer, and limited authentication is done
18571by certificates.
18572
18573It is possible to make use of any SASL authentication mechanism as well,
18574by using 'sasl' for this option
18575
18576Defaults to @samp{"none"}.
18577
18578@end deftypevr
18579
18580@deftypevr {@code{libvirt-configuration} parameter} optional-list access-drivers
18581API access control scheme.
18582
18583By default an authenticated user is allowed access to all APIs. Access
18584drivers can place restrictions on this.
18585
18586Defaults to @samp{()}.
18587
18588@end deftypevr
18589
18590@deftypevr {@code{libvirt-configuration} parameter} string key-file
18591Server key file path. If set to an empty string, then no private key is
18592loaded.
18593
18594Defaults to @samp{""}.
18595
18596@end deftypevr
18597
18598@deftypevr {@code{libvirt-configuration} parameter} string cert-file
18599Server key file path. If set to an empty string, then no certificate is
18600loaded.
18601
18602Defaults to @samp{""}.
18603
18604@end deftypevr
18605
18606@deftypevr {@code{libvirt-configuration} parameter} string ca-file
18607Server key file path. If set to an empty string, then no CA certificate
18608is loaded.
18609
18610Defaults to @samp{""}.
18611
18612@end deftypevr
18613
18614@deftypevr {@code{libvirt-configuration} parameter} string crl-file
18615Certificate revocation list path. If set to an empty string, then no
18616CRL is loaded.
18617
18618Defaults to @samp{""}.
18619
18620@end deftypevr
18621
18622@deftypevr {@code{libvirt-configuration} parameter} boolean tls-no-sanity-cert
18623Disable verification of our own server certificates.
18624
18625When libvirtd starts it performs some sanity checks against its own
18626certificates.
18627
18628Defaults to @samp{#f}.
18629
18630@end deftypevr
18631
18632@deftypevr {@code{libvirt-configuration} parameter} boolean tls-no-verify-cert
18633Disable verification of client certificates.
18634
18635Client certificate verification is the primary authentication mechanism.
18636Any client which does not present a certificate signed by the CA will be
18637rejected.
18638
18639Defaults to @samp{#f}.
18640
18641@end deftypevr
18642
18643@deftypevr {@code{libvirt-configuration} parameter} optional-list tls-allowed-dn-list
18644Whitelist of allowed x509 Distinguished Name.
18645
18646Defaults to @samp{()}.
18647
18648@end deftypevr
18649
18650@deftypevr {@code{libvirt-configuration} parameter} optional-list sasl-allowed-usernames
18651Whitelist of allowed SASL usernames. The format for username depends on
18652the SASL authentication mechanism.
18653
18654Defaults to @samp{()}.
18655
18656@end deftypevr
18657
18658@deftypevr {@code{libvirt-configuration} parameter} string tls-priority
18659Override the compile time default TLS priority string. The default is
18660usually "NORMAL" unless overridden at build time. Only set this is it
18661is desired for libvirt to deviate from the global default settings.
18662
18663Defaults to @samp{"NORMAL"}.
18664
18665@end deftypevr
18666
18667@deftypevr {@code{libvirt-configuration} parameter} integer max-clients
18668Maximum number of concurrent client connections to allow over all
18669sockets combined.
18670
18671Defaults to @samp{5000}.
18672
18673@end deftypevr
18674
18675@deftypevr {@code{libvirt-configuration} parameter} integer max-queued-clients
18676Maximum length of queue of connections waiting to be accepted by the
18677daemon. Note, that some protocols supporting retransmission may obey
18678this so that a later reattempt at connection succeeds.
18679
18680Defaults to @samp{1000}.
18681
18682@end deftypevr
18683
18684@deftypevr {@code{libvirt-configuration} parameter} integer max-anonymous-clients
18685Maximum length of queue of accepted but not yet authenticated clients.
18686Set this to zero to turn this feature off
18687
18688Defaults to @samp{20}.
18689
18690@end deftypevr
18691
18692@deftypevr {@code{libvirt-configuration} parameter} integer min-workers
18693Number of workers to start up initially.
18694
18695Defaults to @samp{5}.
18696
18697@end deftypevr
18698
18699@deftypevr {@code{libvirt-configuration} parameter} integer max-workers
18700Maximum number of worker threads.
18701
18702If the number of active clients exceeds @code{min-workers}, then more
18703threads are spawned, up to max_workers limit. Typically you'd want
18704max_workers to equal maximum number of clients allowed.
18705
18706Defaults to @samp{20}.
18707
18708@end deftypevr
18709
18710@deftypevr {@code{libvirt-configuration} parameter} integer prio-workers
18711Number of priority workers. If all workers from above pool are stuck,
18712some calls marked as high priority (notably domainDestroy) can be
18713executed in this pool.
18714
18715Defaults to @samp{5}.
18716
18717@end deftypevr
18718
18719@deftypevr {@code{libvirt-configuration} parameter} integer max-requests
18720Total global limit on concurrent RPC calls.
18721
18722Defaults to @samp{20}.
18723
18724@end deftypevr
18725
18726@deftypevr {@code{libvirt-configuration} parameter} integer max-client-requests
18727Limit on concurrent requests from a single client connection. To avoid
18728one client monopolizing the server this should be a small fraction of
18729the global max_requests and max_workers parameter.
18730
18731Defaults to @samp{5}.
18732
18733@end deftypevr
18734
18735@deftypevr {@code{libvirt-configuration} parameter} integer admin-min-workers
18736Same as @code{min-workers} but for the admin interface.
18737
18738Defaults to @samp{1}.
18739
18740@end deftypevr
18741
18742@deftypevr {@code{libvirt-configuration} parameter} integer admin-max-workers
18743Same as @code{max-workers} but for the admin interface.
18744
18745Defaults to @samp{5}.
18746
18747@end deftypevr
18748
18749@deftypevr {@code{libvirt-configuration} parameter} integer admin-max-clients
18750Same as @code{max-clients} but for the admin interface.
18751
18752Defaults to @samp{5}.
18753
18754@end deftypevr
18755
18756@deftypevr {@code{libvirt-configuration} parameter} integer admin-max-queued-clients
18757Same as @code{max-queued-clients} but for the admin interface.
18758
18759Defaults to @samp{5}.
18760
18761@end deftypevr
18762
18763@deftypevr {@code{libvirt-configuration} parameter} integer admin-max-client-requests
18764Same as @code{max-client-requests} but for the admin interface.
18765
18766Defaults to @samp{5}.
18767
18768@end deftypevr
18769
18770@deftypevr {@code{libvirt-configuration} parameter} integer log-level
18771Logging level. 4 errors, 3 warnings, 2 information, 1 debug.
18772
18773Defaults to @samp{3}.
18774
18775@end deftypevr
18776
18777@deftypevr {@code{libvirt-configuration} parameter} string log-filters
18778Logging filters.
18779
18780A filter allows to select a different logging level for a given category
18781of logs The format for a filter is one of:
18782
18783@itemize @bullet
18784@item
18785x:name
18786
18787@item
18788x:+name
18789
18790@end itemize
18791
18792where @code{name} is a string which is matched against the category
18793given in the @code{VIR_LOG_INIT()} at the top of each libvirt source
18794file, e.g., "remote", "qemu", or "util.json" (the name in the filter can
18795be a substring of the full category name, in order to match multiple
18796similar categories), the optional "+" prefix tells libvirt to log stack
18797trace for each message matching name, and @code{x} is the minimal level
18798where matching messages should be logged:
18799
18800@itemize @bullet
18801@item
188021: DEBUG
18803
18804@item
188052: INFO
18806
18807@item
188083: WARNING
18809
18810@item
188114: ERROR
18812
18813@end itemize
18814
18815Multiple filters can be defined in a single filters statement, they just
18816need to be separated by spaces.
18817
18818Defaults to @samp{"3:remote 4:event"}.
18819
18820@end deftypevr
18821
18822@deftypevr {@code{libvirt-configuration} parameter} string log-outputs
18823Logging outputs.
18824
18825An output is one of the places to save logging information The format
18826for an output can be:
18827
18828@table @code
18829@item x:stderr
18830output goes to stderr
18831
18832@item x:syslog:name
18833use syslog for the output and use the given name as the ident
18834
18835@item x:file:file_path
18836output to a file, with the given filepath
18837
18838@item x:journald
18839output to journald logging system
18840
18841@end table
18842
18843In all case the x prefix is the minimal level, acting as a filter
18844
18845@itemize @bullet
18846@item
188471: DEBUG
18848
18849@item
188502: INFO
18851
18852@item
188533: WARNING
18854
18855@item
188564: ERROR
18857
18858@end itemize
18859
18860Multiple outputs can be defined, they just need to be separated by
18861spaces.
18862
18863Defaults to @samp{"3:stderr"}.
18864
18865@end deftypevr
18866
18867@deftypevr {@code{libvirt-configuration} parameter} integer audit-level
18868Allows usage of the auditing subsystem to be altered
18869
18870@itemize @bullet
18871@item
188720: disable all auditing
18873
18874@item
188751: enable auditing, only if enabled on host
18876
18877@item
188782: enable auditing, and exit if disabled on host.
18879
18880@end itemize
18881
18882Defaults to @samp{1}.
18883
18884@end deftypevr
18885
18886@deftypevr {@code{libvirt-configuration} parameter} boolean audit-logging
18887Send audit messages via libvirt logging infrastructure.
18888
18889Defaults to @samp{#f}.
18890
18891@end deftypevr
18892
18893@deftypevr {@code{libvirt-configuration} parameter} optional-string host-uuid
18894Host UUID. UUID must not have all digits be the same.
18895
18896Defaults to @samp{""}.
18897
18898@end deftypevr
18899
18900@deftypevr {@code{libvirt-configuration} parameter} string host-uuid-source
18901Source to read host UUID.
18902
18903@itemize @bullet
18904@item
18905@code{smbios}: fetch the UUID from @code{dmidecode -s system-uuid}
18906
18907@item
18908@code{machine-id}: fetch the UUID from @code{/etc/machine-id}
18909
18910@end itemize
18911
18912If @code{dmidecode} does not provide a valid UUID a temporary UUID will
18913be generated.
18914
18915Defaults to @samp{"smbios"}.
18916
18917@end deftypevr
18918
18919@deftypevr {@code{libvirt-configuration} parameter} integer keepalive-interval
18920A keepalive message is sent to a client after @code{keepalive_interval}
18921seconds of inactivity to check if the client is still responding. If
18922set to -1, libvirtd will never send keepalive requests; however clients
18923can still send them and the daemon will send responses.
18924
18925Defaults to @samp{5}.
18926
18927@end deftypevr
18928
18929@deftypevr {@code{libvirt-configuration} parameter} integer keepalive-count
18930Maximum number of keepalive messages that are allowed to be sent to the
18931client without getting any response before the connection is considered
18932broken.
18933
18934In other words, the connection is automatically closed approximately
18935after @code{keepalive_interval * (keepalive_count + 1)} seconds since
18936the last message received from the client. When @code{keepalive-count}
18937is set to 0, connections will be automatically closed after
18938@code{keepalive-interval} seconds of inactivity without sending any
18939keepalive messages.
18940
18941Defaults to @samp{5}.
18942
18943@end deftypevr
18944
18945@deftypevr {@code{libvirt-configuration} parameter} integer admin-keepalive-interval
18946Same as above but for admin interface.
18947
18948Defaults to @samp{5}.
18949
18950@end deftypevr
18951
18952@deftypevr {@code{libvirt-configuration} parameter} integer admin-keepalive-count
18953Same as above but for admin interface.
18954
18955Defaults to @samp{5}.
18956
18957@end deftypevr
18958
18959@deftypevr {@code{libvirt-configuration} parameter} integer ovs-timeout
18960Timeout for Open vSwitch calls.
18961
18962The @code{ovs-vsctl} utility is used for the configuration and its
18963timeout option is set by default to 5 seconds to avoid potential
18964infinite waits blocking libvirt.
18965
18966Defaults to @samp{5}.
18967
18968@end deftypevr
18969
18970@c %end of autogenerated docs
18971
18972@subsubheading Virtlog daemon
18973The virtlogd service is a server side daemon component of libvirt that is
18974used to manage logs from virtual machine consoles.
18975
18976This daemon is not used directly by libvirt client applications, rather it
18977is called on their behalf by @code{libvirtd}. By maintaining the logs in a
18978standalone daemon, the main @code{libvirtd} daemon can be restarted without
18979risk of losing logs. The @code{virtlogd} daemon has the ability to re-exec()
18980itself upon receiving @code{SIGUSR1}, to allow live upgrades without downtime.
18981
18982@deffn {Scheme Variable} virtlog-service-type
18983This is the type of the virtlog daemon.
18984Its value must be a @code{virtlog-configuration}.
18985
18986@example
18987(service virtlog-service-type
18988 (virtlog-configuration
18989 (max-clients 1000)))
18990@end example
18991@end deffn
18992
18993@deftypevr {@code{virtlog-configuration} parameter} integer log-level
18994Logging level. 4 errors, 3 warnings, 2 information, 1 debug.
18995
18996Defaults to @samp{3}.
18997
18998@end deftypevr
18999
19000@deftypevr {@code{virtlog-configuration} parameter} string log-filters
19001Logging filters.
19002
19003A filter allows to select a different logging level for a given category
19004of logs The format for a filter is one of:
19005
19006@itemize @bullet
19007@item
19008x:name
19009
19010@item
19011x:+name
19012
19013@end itemize
19014
19015where @code{name} is a string which is matched against the category
19016given in the @code{VIR_LOG_INIT()} at the top of each libvirt source
19017file, e.g., "remote", "qemu", or "util.json" (the name in the filter can
19018be a substring of the full category name, in order to match multiple
19019similar categories), the optional "+" prefix tells libvirt to log stack
19020trace for each message matching name, and @code{x} is the minimal level
19021where matching messages should be logged:
19022
19023@itemize @bullet
19024@item
190251: DEBUG
19026
19027@item
190282: INFO
19029
19030@item
190313: WARNING
19032
19033@item
190344: ERROR
19035
19036@end itemize
19037
19038Multiple filters can be defined in a single filters statement, they just
19039need to be separated by spaces.
19040
19041Defaults to @samp{"3:remote 4:event"}.
19042
19043@end deftypevr
19044
19045@deftypevr {@code{virtlog-configuration} parameter} string log-outputs
19046Logging outputs.
19047
19048An output is one of the places to save logging information The format
19049for an output can be:
19050
19051@table @code
19052@item x:stderr
19053output goes to stderr
19054
19055@item x:syslog:name
19056use syslog for the output and use the given name as the ident
19057
19058@item x:file:file_path
19059output to a file, with the given filepath
19060
19061@item x:journald
19062output to journald logging system
19063
19064@end table
19065
19066In all case the x prefix is the minimal level, acting as a filter
19067
19068@itemize @bullet
19069@item
190701: DEBUG
19071
19072@item
190732: INFO
19074
19075@item
190763: WARNING
19077
19078@item
190794: ERROR
19080
19081@end itemize
19082
19083Multiple outputs can be defined, they just need to be separated by
19084spaces.
19085
19086Defaults to @samp{"3:stderr"}.
19087
19088@end deftypevr
19089
19090@deftypevr {@code{virtlog-configuration} parameter} integer max-clients
19091Maximum number of concurrent client connections to allow over all
19092sockets combined.
19093
19094Defaults to @samp{1024}.
19095
19096@end deftypevr
19097
19098@deftypevr {@code{virtlog-configuration} parameter} integer max-size
19099Maximum file size before rolling over.
19100
19101Defaults to @samp{2MB}
19102
19103@end deftypevr
19104
19105@deftypevr {@code{virtlog-configuration} parameter} integer max-backups
19106Maximum number of backup files to keep.
19107
19108Defaults to @samp{3}
19109
19110@end deftypevr
19111
6738c29f
LC
19112@subsubheading Transparent Emulation with QEMU
19113
19114@cindex emulation
19115@cindex @code{binfmt_misc}
19116@code{qemu-binfmt-service-type} provides support for transparent
19117emulation of program binaries built for different architectures---e.g.,
19118it allows you to transparently execute an ARMv7 program on an x86_64
19119machine. It achieves this by combining the @uref{https://www.qemu.org,
19120QEMU} emulator and the @code{binfmt_misc} feature of the kernel Linux.
19121
19122@defvr {Scheme Variable} qemu-binfmt-service-type
19123This is the type of the QEMU/binfmt service for transparent emulation.
19124Its value must be a @code{qemu-binfmt-configuration} object, which
19125specifies the QEMU package to use as well as the architecture we want to
19126emulated:
19127
19128@example
19129(service qemu-binfmt-service-type
19130 (qemu-binfmt-configuration
19131 (platforms (lookup-qemu-platforms "arm" "aarch64" "ppc"))))
19132@end example
19133
19134In this example, we enable transparent emulation for the ARM and aarch64
19135platforms. Running @code{herd stop qemu-binfmt} turns it off, and
19136running @code{herd start qemu-binfmt} turns it back on (@pxref{Invoking
19137herd, the @command{herd} command,, shepherd, The GNU Shepherd Manual}).
19138@end defvr
19139
19140@deftp {Data Type} qemu-binfmt-configuration
19141This is the configuration for the @code{qemu-binfmt} service.
19142
19143@table @asis
19144@item @code{platforms} (default: @code{'()})
19145The list of emulated QEMU platforms. Each item must be a @dfn{platform
19146object} as returned by @code{lookup-qemu-platforms} (see below).
19147
71b98b9d
LC
19148@item @code{guix-support?} (default: @code{#f})
19149When it is true, QEMU and all its dependencies are added to the build
19150environment of @command{guix-daemon} (@pxref{Invoking guix-daemon,
19151@code{--chroot-directory} option}). This allows the @code{binfmt_misc}
19152handlers to be used within the build environment, which in turn means
19153that you can transparently build programs for another architecture.
19154
19155For example, let's suppose you're on an x86_64 machine and you have this
19156service:
19157
19158@example
19159(service qemu-binfmt-service-type
19160 (qemu-binfmt-configuration
19161 (platforms (lookup-qemu-platforms "arm"))
ba491912 19162 (guix-support? #t)))
71b98b9d
LC
19163@end example
19164
19165You can run:
19166
19167@example
19168guix build -s armhf-linux inkscape
19169@end example
19170
19171@noindent
19172and it will build Inkscape for ARMv7 @emph{as if it were a native
19173build}, transparently using QEMU to emulate the ARMv7 CPU. Pretty handy
19174if you'd like to test a package build for an architecture you don't have
19175access to!
19176
6738c29f
LC
19177@item @code{qemu} (default: @code{qemu})
19178The QEMU package to use.
19179@end table
19180@end deftp
19181
19182@deffn {Scheme Procedure} lookup-qemu-platforms @var{platforms}@dots{}
19183Return the list of QEMU platform objects corresponding to
19184@var{platforms}@dots{}. @var{platforms} must be a list of strings
19185corresponding to platform names, such as @code{"arm"}, @code{"sparc"},
19186@code{"mips64el"}, and so on.
19187@end deffn
19188
19189@deffn {Scheme Procedure} qemu-platform? @var{obj}
19190Return true if @var{obj} is a platform object.
19191@end deffn
19192
19193@deffn {Scheme Procedure} qemu-platform-name @var{platform}
19194Return the name of @var{platform}---a string such as @code{"arm"}.
19195@end deffn
e6051057 19196
05f1cb3c
AW
19197@node Version Control Services
19198@subsubsection Version Control Services
19199
19200The @code{(gnu services version-control)} module provides a service to
03e1cca2 19201allow remote access to local Git repositories. There are three options:
41034934 19202the @code{git-daemon-service}, which provides access to repositories via
03e1cca2 19203the @code{git://} unsecured TCP-based protocol, extending the
41034934 19204@code{nginx} web server to proxy some requests to
03e1cca2
LF
19205@code{git-http-backend}, or providing a web interface with
19206@code{cgit-service-type}.
05f1cb3c
AW
19207
19208@deffn {Scheme Procedure} git-daemon-service [#:config (git-daemon-configuration)]
19209
19210Return a service that runs @command{git daemon}, a simple TCP server to
19211expose repositories over the Git protocol for anonymous access.
19212
19213The optional @var{config} argument should be a
19214@code{<git-daemon-configuration>} object, by default it allows read-only
19215access to exported@footnote{By creating the magic file
19216"git-daemon-export-ok" in the repository directory.} repositories under
19217@file{/srv/git}.
19218
19219@end deffn
19220
19221@deftp {Data Type} git-daemon-configuration
19222Data type representing the configuration for @code{git-daemon-service}.
19223
19224@table @asis
19225@item @code{package} (default: @var{git})
19226Package object of the Git distributed version control system.
19227
19228@item @code{export-all?} (default: @var{#f})
19229Whether to allow access for all Git repositories, even if they do not
19230have the @file{git-daemon-export-ok} file.
19231
19232@item @code{base-path} (default: @file{/srv/git})
19233Whether to remap all the path requests as relative to the given path.
19234If you run git daemon with @var{(base-path "/srv/git")} on example.com,
19235then if you later try to pull @code{git://example.com/hello.git}, git
19236daemon will interpret the path as @code{/srv/git/hello.git}.
19237
19238@item @code{user-path} (default: @var{#f})
19239Whether to allow @code{~user} notation to be used in requests. When
19240specified with empty string, requests to @code{git://host/~alice/foo} is
19241taken as a request to access @code{foo} repository in the home directory
19242of user @code{alice}. If @var{(user-path "path")} is specified, the
19243same request is taken as a request to access @code{path/foo} repository
19244in the home directory of user @code{alice}.
19245
19246@item @code{listen} (default: @var{'()})
19247Whether to listen on specific IP addresses or hostnames, defaults to
19248all.
19249
19250@item @code{port} (default: @var{#f})
19251Whether to listen on an alternative port, which defaults to 9418.
19252
19253@item @code{whitelist} (default: @var{'()})
19254If not empty, only allow access to this list of directories.
19255
19256@item @code{extra-options} (default: @var{'()})
19257Extra options will be passed to @code{git daemon}, please run
19258@command{man git-daemon} for more information.
19259
19260@end table
19261@end deftp
19262
41034934
AW
19263The @code{git://} protocol lacks authentication. When you pull from a
19264repository fetched via @code{git://}, you don't know that the data you
19265receive was modified is really coming from the specified host, and you
19266have your connection is subject to eavesdropping. It's better to use an
19267authenticated and encrypted transport, such as @code{https}. Although Git allows you
19268to serve repositories using unsophisticated file-based web servers,
19269there is a faster protocol implemented by the @code{git-http-backend}
19270program. This program is the back-end of a proper Git web service. It
19271is designed to sit behind a FastCGI proxy. @xref{Web Services}, for more
19272on running the necessary @code{fcgiwrap} daemon.
19273
19274Guix has a separate configuration data type for serving Git repositories
19275over HTTP.
19276
19277@deftp {Data Type} git-http-configuration
19278Data type representing the configuration for @code{git-http-service}.
19279
19280@table @asis
19281@item @code{package} (default: @var{git})
19282Package object of the Git distributed version control system.
19283
19284@item @code{git-root} (default: @file{/srv/git})
19285Directory containing the Git repositories to expose to the world.
19286
19287@item @code{export-all?} (default: @var{#f})
19288Whether to expose access for all Git repositories in @var{git-root},
19289even if they do not have the @file{git-daemon-export-ok} file.
19290
19291@item @code{uri-path} (default: @file{/git/})
19292Path prefix for Git access. With the default @code{/git/} prefix, this
19293will map @code{http://@var{server}/git/@var{repo}.git} to
19294@code{/srv/git/@var{repo}.git}. Requests whose URI paths do not begin
19295with this prefix are not passed on to this Git instance.
19296
19297@item @code{fcgiwrap-socket} (default: @code{127.0.0.1:9000})
19298The socket on which the @code{fcgiwrap} daemon is listening. @xref{Web
19299Services}.
19300@end table
19301@end deftp
19302
19303There is no @code{git-http-service-type}, currently; instead you can
19304create an @code{nginx-location-configuration} from a
19305@code{git-http-configuration} and then add that location to a web
19306server.
19307
19308@deffn {Scheme Procedure} git-http-nginx-location-configuration @
19309 [config=(git-http-configuration)]
19310Compute an @code{nginx-location-configuration} that corresponds to the
19311given Git http configuration. An example nginx service definition to
19312serve the default @file{/srv/git} over HTTPS might be:
19313
19314@example
19315(service nginx-service-type
19316 (nginx-configuration
19317 (server-blocks
19318 (list
19319 (nginx-server-configuration
8b223cea 19320 (listen '("443 ssl"))
41034934
AW
19321 (server-name "git.my-host.org")
19322 (ssl-certificate
19323 "/etc/letsencrypt/live/git.my-host.org/fullchain.pem")
19324 (ssl-certificate-key
19325 "/etc/letsencrypt/live/git.my-host.org/privkey.pem")
19326 (locations
19327 (list
19328 (git-http-nginx-location-configuration
19329 (git-http-configuration (uri-path "/"))))))))))
19330@end example
19331
19332This example assumes that you are using Let's Encrypt to get your TLS
19333certificate. @xref{Certificate Services}. The default @code{certbot}
19334service will redirect all HTTP traffic on @code{git.my-host.org} to
19335HTTPS. You will also need to add an @code{fcgiwrap} proxy to your
19336system services. @xref{Web Services}.
19337@end deffn
05f1cb3c 19338
032a2760
OP
19339@subsubheading Cgit Service
19340
19341@cindex Cgit service
19342@cindex Git, web interface
19343@uref{https://git.zx2c4.com/cgit/, Cgit} is a web frontend for Git
19344repositories written in C.
19345
19346The following example will configure the service with default values.
19347By default, Cgit can be accessed on port 80 (@code{http://localhost:80}).
19348
19349@example
032a2760
OP
19350(service cgit-service-type)
19351@end example
19352
ad05e96e
CL
19353The @code{file-object} type designates either a file-like object
19354(@pxref{G-Expressions, file-like objects}) or a string.
19355
e1cf4fd2
OP
19356@c %start of fragment
19357
19358Available @code{cgit-configuration} fields are:
19359
19360@deftypevr {@code{cgit-configuration} parameter} package package
19361The CGIT package.
19362
19363@end deftypevr
19364
19365@deftypevr {@code{cgit-configuration} parameter} nginx-server-configuration-list nginx
19366NGINX configuration.
19367
19368@end deftypevr
19369
ad05e96e 19370@deftypevr {@code{cgit-configuration} parameter} file-object about-filter
e1cf4fd2
OP
19371Specifies a command which will be invoked to format the content of about
19372pages (both top-level and for each repository).
19373
19374Defaults to @samp{""}.
19375
19376@end deftypevr
19377
19378@deftypevr {@code{cgit-configuration} parameter} string agefile
19379Specifies a path, relative to each repository path, which can be used to
19380specify the date and time of the youngest commit in the repository.
19381
19382Defaults to @samp{""}.
19383
19384@end deftypevr
19385
ad05e96e 19386@deftypevr {@code{cgit-configuration} parameter} file-object auth-filter
e1cf4fd2
OP
19387Specifies a command that will be invoked for authenticating repository
19388access.
19389
19390Defaults to @samp{""}.
19391
19392@end deftypevr
19393
19394@deftypevr {@code{cgit-configuration} parameter} string branch-sort
19395Flag which, when set to @samp{age}, enables date ordering in the branch
19396ref list, and when set @samp{name} enables ordering by branch name.
19397
19398Defaults to @samp{"name"}.
19399
19400@end deftypevr
19401
19402@deftypevr {@code{cgit-configuration} parameter} string cache-root
19403Path used to store the cgit cache entries.
19404
19405Defaults to @samp{"/var/cache/cgit"}.
19406
19407@end deftypevr
19408
19409@deftypevr {@code{cgit-configuration} parameter} integer cache-static-ttl
19410Number which specifies the time-to-live, in minutes, for the cached
19411version of repository pages accessed with a fixed SHA1.
19412
19413Defaults to @samp{-1}.
19414
19415@end deftypevr
19416
19417@deftypevr {@code{cgit-configuration} parameter} integer cache-dynamic-ttl
19418Number which specifies the time-to-live, in minutes, for the cached
19419version of repository pages accessed without a fixed SHA1.
19420
19421Defaults to @samp{5}.
19422
19423@end deftypevr
19424
19425@deftypevr {@code{cgit-configuration} parameter} integer cache-repo-ttl
19426Number which specifies the time-to-live, in minutes, for the cached
19427version of the repository summary page.
19428
19429Defaults to @samp{5}.
19430
19431@end deftypevr
19432
19433@deftypevr {@code{cgit-configuration} parameter} integer cache-root-ttl
19434Number which specifies the time-to-live, in minutes, for the cached
19435version of the repository index page.
19436
19437Defaults to @samp{5}.
19438
19439@end deftypevr
19440
19441@deftypevr {@code{cgit-configuration} parameter} integer cache-scanrc-ttl
19442Number which specifies the time-to-live, in minutes, for the result of
19443scanning a path for Git repositories.
19444
19445Defaults to @samp{15}.
19446
19447@end deftypevr
19448
19449@deftypevr {@code{cgit-configuration} parameter} integer cache-about-ttl
19450Number which specifies the time-to-live, in minutes, for the cached
19451version of the repository about page.
19452
19453Defaults to @samp{15}.
19454
19455@end deftypevr
19456
19457@deftypevr {@code{cgit-configuration} parameter} integer cache-snapshot-ttl
19458Number which specifies the time-to-live, in minutes, for the cached
19459version of snapshots.
19460
19461Defaults to @samp{5}.
19462
19463@end deftypevr
19464
19465@deftypevr {@code{cgit-configuration} parameter} integer cache-size
19466The maximum number of entries in the cgit cache. When set to @samp{0},
19467caching is disabled.
19468
19469Defaults to @samp{0}.
19470
19471@end deftypevr
19472
19473@deftypevr {@code{cgit-configuration} parameter} boolean case-sensitive-sort?
19474Sort items in the repo list case sensitively.
19475
19476Defaults to @samp{#t}.
19477
19478@end deftypevr
19479
19480@deftypevr {@code{cgit-configuration} parameter} list clone-prefix
19481List of common prefixes which, when combined with a repository URL,
19482generates valid clone URLs for the repository.
19483
19484Defaults to @samp{()}.
19485
19486@end deftypevr
19487
19488@deftypevr {@code{cgit-configuration} parameter} list clone-url
19489List of @code{clone-url} templates.
19490
19491Defaults to @samp{()}.
19492
19493@end deftypevr
19494
ad05e96e 19495@deftypevr {@code{cgit-configuration} parameter} file-object commit-filter
e1cf4fd2
OP
19496Command which will be invoked to format commit messages.
19497
19498Defaults to @samp{""}.
19499
19500@end deftypevr
19501
19502@deftypevr {@code{cgit-configuration} parameter} string commit-sort
19503Flag which, when set to @samp{date}, enables strict date ordering in the
19504commit log, and when set to @samp{topo} enables strict topological
19505ordering.
19506
19507Defaults to @samp{"git log"}.
19508
19509@end deftypevr
19510
ad05e96e 19511@deftypevr {@code{cgit-configuration} parameter} file-object css
e1cf4fd2
OP
19512URL which specifies the css document to include in all cgit pages.
19513
19514Defaults to @samp{"/share/cgit/cgit.css"}.
19515
19516@end deftypevr
19517
ad05e96e 19518@deftypevr {@code{cgit-configuration} parameter} file-object email-filter
e1cf4fd2
OP
19519Specifies a command which will be invoked to format names and email
19520address of committers, authors, and taggers, as represented in various
19521places throughout the cgit interface.
19522
19523Defaults to @samp{""}.
19524
19525@end deftypevr
19526
19527@deftypevr {@code{cgit-configuration} parameter} boolean embedded?
19528Flag which, when set to @samp{#t}, will make cgit generate a HTML
19529fragment suitable for embedding in other HTML pages.
19530
19531Defaults to @samp{#f}.
19532
19533@end deftypevr
19534
19535@deftypevr {@code{cgit-configuration} parameter} boolean enable-commit-graph?
19536Flag which, when set to @samp{#t}, will make cgit print an ASCII-art
19537commit history graph to the left of the commit messages in the
19538repository log page.
19539
19540Defaults to @samp{#f}.
19541
19542@end deftypevr
19543
19544@deftypevr {@code{cgit-configuration} parameter} boolean enable-filter-overrides?
19545Flag which, when set to @samp{#t}, allows all filter settings to be
19546overridden in repository-specific cgitrc files.
19547
19548Defaults to @samp{#f}.
19549
19550@end deftypevr
19551
19552@deftypevr {@code{cgit-configuration} parameter} boolean enable-follow-links?
19553Flag which, when set to @samp{#t}, allows users to follow a file in the
19554log view.
19555
19556Defaults to @samp{#f}.
19557
19558@end deftypevr
19559
19560@deftypevr {@code{cgit-configuration} parameter} boolean enable-http-clone?
19561If set to @samp{#t}, cgit will act as an dumb HTTP endpoint for Git
19562clones.
19563
19564Defaults to @samp{#t}.
19565
19566@end deftypevr
19567
19568@deftypevr {@code{cgit-configuration} parameter} boolean enable-index-links?
19569Flag which, when set to @samp{#t}, will make cgit generate extra links
19570"summary", "commit", "tree" for each repo in the repository index.
19571
19572Defaults to @samp{#f}.
19573
19574@end deftypevr
19575
19576@deftypevr {@code{cgit-configuration} parameter} boolean enable-index-owner?
19577Flag which, when set to @samp{#t}, will make cgit display the owner of
19578each repo in the repository index.
19579
19580Defaults to @samp{#t}.
19581
19582@end deftypevr
19583
19584@deftypevr {@code{cgit-configuration} parameter} boolean enable-log-filecount?
19585Flag which, when set to @samp{#t}, will make cgit print the number of
19586modified files for each commit on the repository log page.
19587
19588Defaults to @samp{#f}.
19589
19590@end deftypevr
19591
19592@deftypevr {@code{cgit-configuration} parameter} boolean enable-log-linecount?
19593Flag which, when set to @samp{#t}, will make cgit print the number of
19594added and removed lines for each commit on the repository log page.
19595
19596Defaults to @samp{#f}.
19597
19598@end deftypevr
19599
19600@deftypevr {@code{cgit-configuration} parameter} boolean enable-remote-branches?
19601Flag which, when set to @code{#t}, will make cgit display remote
19602branches in the summary and refs views.
19603
19604Defaults to @samp{#f}.
19605
19606@end deftypevr
19607
19608@deftypevr {@code{cgit-configuration} parameter} boolean enable-subject-links?
19609Flag which, when set to @code{1}, will make cgit use the subject of the
19610parent commit as link text when generating links to parent commits in
19611commit view.
19612
19613Defaults to @samp{#f}.
19614
19615@end deftypevr
19616
19617@deftypevr {@code{cgit-configuration} parameter} boolean enable-html-serving?
19618Flag which, when set to @samp{#t}, will make cgit use the subject of the
19619parent commit as link text when generating links to parent commits in
19620commit view.
19621
19622Defaults to @samp{#f}.
19623
19624@end deftypevr
19625
19626@deftypevr {@code{cgit-configuration} parameter} boolean enable-tree-linenumbers?
19627Flag which, when set to @samp{#t}, will make cgit generate linenumber
19628links for plaintext blobs printed in the tree view.
19629
19630Defaults to @samp{#t}.
19631
19632@end deftypevr
19633
19634@deftypevr {@code{cgit-configuration} parameter} boolean enable-git-config?
19635Flag which, when set to @samp{#f}, will allow cgit to use Git config to
19636set any repo specific settings.
19637
19638Defaults to @samp{#f}.
19639
19640@end deftypevr
19641
ad05e96e 19642@deftypevr {@code{cgit-configuration} parameter} file-object favicon
e1cf4fd2
OP
19643URL used as link to a shortcut icon for cgit.
19644
19645Defaults to @samp{"/favicon.ico"}.
19646
19647@end deftypevr
19648
19649@deftypevr {@code{cgit-configuration} parameter} string footer
19650The content of the file specified with this option will be included
19651verbatim at the bottom of all pages (i.e. it replaces the standard
19652"generated by..." message).
19653
19654Defaults to @samp{""}.
19655
19656@end deftypevr
19657
19658@deftypevr {@code{cgit-configuration} parameter} string head-include
19659The content of the file specified with this option will be included
19660verbatim in the HTML HEAD section on all pages.
19661
19662Defaults to @samp{""}.
19663
19664@end deftypevr
19665
19666@deftypevr {@code{cgit-configuration} parameter} string header
19667The content of the file specified with this option will be included
19668verbatim at the top of all pages.
19669
19670Defaults to @samp{""}.
19671
19672@end deftypevr
19673
ad05e96e 19674@deftypevr {@code{cgit-configuration} parameter} file-object include
e1cf4fd2
OP
19675Name of a configfile to include before the rest of the current config-
19676file is parsed.
19677
19678Defaults to @samp{""}.
19679
19680@end deftypevr
19681
19682@deftypevr {@code{cgit-configuration} parameter} string index-header
19683The content of the file specified with this option will be included
19684verbatim above the repository index.
19685
19686Defaults to @samp{""}.
19687
19688@end deftypevr
19689
19690@deftypevr {@code{cgit-configuration} parameter} string index-info
19691The content of the file specified with this option will be included
19692verbatim below the heading on the repository index page.
19693
19694Defaults to @samp{""}.
19695
19696@end deftypevr
19697
19698@deftypevr {@code{cgit-configuration} parameter} boolean local-time?
19699Flag which, if set to @samp{#t}, makes cgit print commit and tag times
19700in the servers timezone.
19701
19702Defaults to @samp{#f}.
19703
19704@end deftypevr
19705
ad05e96e 19706@deftypevr {@code{cgit-configuration} parameter} file-object logo
e1cf4fd2
OP
19707URL which specifies the source of an image which will be used as a logo
19708on all cgit pages.
19709
19710Defaults to @samp{"/share/cgit/cgit.png"}.
19711
19712@end deftypevr
19713
19714@deftypevr {@code{cgit-configuration} parameter} string logo-link
19715URL loaded when clicking on the cgit logo image.
19716
19717Defaults to @samp{""}.
19718
19719@end deftypevr
19720
ad05e96e 19721@deftypevr {@code{cgit-configuration} parameter} file-object owner-filter
e1cf4fd2
OP
19722Command which will be invoked to format the Owner column of the main
19723page.
19724
19725Defaults to @samp{""}.
19726
19727@end deftypevr
19728
19729@deftypevr {@code{cgit-configuration} parameter} integer max-atom-items
19730Number of items to display in atom feeds view.
19731
19732Defaults to @samp{10}.
19733
19734@end deftypevr
19735
19736@deftypevr {@code{cgit-configuration} parameter} integer max-commit-count
19737Number of entries to list per page in "log" view.
19738
19739Defaults to @samp{50}.
19740
19741@end deftypevr
19742
19743@deftypevr {@code{cgit-configuration} parameter} integer max-message-length
19744Number of commit message characters to display in "log" view.
19745
19746Defaults to @samp{80}.
19747
19748@end deftypevr
19749
19750@deftypevr {@code{cgit-configuration} parameter} integer max-repo-count
19751Specifies the number of entries to list per page on the repository index
19752page.
19753
19754Defaults to @samp{50}.
19755
19756@end deftypevr
19757
19758@deftypevr {@code{cgit-configuration} parameter} integer max-repodesc-length
19759Specifies the maximum number of repo description characters to display
19760on the repository index page.
19761
19762Defaults to @samp{80}.
19763
19764@end deftypevr
19765
19766@deftypevr {@code{cgit-configuration} parameter} integer max-blob-size
19767Specifies the maximum size of a blob to display HTML for in KBytes.
19768
19769Defaults to @samp{0}.
19770
19771@end deftypevr
19772
19773@deftypevr {@code{cgit-configuration} parameter} string max-stats
19774Maximum statistics period. Valid values are @samp{week},@samp{month},
19775@samp{quarter} and @samp{year}.
19776
19777Defaults to @samp{""}.
19778
19779@end deftypevr
19780
19781@deftypevr {@code{cgit-configuration} parameter} mimetype-alist mimetype
19782Mimetype for the specified filename extension.
19783
19784Defaults to @samp{((gif "image/gif") (html "text/html") (jpg
19785"image/jpeg") (jpeg "image/jpeg") (pdf "application/pdf") (png
19786"image/png") (svg "image/svg+xml"))}.
19787
19788@end deftypevr
19789
ad05e96e 19790@deftypevr {@code{cgit-configuration} parameter} file-object mimetype-file
e1cf4fd2
OP
19791Specifies the file to use for automatic mimetype lookup.
19792
19793Defaults to @samp{""}.
19794
19795@end deftypevr
19796
19797@deftypevr {@code{cgit-configuration} parameter} string module-link
19798Text which will be used as the formatstring for a hyperlink when a
19799submodule is printed in a directory listing.
19800
19801Defaults to @samp{""}.
19802
19803@end deftypevr
19804
19805@deftypevr {@code{cgit-configuration} parameter} boolean nocache?
19806If set to the value @samp{#t} caching will be disabled.
19807
19808Defaults to @samp{#f}.
19809
19810@end deftypevr
19811
19812@deftypevr {@code{cgit-configuration} parameter} boolean noplainemail?
19813If set to @samp{#t} showing full author email addresses will be
19814disabled.
19815
19816Defaults to @samp{#f}.
19817
19818@end deftypevr
19819
19820@deftypevr {@code{cgit-configuration} parameter} boolean noheader?
19821Flag which, when set to @samp{#t}, will make cgit omit the standard
19822header on all pages.
19823
19824Defaults to @samp{#f}.
19825
19826@end deftypevr
19827
6ee3f3de 19828@deftypevr {@code{cgit-configuration} parameter} project-list project-list
e5fe544e
CL
19829A list of subdirectories inside of @code{repository-directory}, relative
19830to it, that should loaded as Git repositories. An empty list means that
19831all subdirectories will be loaded.
19832
19833Defaults to @samp{()}.
19834
19835@end deftypevr
19836
ad05e96e 19837@deftypevr {@code{cgit-configuration} parameter} file-object readme
e1cf4fd2
OP
19838Text which will be used as default value for @code{cgit-repo-readme}.
19839
19840Defaults to @samp{""}.
19841
19842@end deftypevr
19843
19844@deftypevr {@code{cgit-configuration} parameter} boolean remove-suffix?
19845If set to @code{#t} and @code{repository-directory} is enabled, if any
19846repositories are found with a suffix of @code{.git}, this suffix will be
19847removed for the URL and name.
19848
19849Defaults to @samp{#f}.
19850
19851@end deftypevr
19852
19853@deftypevr {@code{cgit-configuration} parameter} integer renamelimit
19854Maximum number of files to consider when detecting renames.
19855
19856Defaults to @samp{-1}.
19857
19858@end deftypevr
19859
19860@deftypevr {@code{cgit-configuration} parameter} string repository-sort
19861The way in which repositories in each section are sorted.
19862
19863Defaults to @samp{""}.
19864
19865@end deftypevr
19866
19867@deftypevr {@code{cgit-configuration} parameter} robots-list robots
19868Text used as content for the @code{robots} meta-tag.
19869
19870Defaults to @samp{("noindex" "nofollow")}.
19871
19872@end deftypevr
19873
19874@deftypevr {@code{cgit-configuration} parameter} string root-desc
19875Text printed below the heading on the repository index page.
19876
19877Defaults to @samp{"a fast webinterface for the git dscm"}.
19878
19879@end deftypevr
19880
19881@deftypevr {@code{cgit-configuration} parameter} string root-readme
19882The content of the file specified with this option will be included
19883verbatim below thef "about" link on the repository index page.
032a2760 19884
e1cf4fd2 19885Defaults to @samp{""}.
032a2760 19886
e1cf4fd2 19887@end deftypevr
032a2760 19888
e1cf4fd2
OP
19889@deftypevr {@code{cgit-configuration} parameter} string root-title
19890Text printed as heading on the repository index page.
032a2760 19891
e1cf4fd2 19892Defaults to @samp{""}.
032a2760 19893
e1cf4fd2 19894@end deftypevr
032a2760 19895
e1cf4fd2
OP
19896@deftypevr {@code{cgit-configuration} parameter} boolean scan-hidden-path
19897If set to @samp{#t} and repository-directory is enabled,
19898repository-directory will recurse into directories whose name starts
19899with a period. Otherwise, repository-directory will stay away from such
19900directories, considered as "hidden". Note that this does not apply to
19901the ".git" directory in non-bare repos.
032a2760 19902
e1cf4fd2
OP
19903Defaults to @samp{#f}.
19904
19905@end deftypevr
19906
19907@deftypevr {@code{cgit-configuration} parameter} list snapshots
19908Text which specifies the default set of snapshot formats that cgit
19909generates links for.
19910
19911Defaults to @samp{()}.
19912
19913@end deftypevr
19914
19915@deftypevr {@code{cgit-configuration} parameter} repository-directory repository-directory
19916Name of the directory to scan for repositories (represents
19917@code{scan-path}).
19918
19919Defaults to @samp{"/srv/git"}.
19920
19921@end deftypevr
19922
19923@deftypevr {@code{cgit-configuration} parameter} string section
19924The name of the current repository section - all repositories defined
19925after this option will inherit the current section name.
19926
19927Defaults to @samp{""}.
19928
19929@end deftypevr
19930
19931@deftypevr {@code{cgit-configuration} parameter} string section-sort
19932Flag which, when set to @samp{1}, will sort the sections on the
19933repository listing by name.
19934
19935Defaults to @samp{""}.
19936
19937@end deftypevr
19938
19939@deftypevr {@code{cgit-configuration} parameter} integer section-from-path
19940A number which, if defined prior to repository-directory, specifies how
19941many path elements from each repo path to use as a default section name.
19942
19943Defaults to @samp{0}.
19944
19945@end deftypevr
19946
19947@deftypevr {@code{cgit-configuration} parameter} boolean side-by-side-diffs?
19948If set to @samp{#t} shows side-by-side diffs instead of unidiffs per
19949default.
19950
19951Defaults to @samp{#f}.
19952
19953@end deftypevr
19954
ad05e96e 19955@deftypevr {@code{cgit-configuration} parameter} file-object source-filter
e1cf4fd2
OP
19956Specifies a command which will be invoked to format plaintext blobs in
19957the tree view.
19958
19959Defaults to @samp{""}.
19960
19961@end deftypevr
19962
19963@deftypevr {@code{cgit-configuration} parameter} integer summary-branches
19964Specifies the number of branches to display in the repository "summary"
19965view.
19966
19967Defaults to @samp{10}.
19968
19969@end deftypevr
19970
19971@deftypevr {@code{cgit-configuration} parameter} integer summary-log
19972Specifies the number of log entries to display in the repository
19973"summary" view.
19974
19975Defaults to @samp{10}.
19976
19977@end deftypevr
19978
19979@deftypevr {@code{cgit-configuration} parameter} integer summary-tags
19980Specifies the number of tags to display in the repository "summary"
19981view.
19982
19983Defaults to @samp{10}.
19984
19985@end deftypevr
19986
19987@deftypevr {@code{cgit-configuration} parameter} string strict-export
19988Filename which, if specified, needs to be present within the repository
19989for cgit to allow access to that repository.
19990
19991Defaults to @samp{""}.
19992
19993@end deftypevr
19994
19995@deftypevr {@code{cgit-configuration} parameter} string virtual-root
19996URL which, if specified, will be used as root for all cgit links.
19997
19998Defaults to @samp{"/"}.
19999
20000@end deftypevr
20001
20002@deftypevr {@code{cgit-configuration} parameter} repository-cgit-configuration-list repositories
20003A list of @dfn{cgit-repo} records to use with config.
20004
20005Defaults to @samp{()}.
20006
20007Available @code{repository-cgit-configuration} fields are:
20008
20009@deftypevr {@code{repository-cgit-configuration} parameter} repo-list snapshots
20010A mask of snapshot formats for this repo that cgit generates links for,
20011restricted by the global @code{snapshots} setting.
20012
20013Defaults to @samp{()}.
20014
20015@end deftypevr
20016
ad05e96e 20017@deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object source-filter
e1cf4fd2
OP
20018Override the default @code{source-filter}.
20019
20020Defaults to @samp{""}.
20021
20022@end deftypevr
20023
20024@deftypevr {@code{repository-cgit-configuration} parameter} repo-string url
20025The relative URL used to access the repository.
20026
20027Defaults to @samp{""}.
20028
20029@end deftypevr
20030
ad05e96e 20031@deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object about-filter
e1cf4fd2
OP
20032Override the default @code{about-filter}.
20033
20034Defaults to @samp{""}.
20035
20036@end deftypevr
20037
20038@deftypevr {@code{repository-cgit-configuration} parameter} repo-string branch-sort
20039Flag which, when set to @samp{age}, enables date ordering in the branch
20040ref list, and when set to @samp{name} enables ordering by branch name.
20041
20042Defaults to @samp{""}.
20043
20044@end deftypevr
20045
20046@deftypevr {@code{repository-cgit-configuration} parameter} repo-list clone-url
20047A list of URLs which can be used to clone repo.
20048
20049Defaults to @samp{()}.
20050
20051@end deftypevr
20052
ad05e96e 20053@deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object commit-filter
e1cf4fd2
OP
20054Override the default @code{commit-filter}.
20055
20056Defaults to @samp{""}.
20057
20058@end deftypevr
20059
20060@deftypevr {@code{repository-cgit-configuration} parameter} repo-string commit-sort
20061Flag which, when set to @samp{date}, enables strict date ordering in the
20062commit log, and when set to @samp{topo} enables strict topological
20063ordering.
20064
20065Defaults to @samp{""}.
20066
20067@end deftypevr
20068
20069@deftypevr {@code{repository-cgit-configuration} parameter} repo-string defbranch
20070The name of the default branch for this repository. If no such branch
20071exists in the repository, the first branch name (when sorted) is used as
20072default instead. By default branch pointed to by HEAD, or "master" if
20073there is no suitable HEAD.
20074
20075Defaults to @samp{""}.
20076
20077@end deftypevr
20078
20079@deftypevr {@code{repository-cgit-configuration} parameter} repo-string desc
20080The value to show as repository description.
20081
20082Defaults to @samp{""}.
032a2760 20083
e1cf4fd2
OP
20084@end deftypevr
20085
20086@deftypevr {@code{repository-cgit-configuration} parameter} repo-string homepage
20087The value to show as repository homepage.
20088
20089Defaults to @samp{""}.
20090
20091@end deftypevr
20092
ad05e96e 20093@deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object email-filter
e1cf4fd2
OP
20094Override the default @code{email-filter}.
20095
20096Defaults to @samp{""}.
20097
20098@end deftypevr
20099
efb22b47 20100@deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-commit-graph?
e1cf4fd2
OP
20101A flag which can be used to disable the global setting
20102@code{enable-commit-graph?}.
20103
efb22b47 20104Defaults to @samp{disabled}.
e1cf4fd2
OP
20105
20106@end deftypevr
20107
efb22b47 20108@deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-log-filecount?
e1cf4fd2
OP
20109A flag which can be used to disable the global setting
20110@code{enable-log-filecount?}.
20111
efb22b47 20112Defaults to @samp{disabled}.
e1cf4fd2
OP
20113
20114@end deftypevr
20115
efb22b47 20116@deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-log-linecount?
e1cf4fd2
OP
20117A flag which can be used to disable the global setting
20118@code{enable-log-linecount?}.
20119
efb22b47 20120Defaults to @samp{disabled}.
e1cf4fd2
OP
20121
20122@end deftypevr
20123
efb22b47 20124@deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-remote-branches?
e1cf4fd2
OP
20125Flag which, when set to @code{#t}, will make cgit display remote
20126branches in the summary and refs views.
20127
efb22b47 20128Defaults to @samp{disabled}.
e1cf4fd2
OP
20129
20130@end deftypevr
20131
efb22b47 20132@deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-subject-links?
e1cf4fd2
OP
20133A flag which can be used to override the global setting
20134@code{enable-subject-links?}.
20135
efb22b47 20136Defaults to @samp{disabled}.
e1cf4fd2
OP
20137
20138@end deftypevr
20139
efb22b47 20140@deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-html-serving?
e1cf4fd2
OP
20141A flag which can be used to override the global setting
20142@code{enable-html-serving?}.
20143
efb22b47 20144Defaults to @samp{disabled}.
e1cf4fd2
OP
20145
20146@end deftypevr
20147
20148@deftypevr {@code{repository-cgit-configuration} parameter} repo-boolean hide?
20149Flag which, when set to @code{#t}, hides the repository from the
20150repository index.
20151
20152Defaults to @samp{#f}.
20153
20154@end deftypevr
20155
20156@deftypevr {@code{repository-cgit-configuration} parameter} repo-boolean ignore?
20157Flag which, when set to @samp{#t}, ignores the repository.
20158
20159Defaults to @samp{#f}.
20160
20161@end deftypevr
20162
ad05e96e 20163@deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object logo
032a2760 20164URL which specifies the source of an image which will be used as a logo
e1cf4fd2 20165on this repo’s pages.
032a2760 20166
e1cf4fd2 20167Defaults to @samp{""}.
032a2760 20168
e1cf4fd2 20169@end deftypevr
032a2760 20170
e1cf4fd2
OP
20171@deftypevr {@code{repository-cgit-configuration} parameter} repo-string logo-link
20172URL loaded when clicking on the cgit logo image.
032a2760 20173
e1cf4fd2
OP
20174Defaults to @samp{""}.
20175
20176@end deftypevr
20177
ad05e96e 20178@deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object owner-filter
e1cf4fd2
OP
20179Override the default @code{owner-filter}.
20180
20181Defaults to @samp{""}.
20182
20183@end deftypevr
20184
20185@deftypevr {@code{repository-cgit-configuration} parameter} repo-string module-link
20186Text which will be used as the formatstring for a hyperlink when a
20187submodule is printed in a directory listing. The arguments for the
20188formatstring are the path and SHA1 of the submodule commit.
20189
20190Defaults to @samp{""}.
20191
20192@end deftypevr
20193
20194@deftypevr {@code{repository-cgit-configuration} parameter} module-link-path module-link-path
20195Text which will be used as the formatstring for a hyperlink when a
20196submodule with the specified subdirectory path is printed in a directory
20197listing.
20198
20199Defaults to @samp{()}.
20200
20201@end deftypevr
20202
20203@deftypevr {@code{repository-cgit-configuration} parameter} repo-string max-stats
20204Override the default maximum statistics period.
20205
20206Defaults to @samp{""}.
20207
20208@end deftypevr
20209
20210@deftypevr {@code{repository-cgit-configuration} parameter} repo-string name
20211The value to show as repository name.
20212
20213Defaults to @samp{""}.
20214
20215@end deftypevr
20216
20217@deftypevr {@code{repository-cgit-configuration} parameter} repo-string owner
20218A value used to identify the owner of the repository.
20219
20220Defaults to @samp{""}.
20221
20222@end deftypevr
20223
20224@deftypevr {@code{repository-cgit-configuration} parameter} repo-string path
20225An absolute path to the repository directory.
20226
20227Defaults to @samp{""}.
20228
20229@end deftypevr
20230
20231@deftypevr {@code{repository-cgit-configuration} parameter} repo-string readme
20232A path (relative to repo) which specifies a file to include verbatim as
20233the "About" page for this repo.
20234
20235Defaults to @samp{""}.
20236
20237@end deftypevr
20238
20239@deftypevr {@code{repository-cgit-configuration} parameter} repo-string section
20240The name of the current repository section - all repositories defined
20241after this option will inherit the current section name.
20242
20243Defaults to @samp{""}.
20244
20245@end deftypevr
20246
20247@deftypevr {@code{repository-cgit-configuration} parameter} repo-list extra-options
20248Extra options will be appended to cgitrc file.
20249
20250Defaults to @samp{()}.
20251
20252@end deftypevr
20253
20254@end deftypevr
20255
20256@deftypevr {@code{cgit-configuration} parameter} list extra-options
20257Extra options will be appended to cgitrc file.
20258
20259Defaults to @samp{()}.
20260
20261@end deftypevr
20262
ad05e96e 20263
e1cf4fd2
OP
20264@c %end of fragment
20265
20266However, it could be that you just want to get a @code{cgitrc} up and
20267running. In that case, you can pass an @code{opaque-cgit-configuration}
20268as a record to @code{cgit-service-type}. As its name indicates, an
20269opaque configuration does not have easy reflective capabilities.
20270
20271Available @code{opaque-cgit-configuration} fields are:
20272
20273@deftypevr {@code{opaque-cgit-configuration} parameter} package cgit
20274The cgit package.
20275@end deftypevr
20276
20277@deftypevr {@code{opaque-cgit-configuration} parameter} string string
20278The contents of the @code{cgitrc}, as a string.
20279@end deftypevr
20280
20281For example, if your @code{cgitrc} is just the empty string, you
20282could instantiate a cgit service like this:
20283
20284@example
20285(service cgit-service-type
20286 (opaque-cgit-configuration
20287 (cgitrc "")))
20288@end example
03e1cca2
LF
20289
20290
20291@node Game Services
20292@subsubsection Game Services
20293
20294@subsubheading The Battle for Wesnoth Service
20295@cindex wesnothd
20296@uref{https://wesnoth.org, The Battle for Wesnoth} is a fantasy, turn
20297based tactical strategy game, with several single player campaigns, and
20298multiplayer games (both networked and local).
20299
20300@defvar {Scheme Variable} wesnothd-service-type
20301Service type for the wesnothd service. Its value must be a
20302@code{wesnothd-configuration} object. To run wesnothd in the default
20303configuration, instantiate it as:
20304
20305@example
20306(service wesnothd-service-type)
20307@end example
20308@end defvar
20309
20310@deftp {Data Type} wesnothd-configuration
20311Data type representing the configuration of @command{wesnothd}.
20312
20313@table @asis
20314@item @code{package} (default: @code{wesnoth-server})
20315The wesnoth server package to use.
20316
20317@item @code{port} (default: @code{15000})
20318The port to bind the server to.
20319@end table
20320@end deftp
20321
20322@node Miscellaneous Services
20323@subsubsection Miscellaneous Services
20324
7f93bbd5
DM
20325@cindex fingerprint
20326@subsubheading Fingerprint Service
20327
20328The @code{(gnu services fingerprint)} module provides a DBus service to
20329read and identify fingerprints via a fingerprint sensor.
20330
20331@defvr {Scheme Variable} fprintd-service-type
20332The service type for @command{fprintd}, which provides the fingerprint
20333reading capability.
20334
20335@example
20336(service fprintd-service-type)
20337@end example
20338@end defvr
20339
03e1cca2
LF
20340@cindex sysctl
20341@subsubheading System Control Service
20342
20343The @code{(gnu services sysctl)} provides a service to configure kernel
20344parameters at boot.
20345
20346@defvr {Scheme Variable} sysctl-service-type
20347The service type for @command{sysctl}, which modifies kernel parameters
20348under @file{/proc/sys/}. To enable IPv4 forwarding, it can be
20349instantiated as:
20350
20351@example
20352(service sysctl-service-type
20353 (sysctl-configuration
20354 (settings '(("net.ipv4.ip_forward" . "1")))))
20355@end example
20356@end defvr
20357
20358@deftp {Data Type} sysctl-configuration
20359The data type representing the configuration of @command{sysctl}.
20360
20361@table @asis
20362@item @code{sysctl} (default: @code{(file-append procps "/sbin/sysctl"})
20363The @command{sysctl} executable to use.
20364
20365@item @code{settings} (default: @code{'()})
20366An association list specifies kernel parameters and their values.
20367@end table
20368@end deftp
20369
de30205b
AI
20370@cindex pcscd
20371@subsubheading PC/SC Smart Card Daemon Service
20372
20373The @code{(gnu services security-token)} module provides the following service
20374to run @command{pcscd}, the PC/SC Smart Card Daemon. @command{pcscd} is the
20375daemon program for pcsc-lite and the MuscleCard framework. It is a resource
20376manager that coordinates communications with smart card readers, smart cards
20377and cryptographic tokens that are connected to the system.
20378
20379@defvr {Scheme Variable} pcscd-service-type
20380Service type for the @command{pcscd} service. Its value must be a
20381@code{pcscd-configuration} object. To run pcscd in the default
20382configuration, instantiate it as:
20383
20384@example
20385(service pcscd-service-type)
20386@end example
20387@end defvr
20388
20389@deftp {Data Type} pcscd-configuration
20390The data type representing the configuration of @command{pcscd}.
20391
20392@table @asis
20393@item @code{pcsc-lite} (default: @code{pcsc-lite})
20394The pcsc-lite package that provides pcscd.
20395@item @code{usb-drivers} (default: @code{(list ccid)})
20396List of packages that provide USB drivers to pcscd. Drivers are expected to be
20397under @file{pcsc/drivers} in the store directory of the package.
20398@end table
20399@end deftp
20400
03e1cca2
LF
20401@cindex lirc
20402@subsubheading Lirc Service
20403
20404The @code{(gnu services lirc)} module provides the following service.
20405
20406@deffn {Scheme Procedure} lirc-service [#:lirc lirc] @
20407 [#:device #f] [#:driver #f] [#:config-file #f] @
20408 [#:extra-options '()]
20409Return a service that runs @url{http://www.lirc.org,LIRC}, a daemon that
20410decodes infrared signals from remote controls.
20411
20412Optionally, @var{device}, @var{driver} and @var{config-file}
20413(configuration file name) may be specified. See @command{lircd} manual
20414for details.
20415
20416Finally, @var{extra-options} is a list of additional command-line options
20417passed to @command{lircd}.
20418@end deffn
20419
20420@cindex spice
20421@subsubheading Spice Service
20422
20423The @code{(gnu services spice)} module provides the following service.
20424
20425@deffn {Scheme Procedure} spice-vdagent-service [#:spice-vdagent]
20426Returns a service that runs @url{http://www.spice-space.org,VDAGENT}, a daemon
20427that enables sharing the clipboard with a vm and setting the guest display
20428resolution when the graphical console window resizes.
20429@end deffn
20430
20431@subsubsection Dictionary Services
20432@cindex dictionary
20433The @code{(gnu services dict)} module provides the following service:
20434
20435@deffn {Scheme Procedure} dicod-service [#:config (dicod-configuration)]
20436Return a service that runs the @command{dicod} daemon, an implementation
20437of DICT server (@pxref{Dicod,,, dico, GNU Dico Manual}).
20438
20439The optional @var{config} argument specifies the configuration for
20440@command{dicod}, which should be a @code{<dicod-configuration>} object, by
20441default it serves the GNU Collaborative International Dictonary of English.
20442
20443You can add @command{open localhost} to your @file{~/.dico} file to make
20444@code{localhost} the default server for @command{dico} client
20445(@pxref{Initialization File,,, dico, GNU Dico Manual}).
20446@end deffn
20447
20448@deftp {Data Type} dicod-configuration
20449Data type representing the configuration of dicod.
20450
20451@table @asis
20452@item @code{dico} (default: @var{dico})
20453Package object of the GNU Dico dictionary server.
20454
20455@item @code{interfaces} (default: @var{'("localhost")})
20456This is the list of IP addresses and ports and possibly socket file
20457names to listen to (@pxref{Server Settings, @code{listen} directive,,
20458dico, GNU Dico Manual}).
20459
20460@item @code{handlers} (default: @var{'()})
20461List of @code{<dicod-handler>} objects denoting handlers (module instances).
20462
20463@item @code{databases} (default: @var{(list %dicod-database:gcide)})
20464List of @code{<dicod-database>} objects denoting dictionaries to be served.
20465@end table
20466@end deftp
20467
20468@deftp {Data Type} dicod-handler
20469Data type representing a dictionary handler (module instance).
20470
20471@table @asis
20472@item @code{name}
20473Name of the handler (module instance).
20474
20475@item @code{module} (default: @var{#f})
20476Name of the dicod module of the handler (instance). If it is @code{#f},
20477the module has the same name as the handler.
20478(@pxref{Modules,,, dico, GNU Dico Manual}).
20479
20480@item @code{options}
20481List of strings or gexps representing the arguments for the module handler
20482@end table
20483@end deftp
20484
20485@deftp {Data Type} dicod-database
20486Data type representing a dictionary database.
20487
20488@table @asis
20489@item @code{name}
20490Name of the database, will be used in DICT commands.
20491
20492@item @code{handler}
20493Name of the dicod handler (module instance) used by this database
20494(@pxref{Handlers,,, dico, GNU Dico Manual}).
20495
20496@item @code{complex?} (default: @var{#f})
20497Whether the database configuration complex. The complex configuration
20498will need a corresponding @code{<dicod-handler>} object, otherwise not.
20499
20500@item @code{options}
20501List of strings or gexps representing the arguments for the database
20502(@pxref{Databases,,, dico, GNU Dico Manual}).
20503@end table
20504@end deftp
20505
20506@defvr {Scheme Variable} %dicod-database:gcide
20507A @code{<dicod-database>} object serving the GNU Collaborative International
20508Dictionary of English using the @code{gcide} package.
20509@end defvr
20510
20511The following is an example @code{dicod-service} configuration.
20512
20513@example
20514(dicod-service #:config
20515 (dicod-configuration
20516 (handlers (list (dicod-handler
20517 (name "wordnet")
20518 (module "dictorg")
20519 (options
20520 (list #~(string-append "dbdir=" #$wordnet))))))
20521 (databases (list (dicod-database
20522 (name "wordnet")
20523 (complex? #t)
20524 (handler "wordnet")
20525 (options '("database=wn")))
20526 %dicod-database:gcide))))
20527@end example
032a2760 20528
0ae8c15a
LC
20529@node Setuid Programs
20530@subsection Setuid Programs
20531
20532@cindex setuid programs
20533Some programs need to run with ``root'' privileges, even when they are
20534launched by unprivileged users. A notorious example is the
4d40227c
LC
20535@command{passwd} program, which users can run to change their
20536password, and which needs to access the @file{/etc/passwd} and
0ae8c15a
LC
20537@file{/etc/shadow} files---something normally restricted to root, for
20538obvious security reasons. To address that, these executables are
20539@dfn{setuid-root}, meaning that they always run with root privileges
20540(@pxref{How Change Persona,,, libc, The GNU C Library Reference Manual},
f7e4ae7f 20541for more info about the setuid mechanism.)
0ae8c15a
LC
20542
20543The store itself @emph{cannot} contain setuid programs: that would be a
20544security issue since any user on the system can write derivations that
20545populate the store (@pxref{The Store}). Thus, a different mechanism is
20546used: instead of changing the setuid bit directly on files that are in
20547the store, we let the system administrator @emph{declare} which programs
20548should be setuid root.
20549
20550The @code{setuid-programs} field of an @code{operating-system}
20551declaration contains a list of G-expressions denoting the names of
20552programs to be setuid-root (@pxref{Using the Configuration System}).
20553For instance, the @command{passwd} program, which is part of the Shadow
20554package, can be designated by this G-expression (@pxref{G-Expressions}):
20555
20556@example
20557#~(string-append #$shadow "/bin/passwd")
20558@end example
20559
20560A default set of setuid programs is defined by the
20561@code{%setuid-programs} variable of the @code{(gnu system)} module.
20562
20563@defvr {Scheme Variable} %setuid-programs
20564A list of G-expressions denoting common programs that are setuid-root.
20565
20566The list includes commands such as @command{passwd}, @command{ping},
20567@command{su}, and @command{sudo}.
20568@end defvr
20569
20570Under the hood, the actual setuid programs are created in the
20571@file{/run/setuid-programs} directory at system activation time. The
20572files in this directory refer to the ``real'' binaries, which are in the
20573store.
20574
efb5e833
LC
20575@node X.509 Certificates
20576@subsection X.509 Certificates
20577
20578@cindex HTTPS, certificates
20579@cindex X.509 certificates
20580@cindex TLS
20581Web servers available over HTTPS (that is, HTTP over the transport-layer
20582security mechanism, TLS) send client programs an @dfn{X.509 certificate}
20583that the client can then use to @emph{authenticate} the server. To do
20584that, clients verify that the server's certificate is signed by a
20585so-called @dfn{certificate authority} (CA). But to verify the CA's
20586signature, clients must have first acquired the CA's certificate.
20587
20588Web browsers such as GNU@tie{}IceCat include their own set of CA
20589certificates, such that they are able to verify CA signatures
20590out-of-the-box.
20591
20592However, most other programs that can talk HTTPS---@command{wget},
20593@command{git}, @command{w3m}, etc.---need to be told where CA
20594certificates can be found.
20595
20596@cindex @code{nss-certs}
20597In GuixSD, this is done by adding a package that provides certificates
20598to the @code{packages} field of the @code{operating-system} declaration
20599(@pxref{operating-system Reference}). GuixSD includes one such package,
20600@code{nss-certs}, which is a set of CA certificates provided as part of
20601Mozilla's Network Security Services.
20602
20603Note that it is @emph{not} part of @var{%base-packages}, so you need to
20604explicitly add it. The @file{/etc/ssl/certs} directory, which is where
20605most applications and libraries look for certificates by default, points
20606to the certificates installed globally.
20607
b3129f2b
LC
20608Unprivileged users, including users of Guix on a foreign distro,
20609can also install their own certificate package in
efb5e833
LC
20610their profile. A number of environment variables need to be defined so
20611that applications and libraries know where to find them. Namely, the
20612OpenSSL library honors the @code{SSL_CERT_DIR} and @code{SSL_CERT_FILE}
20613variables. Some applications add their own environment variables; for
20614instance, the Git version control system honors the certificate bundle
b3129f2b
LC
20615pointed to by the @code{GIT_SSL_CAINFO} environment variable. Thus, you
20616would typically run something like:
efb5e833 20617
b3129f2b
LC
20618@example
20619$ guix package -i nss-certs
20620$ export SSL_CERT_DIR="$HOME/.guix-profile/etc/ssl/certs"
20621$ export SSL_CERT_FILE="$HOME/.guix-profile/etc/ssl/certs/ca-certificates.crt"
20622$ export GIT_SSL_CAINFO="$SSL_CERT_FILE"
20623@end example
efb5e833 20624
63657335
RW
20625As another example, R requires the @code{CURL_CA_BUNDLE} environment
20626variable to point to a certificate bundle, so you would have to run
20627something like this:
20628
20629@example
20630$ guix package -i nss-certs
20631$ export CURL_CA_BUNDLE="$HOME/.guix-profile/etc/ssl/certs/ca-certificates.crt"
20632@end example
20633
20634For other applications you may want to look up the required environment
20635variable in the relevant documentation.
20636
20637
996ed739
LC
20638@node Name Service Switch
20639@subsection Name Service Switch
20640
20641@cindex name service switch
20642@cindex NSS
20643The @code{(gnu system nss)} module provides bindings to the
1068f26b 20644configuration file of the libc @dfn{name service switch} or @dfn{NSS}
996ed739
LC
20645(@pxref{NSS Configuration File,,, libc, The GNU C Library Reference
20646Manual}). In a nutshell, the NSS is a mechanism that allows libc to be
20647extended with new ``name'' lookup methods for system databases, which
20648includes host names, service names, user accounts, and more (@pxref{Name
20649Service Switch, System Databases and Name Service Switch,, libc, The GNU
20650C Library Reference Manual}).
20651
20652The NSS configuration specifies, for each system database, which lookup
20653method is to be used, and how the various methods are chained
20654together---for instance, under which circumstances NSS should try the
20655next method in the list. The NSS configuration is given in the
20656@code{name-service-switch} field of @code{operating-system} declarations
20657(@pxref{operating-system Reference, @code{name-service-switch}}).
20658
4c9050c6
LC
20659@cindex nss-mdns
20660@cindex .local, host name lookup
996ed739 20661As an example, the declaration below configures the NSS to use the
4c9050c6
LC
20662@uref{http://0pointer.de/lennart/projects/nss-mdns/, @code{nss-mdns}
20663back-end}, which supports host name lookups over multicast DNS (mDNS)
20664for host names ending in @code{.local}:
996ed739
LC
20665
20666@example
20667(name-service-switch
20668 (hosts (list %files ;first, check /etc/hosts
20669
20670 ;; If the above did not succeed, try
20671 ;; with 'mdns_minimal'.
20672 (name-service
20673 (name "mdns_minimal")
20674
20675 ;; 'mdns_minimal' is authoritative for
20676 ;; '.local'. When it returns "not found",
20677 ;; no need to try the next methods.
20678 (reaction (lookup-specification
20679 (not-found => return))))
20680
20681 ;; Then fall back to DNS.
20682 (name-service
20683 (name "dns"))
20684
20685 ;; Finally, try with the "full" 'mdns'.
20686 (name-service
20687 (name "mdns")))))
20688@end example
20689
1068f26b
AE
20690Do not worry: the @code{%mdns-host-lookup-nss} variable (see below)
20691contains this configuration, so you will not have to type it if all you
15137a29
LC
20692want is to have @code{.local} host lookup working.
20693
4c9050c6
LC
20694Note that, in this case, in addition to setting the
20695@code{name-service-switch} of the @code{operating-system} declaration,
cc9c1f39
LC
20696you also need to use @code{avahi-service} (@pxref{Networking Services,
20697@code{avahi-service}}), or @var{%desktop-services}, which includes it
20698(@pxref{Desktop Services}). Doing this makes @code{nss-mdns} accessible
20699to the name service cache daemon (@pxref{Base Services,
20700@code{nscd-service}}).
15137a29
LC
20701
20702For convenience, the following variables provide typical NSS
20703configurations.
20704
20705@defvr {Scheme Variable} %default-nss
20706This is the default name service switch configuration, a
20707@code{name-service-switch} object.
20708@end defvr
20709
20710@defvr {Scheme Variable} %mdns-host-lookup-nss
20711This is the name service switch configuration with support for host name
20712lookup over multicast DNS (mDNS) for host names ending in @code{.local}.
20713@end defvr
4c9050c6 20714
996ed739 20715The reference for name service switch configuration is given below. It
1068f26b 20716is a direct mapping of the configuration file format of the C library , so
996ed739
LC
20717please refer to the C library manual for more information (@pxref{NSS
20718Configuration File,,, libc, The GNU C Library Reference Manual}).
1068f26b 20719Compared to the configuration file format of libc NSS, it has the advantage
996ed739 20720not only of adding this warm parenthetic feel that we like, but also
1068f26b 20721static checks: you will know about syntax errors and typos as soon as you
996ed739
LC
20722run @command{guix system}.
20723
996ed739
LC
20724@deftp {Data Type} name-service-switch
20725
20726This is the data type representation the configuration of libc's name
20727service switch (NSS). Each field below represents one of the supported
20728system databases.
20729
20730@table @code
20731@item aliases
20732@itemx ethers
20733@itemx group
20734@itemx gshadow
20735@itemx hosts
20736@itemx initgroups
20737@itemx netgroup
20738@itemx networks
20739@itemx password
20740@itemx public-key
20741@itemx rpc
20742@itemx services
20743@itemx shadow
20744The system databases handled by the NSS. Each of these fields must be a
1068f26b 20745list of @code{<name-service>} objects (see below).
996ed739
LC
20746@end table
20747@end deftp
20748
20749@deftp {Data Type} name-service
20750
20751This is the data type representing an actual name service and the
20752associated lookup action.
20753
20754@table @code
20755@item name
20756A string denoting the name service (@pxref{Services in the NSS
20757configuration,,, libc, The GNU C Library Reference Manual}).
20758
4aee6e60
LC
20759Note that name services listed here must be visible to nscd. This is
20760achieved by passing the @code{#:name-services} argument to
20761@code{nscd-service} the list of packages providing the needed name
20762services (@pxref{Base Services, @code{nscd-service}}).
20763
996ed739
LC
20764@item reaction
20765An action specified using the @code{lookup-specification} macro
20766(@pxref{Actions in the NSS configuration,,, libc, The GNU C Library
20767Reference Manual}). For example:
20768
20769@example
20770(lookup-specification (unavailable => continue)
20771 (success => return))
20772@end example
20773@end table
20774@end deftp
0ae8c15a 20775
fd1b1fa2
LC
20776@node Initial RAM Disk
20777@subsection Initial RAM Disk
20778
e32171ee
JD
20779@cindex initrd
20780@cindex initial RAM disk
fd1b1fa2
LC
20781For bootstrapping purposes, the Linux-Libre kernel is passed an
20782@dfn{initial RAM disk}, or @dfn{initrd}. An initrd contains a temporary
1068f26b 20783root file system as well as an initialization script. The latter is
fd1b1fa2
LC
20784responsible for mounting the real root file system, and for loading any
20785kernel modules that may be needed to achieve that.
20786
bc499b11
LC
20787The @code{initrd-modules} field of an @code{operating-system}
20788declaration allows you to specify Linux-libre kernel modules that must
20789be available in the initrd. In particular, this is where you would list
20790modules needed to actually drive the hard disk where your root partition
20791is---although the default value of @code{initrd-modules} should cover
20792most use cases. For example, assuming you need the @code{megaraid_sas}
20793module in addition to the default modules to be able to access your root
20794file system, you would write:
20795
20796@example
20797(operating-system
20798 ;; @dots{}
20799 (initrd-modules (cons "megaraid_sas" %base-initrd-modules)))
20800@end example
20801
20802@defvr {Scheme Variable} %base-initrd-modules
20803This is the list of kernel modules included in the initrd by default.
20804@end defvr
20805
20806Furthermore, if you need lower-level customization, the @code{initrd}
20807field of an @code{operating-system} declaration allows
fd1b1fa2 20808you to specify which initrd you would like to use. The @code{(gnu
47bdc5a1
MO
20809system linux-initrd)} module provides three ways to build an initrd: the
20810high-level @code{base-initrd} procedure and the low-level
20811@code{raw-initrd} and @code{expression->initrd} procedures.
fd1b1fa2
LC
20812
20813The @code{base-initrd} procedure is intended to cover most common uses.
20814For example, if you want to add a bunch of kernel modules to be loaded
20815at boot time, you can define the @code{initrd} field of the operating
20816system declaration like this:
20817
20818@example
52ac153e 20819(initrd (lambda (file-systems . rest)
bc499b11
LC
20820 ;; Create a standard initrd but set up networking
20821 ;; with the parameters QEMU expects by default.
52ac153e 20822 (apply base-initrd file-systems
bc499b11 20823 #:qemu-networking? #t
52ac153e 20824 rest)))
fd1b1fa2
LC
20825@end example
20826
52ac153e 20827The @code{base-initrd} procedure also handles common use cases that
1068f26b
AE
20828involves using the system as a QEMU guest, or as a ``live'' system with
20829volatile root file system.
fd1b1fa2 20830
47bdc5a1
MO
20831The @code{base-initrd} procedure is built from @code{raw-initrd} procedure.
20832Unlike @code{base-initrd}, @code{raw-initrd} doesn't do anything high-level,
20833such as trying to guess which kernel modules and packages should be included
20834to the initrd. An example use of @code{raw-initrd} is when a user has
20835a custom Linux kernel configuration and default kernel modules included by
20836@code{base-initrd} are not available.
20837
20838The initial RAM disk produced by @code{base-initrd} or @code{raw-initrd}
20839honors several options passed on the Linux kernel command line
20840(that is, arguments passed @i{via} the @code{linux} command of GRUB, or the
4af2fafd 20841@code{-append} option of QEMU), notably:
e90cf6c1
LC
20842
20843@table @code
20844@item --load=@var{boot}
20845Tell the initial RAM disk to load @var{boot}, a file containing a Scheme
20846program, once it has mounted the root file system.
20847
20848GuixSD uses this option to yield control to a boot program that runs the
dd17bc38 20849service activation programs and then spawns the GNU@tie{}Shepherd, the
e90cf6c1
LC
20850initialization system.
20851
20852@item --root=@var{root}
1068f26b 20853Mount @var{root} as the root file system. @var{root} can be a
01bd3b5e 20854device name like @code{/dev/sda1}, a file system label, or a file system
e90cf6c1
LC
20855UUID.
20856
20857@item --system=@var{system}
20858Have @file{/run/booted-system} and @file{/run/current-system} point to
20859@var{system}.
20860
20861@item modprobe.blacklist=@var{modules}@dots{}
20862@cindex module, black-listing
20863@cindex black list, of kernel modules
20864Instruct the initial RAM disk as well as the @command{modprobe} command
20865(from the kmod package) to refuse to load @var{modules}. @var{modules}
20866must be a comma-separated list of module names---e.g.,
20867@code{usbkbd,9pnet}.
20868
20869@item --repl
20870Start a read-eval-print loop (REPL) from the initial RAM disk before it
20871tries to load kernel modules and to mount the root file system. Our
20872marketing team calls it @dfn{boot-to-Guile}. The Schemer in you will
20873love it. @xref{Using Guile Interactively,,, guile, GNU Guile Reference
20874Manual}, for more information on Guile's REPL.
20875
20876@end table
20877
20878Now that you know all the features that initial RAM disks produced by
47bdc5a1
MO
20879@code{base-initrd} and @code{raw-initrd} provide,
20880here is how to use it and customize it further.
e90cf6c1 20881
e32171ee
JD
20882@cindex initrd
20883@cindex initial RAM disk
47bdc5a1
MO
20884@deffn {Monadic Procedure} raw-initrd @var{file-systems} @
20885 [#:linux-modules '()] [#:mapped-devices '()] @
20886 [#:helper-packages '()] [#:qemu-networking? #f] [#:volatile-root? #f]
20887Return a monadic derivation that builds a raw initrd. @var{file-systems} is
1068f26b 20888a list of file systems to be mounted by the initrd, possibly in addition to
fd1b1fa2 20889the root file system specified on the kernel command line via @code{--root}.
47bdc5a1 20890@var{linux-modules} is a list of kernel modules to be loaded at boot time.
52ac153e
LC
20891@var{mapped-devices} is a list of device mappings to realize before
20892@var{file-systems} are mounted (@pxref{Mapped Devices}).
47bdc5a1
MO
20893@var{helper-packages} is a list of packages to be copied in the initrd. It may
20894include @code{e2fsck/static} or other packages needed by the initrd to check
01bd3b5e 20895the root file system.
fd1b1fa2
LC
20896
20897When @var{qemu-networking?} is true, set up networking with the standard QEMU
1068f26b
AE
20898parameters. When @var{virtio?} is true, load additional modules so that the
20899initrd can be used as a QEMU guest with para-virtualized I/O drivers.
fd1b1fa2
LC
20900
20901When @var{volatile-root?} is true, the root file system is writable but any changes
20902to it are lost.
47bdc5a1
MO
20903@end deffn
20904
20905@deffn {Monadic Procedure} base-initrd @var{file-systems} @
20906 [#:mapped-devices '()] [#:qemu-networking? #f] [#:volatile-root? #f]@
eac026e5
LC
20907 [#:linux-modules '()]
20908Return a monadic derivation that builds a generic initrd, with kernel
20909modules taken from @var{linux}. @var{file-systems} is a list of file-systems to be
20910mounted by the initrd, possibly in addition to the root file system specified
20911on the kernel command line via @code{--root}. @var{mapped-devices} is a list of device
20912mappings to realize before @var{file-systems} are mounted.
47bdc5a1 20913
eac026e5 20914@var{qemu-networking?} and @var{volatile-root?} behaves as in @code{raw-initrd}.
fd1b1fa2
LC
20915
20916The initrd is automatically populated with all the kernel modules necessary
eac026e5
LC
20917for @var{file-systems} and for the given options. Additional kernel
20918modules can be listed in @var{linux-modules}. They will be added to the initrd, and
fd1b1fa2
LC
20919loaded at boot time in the order in which they appear.
20920@end deffn
20921
20922Needless to say, the initrds we produce and use embed a
20923statically-linked Guile, and the initialization program is a Guile
20924program. That gives a lot of flexibility. The
20925@code{expression->initrd} procedure builds such an initrd, given the
20926program to run in that initrd.
20927
20928@deffn {Monadic Procedure} expression->initrd @var{exp} @
4ee96a79 20929 [#:guile %guile-static-stripped] [#:name "guile-initrd"]
fd1b1fa2
LC
20930Return a derivation that builds a Linux initrd (a gzipped cpio archive)
20931containing @var{guile} and that evaluates @var{exp}, a G-expression,
df650fa8
LC
20932upon booting. All the derivations referenced by @var{exp} are
20933automatically copied to the initrd.
fd1b1fa2
LC
20934@end deffn
20935
74e64724
MO
20936@node Bootloader Configuration
20937@subsection Bootloader Configuration
88faf933 20938
74e64724 20939@cindex bootloader
88faf933
LC
20940@cindex boot loader
20941
74e64724
MO
20942The operating system supports multiple bootloaders. The bootloader is
20943configured using @code{bootloader-configuration} declaration. All the
20944fields of this structure are bootloader agnostic except for one field,
20945@code{bootloader} that indicates the bootloader to be configured and
20946installed.
88faf933 20947
74e64724
MO
20948Some of the bootloaders do not honor every field of
20949@code{bootloader-configuration}. For instance, the extlinux
20950bootloader does not support themes and thus ignores the @code{theme}
20951field.
20952
20953@deftp {Data Type} bootloader-configuration
20954The type of a bootloader configuration declaration.
88faf933
LC
20955
20956@table @asis
20957
74e64724
MO
20958@item @code{bootloader}
20959@cindex EFI, bootloader
20960@cindex UEFI, bootloader
20961@cindex BIOS, bootloader
20962The bootloader to use, as a @code{bootloader} object. For now
8d858010
DM
20963@code{grub-bootloader}, @code{grub-efi-bootloader},
20964@code{extlinux-bootloader} and @code{u-boot-bootloader} are supported.
fc0e663f
LC
20965
20966@vindex grub-efi-bootloader
8d858010 20967@code{grub-efi-bootloader} allows to boot on modern systems using the
fc0e663f
LC
20968@dfn{Unified Extensible Firmware Interface} (UEFI). This is what you should
20969use if the installation image contains a @file{/sys/firmware/efi} directory
20970when you boot it on your system.
20971
20972@vindex grub-bootloader
20973@code{grub-bootloader} allows you to boot in particular Intel-based machines
20974in ``legacy'' BIOS mode.
74e64724 20975
900e6d40
LC
20976@cindex ARM, bootloaders
20977@cindex AArch64, bootloaders
74e64724 20978Available bootloaders are described in @code{(gnu bootloader @dots{})}
900e6d40
LC
20979modules. In particular, @code{(gnu bootloader u-boot)} contains definitions
20980of bootloaders for a wide range of ARM and AArch64 systems, using the
20981@uref{http://www.denx.de/wiki/U-Boot/, U-Boot bootloader}.
74e64724 20982
045ebb3e
AW
20983@item @code{target}
20984This is a string denoting the target onto which to install the
fc0e663f
LC
20985bootloader.
20986
20987The interpretation depends on the bootloader in question. For
20988@code{grub-bootloader}, for example, it should be a device name understood by
20989the bootloader @command{installer} command, such as @code{/dev/sda} or
20990@code{(hd0)} (@pxref{Invoking grub-install,,, grub, GNU GRUB Manual}). For
20991@code{grub-efi-bootloader}, it should be the mount point of the EFI file
20992system, usually @file{/boot/efi}.
88faf933
LC
20993
20994@item @code{menu-entries} (default: @code{()})
20995A possibly empty list of @code{menu-entry} objects (see below), denoting
74e64724 20996entries to appear in the bootloader menu, in addition to the current
88faf933
LC
20997system entry and the entry pointing to previous system generations.
20998
20999@item @code{default-entry} (default: @code{0})
1068f26b
AE
21000The index of the default boot menu entry. Index 0 is for the entry of the
21001current system.
88faf933
LC
21002
21003@item @code{timeout} (default: @code{5})
21004The number of seconds to wait for keyboard input before booting. Set to
210050 to boot immediately, and to -1 to wait indefinitely.
21006
74e64724
MO
21007@item @code{theme} (default: @var{#f})
21008The bootloader theme object describing the theme to use. If no theme
21009is provided, some bootloaders might use a default theme, that's true
21010for GRUB.
e0b2e930
LF
21011
21012@item @code{terminal-outputs} (default: @code{'gfxterm})
74e64724
MO
21013The output terminals used for the bootloader boot menu, as a list of
21014symbols. GRUB accepts the values: @code{console}, @code{serial},
21015@code{serial_@{0-3@}}, @code{gfxterm}, @code{vga_text},
21016@code{mda_text}, @code{morse}, and @code{pkmodem}. This field
900e6d40 21017corresponds to the GRUB variable @code{GRUB_TERMINAL_OUTPUT} (@pxref{Simple
74e64724 21018configuration,,, grub,GNU GRUB manual}).
e0b2e930
LF
21019
21020@item @code{terminal-inputs} (default: @code{'()})
74e64724
MO
21021The input terminals used for the bootloader boot menu, as a list of
21022symbols. For GRUB, the default is the native platform terminal as
21023determined at run-time. GRUB accepts the values: @code{console},
21024@code{serial}, @code{serial_@{0-3@}}, @code{at_keyboard}, and
21025@code{usb_keyboard}. This field corresponds to the GRUB variable
900e6d40 21026@code{GRUB_TERMINAL_INPUT} (@pxref{Simple configuration,,, grub,GNU GRUB
74e64724 21027manual}).
e0b2e930
LF
21028
21029@item @code{serial-unit} (default: @code{#f})
74e64724 21030The serial unit used by the bootloader, as an integer from 0 to 3.
68b49109 21031For GRUB, it is chosen at run-time; currently GRUB chooses 0, which
e0b2e930
LF
21032corresponds to COM1 (@pxref{Serial terminal,,, grub,GNU GRUB manual}).
21033
21034@item @code{serial-speed} (default: @code{#f})
74e64724
MO
21035The speed of the serial interface, as an integer. For GRUB, the
21036default value is chosen at run-time; currently GRUB chooses
210379600@tie{}bps (@pxref{Serial terminal,,, grub,GNU GRUB manual}).
88faf933
LC
21038@end table
21039
21040@end deftp
21041
44d5f54e
LC
21042@cindex dual boot
21043@cindex boot menu
88faf933
LC
21044Should you want to list additional boot menu entries @i{via} the
21045@code{menu-entries} field above, you will need to create them with the
44d5f54e
LC
21046@code{menu-entry} form. For example, imagine you want to be able to
21047boot another distro (hard to imagine!), you can define a menu entry
21048along these lines:
21049
21050@example
21051(menu-entry
21052 (label "The Other Distro")
21053 (linux "/boot/old/vmlinux-2.6.32")
21054 (linux-arguments '("root=/dev/sda2"))
21055 (initrd "/boot/old/initrd"))
21056@end example
21057
21058Details below.
88faf933
LC
21059
21060@deftp {Data Type} menu-entry
74e64724 21061The type of an entry in the bootloader menu.
88faf933
LC
21062
21063@table @asis
21064
21065@item @code{label}
35ed9306 21066The label to show in the menu---e.g., @code{"GNU"}.
88faf933
LC
21067
21068@item @code{linux}
44d5f54e
LC
21069The Linux kernel image to boot, for example:
21070
21071@example
21072(file-append linux-libre "/bzImage")
21073@end example
88faf933 21074
74e64724
MO
21075For GRUB, it is also possible to specify a device explicitly in the
21076file path using GRUB's device naming convention (@pxref{Naming
21077convention,,, grub, GNU GRUB manual}), for example:
1ef8b72a
CM
21078
21079@example
21080"(hd0,msdos1)/boot/vmlinuz"
21081@end example
21082
21083If the device is specified explicitly as above, then the @code{device}
21084field is ignored entirely.
21085
88faf933
LC
21086@item @code{linux-arguments} (default: @code{()})
21087The list of extra Linux kernel command-line arguments---e.g.,
21088@code{("console=ttyS0")}.
21089
21090@item @code{initrd}
21091A G-Expression or string denoting the file name of the initial RAM disk
21092to use (@pxref{G-Expressions}).
1ef8b72a 21093@item @code{device} (default: @code{#f})
74e64724 21094The device where the kernel and initrd are to be found---i.e., for GRUB,
1ef8b72a
CM
21095@dfn{root} for this menu entry (@pxref{root,,, grub, GNU GRUB manual}).
21096
21097This may be a file system label (a string), a file system UUID (a
74e64724
MO
21098bytevector, @pxref{File Systems}), or @code{#f}, in which case
21099the bootloader will search the device containing the file specified by
21100the @code{linux} field (@pxref{search,,, grub, GNU GRUB manual}). It
21101must @emph{not} be an OS device name such as @file{/dev/sda1}.
1ef8b72a 21102
88faf933
LC
21103@end table
21104@end deftp
21105
21106@c FIXME: Write documentation once it's stable.
74e64724
MO
21107Fow now only GRUB has theme support. GRUB themes are created using
21108the @code{grub-theme} form, which is not documented yet.
88faf933
LC
21109
21110@defvr {Scheme Variable} %default-theme
74e64724
MO
21111This is the default GRUB theme used by the operating system if no
21112@code{theme} field is specified in @code{bootloader-configuration}
21113record.
21114
21115It comes with a fancy background image displaying the GNU and Guix
21116logos.
88faf933
LC
21117@end defvr
21118
21119
cf4a9129
LC
21120@node Invoking guix system
21121@subsection Invoking @code{guix system}
0918e64a 21122
1068f26b 21123Once you have written an operating system declaration as seen in the
cf4a9129
LC
21124previous section, it can be @dfn{instantiated} using the @command{guix
21125system} command. The synopsis is:
4af2447e 21126
cf4a9129
LC
21127@example
21128guix system @var{options}@dots{} @var{action} @var{file}
21129@end example
4af2447e 21130
cf4a9129
LC
21131@var{file} must be the name of a file containing an
21132@code{operating-system} declaration. @var{action} specifies how the
a40424bd 21133operating system is instantiated. Currently the following values are
cf4a9129 21134supported:
4af2447e 21135
cf4a9129 21136@table @code
0649321d
LC
21137@item search
21138Display available service type definitions that match the given regular
21139expressions, sorted by relevance:
21140
21141@example
21142$ guix system search console font
21143name: console-fonts
21144location: gnu/services/base.scm:729:2
21145extends: shepherd-root
21146description: Install the given fonts on the specified ttys (fonts are
21147+ per virtual console on GNU/Linux). The value of this service is a list
21148+ of tty/font pairs like:
21149+
21150+ '(("tty1" . "LatGrkCyr-8x16"))
21151relevance: 20
21152
21153name: mingetty
21154location: gnu/services/base.scm:1048:2
21155extends: shepherd-root
21156description: Provide console login using the `mingetty' program.
21157relevance: 2
21158
21159name: login
21160location: gnu/services/base.scm:775:2
21161extends: pam
21162description: Provide a console log-in service as specified by its
21163+ configuration value, a `login-configuration' object.
21164relevance: 2
21165
21166@dots{}
21167@end example
21168
21169As for @command{guix package --search}, the result is written in
21170@code{recutils} format, which makes it easy to filter the output
21171(@pxref{Top, GNU recutils databases,, recutils, GNU recutils manual}).
21172
cf4a9129
LC
21173@item reconfigure
21174Build the operating system described in @var{file}, activate it, and
8074b330
CM
21175switch to it@footnote{This action (and the related actions
21176@code{switch-generation} and @code{roll-back}) are usable only on
21177systems already running GuixSD.}.
4af2447e 21178
cf4a9129
LC
21179This effects all the configuration specified in @var{file}: user
21180accounts, system services, global package list, setuid programs, etc.
240b57f0
LC
21181The command starts system services specified in @var{file} that are not
21182currently running; if a service is currently running, it does not
1068f26b 21183attempt to upgrade it since this would not be possible without stopping it
240b57f0 21184first.
4af2447e 21185
067a2e2d
CM
21186This command creates a new generation whose number is one greater than
21187the current generation (as reported by @command{guix system
21188list-generations}). If that generation already exists, it will be
21189overwritten. This behavior mirrors that of @command{guix package}
21190(@pxref{Invoking guix package}).
21191
74e64724
MO
21192It also adds a bootloader menu entry for the new OS configuration,
21193---unless @option{--no-bootloader} is passed. For GRUB, it moves
21194entries for older configurations to a submenu, allowing you to choose
21195an older system generation at boot time should you need it.
4af2447e 21196
240b57f0 21197@quotation Note
bf2479c7
LC
21198@c The paragraph below refers to the problem discussed at
21199@c <http://lists.gnu.org/archive/html/guix-devel/2014-08/msg00057.html>.
21200It is highly recommended to run @command{guix pull} once before you run
21201@command{guix system reconfigure} for the first time (@pxref{Invoking
21202guix pull}). Failing to do that you would see an older version of Guix
21203once @command{reconfigure} has completed.
240b57f0 21204@end quotation
bf2479c7 21205
8074b330 21206@item switch-generation
e32171ee 21207@cindex generations
8074b330 21208Switch to an existing system generation. This action atomically
74e64724
MO
21209switches the system profile to the specified system generation. It
21210also rearranges the system's existing bootloader menu entries. It
21211makes the menu entry for the specified system generation the default,
21212and it moves the entries for the other generatiors to a submenu, if
21213supported by the bootloader being used. The next time the system
21214boots, it will use the specified system generation.
21215
21216The bootloader itself is not being reinstalled when using this
21217command. Thus, the installed bootloader is used with an updated
21218configuration file.
8074b330
CM
21219
21220The target generation can be specified explicitly by its generation
21221number. For example, the following invocation would switch to system
21222generation 7:
21223
21224@example
21225guix system switch-generation 7
21226@end example
21227
21228The target generation can also be specified relative to the current
21229generation with the form @code{+N} or @code{-N}, where @code{+3} means
21230``3 generations ahead of the current generation,'' and @code{-1} means
21231``1 generation prior to the current generation.'' When specifying a
21232negative value such as @code{-1}, you must precede it with @code{--} to
21233prevent it from being parsed as an option. For example:
21234
21235@example
21236guix system switch-generation -- -1
21237@end example
21238
21239Currently, the effect of invoking this action is @emph{only} to switch
74e64724
MO
21240the system profile to an existing generation and rearrange the
21241bootloader menu entries. To actually start using the target system
21242generation, you must reboot after running this action. In the future,
21243it will be updated to do the same things as @command{reconfigure},
21244like activating and deactivating services.
8074b330
CM
21245
21246This action will fail if the specified generation does not exist.
21247
21248@item roll-back
e32171ee 21249@cindex rolling back
8074b330
CM
21250Switch to the preceding system generation. The next time the system
21251boots, it will use the preceding system generation. This is the inverse
21252of @command{reconfigure}, and it is exactly the same as invoking
21253@command{switch-generation} with an argument of @code{-1}.
21254
21255Currently, as with @command{switch-generation}, you must reboot after
21256running this action to actually start using the preceding system
21257generation.
21258
cf4a9129 21259@item build
1068f26b 21260Build the derivation of the operating system, which includes all the
cf4a9129
LC
21261configuration files and programs needed to boot and run the system.
21262This action does not actually install anything.
113daf62 21263
cf4a9129
LC
21264@item init
21265Populate the given directory with all the files necessary to run the
21266operating system specified in @var{file}. This is useful for first-time
4705641f 21267installations of GuixSD. For instance:
113daf62
LC
21268
21269@example
cf4a9129 21270guix system init my-os-config.scm /mnt
113daf62
LC
21271@end example
21272
cf4a9129
LC
21273copies to @file{/mnt} all the store items required by the configuration
21274specified in @file{my-os-config.scm}. This includes configuration
21275files, packages, and so on. It also creates other essential files
21276needed for the system to operate correctly---e.g., the @file{/etc},
21277@file{/var}, and @file{/run} directories, and the @file{/bin/sh} file.
113daf62 21278
045ebb3e 21279This command also installs bootloader on the target specified in
74e64724
MO
21280@file{my-os-config}, unless the @option{--no-bootloader} option was
21281passed.
113daf62 21282
cf4a9129
LC
21283@item vm
21284@cindex virtual machine
0276f697 21285@cindex VM
f535dcbe 21286@anchor{guix system vm}
1068f26b 21287Build a virtual machine that contains the operating system declared in
cf4a9129 21288@var{file}, and return a script to run that virtual machine (VM).
03317cbf
LC
21289Arguments given to the script are passed to QEMU as in the example
21290below, which enables networking and requests 1@tie{}GiB of RAM for the
21291emulated machine:
21292
21293@example
21294$ /gnu/store/@dots{}-run-vm.sh -m 1024 -net user
21295@end example
113daf62 21296
cf4a9129 21297The VM shares its store with the host system.
113daf62 21298
0276f697
LC
21299Additional file systems can be shared between the host and the VM using
21300the @code{--share} and @code{--expose} command-line options: the former
21301specifies a directory to be shared with write access, while the latter
21302provides read-only access to the shared directory.
21303
21304The example below creates a VM in which the user's home directory is
21305accessible read-only, and where the @file{/exchange} directory is a
1068f26b 21306read-write mapping of @file{$HOME/tmp} on the host:
0276f697
LC
21307
21308@example
21309guix system vm my-config.scm \
21310 --expose=$HOME --share=$HOME/tmp=/exchange
21311@end example
21312
6aa260af
LC
21313On GNU/Linux, the default is to boot directly to the kernel; this has
21314the advantage of requiring only a very tiny root disk image since the
1068f26b 21315store of the host can then be mounted.
6aa260af
LC
21316
21317The @code{--full-boot} option forces a complete boot sequence, starting
21318with the bootloader. This requires more disk space since a root image
21319containing at least the kernel, initrd, and bootloader data files must
21320be created. The @code{--image-size} option can be used to specify the
1068f26b 21321size of the image.
ab11f0be 21322
a335f6fc
CM
21323@cindex System images, creation in various formats
21324@cindex Creating system images in various formats
cf4a9129
LC
21325@item vm-image
21326@itemx disk-image
a335f6fc
CM
21327@itemx docker-image
21328Return a virtual machine, disk image, or Docker image of the operating
21329system declared in @var{file} that stands alone. By default,
21330@command{guix system} estimates the size of the image needed to store
21331the system, but you can use the @option{--image-size} option to specify
21332a value. Docker images are built to contain exactly what they need, so
21333the @option{--image-size} option is ignored in the case of
21334@code{docker-image}.
113daf62 21335
3f4d8a7f 21336You can specify the root file system type by using the
3b6e7d86 21337@option{--file-system-type} option. It defaults to @code{ext4}.
3f4d8a7f 21338
cf4a9129 21339When using @code{vm-image}, the returned image is in qcow2 format, which
97d76250
LF
21340the QEMU emulator can efficiently use. @xref{Running GuixSD in a VM},
21341for more information on how to run the image in a virtual machine.
113daf62 21342
cf4a9129
LC
21343When using @code{disk-image}, a raw disk image is produced; it can be
21344copied as is to a USB stick, for instance. Assuming @code{/dev/sdc} is
1068f26b 21345the device corresponding to a USB stick, one can copy the image to it
cf4a9129 21346using the following command:
113daf62 21347
cf4a9129
LC
21348@example
21349# dd if=$(guix system disk-image my-os.scm) of=/dev/sdc
21350@end example
113daf62 21351
a335f6fc
CM
21352When using @code{docker-image}, a Docker image is produced. Guix builds
21353the image from scratch, not from a pre-existing Docker base image. As a
21354result, it contains @emph{exactly} what you define in the operating
21355system configuration file. You can then load the image and launch a
21356Docker container using commands like the following:
21357
21358@example
21359image_id="$(docker load < guixsd-docker-image.tar.gz)"
21360docker run -e GUIX_NEW_SYSTEM=/var/guix/profiles/system \\
21361 --entrypoint /var/guix/profiles/system/profile/bin/guile \\
21362 $image_id /var/guix/profiles/system/boot
21363@end example
21364
21365This command starts a new Docker container from the specified image. It
21366will boot the GuixSD system in the usual manner, which means it will
21367start any services you have defined in the operating system
21368configuration. Depending on what you run in the Docker container, it
21369may be necessary to give the container additional permissions. For
21370example, if you intend to build software using Guix inside of the Docker
21371container, you may need to pass the @option{--privileged} option to
21372@code{docker run}.
21373
1c8a81b1
DT
21374@item container
21375Return a script to run the operating system declared in @var{file}
21376within a container. Containers are a set of lightweight isolation
21377mechanisms provided by the kernel Linux-libre. Containers are
21378substantially less resource-demanding than full virtual machines since
21379the kernel, shared objects, and other resources can be shared with the
21380host system; this also means they provide thinner isolation.
21381
21382Currently, the script must be run as root in order to support more than
21383a single user and group. The container shares its store with the host
21384system.
21385
21386As with the @code{vm} action (@pxref{guix system vm}), additional file
21387systems to be shared between the host and container can be specified
21388using the @option{--share} and @option{--expose} options:
21389
21390@example
21391guix system container my-config.scm \
21392 --expose=$HOME --share=$HOME/tmp=/exchange
21393@end example
21394
0f252e26 21395@quotation Note
cfd35b4e 21396This option requires Linux-libre 3.19 or newer.
0f252e26
DT
21397@end quotation
21398
cf4a9129 21399@end table
113daf62 21400
ccd7158d
LC
21401@var{options} can contain any of the common build options (@pxref{Common
21402Build Options}). In addition, @var{options} can contain one of the
21403following:
113daf62 21404
cf4a9129 21405@table @option
5a72ddf1
MO
21406@item --expression=@var{expr}
21407@itemx -e @var{expr}
21408Consider the operating-system @var{expr} evaluates to.
21409This is an alternative to specifying a file which evaluates to an
21410operating system.
21411This is used to generate the GuixSD installer @pxref{Building the
21412Installation Image}).
21413
cf4a9129
LC
21414@item --system=@var{system}
21415@itemx -s @var{system}
1068f26b 21416Attempt to build for @var{system} instead of the host system type.
cf4a9129 21417This works as per @command{guix build} (@pxref{Invoking guix build}).
113daf62 21418
f3f427c2
LC
21419@item --derivation
21420@itemx -d
21421Return the derivation file name of the given operating system without
21422building anything.
21423
3f4d8a7f
DM
21424@item --file-system-type=@var{type}
21425@itemx -t @var{type}
21426For the @code{disk-image} action, create a file system of the given
21427@var{type} on the image.
21428
21429When this option is omitted, @command{guix system} uses @code{ext4}.
21430
21431@cindex ISO-9660 format
21432@cindex CD image format
21433@cindex DVD image format
21434@code{--file-system-type=iso9660} produces an ISO-9660 image, suitable
21435for burning on CDs and DVDs.
21436
cf4a9129
LC
21437@item --image-size=@var{size}
21438For the @code{vm-image} and @code{disk-image} actions, create an image
21439of the given @var{size}. @var{size} may be a number of bytes, or it may
4a44d7bb
LC
21440include a unit as a suffix (@pxref{Block size, size specifications,,
21441coreutils, GNU Coreutils}).
db030303 21442
a8ac4f08
LC
21443When this option is omitted, @command{guix system} computes an estimate
21444of the image size as a function of the size of the system declared in
21445@var{file}.
21446
5ea69d9a
CM
21447@item --root=@var{file}
21448@itemx -r @var{file}
21449Make @var{file} a symlink to the result, and register it as a garbage
21450collector root.
21451
61b1dbbd
LC
21452@item --skip-checks
21453Skip pre-installation safety checks.
21454
21455By default, @command{guix system init} and @command{guix system
21456reconfigure} perform safety checks: they make sure the file systems that
21457appear in the @code{operating-system} declaration actually exist
21458(@pxref{File Systems}), and that any Linux kernel modules that may be
21459needed at boot time are listed in @code{initrd-modules} (@pxref{Initial
21460RAM Disk}). Passing this option skips these tests altogether.
21461
db030303
LC
21462@item --on-error=@var{strategy}
21463Apply @var{strategy} when an error occurs when reading @var{file}.
21464@var{strategy} may be one of the following:
21465
21466@table @code
21467@item nothing-special
21468Report the error concisely and exit. This is the default strategy.
21469
21470@item backtrace
21471Likewise, but also display a backtrace.
21472
21473@item debug
21474Report the error and enter Guile's debugger. From there, you can run
21475commands such as @code{,bt} to get a backtrace, @code{,locals} to
1068f26b
AE
21476display local variable values, and more generally inspect the state of the
21477program. @xref{Debug Commands,,, guile, GNU Guile Reference Manual}, for
db030303
LC
21478a list of available debugging commands.
21479@end table
113daf62 21480@end table
113daf62 21481
eca69fc0
LC
21482@quotation Note
21483All the actions above, except @code{build} and @code{init},
21484can use KVM support in the Linux-libre kernel. Specifically, if the
21485machine has hardware virtualization support, the corresponding
cf4a9129 21486KVM kernel module should be loaded, and the @file{/dev/kvm} device node
1068f26b 21487must exist and be readable and writable by the user and by the
eca69fc0
LC
21488build users of the daemon (@pxref{Build Environment Setup}).
21489@end quotation
8451a568 21490
65797bff
LC
21491Once you have built, configured, re-configured, and re-re-configured
21492your GuixSD installation, you may find it useful to list the operating
21493system generations available on disk---and that you can choose from the
74e64724 21494bootloader boot menu:
65797bff
LC
21495
21496@table @code
21497
21498@item list-generations
21499List a summary of each generation of the operating system available on
21500disk, in a human-readable way. This is similar to the
21501@option{--list-generations} option of @command{guix package}
21502(@pxref{Invoking guix package}).
21503
21504Optionally, one can specify a pattern, with the same syntax that is used
21505in @command{guix package --list-generations}, to restrict the list of
21506generations displayed. For instance, the following command displays
1068f26b 21507generations that are up to 10 days old:
65797bff
LC
21508
21509@example
21510$ guix system list-generations 10d
21511@end example
21512
21513@end table
21514
d6c3267a
LC
21515The @command{guix system} command has even more to offer! The following
21516sub-commands allow you to visualize how your system services relate to
21517each other:
21518
21519@anchor{system-extension-graph}
21520@table @code
21521
21522@item extension-graph
21523Emit in Dot/Graphviz format to standard output the @dfn{service
21524extension graph} of the operating system defined in @var{file}
21525(@pxref{Service Composition}, for more information on service
21526extensions.)
21527
21528The command:
21529
21530@example
21531$ guix system extension-graph @var{file} | dot -Tpdf > services.pdf
21532@end example
21533
21534produces a PDF file showing the extension relations among services.
21535
710fa231
AK
21536@anchor{system-shepherd-graph}
21537@item shepherd-graph
6f305ea5 21538Emit in Dot/Graphviz format to standard output the @dfn{dependency
dd17bc38
AK
21539graph} of shepherd services of the operating system defined in
21540@var{file}. @xref{Shepherd Services}, for more information and for an
21541example graph.
6f305ea5 21542
d6c3267a
LC
21543@end table
21544
97d76250 21545@node Running GuixSD in a VM
70ac09a5 21546@subsection Running GuixSD in a Virtual Machine
97d76250 21547
e32171ee 21548@cindex virtual machine
4b236c88
LF
21549To run GuixSD in a virtual machine (VM), one can either use the
21550pre-built GuixSD VM image distributed at
af7914a1 21551@indicateurl{https://alpha.gnu.org/gnu/guix/guixsd-vm-image-@value{VERSION}.@var{system}.xz}
4b236c88
LF
21552, or build their own virtual machine image using @command{guix system
21553vm-image} (@pxref{Invoking guix system}). The returned image is in
21554qcow2 format, which the @uref{http://qemu.org/, QEMU emulator} can
21555efficiently use.
97d76250 21556
e32171ee 21557@cindex QEMU
4b236c88
LF
21558If you built your own image, you must copy it out of the store
21559(@pxref{The Store}) and give yourself permission to write to the copy
21560before you can use it. When invoking QEMU, you must choose a system
21561emulator that is suitable for your hardware platform. Here is a minimal
21562QEMU invocation that will boot the result of @command{guix system
21563vm-image} on x86_64 hardware:
97d76250
LF
21564
21565@example
21566$ qemu-system-x86_64 \
21567 -net user -net nic,model=virtio \
21568 -enable-kvm -m 256 /tmp/qemu-image
21569@end example
21570
21571Here is what each of these options means:
21572
21573@table @code
21574@item qemu-system-x86_64
21575This specifies the hardware platform to emulate. This should match the
21576host.
21577
21578@item -net user
21579Enable the unprivileged user-mode network stack. The guest OS can
21580access the host but not vice versa. This is the simplest way to get the
58806e6f 21581guest OS online.
97d76250
LF
21582
21583@item -net nic,model=virtio
1068f26b 21584You must create a network interface of a given model. If you do not
97d76250
LF
21585create a NIC, the boot will fail. Assuming your hardware platform is
21586x86_64, you can get a list of available NIC models by running
21587@command{qemu-system-x86_64 -net nic,model=help}.
21588
21589@item -enable-kvm
21590If your system has hardware virtualization extensions, enabling the
1068f26b 21591virtual machine support (KVM) of the Linux kernel will make things run
97d76250
LF
21592faster.
21593
21594@item -m 256
21595RAM available to the guest OS, in mebibytes. Defaults to 128@tie{}MiB,
7414de0a 21596which may be insufficient for some operations.
97d76250
LF
21597
21598@item /tmp/qemu-image
21599The file name of the qcow2 image.
21600@end table
d6c3267a 21601
9fc221b5 21602The default @command{run-vm.sh} script that is returned by an invocation of
3ddc50db
DC
21603@command{guix system vm} does not add a @command{-net user} flag by default.
21604To get network access from within the vm add the @code{(dhcp-client-service)}
21605to your system definition and start the VM using
21606@command{`guix system vm config.scm` -net user}. An important caveat of using
21607@command{-net user} for networking is that @command{ping} will not work, because
21608it uses the ICMP protocol. You'll have to use a different command to check for
4100698d 21609network connectivity, for example @command{guix download}.
3ddc50db
DC
21610
21611@subsubsection Connecting Through SSH
21612
e32171ee
JD
21613@cindex SSH
21614@cindex SSH server
3ddc50db
DC
21615To enable SSH inside a VM you need to add a SSH server like @code{(dropbear-service)}
21616or @code{(lsh-service)} to your VM. The @code{(lsh-service}) doesn't currently
21617boot unsupervised. It requires you to type some characters to initialize the
21618randomness generator. In addition you need to forward the SSH port, 22 by
21619default, to the host. You can do this with
21620
21621@example
21622`guix system vm config.scm` -net user,hostfwd=tcp::10022-:22
21623@end example
21624
21625To connect to the VM you can run
21626
21627@example
21628ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 10022
21629@end example
21630
21631The @command{-p} tells @command{ssh} the port you want to connect to.
21632@command{-o UserKnownHostsFile=/dev/null} prevents @command{ssh} from complaining
21633every time you modify your @command{config.scm} file and the
21634@command{-o StrictHostKeyChecking=no} prevents you from having to allow a
21635connection to an unknown host every time you connect.
21636
21637@subsubsection Using @command{virt-viewer} with Spice
21638
21639As an alternative to the default @command{qemu} graphical client you can
21640use the @command{remote-viewer} from the @command{virt-viewer} package. To
21641connect pass the @command{-spice port=5930,disable-ticketing} flag to
21642@command{qemu}. See previous section for further information on how to do this.
21643
21644Spice also allows you to do some nice stuff like share your clipboard with your
21645VM. To enable that you'll also have to pass the following flags to @command{qemu}:
21646
21647@example
21648-device virtio-serial-pci,id=virtio-serial0,max_ports=16,bus=pci.0,addr=0x5
21649-chardev spicevmc,name=vdagent,id=vdagent
21650-device virtserialport,nr=1,bus=virtio-serial0.0,chardev=vdagent,
21651name=com.redhat.spice.0
21652@end example
21653
21654You'll also need to add the @pxref{Miscellaneous Services, Spice service}.
21655
cf4a9129
LC
21656@node Defining Services
21657@subsection Defining Services
8451a568 21658
eb524192 21659The previous sections show the available services and how one can combine
0adfe95a
LC
21660them in an @code{operating-system} declaration. But how do we define
21661them in the first place? And what is a service anyway?
8451a568 21662
0adfe95a
LC
21663@menu
21664* Service Composition:: The model for composing services.
21665* Service Types and Services:: Types and services.
21666* Service Reference:: API reference.
dd17bc38 21667* Shepherd Services:: A particular type of service.
0adfe95a
LC
21668@end menu
21669
21670@node Service Composition
21671@subsubsection Service Composition
21672
21673@cindex services
21674@cindex daemons
21675Here we define a @dfn{service} as, broadly, something that extends the
1068f26b 21676functionality of the operating system. Often a service is a process---a
0adfe95a
LC
21677@dfn{daemon}---started when the system boots: a secure shell server, a
21678Web server, the Guix build daemon, etc. Sometimes a service is a daemon
21679whose execution can be triggered by another daemon---e.g., an FTP server
21680started by @command{inetd} or a D-Bus service activated by
21681@command{dbus-daemon}. Occasionally, a service does not map to a
21682daemon. For instance, the ``account'' service collects user accounts
21683and makes sure they exist when the system runs; the ``udev'' service
21684collects device management rules and makes them available to the eudev
1068f26b
AE
21685daemon; the @file{/etc} service populates the @file{/etc} directory
21686of the system.
0adfe95a 21687
d6c3267a 21688@cindex service extensions
0adfe95a 21689GuixSD services are connected by @dfn{extensions}. For instance, the
1068f26b 21690secure shell service @emph{extends} the Shepherd---the GuixSD
dd17bc38
AK
21691initialization system, running as PID@tie{}1---by giving it the command
21692lines to start and stop the secure shell daemon (@pxref{Networking
21693Services, @code{lsh-service}}); the UPower service extends the D-Bus
21694service by passing it its @file{.service} specification, and extends the
21695udev service by passing it device management rules (@pxref{Desktop
21696Services, @code{upower-service}}); the Guix daemon service extends the
21697Shepherd by passing it the command lines to start and stop the daemon,
21698and extends the account service by passing it a list of required build
21699user accounts (@pxref{Base Services}).
0adfe95a
LC
21700
21701All in all, services and their ``extends'' relations form a directed
21702acyclic graph (DAG). If we represent services as boxes and extensions
21703as arrows, a typical system might provide something like this:
21704
21705@image{images/service-graph,,5in,Typical service extension graph.}
21706
d62e201c
LC
21707@cindex system service
21708At the bottom, we see the @dfn{system service}, which produces the
21709directory containing everything to run and boot the system, as returned
21710by the @command{guix system build} command. @xref{Service Reference},
21711to learn about the other service types shown here.
d6c3267a
LC
21712@xref{system-extension-graph, the @command{guix system extension-graph}
21713command}, for information on how to generate this representation for a
21714particular operating system definition.
0adfe95a
LC
21715
21716@cindex service types
21717Technically, developers can define @dfn{service types} to express these
21718relations. There can be any number of services of a given type on the
21719system---for instance, a system running two instances of the GNU secure
21720shell server (lsh) has two instances of @var{lsh-service-type}, with
21721different parameters.
21722
21723The following section describes the programming interface for service
21724types and services.
21725
21726@node Service Types and Services
21727@subsubsection Service Types and Services
21728
21729A @dfn{service type} is a node in the DAG described above. Let us start
21730with a simple example, the service type for the Guix build daemon
21731(@pxref{Invoking guix-daemon}):
21732
21733@example
21734(define guix-service-type
21735 (service-type
21736 (name 'guix)
21737 (extensions
d4053c71 21738 (list (service-extension shepherd-root-service-type guix-shepherd-service)
0adfe95a 21739 (service-extension account-service-type guix-accounts)
1bb895ea
LC
21740 (service-extension activation-service-type guix-activation)))
21741 (default-value (guix-configuration))))
0adfe95a 21742@end example
8451a568 21743
cf4a9129 21744@noindent
1bb895ea 21745It defines three things:
0adfe95a
LC
21746
21747@enumerate
21748@item
21749A name, whose sole purpose is to make inspection and debugging easier.
21750
21751@item
21752A list of @dfn{service extensions}, where each extension designates the
1068f26b
AE
21753target service type and a procedure that, given the parameters of the
21754service, returns a list of objects to extend the service of that type.
0adfe95a
LC
21755
21756Every service type has at least one service extension. The only
21757exception is the @dfn{boot service type}, which is the ultimate service.
1bb895ea
LC
21758
21759@item
21760Optionally, a default value for instances of this type.
0adfe95a
LC
21761@end enumerate
21762
21763In this example, @var{guix-service-type} extends three services:
21764
21765@table @var
d4053c71
AK
21766@item shepherd-root-service-type
21767The @var{guix-shepherd-service} procedure defines how the Shepherd
21768service is extended. Namely, it returns a @code{<shepherd-service>}
21769object that defines how @command{guix-daemon} is started and stopped
21770(@pxref{Shepherd Services}).
0adfe95a
LC
21771
21772@item account-service-type
21773This extension for this service is computed by @var{guix-accounts},
21774which returns a list of @code{user-group} and @code{user-account}
21775objects representing the build user accounts (@pxref{Invoking
21776guix-daemon}).
21777
21778@item activation-service-type
21779Here @var{guix-activation} is a procedure that returns a gexp, which is
21780a code snippet to run at ``activation time''---e.g., when the service is
21781booted.
21782@end table
21783
21784A service of this type is instantiated like this:
21785
21786@example
21787(service guix-service-type
21788 (guix-configuration
21789 (build-accounts 5)
21790 (use-substitutes? #f)))
21791@end example
21792
21793The second argument to the @code{service} form is a value representing
21794the parameters of this specific service instance.
21795@xref{guix-configuration-type, @code{guix-configuration}}, for
1bb895ea
LC
21796information about the @code{guix-configuration} data type. When the
21797value is omitted, the default value specified by
21798@code{guix-service-type} is used:
21799
21800@example
21801(service guix-service-type)
21802@end example
0adfe95a
LC
21803
21804@var{guix-service-type} is quite simple because it extends other
21805services but is not extensible itself.
21806
21807@c @subsubsubsection Extensible Service Types
21808
21809The service type for an @emph{extensible} service looks like this:
21810
21811@example
21812(define udev-service-type
21813 (service-type (name 'udev)
21814 (extensions
d4053c71
AK
21815 (list (service-extension shepherd-root-service-type
21816 udev-shepherd-service)))
0adfe95a
LC
21817
21818 (compose concatenate) ;concatenate the list of rules
21819 (extend (lambda (config rules)
21820 (match config
21821 (($ <udev-configuration> udev initial-rules)
21822 (udev-configuration
21823 (udev udev) ;the udev package to use
21824 (rules (append initial-rules rules)))))))))
21825@end example
21826
21827This is the service type for the
21828@uref{https://wiki.gentoo.org/wiki/Project:Eudev, eudev device
21829management daemon}. Compared to the previous example, in addition to an
d4053c71 21830extension of @var{shepherd-root-service-type}, we see two new fields:
0adfe95a
LC
21831
21832@table @code
21833@item compose
21834This is the procedure to @dfn{compose} the list of extensions to
21835services of this type.
21836
21837Services can extend the udev service by passing it lists of rules; we
21838compose those extensions simply by concatenating them.
21839
21840@item extend
1068f26b 21841This procedure defines how the value of the service is @dfn{extended} with
0adfe95a
LC
21842the composition of the extensions.
21843
21844Udev extensions are composed into a list of rules, but the udev service
21845value is itself a @code{<udev-configuration>} record. So here, we
a40424bd 21846extend that record by appending the list of rules it contains to the
0adfe95a 21847list of contributed rules.
b714395a
LC
21848
21849@item description
21850This is a string giving an overview of the service type. The string can
0649321d
LC
21851contain Texinfo markup (@pxref{Overview,,, texinfo, GNU Texinfo}). The
21852@command{guix system search} command searches these strings and displays
21853them (@pxref{Invoking guix system}).
0adfe95a
LC
21854@end table
21855
21856There can be only one instance of an extensible service type such as
21857@var{udev-service-type}. If there were more, the
21858@code{service-extension} specifications would be ambiguous.
21859
21860Still here? The next section provides a reference of the programming
21861interface for services.
21862
21863@node Service Reference
21864@subsubsection Service Reference
21865
21866We have seen an overview of service types (@pxref{Service Types and
21867Services}). This section provides a reference on how to manipulate
21868services and service types. This interface is provided by the
21869@code{(gnu services)} module.
21870
1bb895ea 21871@deffn {Scheme Procedure} service @var{type} [@var{value}]
0adfe95a
LC
21872Return a new service of @var{type}, a @code{<service-type>} object (see
21873below.) @var{value} can be any object; it represents the parameters of
21874this particular service instance.
1bb895ea
LC
21875
21876When @var{value} is omitted, the default value specified by @var{type}
21877is used; if @var{type} does not specify a default value, an error is
21878raised.
21879
21880For instance, this:
21881
21882@example
21883(service openssh-service-type)
21884@end example
21885
21886@noindent
21887is equivalent to this:
21888
21889@example
21890(service openssh-service-type
21891 (openssh-configuration))
21892@end example
21893
21894In both cases the result is an instance of @code{openssh-service-type}
21895with the default configuration.
0adfe95a
LC
21896@end deffn
21897
21898@deffn {Scheme Procedure} service? @var{obj}
21899Return true if @var{obj} is a service.
21900@end deffn
8451a568 21901
0adfe95a
LC
21902@deffn {Scheme Procedure} service-kind @var{service}
21903Return the type of @var{service}---i.e., a @code{<service-type>} object.
21904@end deffn
21905
efe7d19a 21906@deffn {Scheme Procedure} service-value @var{service}
0adfe95a
LC
21907Return the value associated with @var{service}. It represents its
21908parameters.
21909@end deffn
21910
21911Here is an example of how a service is created and manipulated:
21912
21913@example
21914(define s
21915 (service nginx-service-type
21916 (nginx-configuration
21917 (nginx nginx)
21918 (log-directory log-directory)
21919 (run-directory run-directory)
21920 (file config-file))))
21921
21922(service? s)
21923@result{} #t
21924
21925(eq? (service-kind s) nginx-service-type)
21926@result{} #t
21927@end example
21928
cd6f6c22
LC
21929The @code{modify-services} form provides a handy way to change the
21930parameters of some of the services of a list such as
4d343a14 21931@var{%base-services} (@pxref{Base Services, @code{%base-services}}). It
7414de0a 21932evaluates to a list of services. Of course, you could always use
4d343a14
CM
21933standard list combinators such as @code{map} and @code{fold} to do that
21934(@pxref{SRFI-1, List Library,, guile, GNU Guile Reference Manual});
21935@code{modify-services} simply provides a more concise form for this
21936common pattern.
cd6f6c22
LC
21937
21938@deffn {Scheme Syntax} modify-services @var{services} @
21939 (@var{type} @var{variable} => @var{body}) @dots{}
21940
21941Modify the services listed in @var{services} according to the given
21942clauses. Each clause has the form:
21943
21944@example
21945(@var{type} @var{variable} => @var{body})
21946@end example
21947
4d343a14
CM
21948where @var{type} is a service type---e.g.,
21949@code{guix-service-type}---and @var{variable} is an identifier that is
21950bound within the @var{body} to the service parameters---e.g., a
21951@code{guix-configuration} instance---of the original service of that
21952@var{type}.
cd6f6c22 21953
4d343a14
CM
21954The @var{body} should evaluate to the new service parameters, which will
21955be used to configure the new service. This new service will replace the
21956original in the resulting list. Because a service's service parameters
7414de0a 21957are created using @code{define-record-type*}, you can write a succinct
4d343a14
CM
21958@var{body} that evaluates to the new service parameters by using the
21959@code{inherit} feature that @code{define-record-type*} provides.
21960
b53daad0 21961@xref{Using the Configuration System}, for example usage.
cd6f6c22 21962
cd6f6c22
LC
21963@end deffn
21964
21965Next comes the programming interface for service types. This is
21966something you want to know when writing new service definitions, but not
21967necessarily when simply looking for ways to customize your
21968@code{operating-system} declaration.
21969
0adfe95a
LC
21970@deftp {Data Type} service-type
21971@cindex service type
21972This is the representation of a @dfn{service type} (@pxref{Service Types
21973and Services}).
21974
21975@table @asis
21976@item @code{name}
21977This is a symbol, used only to simplify inspection and debugging.
21978
21979@item @code{extensions}
1068f26b 21980A non-empty list of @code{<service-extension>} objects (see below).
0adfe95a
LC
21981
21982@item @code{compose} (default: @code{#f})
21983If this is @code{#f}, then the service type denotes services that cannot
21984be extended---i.e., services that do not receive ``values'' from other
21985services.
21986
21987Otherwise, it must be a one-argument procedure. The procedure is called
21988by @code{fold-services} and is passed a list of values collected from
881c61d0 21989extensions. It may return any single value.
0adfe95a
LC
21990
21991@item @code{extend} (default: @code{#f})
21992If this is @code{#f}, services of this type cannot be extended.
21993
21994Otherwise, it must be a two-argument procedure: @code{fold-services}
881c61d0
CM
21995calls it, passing it the initial value of the service as the first
21996argument and the result of applying @code{compose} to the extension
21997values as the second argument. It must return a value that is a valid
21998parameter value for the service instance.
0adfe95a
LC
21999@end table
22000
22001@xref{Service Types and Services}, for examples.
22002@end deftp
22003
22004@deffn {Scheme Procedure} service-extension @var{target-type} @
22005 @var{compute}
22006Return a new extension for services of type @var{target-type}.
22007@var{compute} must be a one-argument procedure: @code{fold-services}
22008calls it, passing it the value associated with the service that provides
22009the extension; it must return a valid value for the target service.
22010@end deffn
22011
22012@deffn {Scheme Procedure} service-extension? @var{obj}
22013Return true if @var{obj} is a service extension.
22014@end deffn
22015
71654dfd
LC
22016Occasionally, you might want to simply extend an existing service. This
22017involves creating a new service type and specifying the extension of
22018interest, which can be verbose; the @code{simple-service} procedure
22019provides a shorthand for this.
22020
22021@deffn {Scheme Procedure} simple-service @var{name} @var{target} @var{value}
22022Return a service that extends @var{target} with @var{value}. This works
22023by creating a singleton service type @var{name}, of which the returned
22024service is an instance.
22025
22026For example, this extends mcron (@pxref{Scheduled Job Execution}) with
22027an additional job:
22028
22029@example
22030(simple-service 'my-mcron-job mcron-service-type
22031 #~(job '(next-hour (3)) "guix gc -F 2G"))
22032@end example
22033@end deffn
22034
0adfe95a
LC
22035At the core of the service abstraction lies the @code{fold-services}
22036procedure, which is responsible for ``compiling'' a list of services
d62e201c
LC
22037down to a single directory that contains everything needed to boot and
22038run the system---the directory shown by the @command{guix system build}
22039command (@pxref{Invoking guix system}). In essence, it propagates
22040service extensions down the service graph, updating each node parameters
22041on the way, until it reaches the root node.
0adfe95a
LC
22042
22043@deffn {Scheme Procedure} fold-services @var{services} @
d62e201c 22044 [#:target-type @var{system-service-type}]
0adfe95a
LC
22045Fold @var{services} by propagating their extensions down to the root of
22046type @var{target-type}; return the root service adjusted accordingly.
22047@end deffn
22048
22049Lastly, the @code{(gnu services)} module also defines several essential
22050service types, some of which are listed below.
22051
d62e201c
LC
22052@defvr {Scheme Variable} system-service-type
22053This is the root of the service graph. It produces the system directory
22054as returned by the @command{guix system build} command.
22055@end defvr
22056
0adfe95a 22057@defvr {Scheme Variable} boot-service-type
d62e201c
LC
22058The type of the ``boot service'', which produces the @dfn{boot script}.
22059The boot script is what the initial RAM disk runs when booting.
0adfe95a
LC
22060@end defvr
22061
22062@defvr {Scheme Variable} etc-service-type
ed26b3a8
HG
22063The type of the @file{/etc} service. This service is used to create
22064files under @file{/etc} and can be extended by
0adfe95a
LC
22065passing it name/file tuples such as:
22066
22067@example
22068(list `("issue" ,(plain-file "issue" "Welcome!\n")))
22069@end example
22070
22071In this example, the effect would be to add an @file{/etc/issue} file
22072pointing to the given file.
22073@end defvr
22074
22075@defvr {Scheme Variable} setuid-program-service-type
22076Type for the ``setuid-program service''. This service collects lists of
22077executable file names, passed as gexps, and adds them to the set of
22078setuid-root programs on the system (@pxref{Setuid Programs}).
22079@end defvr
22080
af4c3fd5
LC
22081@defvr {Scheme Variable} profile-service-type
22082Type of the service that populates the @dfn{system profile}---i.e., the
22083programs under @file{/run/current-system/profile}. Other services can
22084extend it by passing it lists of packages to add to the system profile.
22085@end defvr
22086
0adfe95a 22087
dd17bc38
AK
22088@node Shepherd Services
22089@subsubsection Shepherd Services
0adfe95a 22090
e32171ee 22091@cindex shepherd services
0adfe95a
LC
22092@cindex PID 1
22093@cindex init system
a40424bd
CM
22094The @code{(gnu services shepherd)} module provides a way to define
22095services managed by the GNU@tie{}Shepherd, which is the GuixSD
22096initialization system---the first process that is started when the
1068f26b
AE
22097system boots, also known as PID@tie{}1
22098(@pxref{Introduction,,, shepherd, The GNU Shepherd Manual}).
6f305ea5 22099
dd17bc38
AK
22100Services in the Shepherd can depend on each other. For instance, the
22101SSH daemon may need to be started after the syslog daemon has been
22102started, which in turn can only happen once all the file systems have
22103been mounted. The simple operating system defined earlier (@pxref{Using
22104the Configuration System}) results in a service graph like this:
6f305ea5 22105
710fa231 22106@image{images/shepherd-graph,,5in,Typical shepherd service graph.}
6f305ea5
LC
22107
22108You can actually generate such a graph for any operating system
710fa231
AK
22109definition using the @command{guix system shepherd-graph} command
22110(@pxref{system-shepherd-graph, @command{guix system shepherd-graph}}).
6f305ea5 22111
d4053c71
AK
22112The @var{%shepherd-root-service} is a service object representing
22113PID@tie{}1, of type @var{shepherd-root-service-type}; it can be extended
22114by passing it lists of @code{<shepherd-service>} objects.
0adfe95a 22115
d4053c71 22116@deftp {Data Type} shepherd-service
dd17bc38 22117The data type representing a service managed by the Shepherd.
0adfe95a
LC
22118
22119@table @asis
22120@item @code{provision}
22121This is a list of symbols denoting what the service provides.
22122
dd17bc38
AK
22123These are the names that may be passed to @command{herd start},
22124@command{herd status}, and similar commands (@pxref{Invoking herd,,,
22125shepherd, The GNU Shepherd Manual}). @xref{Slots of services, the
22126@code{provides} slot,, shepherd, The GNU Shepherd Manual}, for details.
0adfe95a
LC
22127
22128@item @code{requirements} (default: @code{'()})
dd17bc38 22129List of symbols denoting the Shepherd services this one depends on.
0adfe95a
LC
22130
22131@item @code{respawn?} (default: @code{#t})
22132Whether to restart the service when it stops, for instance when the
22133underlying process dies.
22134
22135@item @code{start}
22136@itemx @code{stop} (default: @code{#~(const #f)})
dd17bc38
AK
22137The @code{start} and @code{stop} fields refer to the Shepherd's
22138facilities to start and stop processes (@pxref{Service De- and
22139Constructors,,, shepherd, The GNU Shepherd Manual}). They are given as
22140G-expressions that get expanded in the Shepherd configuration file
22141(@pxref{G-Expressions}).
0adfe95a 22142
70138308
LC
22143@item @code{actions} (default: @code{'()})
22144@cindex actions, of Shepherd services
22145This is a list of @code{shepherd-action} objects (see below) defining
22146@dfn{actions} supported by the service, in addition to the standard
22147@code{start} and @code{stop} actions. Actions listed here become available as
22148@command{herd} sub-commands:
22149
22150@example
22151herd @var{action} @var{service} [@var{arguments}@dots{}]
22152@end example
22153
0adfe95a
LC
22154@item @code{documentation}
22155A documentation string, as shown when running:
22156
22157@example
dd17bc38 22158herd doc @var{service-name}
0adfe95a
LC
22159@end example
22160
22161where @var{service-name} is one of the symbols in @var{provision}
dd17bc38 22162(@pxref{Invoking herd,,, shepherd, The GNU Shepherd Manual}).
fae685b9
LC
22163
22164@item @code{modules} (default: @var{%default-modules})
22165This is the list of modules that must be in scope when @code{start} and
22166@code{stop} are evaluated.
22167
0adfe95a
LC
22168@end table
22169@end deftp
22170
70138308
LC
22171@deftp {Data Type} shepherd-action
22172This is the data type that defines additional actions implemented by a
22173Shepherd service (see above).
22174
22175@table @code
22176@item name
22177Symbol naming the action.
22178
22179@item documentation
22180This is a documentation string for the action. It can be viewed by running:
22181
22182@example
22183herd doc @var{service} action @var{action}
22184@end example
22185
22186@item procedure
22187This should be a gexp that evaluates to a procedure of at least one argument,
22188which is the ``running value'' of the service (@pxref{Slots of services,,,
22189shepherd, The GNU Shepherd Manual}).
22190@end table
22191
22192The following example defines an action called @code{say-hello} that kindly
22193greets the user:
22194
22195@example
22196(shepherd-action
22197 (name 'say-hello)
22198 (documentation "Say hi!")
22199 (procedure #~(lambda (running . args)
22200 (format #t "Hello, friend! arguments: ~s\n"
22201 args)
22202 #t)))
22203@end example
22204
22205Assuming this action is added to the @code{example} service, then you can do:
22206
22207@example
22208# herd say-hello example
22209Hello, friend! arguments: ()
22210# herd say-hello example a b c
22211Hello, friend! arguments: ("a" "b" "c")
22212@end example
22213
22214This, as you can see, is a fairly sophisticated way to say hello.
22215@xref{Service Convenience,,, shepherd, The GNU Shepherd Manual}, for more
22216info on actions.
22217@end deftp
22218
d4053c71 22219@defvr {Scheme Variable} shepherd-root-service-type
dd17bc38 22220The service type for the Shepherd ``root service''---i.e., PID@tie{}1.
0adfe95a
LC
22221
22222This is the service type that extensions target when they want to create
dd17bc38 22223shepherd services (@pxref{Service Types and Services}, for an example).
d4053c71 22224Each extension must pass a list of @code{<shepherd-service>}.
0adfe95a
LC
22225@end defvr
22226
d4053c71 22227@defvr {Scheme Variable} %shepherd-root-service
0adfe95a
LC
22228This service represents PID@tie{}1.
22229@end defvr
8451a568 22230
8451a568 22231
31f1f593
LC
22232@node Documentation
22233@section Documentation
22234
22235@cindex documentation, searching for
22236@cindex searching for documentation
22237@cindex Info, documentation format
22238@cindex man pages
22239@cindex manual pages
22240In most cases packages installed with Guix come with documentation.
22241There are two main documentation formats: ``Info'', a browseable
22242hypertext format used for GNU software, and ``manual pages'' (or ``man
22243pages''), the linear documentation format traditionally found on Unix.
22244Info manuals are accessed with the @command{info} command or with Emacs,
22245and man pages are accessed using @command{man}.
22246
22247You can look for documentation of software installed on your system by
22248keyword. For example, the following command searches for information
22249about ``TLS'' in Info manuals:
22250
22251@example
22252$ info -k TLS
22253"(emacs)Network Security" -- STARTTLS
22254"(emacs)Network Security" -- TLS
22255"(gnutls)Core TLS API" -- gnutls_certificate_set_verify_flags
22256"(gnutls)Core TLS API" -- gnutls_certificate_set_verify_function
22257@dots{}
22258@end example
22259
22260@noindent
22261The command below searches for the same keyword in man pages:
22262
22263@example
22264$ man -k TLS
22265SSL (7) - OpenSSL SSL/TLS library
22266certtool (1) - GnuTLS certificate tool
22267@dots {}
22268@end example
22269
22270These searches are purely local to your computer so you have the
22271guarantee that documentation you find corresponds to what you have
22272actually installed, you can access it off-line, and your privacy is
22273respected.
22274
22275Once you have these results, you can view the relevant documentation by
22276running, say:
22277
22278@example
22279$ info "(gnutls)Core TLS API"
22280@end example
22281
22282@noindent
22283or:
22284
22285@example
22286$ man certtool
22287@end example
22288
22289Info manuals contain sections and indices as well as hyperlinks like
22290those found in Web pages. The @command{info} reader (@pxref{Top, Info
22291reader,, info-stnd, Stand-alone GNU Info}) and its Emacs counterpart
22292(@pxref{Misc Help,,, emacs, The GNU Emacs Manual}) provide intuitive key
22293bindings to navigate manuals. @xref{Getting Started,,, info, Info: An
22294Introduction}, for an introduction to Info navigation.
22295
cf4a9129
LC
22296@node Installing Debugging Files
22297@section Installing Debugging Files
8451a568 22298
cf4a9129
LC
22299@cindex debugging files
22300Program binaries, as produced by the GCC compilers for instance, are
22301typically written in the ELF format, with a section containing
22302@dfn{debugging information}. Debugging information is what allows the
22303debugger, GDB, to map binary code to source code; it is required to
22304debug a compiled program in good conditions.
8451a568 22305
cf4a9129
LC
22306The problem with debugging information is that is takes up a fair amount
22307of disk space. For example, debugging information for the GNU C Library
22308weighs in at more than 60 MiB. Thus, as a user, keeping all the
22309debugging info of all the installed programs is usually not an option.
22310Yet, space savings should not come at the cost of an impediment to
22311debugging---especially in the GNU system, which should make it easier
22312for users to exert their computing freedom (@pxref{GNU Distribution}).
8451a568 22313
cf4a9129
LC
22314Thankfully, the GNU Binary Utilities (Binutils) and GDB provide a
22315mechanism that allows users to get the best of both worlds: debugging
22316information can be stripped from the binaries and stored in separate
22317files. GDB is then able to load debugging information from those files,
22318when they are available (@pxref{Separate Debug Files,,, gdb, Debugging
22319with GDB}).
8451a568 22320
cf4a9129
LC
22321The GNU distribution takes advantage of this by storing debugging
22322information in the @code{lib/debug} sub-directory of a separate package
22323output unimaginatively called @code{debug} (@pxref{Packages with
22324Multiple Outputs}). Users can choose to install the @code{debug} output
22325of a package when they need it. For instance, the following command
22326installs the debugging information for the GNU C Library and for GNU
22327Guile:
8451a568
LC
22328
22329@example
cf4a9129 22330guix package -i glibc:debug guile:debug
8451a568
LC
22331@end example
22332
cf4a9129
LC
22333GDB must then be told to look for debug files in the user's profile, by
22334setting the @code{debug-file-directory} variable (consider setting it
22335from the @file{~/.gdbinit} file, @pxref{Startup,,, gdb, Debugging with
22336GDB}):
8451a568 22337
cf4a9129
LC
22338@example
22339(gdb) set debug-file-directory ~/.guix-profile/lib/debug
22340@end example
8451a568 22341
cf4a9129
LC
22342From there on, GDB will pick up debugging information from the
22343@code{.debug} files under @file{~/.guix-profile/lib/debug}.
8451a568 22344
cf4a9129
LC
22345In addition, you will most likely want GDB to be able to show the source
22346code being debugged. To do that, you will have to unpack the source
22347code of the package of interest (obtained with @code{guix build
22348--source}, @pxref{Invoking guix build}), and to point GDB to that source
22349directory using the @code{directory} command (@pxref{Source Path,
22350@code{directory},, gdb, Debugging with GDB}).
8451a568 22351
cf4a9129
LC
22352@c XXX: keep me up-to-date
22353The @code{debug} output mechanism in Guix is implemented by the
22354@code{gnu-build-system} (@pxref{Build Systems}). Currently, it is
1068f26b
AE
22355opt-in---debugging information is available only for the packages
22356with definitions explicitly declaring a @code{debug} output. This may be
22357changed to opt-out in the future if our build farm servers can handle
cf4a9129
LC
22358the load. To check whether a package has a @code{debug} output, use
22359@command{guix package --list-available} (@pxref{Invoking guix package}).
8451a568 22360
8451a568 22361
05962f29
LC
22362@node Security Updates
22363@section Security Updates
22364
09866b39
LC
22365@cindex security updates
22366@cindex security vulnerabilities
22367Occasionally, important security vulnerabilities are discovered in software
22368packages and must be patched. Guix developers try hard to keep track of
22369known vulnerabilities and to apply fixes as soon as possible in the
22370@code{master} branch of Guix (we do not yet provide a ``stable'' branch
22371containing only security updates.) The @command{guix lint} tool helps
22372developers find out about vulnerable versions of software packages in the
22373distribution:
22374
22375@smallexample
22376$ guix lint -c cve
e30c2be1
LC
22377gnu/packages/base.scm:652:2: glibc@@2.21: probably vulnerable to CVE-2015-1781, CVE-2015-7547
22378gnu/packages/gcc.scm:334:2: gcc@@4.9.3: probably vulnerable to CVE-2015-5276
22379gnu/packages/image.scm:312:2: openjpeg@@2.1.0: probably vulnerable to CVE-2016-1923, CVE-2016-1924
09866b39
LC
22380@dots{}
22381@end smallexample
22382
22383@xref{Invoking guix lint}, for more information.
22384
843858b8 22385@quotation Note
09866b39
LC
22386As of version @value{VERSION}, the feature described below is considered
22387``beta''.
843858b8 22388@end quotation
05962f29 22389
09866b39 22390Guix follows a functional
05962f29
LC
22391package management discipline (@pxref{Introduction}), which implies
22392that, when a package is changed, @emph{every package that depends on it}
22393must be rebuilt. This can significantly slow down the deployment of
22394fixes in core packages such as libc or Bash, since basically the whole
22395distribution would need to be rebuilt. Using pre-built binaries helps
22396(@pxref{Substitutes}), but deployment may still take more time than
22397desired.
22398
22399@cindex grafts
1068f26b 22400To address this, Guix implements @dfn{grafts}, a mechanism that allows
05962f29
LC
22401for fast deployment of critical updates without the costs associated
22402with a whole-distribution rebuild. The idea is to rebuild only the
22403package that needs to be patched, and then to ``graft'' it onto packages
22404explicitly installed by the user and that were previously referring to
22405the original package. The cost of grafting is typically very low, and
22406order of magnitudes lower than a full rebuild of the dependency chain.
22407
22408@cindex replacements of packages, for grafts
22409For instance, suppose a security update needs to be applied to Bash.
22410Guix developers will provide a package definition for the ``fixed''
22411Bash, say @var{bash-fixed}, in the usual way (@pxref{Defining
22412Packages}). Then, the original package definition is augmented with a
22413@code{replacement} field pointing to the package containing the bug fix:
22414
22415@example
22416(define bash
22417 (package
22418 (name "bash")
22419 ;; @dots{}
22420 (replacement bash-fixed)))
22421@end example
22422
c22a1324
LC
22423From there on, any package depending directly or indirectly on Bash---as
22424reported by @command{guix gc --requisites} (@pxref{Invoking guix
22425gc})---that is installed is automatically ``rewritten'' to refer to
05962f29 22426@var{bash-fixed} instead of @var{bash}. This grafting process takes
1068f26b 22427time proportional to the size of the package, usually less than a
c22a1324
LC
22428minute for an ``average'' package on a recent machine. Grafting is
22429recursive: when an indirect dependency requires grafting, then grafting
22430``propagates'' up to the package that the user is installing.
05962f29 22431
57bdd79e
LC
22432Currently, the length of the name and version of the graft and that of
22433the package it replaces (@var{bash-fixed} and @var{bash} in the example
22434above) must be equal. This restriction mostly comes from the fact that
22435grafting works by patching files, including binary files, directly.
05962f29
LC
22436Other restrictions may apply: for instance, when adding a graft to a
22437package providing a shared library, the original shared library and its
22438replacement must have the same @code{SONAME} and be binary-compatible.
22439
59a4dd50
LC
22440The @option{--no-grafts} command-line option allows you to forcefully
22441avoid grafting (@pxref{Common Build Options, @option{--no-grafts}}).
22442Thus, the command:
22443
22444@example
22445guix build bash --no-grafts
22446@end example
22447
22448@noindent
22449returns the store file name of the original Bash, whereas:
22450
22451@example
22452guix build bash
22453@end example
22454
22455@noindent
22456returns the store file name of the ``fixed'', replacement Bash. This
22457allows you to distinguish between the two variants of Bash.
22458
22459To verify which Bash your whole profile refers to, you can run
22460(@pxref{Invoking guix gc}):
22461
22462@example
22463guix gc -R `readlink -f ~/.guix-profile` | grep bash
22464@end example
22465
22466@noindent
22467@dots{} and compare the store file names that you get with those above.
22468Likewise for a complete GuixSD system generation:
22469
22470@example
22471guix gc -R `guix system build my-config.scm` | grep bash
22472@end example
22473
22474Lastly, to check which Bash running processes are using, you can use the
22475@command{lsof} command:
22476
22477@example
22478lsof | grep /gnu/store/.*bash
22479@end example
22480
05962f29 22481
cf4a9129
LC
22482@node Package Modules
22483@section Package Modules
8451a568 22484
cf4a9129
LC
22485From a programming viewpoint, the package definitions of the
22486GNU distribution are provided by Guile modules in the @code{(gnu packages
22487@dots{})} name space@footnote{Note that packages under the @code{(gnu
22488packages @dots{})} module name space are not necessarily ``GNU
22489packages''. This module naming scheme follows the usual Guile module
22490naming convention: @code{gnu} means that these modules are distributed
22491as part of the GNU system, and @code{packages} identifies modules that
22492define packages.} (@pxref{Modules, Guile modules,, guile, GNU Guile
22493Reference Manual}). For instance, the @code{(gnu packages emacs)}
22494module exports a variable named @code{emacs}, which is bound to a
22495@code{<package>} object (@pxref{Defining Packages}).
113daf62 22496
300868ba 22497The @code{(gnu packages @dots{})} module name space is
cf4a9129
LC
22498automatically scanned for packages by the command-line tools. For
22499instance, when running @code{guix package -i emacs}, all the @code{(gnu
22500packages @dots{})} modules are scanned until one that exports a package
22501object whose name is @code{emacs} is found. This package search
22502facility is implemented in the @code{(gnu packages)} module.
113daf62 22503
300868ba 22504@cindex customization, of packages
8689901f 22505@cindex package module search path
cf4a9129 22506Users can store package definitions in modules with different
60142854 22507names---e.g., @code{(my-packages emacs)}@footnote{Note that the file
c95ded7e
LC
22508name and module name must match. For instance, the @code{(my-packages
22509emacs)} module must be stored in a @file{my-packages/emacs.scm} file
22510relative to the load path specified with @option{--load-path} or
22511@code{GUIX_PACKAGE_PATH}. @xref{Modules and the File System,,,
22512guile, GNU Guile Reference Manual}, for details.}. These package definitions
1068f26b
AE
22513will not be visible by default. Users can invoke commands such as
22514@command{guix package} and @command{guix build} with the
c95ded7e
LC
22515@code{-e} option so that they know where to find the package. Better
22516yet, they can use the
300868ba 22517@code{-L} option of these commands to make those modules visible
8689901f
LC
22518(@pxref{Invoking guix build, @code{--load-path}}), or define the
22519@code{GUIX_PACKAGE_PATH} environment variable. This environment
22520variable makes it easy to extend or customize the distribution and is
22521honored by all the user interfaces.
22522
22523@defvr {Environment Variable} GUIX_PACKAGE_PATH
1068f26b
AE
22524This is a colon-separated list of directories to search for additional
22525package modules. Directories listed in this variable take precedence
22526over the own modules of the distribution.
8689901f 22527@end defvr
ef5dd60a 22528
cf4a9129
LC
22529The distribution is fully @dfn{bootstrapped} and @dfn{self-contained}:
22530each package is built based solely on other packages in the
22531distribution. The root of this dependency graph is a small set of
22532@dfn{bootstrap binaries}, provided by the @code{(gnu packages
22533bootstrap)} module. For more information on bootstrapping,
081145cf 22534@pxref{Bootstrapping}.
ef5dd60a 22535
cf4a9129
LC
22536@node Packaging Guidelines
22537@section Packaging Guidelines
ef5dd60a 22538
e32171ee 22539@cindex packages, creating
cf4a9129
LC
22540The GNU distribution is nascent and may well lack some of your favorite
22541packages. This section describes how you can help make the distribution
22542grow. @xref{Contributing}, for additional information on how you can
22543help.
ef5dd60a 22544
cf4a9129
LC
22545Free software packages are usually distributed in the form of
22546@dfn{source code tarballs}---typically @file{tar.gz} files that contain
22547all the source files. Adding a package to the distribution means
22548essentially two things: adding a @dfn{recipe} that describes how to
22549build the package, including a list of other packages required to build
f97c9175 22550it, and adding @dfn{package metadata} along with that recipe, such as a
cf4a9129 22551description and licensing information.
ef5dd60a 22552
cf4a9129
LC
22553In Guix all this information is embodied in @dfn{package definitions}.
22554Package definitions provide a high-level view of the package. They are
22555written using the syntax of the Scheme programming language; in fact,
22556for each package we define a variable bound to the package definition,
22557and export that variable from a module (@pxref{Package Modules}).
22558However, in-depth Scheme knowledge is @emph{not} a prerequisite for
22559creating packages. For more information on package definitions,
081145cf 22560@pxref{Defining Packages}.
ef5dd60a 22561
cf4a9129
LC
22562Once a package definition is in place, stored in a file in the Guix
22563source tree, it can be tested using the @command{guix build} command
22564(@pxref{Invoking guix build}). For example, assuming the new package is
c71979f4
LC
22565called @code{gnew}, you may run this command from the Guix build tree
22566(@pxref{Running Guix Before It Is Installed}):
ef5dd60a
LC
22567
22568@example
cf4a9129 22569./pre-inst-env guix build gnew --keep-failed
ef5dd60a 22570@end example
ef5dd60a 22571
cf4a9129
LC
22572Using @code{--keep-failed} makes it easier to debug build failures since
22573it provides access to the failed build tree. Another useful
22574command-line option when debugging is @code{--log-file}, to access the
22575build log.
ef5dd60a 22576
cf4a9129
LC
22577If the package is unknown to the @command{guix} command, it may be that
22578the source file contains a syntax error, or lacks a @code{define-public}
22579clause to export the package variable. To figure it out, you may load
22580the module from Guile to get more information about the actual error:
ef5dd60a 22581
cf4a9129
LC
22582@example
22583./pre-inst-env guile -c '(use-modules (gnu packages gnew))'
22584@end example
ef5dd60a 22585
cf4a9129
LC
22586Once your package builds correctly, please send us a patch
22587(@pxref{Contributing}). Well, if you need help, we will be happy to
22588help you too. Once the patch is committed in the Guix repository, the
22589new package automatically gets built on the supported platforms by
2b1cee21 22590@url{http://hydra.gnu.org/jobset/gnu/master, our continuous integration
cf4a9129 22591system}.
ef5dd60a 22592
cf4a9129
LC
22593@cindex substituter
22594Users can obtain the new package definition simply by running
22595@command{guix pull} (@pxref{Invoking guix pull}). When
22596@code{hydra.gnu.org} is done building the package, installing the
22597package automatically downloads binaries from there
22598(@pxref{Substitutes}). The only place where human intervention is
22599needed is to review and apply the patch.
ef5dd60a 22600
ef5dd60a 22601
cf4a9129 22602@menu
ec0339cd
LC
22603* Software Freedom:: What may go into the distribution.
22604* Package Naming:: What's in a name?
22605* Version Numbers:: When the name is not enough.
cbd02397 22606* Synopses and Descriptions:: Helping users find the right package.
fb4d6f6c 22607* Python Modules:: A touch of British comedy.
ec0339cd 22608* Perl Modules:: Little pearls.
e1c963bf 22609* Java Packages:: Coffee break.
ec0339cd 22610* Fonts:: Fond of fonts.
cf4a9129 22611@end menu
ef5dd60a 22612
cf4a9129
LC
22613@node Software Freedom
22614@subsection Software Freedom
ef5dd60a 22615
cf4a9129 22616@c Adapted from http://www.gnu.org/philosophy/philosophy.html.
e32171ee 22617@cindex free software
cf4a9129
LC
22618The GNU operating system has been developed so that users can have
22619freedom in their computing. GNU is @dfn{free software}, meaning that
22620users have the @url{http://www.gnu.org/philosophy/free-sw.html,four
22621essential freedoms}: to run the program, to study and change the program
22622in source code form, to redistribute exact copies, and to distribute
22623modified versions. Packages found in the GNU distribution provide only
22624software that conveys these four freedoms.
c11a6eb1 22625
cf4a9129
LC
22626In addition, the GNU distribution follow the
22627@url{http://www.gnu.org/distros/free-system-distribution-guidelines.html,free
22628software distribution guidelines}. Among other things, these guidelines
22629reject non-free firmware, recommendations of non-free software, and
22630discuss ways to deal with trademarks and patents.
ef5dd60a 22631
1068f26b
AE
22632Some otherwise free upstream package sources contain a small and optional
22633subset that violates the above guidelines, for instance because this subset
22634is itself non-free code. When that happens, the offending items are removed
22635with appropriate patches or code snippets in the @code{origin} form of the
22636package (@pxref{Defining Packages}). This way, @code{guix
cf4a9129
LC
22637build --source} returns the ``freed'' source rather than the unmodified
22638upstream source.
ef5dd60a 22639
ef5dd60a 22640
cf4a9129
LC
22641@node Package Naming
22642@subsection Package Naming
ef5dd60a 22643
e32171ee 22644@cindex package name
cf4a9129
LC
22645A package has actually two names associated with it:
22646First, there is the name of the @emph{Scheme variable}, the one following
22647@code{define-public}. By this name, the package can be made known in the
22648Scheme code, for instance as input to another package. Second, there is
22649the string in the @code{name} field of a package definition. This name
22650is used by package management commands such as
22651@command{guix package} and @command{guix build}.
ef5dd60a 22652
cf4a9129
LC
22653Both are usually the same and correspond to the lowercase conversion of
22654the project name chosen upstream, with underscores replaced with
22655hyphens. For instance, GNUnet is available as @code{gnunet}, and
22656SDL_net as @code{sdl-net}.
927097ef 22657
cf4a9129 22658We do not add @code{lib} prefixes for library packages, unless these are
081145cf 22659already part of the official project name. But @pxref{Python
cf4a9129
LC
22660Modules} and @ref{Perl Modules} for special rules concerning modules for
22661the Python and Perl languages.
927097ef 22662
1b366ee4 22663Font package names are handled differently, @pxref{Fonts}.
7fec52b7 22664
ef5dd60a 22665
cf4a9129
LC
22666@node Version Numbers
22667@subsection Version Numbers
ef5dd60a 22668
e32171ee 22669@cindex package version
cf4a9129
LC
22670We usually package only the latest version of a given free software
22671project. But sometimes, for instance for incompatible library versions,
22672two (or more) versions of the same package are needed. These require
22673different Scheme variable names. We use the name as defined
22674in @ref{Package Naming}
22675for the most recent version; previous versions use the same name, suffixed
22676by @code{-} and the smallest prefix of the version number that may
22677distinguish the two versions.
ef5dd60a 22678
cf4a9129
LC
22679The name inside the package definition is the same for all versions of a
22680package and does not contain any version number.
ef5dd60a 22681
cf4a9129 22682For instance, the versions 2.24.20 and 3.9.12 of GTK+ may be packaged as follows:
ef5dd60a 22683
cf4a9129
LC
22684@example
22685(define-public gtk+
22686 (package
17d8e33f
ML
22687 (name "gtk+")
22688 (version "3.9.12")
22689 ...))
cf4a9129
LC
22690(define-public gtk+-2
22691 (package
17d8e33f
ML
22692 (name "gtk+")
22693 (version "2.24.20")
22694 ...))
cf4a9129
LC
22695@end example
22696If we also wanted GTK+ 3.8.2, this would be packaged as
22697@example
22698(define-public gtk+-3.8
22699 (package
17d8e33f
ML
22700 (name "gtk+")
22701 (version "3.8.2")
22702 ...))
cf4a9129 22703@end example
ef5dd60a 22704
880d647d
LC
22705@c See <https://lists.gnu.org/archive/html/guix-devel/2016-01/msg00425.html>,
22706@c for a discussion of what follows.
22707@cindex version number, for VCS snapshots
22708Occasionally, we package snapshots of upstream's version control system
22709(VCS) instead of formal releases. This should remain exceptional,
22710because it is up to upstream developers to clarify what the stable
22711release is. Yet, it is sometimes necessary. So, what should we put in
22712the @code{version} field?
22713
22714Clearly, we need to make the commit identifier of the VCS snapshot
22715visible in the version string, but we also need to make sure that the
22716version string is monotonically increasing so that @command{guix package
22717--upgrade} can determine which version is newer. Since commit
22718identifiers, notably with Git, are not monotonically increasing, we add
22719a revision number that we increase each time we upgrade to a newer
22720snapshot. The resulting version string looks like this:
22721
22722@example
227232.0.11-3.cabba9e
22724 ^ ^ ^
22725 | | `-- upstream commit ID
22726 | |
22727 | `--- Guix package revision
22728 |
22729latest upstream version
22730@end example
22731
22732It is a good idea to strip commit identifiers in the @code{version}
22733field to, say, 7 digits. It avoids an aesthetic annoyance (assuming
22734aesthetics have a role to play here) as well as problems related to OS
22735limits such as the maximum shebang length (127 bytes for the Linux
22736kernel.) It is best to use the full commit identifiers in
561360a5
LC
22737@code{origin}s, though, to avoid ambiguities. A typical package
22738definition may look like this:
22739
22740@example
22741(define my-package
6e42660b 22742 (let ((commit "c3f29bc928d5900971f65965feaae59e1272a3f7")
22743 (revision "1")) ;Guix package revision
561360a5 22744 (package
9ce07f2d 22745 (version (git-version "0.9" revision commit))
561360a5
LC
22746 (source (origin
22747 (method git-fetch)
22748 (uri (git-reference
22749 (url "git://example.org/my-package.git")
22750 (commit commit)))
22751 (sha256 (base32 "1mbikn@dots{}"))
9ce07f2d 22752 (file-name (git-file-name name version))))
561360a5
LC
22753 ;; @dots{}
22754 )))
22755@end example
880d647d 22756
cbd02397
LC
22757@node Synopses and Descriptions
22758@subsection Synopses and Descriptions
22759
e32171ee
JD
22760@cindex package description
22761@cindex package synopsis
cbd02397
LC
22762As we have seen before, each package in GNU@tie{}Guix includes a
22763synopsis and a description (@pxref{Defining Packages}). Synopses and
22764descriptions are important: They are what @command{guix package
22765--search} searches, and a crucial piece of information to help users
22766determine whether a given package suits their needs. Consequently,
22767packagers should pay attention to what goes into them.
22768
22769Synopses must start with a capital letter and must not end with a
22770period. They must not start with ``a'' or ``the'', which usually does
22771not bring anything; for instance, prefer ``File-frobbing tool'' over ``A
22772tool that frobs files''. The synopsis should say what the package
22773is---e.g., ``Core GNU utilities (file, text, shell)''---or what it is
22774used for---e.g., the synopsis for GNU@tie{}grep is ``Print lines
22775matching a pattern''.
22776
22777Keep in mind that the synopsis must be meaningful for a very wide
22778audience. For example, ``Manipulate alignments in the SAM format''
22779might make sense for a seasoned bioinformatics researcher, but might be
22780fairly unhelpful or even misleading to a non-specialized audience. It
22781is a good idea to come up with a synopsis that gives an idea of the
22782application domain of the package. In this example, this might give
22783something like ``Manipulate nucleotide sequence alignments'', which
22784hopefully gives the user a better idea of whether this is what they are
22785looking for.
22786
cbd02397
LC
22787Descriptions should take between five and ten lines. Use full
22788sentences, and avoid using acronyms without first introducing them.
762e54b7
LC
22789Please avoid marketing phrases such as ``world-leading'',
22790``industrial-strength'', and ``next-generation'', and avoid superlatives
22791like ``the most advanced''---they are not helpful to users looking for a
22792package and may even sound suspicious. Instead, try to be factual,
22793mentioning use cases and features.
22794
22795@cindex Texinfo markup, in package descriptions
cbd02397
LC
22796Descriptions can include Texinfo markup, which is useful to introduce
22797ornaments such as @code{@@code} or @code{@@dfn}, bullet lists, or
ba7d6c76
ML
22798hyperlinks (@pxref{Overview,,, texinfo, GNU Texinfo}). However you
22799should be careful when using some characters for example @samp{@@} and
22800curly braces which are the basic special characters in Texinfo
22801(@pxref{Special Characters,,, texinfo, GNU Texinfo}). User interfaces
22802such as @command{guix package --show} take care of rendering it
22803appropriately.
cbd02397
LC
22804
22805Synopses and descriptions are translated by volunteers
22806@uref{http://translationproject.org/domain/guix-packages.html, at the
22807Translation Project} so that as many users as possible can read them in
22808their native language. User interfaces search them and display them in
22809the language specified by the current locale.
22810
e797e94b
LC
22811To allow @command{xgettext} to extract them as translatable strings,
22812synopses and descriptions @emph{must be literal strings}. This means
22813that you cannot use @code{string-append} or @code{format} to construct
22814these strings:
22815
22816@lisp
22817(package
22818 ;; @dots{}
22819 (synopsis "This is translatable")
22820 (description (string-append "This is " "*not*" " translatable.")))
22821@end lisp
22822
cbd02397
LC
22823Translation is a lot of work so, as a packager, please pay even more
22824attention to your synopses and descriptions as every change may entail
ba7d6c76 22825additional work for translators. In order to help them, it is possible
36743e71 22826to make recommendations or instructions visible to them by inserting
ba7d6c76
ML
22827special comments like this (@pxref{xgettext Invocation,,, gettext, GNU
22828Gettext}):
22829
22830@example
22831;; TRANSLATORS: "X11 resize-and-rotate" should not be translated.
22832(description "ARandR is designed to provide a simple visual front end
22833for the X11 resize-and-rotate (RandR) extension. @dots{}")
22834@end example
cbd02397 22835
ef5dd60a 22836
cf4a9129
LC
22837@node Python Modules
22838@subsection Python Modules
ef5dd60a 22839
e32171ee 22840@cindex python
cf4a9129
LC
22841We currently package Python 2 and Python 3, under the Scheme variable names
22842@code{python-2} and @code{python} as explained in @ref{Version Numbers}.
22843To avoid confusion and naming clashes with other programming languages, it
22844seems desirable that the name of a package for a Python module contains
22845the word @code{python}.
ef5dd60a 22846
cf4a9129
LC
22847Some modules are compatible with only one version of Python, others with both.
22848If the package Foo compiles only with Python 3, we name it
22849@code{python-foo}; if it compiles only with Python 2, we name it
22850@code{python2-foo}. If it is compatible with both versions, we create two
22851packages with the corresponding names.
ef5dd60a 22852
cf4a9129
LC
22853If a project already contains the word @code{python}, we drop this;
22854for instance, the module python-dateutil is packaged under the names
99c866a0
HG
22855@code{python-dateutil} and @code{python2-dateutil}. If the project name
22856starts with @code{py} (e.g. @code{pytz}), we keep it and prefix it as
22857described above.
113daf62 22858
e940a271
HG
22859@subsubsection Specifying Dependencies
22860@cindex inputs, for Python packages
22861
22862Dependency information for Python packages is usually available in the
22863package source tree, with varying degrees of accuracy: in the
22864@file{setup.py} file, in @file{requirements.txt}, or in @file{tox.ini}.
22865
22866Your mission, when writing a recipe for a Python package, is to map
22867these dependencies to the appropriate type of ``input'' (@pxref{package
22868Reference, inputs}). Although the @code{pypi} importer normally does a
22869good job (@pxref{Invoking guix import}), you may want to check the
22870following check list to determine which dependency goes where.
22871
22872@itemize
22873
aaf75c89
HG
22874@item
22875We currently package Python 2 with @code{setuptools} and @code{pip}
22876installed like Python 3.4 has per default. Thus you don't need to
891a843d
HG
22877specify either of these as an input. @command{guix lint} will warn you
22878if you do.
aaf75c89 22879
e940a271
HG
22880@item
22881Python dependencies required at run time go into
22882@code{propagated-inputs}. They are typically defined with the
22883@code{install_requires} keyword in @file{setup.py}, or in the
22884@file{requirements.txt} file.
22885
22886@item
22887Python packages required only at build time---e.g., those listed with
22888the @code{setup_requires} keyword in @file{setup.py}---or only for
22889testing---e.g., those in @code{tests_require}---go into
22890@code{native-inputs}. The rationale is that (1) they do not need to be
22891propagated because they are not needed at run time, and (2) in a
22892cross-compilation context, it's the ``native'' input that we'd want.
22893
aaf75c89 22894Examples are the @code{pytest}, @code{mock}, and @code{nose} test
e940a271
HG
22895frameworks. Of course if any of these packages is also required at
22896run-time, it needs to go to @code{propagated-inputs}.
22897
22898@item
22899Anything that does not fall in the previous categories goes to
22900@code{inputs}, for example programs or C libraries required for building
22901Python packages containing C extensions.
22902
22903@item
22904If a Python package has optional dependencies (@code{extras_require}),
22905it is up to you to decide whether to add them or not, based on their
22906usefulness/overhead ratio (@pxref{Submitting Patches, @command{guix
22907size}}).
22908
22909@end itemize
22910
22911
cf4a9129
LC
22912@node Perl Modules
22913@subsection Perl Modules
523e4896 22914
e32171ee 22915@cindex perl
cf4a9129
LC
22916Perl programs standing for themselves are named as any other package,
22917using the lowercase upstream name.
22918For Perl packages containing a single class, we use the lowercase class name,
22919replace all occurrences of @code{::} by dashes and prepend the prefix
22920@code{perl-}.
22921So the class @code{XML::Parser} becomes @code{perl-xml-parser}.
22922Modules containing several classes keep their lowercase upstream name and
22923are also prepended by @code{perl-}. Such modules tend to have the word
22924@code{perl} somewhere in their name, which gets dropped in favor of the
22925prefix. For instance, @code{libwww-perl} becomes @code{perl-libwww}.
523e4896 22926
523e4896 22927
e1c963bf
HG
22928@node Java Packages
22929@subsection Java Packages
22930
e32171ee 22931@cindex java
e1c963bf
HG
22932Java programs standing for themselves are named as any other package,
22933using the lowercase upstream name.
22934
22935To avoid confusion and naming clashes with other programming languages,
22936it is desirable that the name of a package for a Java package is
22937prefixed with @code{java-}. If a project already contains the word
22938@code{java}, we drop this; for instance, the package @code{ngsjava} is
22939packaged under the name @code{java-ngs}.
22940
22941For Java packages containing a single class or a small class hierarchy,
22942we use the lowercase class name, replace all occurrences of @code{.} by
22943dashes and prepend the prefix @code{java-}. So the class
22944@code{apache.commons.cli} becomes package
22945@code{java-apache-commons-cli}.
22946
22947
7fec52b7
AE
22948@node Fonts
22949@subsection Fonts
22950
e32171ee 22951@cindex fonts
7fec52b7
AE
22952For fonts that are in general not installed by a user for typesetting
22953purposes, or that are distributed as part of a larger software package,
22954we rely on the general packaging rules for software; for instance, this
22955applies to the fonts delivered as part of the X.Org system or fonts that
22956are part of TeX Live.
22957
22958To make it easier for a user to search for fonts, names for other packages
22959containing only fonts are constructed as follows, independently of the
22960upstream package name.
22961
22962The name of a package containing only one font family starts with
22963@code{font-}; it is followed by the foundry name and a dash @code{-}
22964if the foundry is known, and the font family name, in which spaces are
22965replaced by dashes (and as usual, all upper case letters are transformed
22966to lower case).
22967For example, the Gentium font family by SIL is packaged under the name
22968@code{font-sil-gentium}.
22969
22970For a package containing several font families, the name of the collection
22971is used in the place of the font family name.
22972For instance, the Liberation fonts consist of three families,
22973Liberation Sans, Liberation Serif and Liberation Mono.
22974These could be packaged separately under the names
22975@code{font-liberation-sans} and so on; but as they are distributed together
22976under a common name, we prefer to package them together as
22977@code{font-liberation}.
22978
22979In the case where several formats of the same font family or font collection
22980are packaged separately, a short form of the format, prepended by a dash,
22981is added to the package name. We use @code{-ttf} for TrueType fonts,
1b366ee4 22982@code{-otf} for OpenType fonts and @code{-type1} for PostScript Type 1
7fec52b7
AE
22983fonts.
22984
22985
b25937e3 22986
cf4a9129
LC
22987@node Bootstrapping
22988@section Bootstrapping
b25937e3 22989
cf4a9129 22990@c Adapted from the ELS 2013 paper.
b25937e3 22991
cf4a9129 22992@cindex bootstrapping
7889394e 22993
cf4a9129
LC
22994Bootstrapping in our context refers to how the distribution gets built
22995``from nothing''. Remember that the build environment of a derivation
22996contains nothing but its declared inputs (@pxref{Introduction}). So
22997there's an obvious chicken-and-egg problem: how does the first package
22998get built? How does the first compiler get compiled? Note that this is
22999a question of interest only to the curious hacker, not to the regular
23000user, so you can shamelessly skip this section if you consider yourself
23001a ``regular user''.
72b9d60d 23002
cf4a9129
LC
23003@cindex bootstrap binaries
23004The GNU system is primarily made of C code, with libc at its core. The
23005GNU build system itself assumes the availability of a Bourne shell and
23006command-line tools provided by GNU Coreutils, Awk, Findutils, `sed', and
23007`grep'. Furthermore, build programs---programs that run
23008@code{./configure}, @code{make}, etc.---are written in Guile Scheme
23009(@pxref{Derivations}). Consequently, to be able to build anything at
23010all, from scratch, Guix relies on pre-built binaries of Guile, GCC,
23011Binutils, libc, and the other packages mentioned above---the
23012@dfn{bootstrap binaries}.
72b9d60d 23013
cf4a9129
LC
23014These bootstrap binaries are ``taken for granted'', though we can also
23015re-create them if needed (more on that later).
72b9d60d 23016
cf4a9129 23017@unnumberedsubsec Preparing to Use the Bootstrap Binaries
c79d54fe 23018
cf4a9129
LC
23019@c As of Emacs 24.3, Info-mode displays the image, but since it's a
23020@c large image, it's hard to scroll. Oh well.
23021@image{images/bootstrap-graph,6in,,Dependency graph of the early bootstrap derivations}
523e4896 23022
cf4a9129
LC
23023The figure above shows the very beginning of the dependency graph of the
23024distribution, corresponding to the package definitions of the @code{(gnu
d33fa0c7
LC
23025packages bootstrap)} module. A similar figure can be generated with
23026@command{guix graph} (@pxref{Invoking guix graph}), along the lines of:
23027
23028@example
23029guix graph -t derivation \
23030 -e '(@@@@ (gnu packages bootstrap) %bootstrap-gcc)' \
23031 | dot -Tps > t.ps
23032@end example
23033
23034At this level of detail, things are
cf4a9129
LC
23035slightly complex. First, Guile itself consists of an ELF executable,
23036along with many source and compiled Scheme files that are dynamically
23037loaded when it runs. This gets stored in the @file{guile-2.0.7.tar.xz}
23038tarball shown in this graph. This tarball is part of Guix's ``source''
23039distribution, and gets inserted into the store with @code{add-to-store}
23040(@pxref{The Store}).
2e7b5cea 23041
cf4a9129
LC
23042But how do we write a derivation that unpacks this tarball and adds it
23043to the store? To solve this problem, the @code{guile-bootstrap-2.0.drv}
23044derivation---the first one that gets built---uses @code{bash} as its
23045builder, which runs @code{build-bootstrap-guile.sh}, which in turn calls
23046@code{tar} to unpack the tarball. Thus, @file{bash}, @file{tar},
23047@file{xz}, and @file{mkdir} are statically-linked binaries, also part of
23048the Guix source distribution, whose sole purpose is to allow the Guile
23049tarball to be unpacked.
fb729425 23050
cf4a9129
LC
23051Once @code{guile-bootstrap-2.0.drv} is built, we have a functioning
23052Guile that can be used to run subsequent build programs. Its first task
23053is to download tarballs containing the other pre-built binaries---this
23054is what the @code{.tar.xz.drv} derivations do. Guix modules such as
23055@code{ftp-client.scm} are used for this purpose. The
23056@code{module-import.drv} derivations import those modules in a directory
23057in the store, using the original layout. The
23058@code{module-import-compiled.drv} derivations compile those modules, and
23059write them in an output directory with the right layout. This
23060corresponds to the @code{#:modules} argument of
23061@code{build-expression->derivation} (@pxref{Derivations}).
fb729425 23062
cf4a9129
LC
23063Finally, the various tarballs are unpacked by the
23064derivations @code{gcc-bootstrap-0.drv}, @code{glibc-bootstrap-0.drv},
23065etc., at which point we have a working C tool chain.
fb729425 23066
fb729425 23067
cf4a9129 23068@unnumberedsubsec Building the Build Tools
523e4896 23069
cf4a9129
LC
23070Bootstrapping is complete when we have a full tool chain that does not
23071depend on the pre-built bootstrap tools discussed above. This
23072no-dependency requirement is verified by checking whether the files of
23073the final tool chain contain references to the @file{/gnu/store}
23074directories of the bootstrap inputs. The process that leads to this
23075``final'' tool chain is described by the package definitions found in
1f6f57df 23076the @code{(gnu packages commencement)} module.
df2ce343 23077
d33fa0c7
LC
23078The @command{guix graph} command allows us to ``zoom out'' compared to
23079the graph above, by looking at the level of package objects instead of
23080individual derivations---remember that a package may translate to
23081several derivations, typically one derivation to download its source,
23082one to build the Guile modules it needs, and one to actually build the
23083package from source. The command:
23084
23085@example
23086guix graph -t bag \
23087 -e '(@@@@ (gnu packages commencement)
23088 glibc-final-with-bootstrap-bash)' | dot -Tps > t.ps
23089@end example
23090
23091@noindent
23092produces the dependency graph leading to the ``final'' C
23093library@footnote{You may notice the @code{glibc-intermediate} label,
23094suggesting that it is not @emph{quite} final, but as a good
23095approximation, we will consider it final.}, depicted below.
23096
23097@image{images/bootstrap-packages,6in,,Dependency graph of the early packages}
23098
cf4a9129
LC
23099@c See <http://lists.gnu.org/archive/html/gnu-system-discuss/2012-10/msg00000.html>.
23100The first tool that gets built with the bootstrap binaries is
d33fa0c7
LC
23101GNU@tie{}Make---noted @code{make-boot0} above---which is a prerequisite
23102for all the following packages. From there Findutils and Diffutils get
23103built.
523e4896 23104
cf4a9129
LC
23105Then come the first-stage Binutils and GCC, built as pseudo cross
23106tools---i.e., with @code{--target} equal to @code{--host}. They are
23107used to build libc. Thanks to this cross-build trick, this libc is
23108guaranteed not to hold any reference to the initial tool chain.
4af2447e 23109
d33fa0c7
LC
23110From there the final Binutils and GCC (not shown above) are built.
23111GCC uses @code{ld}
cf4a9129
LC
23112from the final Binutils, and links programs against the just-built libc.
23113This tool chain is used to build the other packages used by Guix and by
23114the GNU Build System: Guile, Bash, Coreutils, etc.
4af2447e 23115
cf4a9129
LC
23116And voilà! At this point we have the complete set of build tools that
23117the GNU Build System expects. These are in the @code{%final-inputs}
dd164244
MW
23118variable of the @code{(gnu packages commencement)} module, and are
23119implicitly used by any package that uses @code{gnu-build-system}
1f6f57df 23120(@pxref{Build Systems, @code{gnu-build-system}}).
4af2447e 23121
4af2447e 23122
cf4a9129 23123@unnumberedsubsec Building the Bootstrap Binaries
4af2447e 23124
e32171ee 23125@cindex bootstrap binaries
cf4a9129
LC
23126Because the final tool chain does not depend on the bootstrap binaries,
23127those rarely need to be updated. Nevertheless, it is useful to have an
23128automated way to produce them, should an update occur, and this is what
23129the @code{(gnu packages make-bootstrap)} module provides.
4af2447e 23130
cf4a9129
LC
23131The following command builds the tarballs containing the bootstrap
23132binaries (Guile, Binutils, GCC, libc, and a tarball containing a mixture
23133of Coreutils and other basic command-line tools):
4b2615e1 23134
cf4a9129
LC
23135@example
23136guix build bootstrap-tarballs
23137@end example
23138
23139The generated tarballs are those that should be referred to in the
23140@code{(gnu packages bootstrap)} module mentioned at the beginning of
23141this section.
23142
23143Still here? Then perhaps by now you've started to wonder: when do we
23144reach a fixed point? That is an interesting question! The answer is
23145unknown, but if you would like to investigate further (and have
23146significant computational and storage resources to do so), then let us
23147know.
23148
350cb5ba
LC
23149@unnumberedsubsec Reducing the Set of Bootstrap Binaries
23150
23151Our bootstrap binaries currently include GCC, Guile, etc. That's a lot
23152of binary code! Why is that a problem? It's a problem because these
23153big chunks of binary code are practically non-auditable, which makes it
23154hard to establish what source code produced them. Every unauditable
23155binary also leaves us vulnerable to compiler backdoors as described by
23156Ken Thompson in the 1984 paper @emph{Reflections on Trusting Trust}.
23157
23158This is mitigated by the fact that our bootstrap binaries were generated
23159from an earlier Guix revision. Nevertheless it lacks the level of
23160transparency that we get in the rest of the package dependency graph,
23161where Guix always gives us a source-to-binary mapping. Thus, our goal
23162is to reduce the set of bootstrap binaries to the bare minimum.
23163
23164The @uref{http://bootstrappable.org, Bootstrappable.org web site} lists
23165on-going projects to do that. One of these is about replacing the
23166bootstrap GCC with a sequence of assemblers, interpreters, and compilers
23167of increasing complexity, which could be built from source starting from
23168a simple and auditable assembler. Your help is welcome!
23169
23170
cf4a9129
LC
23171@node Porting
23172@section Porting to a New Platform
23173
23174As discussed above, the GNU distribution is self-contained, and
23175self-containment is achieved by relying on pre-built ``bootstrap
23176binaries'' (@pxref{Bootstrapping}). These binaries are specific to an
23177operating system kernel, CPU architecture, and application binary
23178interface (ABI). Thus, to port the distribution to a platform that is
23179not yet supported, one must build those bootstrap binaries, and update
23180the @code{(gnu packages bootstrap)} module to use them on that platform.
23181
23182Fortunately, Guix can @emph{cross compile} those bootstrap binaries.
23183When everything goes well, and assuming the GNU tool chain supports the
23184target platform, this can be as simple as running a command like this
23185one:
23186
23187@example
23188guix build --target=armv5tel-linux-gnueabi bootstrap-tarballs
23189@end example
23190
1c0c417d
LC
23191For this to work, the @code{glibc-dynamic-linker} procedure in
23192@code{(gnu packages bootstrap)} must be augmented to return the right
23193file name for libc's dynamic linker on that platform; likewise,
23194@code{system->linux-architecture} in @code{(gnu packages linux)} must be
23195taught about the new platform.
23196
cf4a9129 23197Once these are built, the @code{(gnu packages bootstrap)} module needs
1c0c417d
LC
23198to be updated to refer to these binaries on the target platform. That
23199is, the hashes and URLs of the bootstrap tarballs for the new platform
23200must be added alongside those of the currently supported platforms. The
23201bootstrap Guile tarball is treated specially: it is expected to be
03d0e2d2 23202available locally, and @file{gnu/local.mk} has rules do download it for
1c0c417d
LC
23203the supported architectures; a rule for the new platform must be added
23204as well.
cf4a9129
LC
23205
23206In practice, there may be some complications. First, it may be that the
23207extended GNU triplet that specifies an ABI (like the @code{eabi} suffix
23208above) is not recognized by all the GNU tools. Typically, glibc
23209recognizes some of these, whereas GCC uses an extra @code{--with-abi}
23210configure flag (see @code{gcc.scm} for examples of how to handle this).
23211Second, some of the required packages could fail to build for that
23212platform. Lastly, the generated binaries could be broken for some
23213reason.
4af2447e 23214
9bf3c1a7 23215@c *********************************************************************
8c01b9d0 23216@include contributing.texi
c78bd12b 23217
568717fd
LC
23218@c *********************************************************************
23219@node Acknowledgments
23220@chapter Acknowledgments
23221
136787cb
LC
23222Guix is based on the @uref{http://nixos.org/nix/, Nix package manager},
23223which was designed and
4c7ac9aa
LC
23224implemented by Eelco Dolstra, with contributions from other people (see
23225the @file{nix/AUTHORS} file in Guix.) Nix pioneered functional package
568717fd
LC
23226management, and promoted unprecedented features, such as transactional
23227package upgrades and rollbacks, per-user profiles, and referentially
23228transparent build processes. Without this work, Guix would not exist.
23229
23230The Nix-based software distributions, Nixpkgs and NixOS, have also been
23231an inspiration for Guix.
23232
4c7ac9aa
LC
23233GNU@tie{}Guix itself is a collective work with contributions from a
23234number of people. See the @file{AUTHORS} file in Guix for more
23235information on these fine people. The @file{THANKS} file lists people
23236who have helped by reporting bugs, taking care of the infrastructure,
23237providing artwork and themes, making suggestions, and more---thank you!
23238
23239
568717fd
LC
23240@c *********************************************************************
23241@node GNU Free Documentation License
23242@appendix GNU Free Documentation License
e32171ee 23243@cindex license, GNU Free Documentation License
568717fd
LC
23244@include fdl-1.3.texi
23245
23246@c *********************************************************************
23247@node Concept Index
23248@unnumbered Concept Index
23249@printindex cp
23250
a85b83d2
LC
23251@node Programming Index
23252@unnumbered Programming Index
23253@syncodeindex tp fn
23254@syncodeindex vr fn
568717fd
LC
23255@printindex fn
23256
23257@bye
23258
23259@c Local Variables:
23260@c ispell-local-dictionary: "american";
23261@c End: