build: Require Guile >= 2.0.9.
[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.
cccbc639 13@set OPENPGP-SIGNING-KEY-ID BCA689B636553801C3C62150197A5888235FACAC
debc6360 14
7df7a74e 15@copying
8de938d5 16Copyright @copyright{} 2012, 2013, 2014, 2015, 2016, 2017 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@*
909147e4 24Copyright @copyright{} 2015, 2016 Ricardo Wurmus@*
4d343a14 25Copyright @copyright{} 2016 Ben Woodcroft@*
76192896 26Copyright @copyright{} 2016 Chris Marusich@*
6e42660b 27Copyright @copyright{} 2016 Efraim Flashner@*
d6a07ee6 28Copyright @copyright{} 2016 John Darrington@*
92c03a87 29Copyright @copyright{} 2016 ng0@*
8c00b838 30Copyright @copyright{} 2016 Jan Nieuwenhuizen@*
9747d189 31Copyright @copyright{} 2016 Julien Lepiller@*
78cef99b 32Copyright @copyright{} 2016 Alex ter Weele@*
11b7717d 33Copyright @copyright{} 2017 Clément Lassieur@*
bc5844d1 34Copyright @copyright{} 2017 Mathieu Othacehe@*
82ccc499
CZ
35Copyright @copyright{} 2017 Federico Beffa@*
36Copyright @copyright{} 2017 Carlo Zancanaro
7df7a74e
NK
37
38Permission is granted to copy, distribute and/or modify this document
39under the terms of the GNU Free Documentation License, Version 1.3 or
40any later version published by the Free Software Foundation; with no
41Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A
42copy of the license is included in the section entitled ``GNU Free
43Documentation License''.
44@end copying
568717fd 45
abd67856 46@dircategory System administration
568717fd 47@direntry
abd67856
LC
48* Guix: (guix). Manage installed software and system configuration.
49* guix package: (guix)Invoking guix package. Installing, removing, and upgrading packages.
abd67856
LC
50* guix gc: (guix)Invoking guix gc. Reclaiming unused disk space.
51* guix pull: (guix)Invoking guix pull. Update the list of available packages.
52* guix system: (guix)Invoking guix system. Manage the operating system configuration.
568717fd 53@end direntry
568717fd 54
372c4bbc
DT
55@dircategory Software development
56@direntry
abd67856 57* guix environment: (guix)Invoking guix environment. Building development environments with Guix.
ad172c4a
LC
58* guix build: (guix)Invoking guix build. Building packages.
59* guix pack: (guix)Invoking guix pack. Creating binary bundles.
372c4bbc
DT
60@end direntry
61
568717fd 62@titlepage
7730d112
LC
63@title GNU Guix Reference Manual
64@subtitle Using the GNU Guix Functional Package Manager
2cbed07e 65@author The GNU Guix Developers
568717fd
LC
66
67@page
68@vskip 0pt plus 1filll
69Edition @value{EDITION} @*
70@value{UPDATED} @*
71
7df7a74e 72@insertcopying
568717fd
LC
73@end titlepage
74
568717fd
LC
75@contents
76
77@c *********************************************************************
78@node Top
f8348b91 79@top GNU Guix
568717fd 80
f8348b91
LC
81This document describes GNU Guix version @value{VERSION}, a functional
82package management tool written for the GNU system.
568717fd
LC
83
84@menu
85* Introduction:: What is Guix about?
bd5e766b 86* Installation:: Installing Guix.
eeaf4427 87* Package Management:: Package installation, upgrade, etc.
568717fd
LC
88* Programming Interface:: Using Guix in Scheme.
89* Utilities:: Package management commands.
a1ba8475 90* GNU Distribution:: Software for your friendly GNU system.
9bf3c1a7 91* Contributing:: Your help needed!
568717fd
LC
92
93* Acknowledgments:: Thanks!
94* GNU Free Documentation License:: The license of this manual.
95* Concept Index:: Concepts.
a85b83d2 96* Programming Index:: Data types, functions, and variables.
aaa3eaa9
LC
97
98@detailmenu
99 --- The Detailed Node Listing ---
100
101Installation
102
1b2b8177 103* Binary Installation:: Getting Guix running in no time!
aaa3eaa9 104* Requirements:: Software needed to build and run Guix.
ec0339cd 105* Running the Test Suite:: Testing Guix.
aaa3eaa9
LC
106* Setting Up the Daemon:: Preparing the build daemon's environment.
107* Invoking guix-daemon:: Running the build daemon.
0e2d0213 108* Application Setup:: Application-specific setup.
aaa3eaa9
LC
109
110Setting Up the Daemon
111
112* Build Environment Setup:: Preparing the isolated build environment.
113* Daemon Offload Setup:: Offloading builds to remote machines.
114
115Package Management
116
117* Features:: How Guix will make your life brighter.
118* Invoking guix package:: Package installation, removal, etc.
aaa3eaa9
LC
119* Substitutes:: Downloading pre-built binaries.
120* Packages with Multiple Outputs:: Single source package, multiple outputs.
121* Invoking guix gc:: Running the garbage collector.
122* Invoking guix pull:: Fetching the latest Guix and distribution.
239c2266 123* Invoking guix pack:: Creating software bundles.
aaa3eaa9
LC
124* Invoking guix archive:: Exporting and importing store files.
125
126Programming Interface
127
128* Defining Packages:: Defining new packages.
129* Build Systems:: Specifying how packages are built.
130* The Store:: Manipulating the package store.
131* Derivations:: Low-level interface to package derivations.
132* The Store Monad:: Purely functional interface to the store.
133* G-Expressions:: Manipulating build expressions.
134
92492b23
LC
135Defining Packages
136
137* package Reference:: The package data type.
138* origin Reference:: The origin data type.
139
aaa3eaa9
LC
140Utilities
141
142* Invoking guix build:: Building packages from the command line.
fcc58db6 143* Invoking guix edit:: Editing package definitions.
aaa3eaa9
LC
144* Invoking guix download:: Downloading a file and printing its hash.
145* Invoking guix hash:: Computing the cryptographic hash of a file.
146* Invoking guix import:: Importing package definitions.
147* Invoking guix refresh:: Updating package definitions.
148* Invoking guix lint:: Finding errors in package definitions.
fcc58db6 149* Invoking guix size:: Profiling disk usage.
88856916 150* Invoking guix graph:: Visualizing the graph of packages.
aaa3eaa9 151* Invoking guix environment:: Setting up development environments.
aff8ce7c 152* Invoking guix publish:: Sharing substitutes.
d23c20f1 153* Invoking guix challenge:: Challenging substitute servers.
f11c444d 154* Invoking guix copy:: Copying to and from a remote store.
32efa254 155* Invoking guix container:: Process isolation.
aaa3eaa9 156
e3009f60
LC
157Invoking @command{guix build}
158
159* Common Build Options:: Build options for most commands.
f11c444d 160* Package Transformation Options:: Creating variants of packages.
e3009f60
LC
161* Additional Build Options:: Options specific to 'guix build'.
162
aaa3eaa9
LC
163GNU Distribution
164
165* System Installation:: Installing the whole operating system.
35ed9306 166* System Configuration:: Configuring the operating system.
aaa3eaa9
LC
167* Installing Debugging Files:: Feeding the debugger.
168* Security Updates:: Deploying security fixes quickly.
169* Package Modules:: Packages from the programmer's viewpoint.
170* Packaging Guidelines:: Growing the distribution.
171* Bootstrapping:: GNU/Linux built from scratch.
172* Porting:: Targeting another platform or kernel.
173
e3009f60
LC
174System Installation
175
176* Limitations:: What you can expect.
177* Hardware Considerations:: Supported hardware.
178* USB Stick Installation:: Preparing the installation medium.
179* Preparing for Installation:: Networking, partitioning, etc.
180* Proceeding with the Installation:: The real thing.
c8b54374 181* Installing GuixSD in a VM:: GuixSD playground.
e3009f60
LC
182* Building the Installation Image:: How this comes to be.
183
aaa3eaa9
LC
184System Configuration
185
186* Using the Configuration System:: Customizing your GNU system.
187* operating-system Reference:: Detail of operating-system declarations.
188* File Systems:: Configuring file system mounts.
189* Mapped Devices:: Block device extra processing.
190* User Accounts:: Specifying user accounts.
598e19dc 191* Locales:: Language and cultural convention settings.
aaa3eaa9
LC
192* Services:: Specifying system services.
193* Setuid Programs:: Programs running with root privileges.
1b2b8177 194* X.509 Certificates:: Authenticating HTTPS servers.
996ed739 195* Name Service Switch:: Configuring libc's name service switch.
aaa3eaa9
LC
196* Initial RAM Disk:: Linux-Libre bootstrapping.
197* GRUB Configuration:: Configuring the boot loader.
198* Invoking guix system:: Instantiating a system configuration.
97d76250 199* Running GuixSD in a VM:: How to run GuixSD in a virtual machine.
aaa3eaa9
LC
200* Defining Services:: Adding new service definitions.
201
202Services
203
204* Base Services:: Essential system services.
c311089b 205* Scheduled Job Execution:: The mcron service.
92c03a87 206* Log Rotation:: The rottlog service.
aaa3eaa9
LC
207* Networking Services:: Network setup, SSH daemon, etc.
208* X Window:: Graphical display.
f11c444d 209* Printing Services:: Local and remote printer support.
1b2b8177
LC
210* Desktop Services:: D-Bus and desktop services.
211* Database Services:: SQL databases.
d8c18af8 212* Mail Services:: IMAP, POP3, SMTP, and all that.
78cef99b 213* Messaging Services:: Messaging services.
859e367d 214* Kerberos Services:: Kerberos services.
cbd02397 215* Web Services:: Web servers.
2be1b471 216* VPN Services:: VPN daemons.
eb419bc9 217* Network File System:: NFS related services.
f11c444d 218* Continuous Integration:: The Cuirass service.
dbc6d370 219* Miscellaneous Services:: Other services.
aaa3eaa9 220
0adfe95a
LC
221Defining Services
222
223* Service Composition:: The model for composing services.
224* Service Types and Services:: Types and services.
225* Service Reference:: API reference.
dd17bc38 226* Shepherd Services:: A particular type of service.
0adfe95a 227
aaa3eaa9
LC
228Packaging Guidelines
229
ec0339cd
LC
230* Software Freedom:: What may go into the distribution.
231* Package Naming:: What's in a name?
232* Version Numbers:: When the name is not enough.
cbd02397 233* Synopses and Descriptions:: Helping users find the right package.
ec0339cd
LC
234* Python Modules:: Taming the snake.
235* Perl Modules:: Little pearls.
e1c963bf 236* Java Packages:: Coffee break.
ec0339cd 237* Fonts:: Fond of fonts.
aaa3eaa9 238
8c01b9d0
ML
239Contributing
240
241* Building from Git:: The latest and greatest.
242* Running Guix Before It Is Installed:: Hacker tricks.
243* The Perfect Setup:: The right tools.
244* Coding Style:: Hygiene of the contributor.
245* Submitting Patches:: Share your work.
246
247Coding Style
248
249* Programming Paradigm:: How to compose your elements.
250* Modules:: Where to store your code?
251* Data Types and Pattern Matching:: Implementing data structures.
252* Formatting Code:: Writing conventions.
253
aaa3eaa9 254@end detailmenu
568717fd
LC
255@end menu
256
257@c *********************************************************************
258@node Introduction
259@chapter Introduction
260
6f773606 261@cindex purpose
c80e7e55 262GNU Guix@footnote{``Guix'' is pronounced like ``geeks'', or ``ɡiːks''
6f773606
LC
263using the international phonetic alphabet (IPA).} is a package
264management tool for the GNU system. Guix makes it easy for unprivileged
265users to install, upgrade, or remove packages, to roll back to a
266previous package set, to build packages from source, and generally
267assists with the creation and maintenance of software environments.
268
269@cindex user interfaces
270Guix provides a command-line package management interface
271(@pxref{Invoking guix package}), a set of command-line utilities
deb6276d 272(@pxref{Utilities}), as well as Scheme programming interfaces
6f773606
LC
273(@pxref{Programming Interface}).
274@cindex build daemon
275Its @dfn{build daemon} is responsible for building packages on behalf of
276users (@pxref{Setting Up the Daemon}) and for downloading pre-built
277binaries from authorized sources (@pxref{Substitutes}).
278
279@cindex extensibility of the distribution
e32171ee 280@cindex customization, of packages
6f773606
LC
281Guix includes package definitions for many GNU and non-GNU packages, all
282of which @uref{https://www.gnu.org/philosophy/free-sw.html, respect the
283user's computing freedom}. It is @emph{extensible}: users can write
284their own package definitions (@pxref{Defining Packages}) and make them
285available as independent package modules (@pxref{Package Modules}). It
286is also @emph{customizable}: users can @emph{derive} specialized package
287definitions from existing ones, including from the command line
288(@pxref{Package Transformation Options}).
289
290@cindex Guix System Distribution
291@cindex GuixSD
292You can install GNU@tie{}Guix on top of an existing GNU/Linux system
293where it complements the available tools without interference
294(@pxref{Installation}), or you can use it as part of the standalone
295@dfn{Guix System Distribution} or GuixSD (@pxref{GNU Distribution}).
296With GNU@tie{}GuixSD, you @emph{declare} all aspects of the operating
297system configuration and Guix takes care of instantiating the
298configuration in a transactional, reproducible, and stateless fashion
299(@pxref{System Configuration}).
568717fd
LC
300
301@cindex functional package management
6f773606 302Under the hood, Guix implements the @dfn{functional package management}
136787cb
LC
303discipline pioneered by Nix (@pxref{Acknowledgments}).
304In Guix, the package build and installation process is seen
6f773606 305as a @emph{function}, in the mathematical sense. That function takes inputs,
4bfc4ea3
NK
306such as build scripts, a compiler, and libraries, and
307returns an installed package. As a pure function, its result depends
568717fd
LC
308solely on its inputs---for instance, it cannot refer to software or
309scripts that were not explicitly passed as inputs. A build function
4bfc4ea3 310always produces the same result when passed a given set of inputs. It
f97c9175 311cannot alter the environment of the running system in
568717fd
LC
312any way; for instance, it cannot create, modify, or delete files outside
313of its build and installation directories. This is achieved by running
e900c503 314build processes in isolated environments (or @dfn{containers}), where only their
4bfc4ea3 315explicit inputs are visible.
568717fd 316
e531ac2a 317@cindex store
568717fd 318The result of package build functions is @dfn{cached} in the file
e531ac2a 319system, in a special directory called @dfn{the store} (@pxref{The
f97c9175 320Store}). Each package is installed in a directory of its own in the
834129e0 321store---by default under @file{/gnu/store}. The directory name contains
568717fd
LC
322a hash of all the inputs used to build that package; thus, changing an
323input yields a different directory name.
324
f97c9175
AE
325This approach is the foundation for the salient features of Guix: support
326for transactional package upgrade and rollback, per-user installation, and
eeaf4427 327garbage collection of packages (@pxref{Features}).
568717fd 328
a1ba8475 329
bd5e766b
LC
330@c *********************************************************************
331@node Installation
332@chapter Installation
333
e32171ee 334@cindex installing Guix
48febeb8
LC
335GNU Guix is available for download from its website at
336@url{http://www.gnu.org/software/guix/}. This section describes the
337software requirements of Guix, as well as how to install it and get
338ready to use it.
bd5e766b 339
5af6de3e
LC
340Note that this section is concerned with the installation of the package
341manager, which can be done on top of a running GNU/Linux system. If,
342instead, you want to install the complete GNU operating system,
6621cdb6 343@pxref{System Installation}.
5af6de3e 344
d23ef788
LC
345@cindex foreign distro
346When installed on a running GNU/Linux system---thereafter called a
347@dfn{foreign distro}---GNU@tie{}Guix complements the available tools
348without interference. Its data lives exclusively in two directories,
349usually @file{/gnu/store} and @file{/var/guix}; other files on your
350system, such as @file{/etc}, are left untouched.
351
7fcf2a0b
LC
352Once installed, Guix can be updated by running @command{guix pull}
353(@pxref{Invoking guix pull}).
354
bd5e766b 355@menu
09722b11 356* Binary Installation:: Getting Guix running in no time!
bd5e766b 357* Requirements:: Software needed to build and run Guix.
ec0339cd 358* Running the Test Suite:: Testing Guix.
bd5e766b
LC
359* Setting Up the Daemon:: Preparing the build daemon's environment.
360* Invoking guix-daemon:: Running the build daemon.
0e2d0213 361* Application Setup:: Application-specific setup.
bd5e766b
LC
362@end menu
363
09722b11
LC
364@node Binary Installation
365@section Binary Installation
366
e32171ee 367@cindex installing Guix from binaries
09722b11
LC
368This section describes how to install Guix on an arbitrary system from a
369self-contained tarball providing binaries for Guix and for all its
370dependencies. This is often quicker than installing from source, which
371is described in the next sections. The only requirement is to have
372GNU@tie{}tar and Xz.
373
374Installing goes along these lines:
375
376@enumerate
377@item
e32171ee 378@cindex downloading Guix binary
09722b11 379Download the binary tarball from
daa8922a
LC
380@indicateurl{ftp://alpha.gnu.org/gnu/guix/guix-binary-@value{VERSION}.@var{system}.tar.xz},
381where @var{system} is @code{x86_64-linux} for an @code{x86_64} machine
382already running the kernel Linux, and so on.
383
debc6360 384@c The following is somewhat duplicated in ``System Installation''.
daa8922a
LC
385Make sure to download the associated @file{.sig} file and to verify the
386authenticity of the tarball against it, along these lines:
387
388@example
389$ wget ftp://alpha.gnu.org/gnu/guix/guix-binary-@value{VERSION}.@var{system}.tar.xz.sig
390$ gpg --verify guix-binary-@value{VERSION}.@var{system}.tar.xz.sig
391@end example
392
f97c9175 393If that command fails because you do not have the required public key,
daa8922a
LC
394then run this command to import it:
395
396@example
debc6360 397$ gpg --keyserver pgp.mit.edu --recv-keys @value{OPENPGP-SIGNING-KEY-ID}
daa8922a
LC
398@end example
399
400@noindent
401and rerun the @code{gpg --verify} command.
debc6360 402@c end authentication part
09722b11
LC
403
404@item
405As @code{root}, run:
406
407@example
5dc42964 408# cd /tmp
254b1c2e
LC
409# tar --warning=no-timestamp -xf \
410 guix-binary-@value{VERSION}.@var{system}.tar.xz
5dc42964 411# mv var/guix /var/ && mv gnu /
09722b11
LC
412@end example
413
7acd3439
LC
414This creates @file{/gnu/store} (@pxref{The Store}) and @file{/var/guix}.
415The latter contains a ready-to-use profile for @code{root} (see next
416step.)
09722b11 417
5dc3ce5f
LC
418Do @emph{not} unpack the tarball on a working Guix system since that
419would overwrite its own essential files.
420
254b1c2e 421The @code{--warning=no-timestamp} option makes sure GNU@tie{}tar does
e9ba6357
LC
422not emit warnings about ``implausibly old time stamps'' (such
423warnings were triggered by GNU@tie{}tar 1.26 and older; recent
424versions are fine.)
425They stem from the fact that all the
254b1c2e
LC
426files in the archive have their modification time set to zero (which
427means January 1st, 1970.) This is done on purpose to make sure the
428archive content is independent of its creation time, thus making it
429reproducible.
430
7acd3439
LC
431@item
432Make @code{root}'s profile available under @file{~/.guix-profile}:
433
434@example
435# ln -sf /var/guix/profiles/per-user/root/guix-profile \
436 ~root/.guix-profile
437@end example
438
43c33047
LC
439@item
440Create the group and user accounts for build users as explained below
441(@pxref{Build Environment Setup}).
442
09722b11 443@item
bf98aea9 444Run the daemon, and set it to automatically start on boot.
c8e26887 445
bf98aea9
LC
446If your host distro uses the systemd init system, this can be achieved
447with these commands:
c8e26887 448
b812da70
LF
449@c Versions of systemd that supported symlinked service files are not
450@c yet widely deployed, so we should suggest that users copy the service
451@c files into place.
452@c
453@c See this thread for more information:
454@c http://lists.gnu.org/archive/html/guix-devel/2017-01/msg01199.html
455
c8e26887 456@example
b812da70 457# cp ~root/.guix-profile/lib/systemd/system/guix-daemon.service \
c8e26887
GC
458 /etc/systemd/system/
459# systemctl start guix-daemon && systemctl enable guix-daemon
460@end example
461
462If your host distro uses the Upstart init system:
09722b11
LC
463
464@example
4a780bdf 465# initctl reload-configuration
b812da70 466# cp ~root/.guix-profile/lib/upstart/system/guix-daemon.conf /etc/init/
bf98aea9 467# start guix-daemon
09722b11
LC
468@end example
469
c8e26887
GC
470Otherwise, you can still start the daemon manually with:
471
472@example
473# ~root/.guix-profile/bin/guix-daemon --build-users-group=guixbuild
474@end example
d2825c96 475
09722b11
LC
476@item
477Make the @command{guix} command available to other users on the machine,
478for instance with:
479
480@example
481# mkdir -p /usr/local/bin
482# cd /usr/local/bin
d72d05f9 483# ln -s /var/guix/profiles/per-user/root/guix-profile/bin/guix
09722b11 484@end example
39f8ed14 485
aca738f3
LC
486It is also a good idea to make the Info version of this manual available
487there:
488
489@example
490# mkdir -p /usr/local/share/info
491# cd /usr/local/share/info
492# for i in /var/guix/profiles/per-user/root/guix-profile/share/info/* ;
493 do ln -s $i ; done
494@end example
495
496That way, assuming @file{/usr/local/share/info} is in the search path,
497running @command{info guix} will open this manual (@pxref{Other Info
498Directories,,, texinfo, GNU Texinfo}, for more details on changing the
499Info search path.)
500
39f8ed14 501@item
e32171ee 502@cindex substitutes, authorization thereof
df061d07
LC
503To use substitutes from @code{hydra.gnu.org} or one of its mirrors
504(@pxref{Substitutes}), authorize them:
39f8ed14
LC
505
506@example
7acd3439 507# guix archive --authorize < ~root/.guix-profile/share/guix/hydra.gnu.org.pub
39f8ed14 508@end example
09722b11
LC
509@end enumerate
510
bf98aea9 511This completes root-level install of Guix. Each user will need to
7414de0a 512perform additional steps to make their Guix environment ready for use,
c8e26887 513@pxref{Application Setup}.
09722b11 514
c8e26887
GC
515You can confirm that Guix is working by installing a sample package into
516the root profile:
09722b11
LC
517
518@example
c8e26887 519# guix package -i hello
09722b11
LC
520@end example
521
c8e26887
GC
522The @code{guix} package must remain available in @code{root}'s profile,
523or it would become subject to garbage collection---in which case you
524would find yourself badly handicapped by the lack of the @command{guix}
bf98aea9
LC
525command. In other words, do not remove @code{guix} by running
526@code{guix package -r guix}.
527
528The binary installation tarball can be (re)produced and verified simply
529by running the following command in the Guix source tree:
530
531@example
532make guix-binary.@var{system}.tar.xz
533@end example
c8e26887 534
239c2266
LC
535@noindent
536... which, in turn, runs:
537
538@example
6b63c43e 539guix pack -s @var{system} --localstatedir guix
239c2266
LC
540@end example
541
542@xref{Invoking guix pack}, for more info on this handy tool.
09722b11 543
bd5e766b
LC
544@node Requirements
545@section Requirements
546
09722b11
LC
547This section lists requirements when building Guix from source. The
548build procedure for Guix is the same as for other GNU software, and is
549not covered here. Please see the files @file{README} and @file{INSTALL}
550in the Guix source tree for additional details.
551
bd5e766b
LC
552GNU Guix depends on the following packages:
553
554@itemize
36626c55 555@item @url{http://gnu.org/software/guile/, GNU Guile}, version 2.0.9 or
608e42e7 556later, including 2.2.x;
288dca55 557@item @url{http://gnupg.org/, GNU libgcrypt};
1dbe3a8d
LC
558@item
559@uref{http://gnutls.org/, GnuTLS}, specifically its Guile bindings
560(@pxref{Guile Preparations, how to install the GnuTLS bindings for
561Guile,, gnutls-guile, GnuTLS-Guile});
f0b98b84 562@item @url{http://www.gnu.org/software/make/, GNU Make}.
8a96bd4b
ID
563@end itemize
564
565The following dependencies are optional:
566
567@itemize
288dca55 568@item
8a96bd4b 569Installing
288dca55 570@url{http://savannah.nongnu.org/projects/guile-json/, Guile-JSON} will
2f7d2d91
LC
571allow you to use the @command{guix import pypi} command (@pxref{Invoking
572guix import}). It is of
288dca55 573interest primarily for developers and not for casual users.
4591c02e 574
21531add
LC
575@item
576@c Note: We need at least 0.10.2 for 'channel-send-eof'.
f11c444d
LC
577Support for build offloading (@pxref{Daemon Offload Setup}) and
578@command{guix copy} (@pxref{Invoking guix copy}) depends on
21531add
LC
579@uref{https://github.com/artyom-poptsov/guile-ssh, Guile-SSH},
580version 0.10.2 or later.
581
4591c02e
LC
582@item
583When @url{http://zlib.net, zlib} is available, @command{guix publish}
584can compress build byproducts (@pxref{Invoking guix publish}).
bd5e766b
LC
585@end itemize
586
587Unless @code{--disable-daemon} was passed to @command{configure}, the
588following packages are also needed:
589
590@itemize
368d08f7
LC
591@item @url{http://sqlite.org, SQLite 3};
592@item @url{http://www.bzip.org, libbz2};
593@item @url{http://gcc.gnu.org, GCC's g++}, with support for the
594C++11 standard.
bd5e766b
LC
595@end itemize
596
e32171ee 597@cindex state directory
ef5f5c86
LC
598When configuring Guix on a system that already has a Guix installation,
599be sure to specify the same state directory as the existing installation
600using the @code{--localstatedir} option of the @command{configure}
601script (@pxref{Directory Variables, @code{localstatedir},, standards,
602GNU Coding Standards}). The @command{configure} script protects against
603unintended misconfiguration of @var{localstatedir} so you do not
604inadvertently corrupt your store (@pxref{The Store}).
605
e32171ee 606@cindex Nix, compatibility
4bfc4ea3
NK
607When a working installation of @url{http://nixos.org/nix/, the Nix package
608manager} is available, you
bd5e766b 609can instead configure Guix with @code{--disable-daemon}. In that case,
4bfc4ea3 610Nix replaces the three dependencies above.
bd5e766b 611
b22a12fd
LC
612Guix is compatible with Nix, so it is possible to share the same store
613between both. To do so, you must pass @command{configure} not only the
614same @code{--with-store-dir} value, but also the same
4bfc4ea3
NK
615@code{--localstatedir} value. The latter is essential because it
616specifies where the database that stores metadata about the store is
834129e0 617located, among other things. The default values for Nix are
b22a12fd 618@code{--with-store-dir=/nix/store} and @code{--localstatedir=/nix/var}.
4bfc4ea3
NK
619Note that @code{--disable-daemon} is not required if
620your goal is to share the store with Nix.
b22a12fd 621
ec0339cd
LC
622@node Running the Test Suite
623@section Running the Test Suite
624
e32171ee 625@cindex test suite
ec0339cd
LC
626After a successful @command{configure} and @code{make} run, it is a good
627idea to run the test suite. It can help catch issues with the setup or
628environment, or bugs in Guix itself---and really, reporting test
629failures is a good way to help improve the software. To run the test
630suite, type:
631
632@example
633make check
634@end example
635
636Test cases can run in parallel: you can use the @code{-j} option of
637GNU@tie{}make to speed things up. The first run may take a few minutes
638on a recent machine; subsequent runs will be faster because the store
639that is created for test purposes will already have various things in
640cache.
641
a887fd8d
LC
642It is also possible to run a subset of the tests by defining the
643@code{TESTS} makefile variable as in this example:
644
645@example
646make check TESTS="tests/store.scm tests/cpio.scm"
647@end example
648
a9edb211
ML
649By default, tests results are displayed at a file level. In order to
650see the details of every individual test cases, it is possible to define
651the @code{SCM_LOG_DRIVER_FLAGS} makefile variable as in this example:
652
653@example
654make check TESTS="tests/base64.scm" SCM_LOG_DRIVER_FLAGS="--brief=no"
655@end example
656
ec0339cd 657Upon failure, please email @email{bug-guix@@gnu.org} and attach the
a9edb211
ML
658@file{test-suite.log} file. Please specify the Guix version being used
659as well as version numbers of the dependencies (@pxref{Requirements}) in
660your message.
ec0339cd 661
0a2f2848
LC
662Guix also comes with a whole-system test suite that tests complete
663GuixSD operating system instances. It can only run on systems where
664Guix is already installed, using:
665
666@example
667make check-system
668@end example
669
670@noindent
671or, again, by defining @code{TESTS} to select a subset of tests to run:
672
673@example
674make check-system TESTS="basic mcron"
675@end example
676
677These system tests are defined in the @code{(gnu tests @dots{})}
678modules. They work by running the operating systems under test with
679lightweight instrumentation in a virtual machine (VM). They can be
680computationally intensive or rather cheap, depending on whether
681substitutes are available for their dependencies (@pxref{Substitutes}).
682Some of them require a lot of storage space to hold VM images.
683
684Again in case of test failures, please send @email{bug-guix@@gnu.org}
685all the details.
686
bd5e766b
LC
687@node Setting Up the Daemon
688@section Setting Up the Daemon
689
690@cindex daemon
691Operations such as building a package or running the garbage collector
49e6291a 692are all performed by a specialized process, the @dfn{build daemon}, on
bd5e766b
LC
693behalf of clients. Only the daemon may access the store and its
694associated database. Thus, any operation that manipulates the store
695goes through the daemon. For instance, command-line tools such as
e49951eb 696@command{guix package} and @command{guix build} communicate with the
bd5e766b
LC
697daemon (@i{via} remote procedure calls) to instruct it what to do.
698
49e6291a 699The following sections explain how to prepare the build daemon's
f97c9175 700environment. See also @ref{Substitutes}, for information on how to allow
225dafde 701the daemon to download pre-built binaries.
49e6291a
LC
702
703@menu
704* Build Environment Setup:: Preparing the isolated build environment.
705* Daemon Offload Setup:: Offloading builds to remote machines.
706@end menu
707
708@node Build Environment Setup
709@subsection Build Environment Setup
710
e32171ee 711@cindex build environment
bd5e766b
LC
712In a standard multi-user setup, Guix and its daemon---the
713@command{guix-daemon} program---are installed by the system
834129e0 714administrator; @file{/gnu/store} is owned by @code{root} and
bd5e766b
LC
715@command{guix-daemon} runs as @code{root}. Unprivileged users may use
716Guix tools to build packages or otherwise access the store, and the
717daemon will do it on their behalf, ensuring that the store is kept in a
718consistent state, and allowing built packages to be shared among users.
719
720@cindex build users
721When @command{guix-daemon} runs as @code{root}, you may not want package
722build processes themselves to run as @code{root} too, for obvious
723security reasons. To avoid that, a special pool of @dfn{build users}
724should be created for use by build processes started by the daemon.
725These build users need not have a shell and a home directory: they will
726just be used when the daemon drops @code{root} privileges in build
727processes. Having several such users allows the daemon to launch
728distinct build processes under separate UIDs, which guarantees that they
729do not interfere with each other---an essential feature since builds are
730regarded as pure functions (@pxref{Introduction}).
731
732On a GNU/Linux system, a build user pool may be created like this (using
733Bash syntax and the @code{shadow} commands):
734
091196b3
LC
735@c See http://lists.gnu.org/archive/html/bug-guix/2013-01/msg00239.html
736@c for why `-G' is needed.
bd5e766b 737@example
cfc149dc
LC
738# groupadd --system guixbuild
739# for i in `seq -w 1 10`;
bd5e766b 740 do
cfc149dc
LC
741 useradd -g guixbuild -G guixbuild \
742 -d /var/empty -s `which nologin` \
743 -c "Guix build user $i" --system \
744 guixbuilder$i;
bd5e766b
LC
745 done
746@end example
747
748@noindent
54eb03ab
LC
749The number of build users determines how many build jobs may run in
750parallel, as specified by the @option{--max-jobs} option
eca69fc0
LC
751(@pxref{Invoking guix-daemon, @option{--max-jobs}}). To use
752@command{guix system vm} and related commands, you may need to add the
753build users to the @code{kvm} group so they can access @file{/dev/kvm},
754using @code{-G guixbuild,kvm} instead of @code{-G guixbuild}
755(@pxref{Invoking guix system}).
756
757The @code{guix-daemon} program may then be run as @code{root} with the
d2825c96
LC
758following command@footnote{If your machine uses the systemd init system,
759dropping the @file{@var{prefix}/lib/systemd/system/guix-daemon.service}
760file in @file{/etc/systemd/system} will ensure that
ad227484
MDRS
761@command{guix-daemon} is automatically started. Similarly, if your
762machine uses the Upstart init system, drop the
763@file{@var{prefix}/lib/upstart/system/guix-daemon.conf}
764file in @file{/etc/init}.}:
bd5e766b
LC
765
766@example
cfc149dc 767# guix-daemon --build-users-group=guixbuild
bd5e766b
LC
768@end example
769
e900c503 770@cindex chroot
b095792f
LC
771@noindent
772This way, the daemon starts build processes in a chroot, under one of
cfc149dc 773the @code{guixbuilder} users. On GNU/Linux, by default, the chroot
6dc99317
LC
774environment contains nothing but:
775
776@c Keep this list in sync with libstore/build.cc! -----------------------
777@itemize
778@item
4743a4da
LC
779a minimal @code{/dev} directory, created mostly independently from the
780host @code{/dev}@footnote{``Mostly'', because while the set of files
781that appear in the chroot's @code{/dev} is fixed, most of these files
782can only be created if the host has them.};
783
784@item
f97c9175 785the @code{/proc} directory; it only shows the processes of the container
4743a4da 786since a separate PID name space is used;
6dc99317
LC
787
788@item
789@file{/etc/passwd} with an entry for the current user and an entry for
790user @file{nobody};
791
792@item
793@file{/etc/group} with an entry for the user's group;
794
795@item
796@file{/etc/hosts} with an entry that maps @code{localhost} to
797@code{127.0.0.1};
798
799@item
800a writable @file{/tmp} directory.
801@end itemize
b095792f 802
cb960102
ED
803You can influence the directory where the daemon stores build trees
804@i{via} the @code{TMPDIR} environment variable. However, the build tree
f97c9175 805within the chroot is always called @file{/tmp/guix-build-@var{name}.drv-0},
cb960102
ED
806where @var{name} is the derivation name---e.g., @code{coreutils-8.24}.
807This way, the value of @code{TMPDIR} does not leak inside build
808environments, which avoids discrepancies in cases where build processes
809capture the name of their build tree.
810
e0c941fe
LC
811@vindex http_proxy
812The daemon also honors the @code{http_proxy} environment variable for
813HTTP downloads it performs, be it for fixed-output derivations
814(@pxref{Derivations}) or for substitutes (@pxref{Substitutes}).
815
1e2644bb
LC
816If you are installing Guix as an unprivileged user, it is still possible
817to run @command{guix-daemon} provided you pass @code{--disable-chroot}.
818However, build processes will not be isolated from one another, and not
819from the rest of the system. Thus, build processes may interfere with
820each other, and may access programs, libraries, and other files
821available on the system---making it much harder to view them as
822@emph{pure} functions.
bd5e766b 823
49e6291a
LC
824
825@node Daemon Offload Setup
826@subsection Using the Offload Facility
827
828@cindex offloading
4ec2e92d 829@cindex build hook
21531add
LC
830When desired, the build daemon can @dfn{offload} derivation builds to
831other machines running Guix, using the @code{offload} @dfn{build
832hook}@footnote{This feature is available only when
833@uref{https://github.com/artyom-poptsov/guile-ssh, Guile-SSH} is
834present.}. When that
49e6291a 835feature is enabled, a list of user-specified build machines is read from
f97c9175 836@file{/etc/guix/machines.scm}; every time a build is requested, for
49e6291a 837instance via @code{guix build}, the daemon attempts to offload it to one
f97c9175 838of the machines that satisfy the constraints of the derivation, in
49e6291a
LC
839particular its system type---e.g., @file{x86_64-linux}. Missing
840prerequisites for the build are copied over SSH to the target machine,
841which then proceeds with the build; upon success the output(s) of the
842build are copied back to the initial machine.
843
4ec2e92d 844The @file{/etc/guix/machines.scm} file typically looks like this:
49e6291a
LC
845
846@example
847(list (build-machine
848 (name "eightysix.example.org")
849 (system "x86_64-linux")
21531add 850 (host-key "ssh-ed25519 AAAAC3Nza@dots{}")
49e6291a 851 (user "bob")
21531add 852 (speed 2.)) ;incredibly fast!
49e6291a
LC
853
854 (build-machine
855 (name "meeps.example.org")
856 (system "mips64el-linux")
21531add 857 (host-key "ssh-rsa AAAAB3Nza@dots{}")
49e6291a
LC
858 (user "alice")
859 (private-key
860 (string-append (getenv "HOME")
21531add 861 "/.ssh/identity-for-guix"))))
49e6291a
LC
862@end example
863
864@noindent
865In the example above we specify a list of two build machines, one for
866the @code{x86_64} architecture and one for the @code{mips64el}
4ec2e92d
LC
867architecture.
868
869In fact, this file is---not surprisingly!---a Scheme file that is
870evaluated when the @code{offload} hook is started. Its return value
871must be a list of @code{build-machine} objects. While this example
872shows a fixed list of build machines, one could imagine, say, using
873DNS-SD to return a list of potential build machines discovered in the
874local network (@pxref{Introduction, Guile-Avahi,, guile-avahi, Using
c678a4ee
LC
875Avahi in Guile Scheme Programs}). The @code{build-machine} data type is
876detailed below.
4ec2e92d 877
c678a4ee 878@deftp {Data Type} build-machine
f97c9175
AE
879This data type represents build machines to which the daemon may offload
880builds. The important fields are:
49e6291a
LC
881
882@table @code
883
884@item name
f97c9175 885The host name of the remote machine.
49e6291a
LC
886
887@item system
f97c9175 888The system type of the remote machine---e.g., @code{"x86_64-linux"}.
49e6291a
LC
889
890@item user
891The user account to use when connecting to the remote machine over SSH.
892Note that the SSH key pair must @emph{not} be passphrase-protected, to
893allow non-interactive logins.
894
21531add
LC
895@item host-key
896This must be the machine's SSH @dfn{public host key} in OpenSSH format.
897This is used to authenticate the machine when we connect to it. It is a
898long string that looks like this:
899
900@example
901ssh-ed25519 AAAAC3NzaC@dots{}mde+UhL hint@@example.org
902@end example
903
904If the machine is running the OpenSSH daemon, @command{sshd}, the host
905key can be found in a file such as
906@file{/etc/ssh/ssh_host_ed25519_key.pub}.
907
908If the machine is running the SSH daemon of GNU@tie{}lsh,
909@command{lshd}, the host key is in @file{/etc/lsh/host-key.pub} or a
910similar file. It can be converted to the OpenSSH format using
911@command{lsh-export-key} (@pxref{Converting keys,,, lsh, LSH Manual}):
912
913@example
914$ lsh-export-key --openssh < /etc/lsh/host-key.pub
915ssh-rsa AAAAB3NzaC1yc2EAAAAEOp8FoQAAAQEAs1eB46LV@dots{}
916@end example
917
49e6291a
LC
918@end table
919
4ec2e92d 920A number of optional fields may be specified:
49e6291a 921
21531add 922@table @asis
49e6291a 923
21531add
LC
924@item @code{port} (default: @code{22})
925Port number of SSH server on the machine.
cecd72d5 926
21531add
LC
927@item @code{private-key} (default: @file{~/.ssh/id_rsa})
928The SSH private key file to use when connecting to the machine, in
929OpenSSH format.
49e6291a 930
1d48cf94
LC
931@item @code{compression} (default: @code{"zlib@@openssh.com,zlib"})
932@itemx @code{compression-level} (default: @code{3})
933The SSH-level compression methods and compression level requested.
934
935Note that offloading relies on SSH compression to reduce bandwidth usage
936when transferring files to and from build machines.
937
cf283dd9
LC
938@item @code{daemon-socket} (default: @code{"/var/guix/daemon-socket/socket"})
939File name of the Unix-domain socket @command{guix-daemon} is listening
940to on that machine.
c4fdfd6f 941
21531add
LC
942@item @code{parallel-builds} (default: @code{1})
943The number of builds that may run in parallel on the machine.
49e6291a 944
21531add 945@item @code{speed} (default: @code{1.0})
49e6291a
LC
946A ``relative speed factor''. The offload scheduler will tend to prefer
947machines with a higher speed factor.
948
21531add 949@item @code{features} (default: @code{'()})
49e6291a
LC
950A list of strings denoting specific features supported by the machine.
951An example is @code{"kvm"} for machines that have the KVM Linux modules
952and corresponding hardware support. Derivations can request features by
953name, and they will be scheduled on matching build machines.
954
955@end table
c678a4ee 956@end deftp
49e6291a 957
aebaee95
LC
958The @code{guile} command must be in the search path on the build
959machines. In addition, the Guix modules must be in
c4fdfd6f
LC
960@code{$GUILE_LOAD_PATH} on the build machine---you can check whether
961this is the case by running:
962
963@example
21531add 964ssh build-machine guile -c "'(use-modules (guix config))'"
c4fdfd6f 965@end example
49e6291a 966
f97c9175 967There is one last thing to do once @file{machines.scm} is in place. As
49e6291a 968explained above, when offloading, files are transferred back and forth
c4fdfd6f
LC
969between the machine stores. For this to work, you first need to
970generate a key pair on each machine to allow the daemon to export signed
971archives of files from the store (@pxref{Invoking guix archive}):
49e6291a
LC
972
973@example
974# guix archive --generate-key
975@end example
976
977@noindent
c4fdfd6f
LC
978Each build machine must authorize the key of the master machine so that
979it accepts store items it receives from the master:
980
981@example
982# guix archive --authorize < master-public-key.txt
983@end example
984
985@noindent
986Likewise, the master machine must authorize the key of each build machine.
987
988All the fuss with keys is here to express pairwise mutual trust
989relations between the master and the build machines. Concretely, when
990the master receives files from a build machine (and @i{vice versa}), its
991build daemon can make sure they are genuine, have not been tampered
992with, and that they are signed by an authorized key.
49e6291a 993
aebaee95
LC
994@cindex offload test
995To test whether your setup is operational, run this command on the
996master node:
997
998@example
999# guix offload test
1000@end example
1001
1002This will attempt to connect to each of the build machines specified in
1003@file{/etc/guix/machines.scm}, make sure Guile and the Guix modules are
1004available on each machine, attempt to export to the machine and import
1005from it, and report any error in the process.
1006
1007If you want to test a different machine file, just specify it on the
1008command line:
1009
1010@example
1011# guix offload test machines-qualif.scm
1012@end example
1013
27991c97
LC
1014Last, you can test the subset of the machines whose name matches a
1015regular expression like this:
1016
1017@example
1018# guix offload test machines.scm '\.gnu\.org$'
1019@end example
49e6291a 1020
bd5e766b
LC
1021@node Invoking guix-daemon
1022@section Invoking @command{guix-daemon}
1023
1024The @command{guix-daemon} program implements all the functionality to
1025access the store. This includes launching build processes, running the
1026garbage collector, querying the availability of a build result, etc. It
1027is normally run as @code{root} like this:
1028
1029@example
cfc149dc 1030# guix-daemon --build-users-group=guixbuild
bd5e766b
LC
1031@end example
1032
1033@noindent
081145cf 1034For details on how to set it up, @pxref{Setting Up the Daemon}.
bd5e766b 1035
e900c503
LC
1036@cindex chroot
1037@cindex container, build environment
1038@cindex build environment
1039@cindex reproducible builds
bd5e766b
LC
1040By default, @command{guix-daemon} launches build processes under
1041different UIDs, taken from the build group specified with
1042@code{--build-users-group}. In addition, each build process is run in a
1043chroot environment that only contains the subset of the store that the
1044build process depends on, as specified by its derivation
1045(@pxref{Programming Interface, derivation}), plus a set of specific
1046system directories. By default, the latter contains @file{/dev} and
e900c503
LC
1047@file{/dev/pts}. Furthermore, on GNU/Linux, the build environment is a
1048@dfn{container}: in addition to having its own file system tree, it has
1049a separate mount name space, its own PID name space, network name space,
1050etc. This helps achieve reproducible builds (@pxref{Features}).
bd5e766b 1051
cbc538fe
LC
1052When the daemon performs a build on behalf of the user, it creates a
1053build directory under @file{/tmp} or under the directory specified by
1054its @code{TMPDIR} environment variable; this directory is shared with
1055the container for the duration of the build. Be aware that using a
1056directory other than @file{/tmp} can affect build results---for example,
1057with a longer directory name, a build process that uses Unix-domain
1058sockets might hit the name length limitation for @code{sun_path}, which
1059it would otherwise not hit.
1060
1061The build directory is automatically deleted upon completion, unless the
1062build failed and the client specified @option{--keep-failed}
1063(@pxref{Invoking guix build, @option{--keep-failed}}).
1064
bd5e766b
LC
1065The following command-line options are supported:
1066
1067@table @code
1068@item --build-users-group=@var{group}
1069Take users from @var{group} to run build processes (@pxref{Setting Up
1070the Daemon, build users}).
1071
6858f9d1 1072@item --no-substitutes
b5385b52 1073@cindex substitutes
6858f9d1 1074Do not use substitutes for build products. That is, always build things
c4202d60
LC
1075locally instead of allowing downloads of pre-built binaries
1076(@pxref{Substitutes}).
6858f9d1 1077
b5385b52
LC
1078By default substitutes are used, unless the client---such as the
1079@command{guix package} command---is explicitly invoked with
1080@code{--no-substitutes}.
1081
1082When the daemon runs with @code{--no-substitutes}, clients can still
1083explicitly enable substitution @i{via} the @code{set-build-options}
1084remote procedure call (@pxref{The Store}).
1085
9176607e 1086@item --substitute-urls=@var{urls}
f8a8e0fe 1087@anchor{daemon-substitute-urls}
9176607e 1088Consider @var{urls} the default whitespace-separated list of substitute
df061d07
LC
1089source URLs. When this option is omitted,
1090@indicateurl{https://mirror.hydra.gnu.org https://hydra.gnu.org} is used
1091(@code{mirror.hydra.gnu.org} is a mirror of @code{hydra.gnu.org}).
9176607e
LC
1092
1093This means that substitutes may be downloaded from @var{urls}, as long
1094as they are signed by a trusted signature (@pxref{Substitutes}).
1095
4ec2e92d
LC
1096@cindex build hook
1097@item --no-build-hook
1098Do not use the @dfn{build hook}.
1099
1100The build hook is a helper program that the daemon can start and to
1101which it submits build requests. This mechanism is used to offload
1102builds to other machines (@pxref{Daemon Offload Setup}).
1103
bd5e766b
LC
1104@item --cache-failures
1105Cache build failures. By default, only successful builds are cached.
1106
30d9aa54
LC
1107When this option is used, @command{guix gc --list-failures} can be used
1108to query the set of store items marked as failed; @command{guix gc
1109--clear-failures} removes store items from the set of cached failures.
1110@xref{Invoking guix gc}.
1111
bd5e766b
LC
1112@item --cores=@var{n}
1113@itemx -c @var{n}
1114Use @var{n} CPU cores to build each derivation; @code{0} means as many
1115as available.
1116
6efc160e 1117The default value is @code{0}, but it may be overridden by clients, such
e49951eb
MW
1118as the @code{--cores} option of @command{guix build} (@pxref{Invoking
1119guix build}).
bd5e766b
LC
1120
1121The effect is to define the @code{NIX_BUILD_CORES} environment variable
1122in the build process, which can then use it to exploit internal
1123parallelism---for instance, by running @code{make -j$NIX_BUILD_CORES}.
1124
1125@item --max-jobs=@var{n}
1126@itemx -M @var{n}
1127Allow at most @var{n} build jobs in parallel. The default value is
f6526eb3
LC
1128@code{1}. Setting it to @code{0} means that no builds will be performed
1129locally; instead, the daemon will offload builds (@pxref{Daemon Offload
1130Setup}), or simply fail.
bd5e766b 1131
ecf84b7c
LC
1132@item --rounds=@var{N}
1133Build each derivation @var{n} times in a row, and raise an error if
1134consecutive build results are not bit-for-bit identical. Note that this
1135setting can be overridden by clients such as @command{guix build}
1136(@pxref{Invoking guix build}).
1137
b4528110
ED
1138When used in conjunction with @option{--keep-failed}, the differing
1139output is kept in the store, under @file{/gnu/store/@dots{}-check}.
1140This makes it easy to look for differences between the two results.
1141
bd5e766b
LC
1142@item --debug
1143Produce debugging output.
1144
1145This is useful to debug daemon start-up issues, but then it may be
1146overridden by clients, for example the @code{--verbosity} option of
e49951eb 1147@command{guix build} (@pxref{Invoking guix build}).
bd5e766b
LC
1148
1149@item --chroot-directory=@var{dir}
1150Add @var{dir} to the build chroot.
1151
1152Doing this may change the result of build processes---for instance if
1153they use optional dependencies found in @var{dir} when it is available,
1154and not otherwise. For that reason, it is not recommended to do so.
1155Instead, make sure that each derivation declares all the inputs that it
1156needs.
1157
1158@item --disable-chroot
1159Disable chroot builds.
1160
1161Using this option is not recommended since, again, it would allow build
1e2644bb
LC
1162processes to gain access to undeclared dependencies. It is necessary,
1163though, when @command{guix-daemon} is running under an unprivileged user
1164account.
bd5e766b
LC
1165
1166@item --disable-log-compression
1167Disable compression of the build logs.
1168
1da983b9
LC
1169Unless @code{--lose-logs} is used, all the build logs are kept in the
1170@var{localstatedir}. To save space, the daemon automatically compresses
1171them with bzip2 by default. This option disables that.
1172
ab3893d7
LC
1173@item --disable-deduplication
1174@cindex deduplication
bd5e766b
LC
1175Disable automatic file ``deduplication'' in the store.
1176
1da983b9 1177By default, files added to the store are automatically ``deduplicated'':
ab3893d7
LC
1178if a newly added file is identical to another one found in the store,
1179the daemon makes the new file a hard link to the other file. This can
4988dd40 1180noticeably reduce disk usage, at the expense of slightly increased
ab3893d7
LC
1181input/output load at the end of a build process. This option disables
1182this optimization.
1da983b9 1183
6e37066e
LC
1184@item --gc-keep-outputs[=yes|no]
1185Tell whether the garbage collector (GC) must keep outputs of live
1186derivations.
1187
1188When set to ``yes'', the GC will keep the outputs of any live derivation
1189available in the store---the @code{.drv} files. The default is ``no'',
1190meaning that derivation outputs are kept only if they are GC roots.
1191
1192@item --gc-keep-derivations[=yes|no]
1193Tell whether the garbage collector (GC) must keep derivations
1194corresponding to live outputs.
1195
1196When set to ``yes'', as is the case by default, the GC keeps
1197derivations---i.e., @code{.drv} files---as long as at least one of their
1198outputs is live. This allows users to keep track of the origins of
1199items in their store. Setting it to ``no'' saves a bit of disk space.
1200
1201Note that when both @code{--gc-keep-derivations} and
1202@code{--gc-keep-outputs} are used, the effect is to keep all the build
1203prerequisites (the sources, compiler, libraries, and other build-time
1204tools) of live objects in the store, regardless of whether these
1205prerequisites are live. This is convenient for developers since it
1206saves rebuilds or downloads.
1207
bd5e766b
LC
1208@item --impersonate-linux-2.6
1209On Linux-based systems, impersonate Linux 2.6. This means that the
1210kernel's @code{uname} system call will report 2.6 as the release number.
1211
1212This might be helpful to build programs that (usually wrongfully) depend
1213on the kernel version number.
1214
1215@item --lose-logs
1216Do not keep build logs. By default they are kept under
ce33631f 1217@code{@var{localstatedir}/guix/log}.
bd5e766b
LC
1218
1219@item --system=@var{system}
1220Assume @var{system} as the current system type. By default it is the
1221architecture/kernel pair found at configure time, such as
1222@code{x86_64-linux}.
b8d2aa26
LC
1223
1224@item --listen=@var{socket}
1225Listen for connections on @var{socket}, the file name of a Unix-domain
1226socket. The default socket is
1227@file{@var{localstatedir}/daemon-socket/socket}. This option is only
1228useful in exceptional circumstances, such as if you need to run several
1229daemons on the same machine.
bd5e766b
LC
1230@end table
1231
1232
0e2d0213
LC
1233@node Application Setup
1234@section Application Setup
1235
d23ef788 1236@cindex foreign distro
85e57214
LC
1237When using Guix on top of GNU/Linux distribution other than GuixSD---a
1238so-called @dfn{foreign distro}---a few additional steps are needed to
1239get everything in place. Here are some of them.
0e2d0213
LC
1240
1241@subsection Locales
1242
5c3c1427 1243@anchor{locales-and-locpath}
0e2d0213 1244@cindex locales, when not on GuixSD
5c3c1427 1245@vindex LOCPATH
85e57214 1246@vindex GUIX_LOCPATH
f97c9175
AE
1247Packages installed @i{via} Guix will not use the locale data of the
1248host system. Instead, you must first install one of the locale packages
85e57214
LC
1249available with Guix and then define the @code{GUIX_LOCPATH} environment
1250variable:
0e2d0213
LC
1251
1252@example
1253$ guix package -i glibc-locales
85e57214 1254$ export GUIX_LOCPATH=$HOME/.guix-profile/lib/locale
0e2d0213
LC
1255@end example
1256
1257Note that the @code{glibc-locales} package contains data for all the
1258locales supported by the GNU@tie{}libc and weighs in at around
f97c9175 1259110@tie{}MiB. Alternatively, the @code{glibc-utf8-locales} is smaller but
0e2d0213
LC
1260limited to a few UTF-8 locales.
1261
85e57214
LC
1262The @code{GUIX_LOCPATH} variable plays a role similar to @code{LOCPATH}
1263(@pxref{Locale Names, @code{LOCPATH},, libc, The GNU C Library Reference
1264Manual}). There are two important differences though:
1265
1266@enumerate
1267@item
f97c9175 1268@code{GUIX_LOCPATH} is honored only by the libc in Guix, and not by the libc
85e57214 1269provided by foreign distros. Thus, using @code{GUIX_LOCPATH} allows you
f97c9175 1270to make sure the programs of the foreign distro will not end up loading
85e57214
LC
1271incompatible locale data.
1272
1273@item
1274libc suffixes each entry of @code{GUIX_LOCPATH} with @code{/X.Y}, where
1275@code{X.Y} is the libc version---e.g., @code{2.22}. This means that,
1276should your Guix profile contain a mixture of programs linked against
1277different libc version, each libc version will only try to load locale
1278data in the right format.
1279@end enumerate
1280
1281This is important because the locale data format used by different libc
1282versions may be incompatible.
1283
9a5187b6
LC
1284@subsection Name Service Switch
1285
1286@cindex name service switch, glibc
1287@cindex NSS (name service switch), glibc
1288@cindex nscd (name service caching daemon)
1289@cindex name service caching daemon (nscd)
1290When using Guix on a foreign distro, we @emph{strongly recommend} that
1291the system run the GNU C library's @dfn{name service cache daemon},
1292@command{nscd}, which should be listening on the
1293@file{/var/run/nscd/socket} socket. Failing to do that, applications
1294installed with Guix may fail to look up host names or user accounts, or
1295may even crash. The next paragraphs explain why.
1296
1297@cindex @file{nsswitch.conf}
1298The GNU C library implements a @dfn{name service switch} (NSS), which is
1299an extensible mechanism for ``name lookups'' in general: host name
1300resolution, user accounts, and more (@pxref{Name Service Switch,,, libc,
1301The GNU C Library Reference Manual}).
1302
1303@cindex Network information service (NIS)
1304@cindex NIS (Network information service)
1305Being extensible, the NSS supports @dfn{plugins}, which provide new name
1306lookup implementations: for example, the @code{nss-mdns} plugin allow
1307resolution of @code{.local} host names, the @code{nis} plugin allows
1308user account lookup using the Network information service (NIS), and so
1309on. These extra ``lookup services'' are configured system-wide in
1310@file{/etc/nsswitch.conf}, and all the programs running on the system
1311honor those settings (@pxref{NSS Configuration File,,, libc, The GNU C
1312Reference Manual}).
1313
1314When they perform a name lookup---for instance by calling the
1315@code{getaddrinfo} function in C---applications first try to connect to
1316the nscd; on success, nscd performs name lookups on their behalf. If
1317the nscd is not running, then they perform the name lookup by
1318themselves, by loading the name lookup services into their own address
1319space and running it. These name lookup services---the
1320@file{libnss_*.so} files---are @code{dlopen}'d, but they may come from
1321the host system's C library, rather than from the C library the
1322application is linked against (the C library coming from Guix).
1323
1324And this is where the problem is: if your application is linked against
1325Guix's C library (say, glibc 2.24) and tries to load NSS plugins from
1326another C library (say, @code{libnss_mdns.so} for glibc 2.22), it will
1327likely crash or have its name lookups fail unexpectedly.
1328
1329Running @command{nscd} on the system, among other advantages, eliminates
1330this binary incompatibility problem because those @code{libnss_*.so}
1331files are loaded in the @command{nscd} process, not in applications
1332themselves.
1333
0e2d0213
LC
1334@subsection X11 Fonts
1335
e32171ee 1336@cindex fonts
4988dd40 1337The majority of graphical applications use Fontconfig to locate and
f97c9175
AE
1338load fonts and perform X11-client-side rendering. The @code{fontconfig}
1339package in Guix looks for fonts in @file{$HOME/.guix-profile}
0e2d0213 1340by default. Thus, to allow graphical applications installed with Guix
f97c9175 1341to display fonts, you have to install fonts with Guix as well.
0e2d0213 1342Essential font packages include @code{gs-fonts}, @code{font-dejavu}, and
8fe5b1d1 1343@code{font-gnu-freefont-ttf}.
0e2d0213 1344
5c36edc8
LC
1345To display text written in Chinese languages, Japanese, or Korean in
1346graphical applications, consider installing
1347@code{font-adobe-source-han-sans} or @code{font-wqy-zenhei}. The former
1348has multiple outputs, one per language family (@pxref{Packages with
1349Multiple Outputs}). For instance, the following command installs fonts
1350for Chinese languages:
1351
1352@example
1353guix package -i font-adobe-source-han-sans:cn
1354@end example
1355
e32171ee 1356@cindex @code{xterm}
1a3e6b15
AK
1357Older programs such as @command{xterm} do not use Fontconfig and instead
1358rely on server-side font rendering. Such programs require to specify a
1359full name of a font using XLFD (X Logical Font Description), like this:
1360
1361@example
1362-*-dejavu sans-medium-r-normal-*-*-100-*-*-*-*-*-1
1363@end example
1364
1365To be able to use such full names for the TrueType fonts installed in
1366your Guix profile, you need to extend the font path of the X server:
1367
1368@example
1369xset +fp ~/.guix-profile/share/fonts/truetype
1370@end example
1371
e32171ee 1372@cindex @code{xlsfonts}
1a3e6b15
AK
1373After that, you can run @code{xlsfonts} (from @code{xlsfonts} package)
1374to make sure your TrueType fonts are listed there.
1375
b3129f2b
LC
1376@subsection X.509 Certificates
1377
e32171ee 1378@cindex @code{nss-certs}
b3129f2b
LC
1379The @code{nss-certs} package provides X.509 certificates, which allow
1380programs to authenticate Web servers accessed over HTTPS.
1381
1382When using Guix on a foreign distro, you can install this package and
1383define the relevant environment variables so that packages know where to
80d944b7 1384look for certificates. @xref{X.509 Certificates}, for detailed
b3129f2b
LC
1385information.
1386
6d97319c
AK
1387@subsection Emacs Packages
1388
e32171ee 1389@cindex @code{emacs}
6d97319c
AK
1390When you install Emacs packages with Guix, the elisp files may be placed
1391either in @file{$HOME/.guix-profile/share/emacs/site-lisp/} or in
1392sub-directories of
1393@file{$HOME/.guix-profile/share/emacs/site-lisp/guix.d/}. The latter
1394directory exists because potentially there may exist thousands of Emacs
1395packages and storing all their files in a single directory may be not
1396reliable (because of name conflicts). So we think using a separate
1397directory for each package is a good idea. It is very similar to how
1398the Emacs package system organizes the file structure (@pxref{Package
1399Files,,, emacs, The GNU Emacs Manual}).
1400
1401By default, Emacs (installed with Guix) ``knows'' where these packages
f97c9175 1402are placed, so you do not need to perform any configuration. If, for
6d97319c 1403some reason, you want to avoid auto-loading Emacs packages installed
f97c9175 1404with Guix, you can do so by running Emacs with @code{--no-site-file}
6d97319c
AK
1405option (@pxref{Init File,,, emacs, The GNU Emacs Manual}).
1406
0e2d0213
LC
1407@c TODO What else?
1408
eeaf4427
LC
1409@c *********************************************************************
1410@node Package Management
1411@chapter Package Management
1412
e32171ee 1413@cindex packages
f8348b91 1414The purpose of GNU Guix is to allow users to easily install, upgrade, and
eeaf4427 1415remove software packages, without having to know about their build
f97c9175 1416procedures or dependencies. Guix also goes beyond this obvious set of
eeaf4427
LC
1417features.
1418
1419This chapter describes the main features of Guix, as well as the package
deb6276d
AK
1420management tools it provides. Along with the command-line interface
1421described below (@pxref{Invoking guix package, @code{guix package}}),
1422you may also use Emacs Interface, after installing @code{emacs-guix}
1423package (run @kbd{M-x guix-help} command to start with it):
1424
1425@example
1426guix package -i emacs-guix
1427@end example
eeaf4427
LC
1428
1429@menu
1430* Features:: How Guix will make your life brighter.
e49951eb 1431* Invoking guix package:: Package installation, removal, etc.
c4202d60 1432* Substitutes:: Downloading pre-built binaries.
760c60d6 1433* Packages with Multiple Outputs:: Single source package, multiple outputs.
e49951eb 1434* Invoking guix gc:: Running the garbage collector.
f651b477 1435* Invoking guix pull:: Fetching the latest Guix and distribution.
239c2266 1436* Invoking guix pack:: Creating software bundles.
760c60d6 1437* Invoking guix archive:: Exporting and importing store files.
eeaf4427
LC
1438@end menu
1439
1440@node Features
1441@section Features
1442
1443When using Guix, each package ends up in the @dfn{package store}, in its
1444own directory---something that resembles
deb6276d 1445@file{/gnu/store/xxx-package-1.2}, where @code{xxx} is a base32 string.
eeaf4427
LC
1446
1447Instead of referring to these directories, users have their own
1448@dfn{profile}, which points to the packages that they actually want to
821b0015
LC
1449use. These profiles are stored within each user's home directory, at
1450@code{$HOME/.guix-profile}.
eeaf4427 1451
821b0015 1452For example, @code{alice} installs GCC 4.7.2. As a result,
eeaf4427 1453@file{/home/alice/.guix-profile/bin/gcc} points to
834129e0 1454@file{/gnu/store/@dots{}-gcc-4.7.2/bin/gcc}. Now, on the same machine,
821b0015
LC
1455@code{bob} had already installed GCC 4.8.0. The profile of @code{bob}
1456simply continues to point to
834129e0 1457@file{/gnu/store/@dots{}-gcc-4.8.0/bin/gcc}---i.e., both versions of GCC
821b0015 1458coexist on the same system without any interference.
eeaf4427 1459
e49951eb 1460The @command{guix package} command is the central tool to manage
f97c9175 1461packages (@pxref{Invoking guix package}). It operates on the per-user
821b0015 1462profiles, and can be used @emph{with normal user privileges}.
eeaf4427 1463
e32171ee 1464@cindex transactions
eeaf4427
LC
1465The command provides the obvious install, remove, and upgrade
1466operations. Each invocation is actually a @emph{transaction}: either
ba55b1cb 1467the specified operation succeeds, or nothing happens. Thus, if the
e49951eb 1468@command{guix package} process is terminated during the transaction,
eeaf4427
LC
1469or if a power outage occurs during the transaction, then the user's
1470profile remains in its previous state, and remains usable.
1471
1472In addition, any package transaction may be @emph{rolled back}. So, if,
1473for example, an upgrade installs a new version of a package that turns
1474out to have a serious bug, users may roll back to the previous instance
4af2447e 1475of their profile, which was known to work well. Similarly, the global
6f773606
LC
1476system configuration on GuixSD is subject to
1477transactional upgrades and roll-back
4af2447e 1478(@pxref{Using the Configuration System}).
eeaf4427 1479
f97c9175
AE
1480All packages in the package store may be @emph{garbage-collected}.
1481Guix can determine which packages are still referenced by user
fe8ff028 1482profiles, and remove those that are provably no longer referenced
e49951eb 1483(@pxref{Invoking guix gc}). Users may also explicitly remove old
fe8ff028
LC
1484generations of their profile so that the packages they refer to can be
1485collected.
eeaf4427 1486
e900c503
LC
1487@cindex reproducibility
1488@cindex reproducible builds
eeaf4427
LC
1489Finally, Guix takes a @dfn{purely functional} approach to package
1490management, as described in the introduction (@pxref{Introduction}).
834129e0 1491Each @file{/gnu/store} package directory name contains a hash of all the
eeaf4427
LC
1492inputs that were used to build that package---compiler, libraries, build
1493scripts, etc. This direct correspondence allows users to make sure a
1494given package installation matches the current state of their
e900c503
LC
1495distribution. It also helps maximize @dfn{build reproducibility}:
1496thanks to the isolated build environments that are used, a given build
1497is likely to yield bit-identical files when performed on different
1498machines (@pxref{Invoking guix-daemon, container}).
eeaf4427 1499
c4202d60 1500@cindex substitutes
eeaf4427 1501This foundation allows Guix to support @dfn{transparent binary/source
c4202d60 1502deployment}. When a pre-built binary for a @file{/gnu/store} item is
18f2887b 1503available from an external source---a @dfn{substitute}, Guix just
c4202d60
LC
1504downloads it and unpacks it;
1505otherwise, it builds the package from source, locally
bf9eacd2
LC
1506(@pxref{Substitutes}). Because build results are usually bit-for-bit
1507reproducible, users do not have to trust servers that provide
1508substitutes: they can force a local build and @emph{challenge} providers
1509(@pxref{Invoking guix challenge}).
eeaf4427 1510
f5fd4fd2
LC
1511Control over the build environment is a feature that is also useful for
1512developers. The @command{guix environment} command allows developers of
1513a package to quickly set up the right development environment for their
f97c9175
AE
1514package, without having to manually install the dependencies of the
1515package into their profile (@pxref{Invoking guix environment}).
f5fd4fd2 1516
e49951eb
MW
1517@node Invoking guix package
1518@section Invoking @command{guix package}
eeaf4427 1519
e32171ee
JD
1520@cindex installing packages
1521@cindex removing packages
1522@cindex package installation
1523@cindex package removal
e49951eb 1524The @command{guix package} command is the tool that allows users to
eeaf4427
LC
1525install, upgrade, and remove packages, as well as rolling back to
1526previous configurations. It operates only on the user's own profile,
1527and works with normal user privileges (@pxref{Features}). Its syntax
1528is:
1529
1530@example
e49951eb 1531guix package @var{options}
eeaf4427 1532@end example
e32171ee 1533@cindex transactions
ba55b1cb 1534Primarily, @var{options} specifies the operations to be performed during
eeaf4427 1535the transaction. Upon completion, a new profile is created, but
99bd74d5 1536previous @dfn{generations} of the profile remain available, should the user
eeaf4427
LC
1537want to roll back.
1538
6447738c
MW
1539For example, to remove @code{lua} and install @code{guile} and
1540@code{guile-cairo} in a single transaction:
1541
1542@example
1543guix package -r lua -i guile guile-cairo
1544@end example
1545
99bd74d5
LC
1546@command{guix package} also supports a @dfn{declarative approach}
1547whereby the user specifies the exact set of packages to be available and
1548passes it @i{via} the @option{--manifest} option
1549(@pxref{profile-manifest, @option{--manifest}}).
1550
e32171ee 1551@cindex profile
b9e5c0a9 1552For each user, a symlink to the user's default profile is automatically
0ec1af59 1553created in @file{$HOME/.guix-profile}. This symlink always points to the
b9e5c0a9
LC
1554current generation of the user's default profile. Thus, users can add
1555@file{$HOME/.guix-profile/bin} to their @code{PATH} environment
1556variable, and so on.
d664f1b4
LC
1557@cindex search paths
1558If you are not using the Guix System Distribution, consider adding the
1559following lines to your @file{~/.bash_profile} (@pxref{Bash Startup
1560Files,,, bash, The GNU Bash Reference Manual}) so that newly-spawned
1561shells get all the right environment variable definitions:
1562
1563@example
1564GUIX_PROFILE="$HOME/.guix-profile" \
1565source "$HOME/.guix-profile/etc/profile"
1566@end example
b9e5c0a9 1567
4379c35b
LC
1568In a multi-user setup, user profiles are stored in a place registered as
1569a @dfn{garbage-collector root}, which @file{$HOME/.guix-profile} points
1570to (@pxref{Invoking guix gc}). That directory is normally
0ec1af59
LC
1571@code{@var{localstatedir}/profiles/per-user/@var{user}}, where
1572@var{localstatedir} is the value passed to @code{configure} as
4379c35b
LC
1573@code{--localstatedir}, and @var{user} is the user name. The
1574@file{per-user} directory is created when @command{guix-daemon} is
1575started, and the @var{user} sub-directory is created by @command{guix
1576package}.
0ec1af59
LC
1577
1578The @var{options} can be among the following:
1579
eeaf4427
LC
1580@table @code
1581
6447738c
MW
1582@item --install=@var{package} @dots{}
1583@itemx -i @var{package} @dots{}
1584Install the specified @var{package}s.
eeaf4427 1585
6447738c 1586Each @var{package} may specify either a simple package name, such as
1b846da8
ML
1587@code{guile}, or a package name followed by an at-sign and version number,
1588such as @code{guile@@1.8.8} or simply @code{guile@@1.8} (in the latter
724311a2
LC
1589case, the newest version prefixed by @code{1.8} is selected.)
1590
1591If no version number is specified, the
dc5669cd
MW
1592newest available version will be selected. In addition, @var{package}
1593may contain a colon, followed by the name of one of the outputs of the
1b846da8 1594package, as in @code{gcc:doc} or @code{binutils@@2.22:lib}
e7f34eb0
LC
1595(@pxref{Packages with Multiple Outputs}). Packages with a corresponding
1596name (and optionally version) are searched for among the GNU
1597distribution modules (@pxref{Package Modules}).
eeaf4427 1598
461572cc
LC
1599@cindex propagated inputs
1600Sometimes packages have @dfn{propagated inputs}: these are dependencies
21461f27
LC
1601that automatically get installed along with the required package
1602(@pxref{package-propagated-inputs, @code{propagated-inputs} in
1603@code{package} objects}, for information about propagated inputs in
1604package definitions).
461572cc 1605
21461f27 1606@anchor{package-cmd-propagated-inputs}
461572cc
LC
1607An example is the GNU MPC library: its C header files refer to those of
1608the GNU MPFR library, which in turn refer to those of the GMP library.
1609Thus, when installing MPC, the MPFR and GMP libraries also get installed
1610in the profile; removing MPC also removes MPFR and GMP---unless they had
f97c9175 1611also been explicitly installed by the user.
461572cc 1612
ba7ea5ce 1613Besides, packages sometimes rely on the definition of environment
5924080d 1614variables for their search paths (see explanation of
ba7ea5ce 1615@code{--search-paths} below). Any missing or possibly incorrect
5924080d
LC
1616environment variable definitions are reported here.
1617
5d4b411f
LC
1618@item --install-from-expression=@var{exp}
1619@itemx -e @var{exp}
1620Install the package @var{exp} evaluates to.
1621
1622@var{exp} must be a Scheme expression that evaluates to a
1623@code{<package>} object. This option is notably useful to disambiguate
1624between same-named variants of a package, with expressions such as
1625@code{(@@ (gnu packages base) guile-final)}.
1626
1627Note that this option installs the first output of the specified
1628package, which may be insufficient when needing a specific output of a
1629multiple-output package.
1630
0d279400
DT
1631@item --install-from-file=@var{file}
1632@itemx -f @var{file}
1633Install the package that the code within @var{file} evaluates to.
1634
1635As an example, @var{file} might contain a definition like this
1636(@pxref{Defining Packages}):
1637
1638@example
1639@verbatiminclude package-hello.scm
1640@end example
1641
baacf042 1642Developers may find it useful to include such a @file{guix.scm} file
f97c9175 1643in the root of their project source tree that can be used to test
0d279400
DT
1644development snapshots and create reproducible development environments
1645(@pxref{Invoking guix environment}).
1646
6447738c
MW
1647@item --remove=@var{package} @dots{}
1648@itemx -r @var{package} @dots{}
1649Remove the specified @var{package}s.
eeaf4427 1650
6447738c 1651As for @code{--install}, each @var{package} may specify a version number
13ed095c
LC
1652and/or output name in addition to the package name. For instance,
1653@code{-r glibc:debug} would remove the @code{debug} output of
1654@code{glibc}.
1655
6447738c
MW
1656@item --upgrade[=@var{regexp} @dots{}]
1657@itemx -u [@var{regexp} @dots{}]
e32171ee 1658@cindex upgrading packages
6447738c
MW
1659Upgrade all the installed packages. If one or more @var{regexp}s are
1660specified, upgrade only installed packages whose name matches a
d5f01e48 1661@var{regexp}. Also see the @code{--do-not-upgrade} option below.
eeaf4427 1662
f651b477
LC
1663Note that this upgrades package to the latest version of packages found
1664in the distribution currently installed. To update your distribution,
1665you should regularly run @command{guix pull} (@pxref{Invoking guix
1666pull}).
1667
d5f01e48
MW
1668@item --do-not-upgrade[=@var{regexp} @dots{}]
1669When used together with the @code{--upgrade} option, do @emph{not}
1670upgrade any packages whose name matches a @var{regexp}. For example, to
1671upgrade all packages in the current profile except those containing the
1672substring ``emacs'':
1673
1674@example
1675$ guix package --upgrade . --do-not-upgrade emacs
1676@end example
1677
99bd74d5 1678@item @anchor{profile-manifest}--manifest=@var{file}
1b676447 1679@itemx -m @var{file}
99bd74d5
LC
1680@cindex profile declaration
1681@cindex profile manifest
1682Create a new generation of the profile from the manifest object
1b676447
DT
1683returned by the Scheme code in @var{file}.
1684
99bd74d5
LC
1685This allows you to @emph{declare} the profile's contents rather than
1686constructing it through a sequence of @code{--install} and similar
1687commands. The advantage is that @var{file} can be put under version
1688control, copied to different machines to reproduce the same profile, and
1689so on.
1690
1691@c FIXME: Add reference to (guix profile) documentation when available.
1692@var{file} must return a @dfn{manifest} object, which is roughly a list
1693of packages:
1b676447 1694
99bd74d5 1695@findex packages->manifest
1b676447 1696@example
99bd74d5 1697(use-package-modules guile emacs)
1b676447
DT
1698
1699(packages->manifest
99bd74d5
LC
1700 (list emacs
1701 guile-2.0
1b676447 1702 ;; Use a specific package output.
99bd74d5 1703 (list guile-2.0 "debug")))
1b676447
DT
1704@end example
1705
6cd10593
LC
1706@findex specification->package+output
1707In this example we have to know which modules define the @code{emacs}
1708and @code{guile-2.0} variables to provide the right
1709@code{use-package-modules} line, which can be cumbersome. We can
1710instead provide regular package specifications and let
1711@code{specification->package-output} look up the corresponding package
1712objects, like this:
1713
1714@example
1715(packages->manifest
1716 (map (compose list specification->package+output)
1717 '("emacs" "guile@@2.0" "guile@@2.0:debug")))
1718@end example
1719
24e262f0 1720@item --roll-back
e32171ee
JD
1721@cindex rolling back
1722@cindex undoing transactions
1723@cindex transactions, undoing
24e262f0
LC
1724Roll back to the previous @dfn{generation} of the profile---i.e., undo
1725the last transaction.
1726
1727When combined with options such as @code{--install}, roll back occurs
1728before any other actions.
1729
d9307267 1730When rolling back from the first generation that actually contains
4b2bc804 1731installed packages, the profile is made to point to the @dfn{zeroth
f97c9175 1732generation}, which contains no files apart from its own metadata.
d9307267 1733
f97c9175
AE
1734After having rolled back, installing, removing, or upgrading packages
1735overwrites previous future generations. Thus, the history of the
1736generations in a profile is always linear.
82fe08ed 1737
b3bb82f1
AK
1738@item --switch-generation=@var{pattern}
1739@itemx -S @var{pattern}
e32171ee 1740@cindex generations
b3bb82f1
AK
1741Switch to a particular generation defined by @var{pattern}.
1742
1743@var{pattern} may be either a generation number or a number prefixed
1744with ``+'' or ``-''. The latter means: move forward/backward by a
1745specified number of generations. For example, if you want to return to
1746the latest generation after @code{--roll-back}, use
1747@code{--switch-generation=+1}.
1748
1749The difference between @code{--roll-back} and
1750@code{--switch-generation=-1} is that @code{--switch-generation} will
1751not make a zeroth generation, so if a specified generation does not
1752exist, the current generation will not be changed.
1753
dbc31ab2 1754@item --search-paths[=@var{kind}]
5924080d
LC
1755@cindex search paths
1756Report environment variable definitions, in Bash syntax, that may be
1757needed in order to use the set of installed packages. These environment
1758variables are used to specify @dfn{search paths} for files used by some
1759of the installed packages.
1760
1761For example, GCC needs the @code{CPATH} and @code{LIBRARY_PATH}
1762environment variables to be defined so it can look for headers and
1763libraries in the user's profile (@pxref{Environment Variables,,, gcc,
1764Using the GNU Compiler Collection (GCC)}). If GCC and, say, the C
1765library are installed in the profile, then @code{--search-paths} will
1766suggest setting these variables to @code{@var{profile}/include} and
1767@code{@var{profile}/lib}, respectively.
1768
dbc31ab2
LC
1769The typical use case is to define these environment variables in the
1770shell:
1771
1772@example
1773$ eval `guix package --search-paths`
1774@end example
1775
1776@var{kind} may be one of @code{exact}, @code{prefix}, or @code{suffix},
1777meaning that the returned environment variable definitions will either
1778be exact settings, or prefixes or suffixes of the current value of these
1779variables. When omitted, @var{kind} defaults to @code{exact}.
1780
fc2d2339
LC
1781This option can also be used to compute the @emph{combined} search paths
1782of several profiles. Consider this example:
1783
1784@example
1785$ guix package -p foo -i guile
1786$ guix package -p bar -i guile-json
1787$ guix package -p foo -p bar --search-paths
1788@end example
1789
1790The last command above reports about the @code{GUILE_LOAD_PATH}
1791variable, even though, taken individually, neither @file{foo} nor
1792@file{bar} would lead to that recommendation.
1793
1794
eeaf4427
LC
1795@item --profile=@var{profile}
1796@itemx -p @var{profile}
1797Use @var{profile} instead of the user's default profile.
1798
70915c1a 1799@item --verbose
f97c9175
AE
1800Produce verbose output. In particular, emit the build log of the
1801environment on the standard error port.
70915c1a 1802
eeaf4427
LC
1803@item --bootstrap
1804Use the bootstrap Guile to build the profile. This option is only
1805useful to distribution developers.
1806
1807@end table
1808
f97c9175 1809In addition to these actions, @command{guix package} supports the
733b4130
LC
1810following options to query the current state of a profile, or the
1811availability of packages:
eeaf4427 1812
733b4130
LC
1813@table @option
1814
acc08466
NK
1815@item --search=@var{regexp}
1816@itemx -s @var{regexp}
b110869d 1817@cindex searching for packages
5763ad92 1818List the available packages whose name, synopsis, or description matches
f97c9175 1819@var{regexp}. Print all the metadata of matching packages in
299112d3
LC
1820@code{recutils} format (@pxref{Top, GNU recutils databases,, recutils,
1821GNU recutils manual}).
acc08466 1822
299112d3
LC
1823This allows specific fields to be extracted using the @command{recsel}
1824command, for instance:
1825
1826@example
e49951eb 1827$ guix package -s malloc | recsel -p name,version
299112d3
LC
1828name: glibc
1829version: 2.17
1830
1831name: libgc
1832version: 7.2alpha6
1833@end example
acc08466 1834
a12d92f5
LC
1835Similarly, to show the name of all the packages available under the
1836terms of the GNU@tie{}LGPL version 3:
1837
1838@example
1839$ guix package -s "" | recsel -p name -e 'license ~ "LGPL 3"'
1840name: elfutils
1841
1842name: gmp
1843@dots{}
1844@end example
1845
db5a9444
LC
1846It is also possible to refine search results using several @code{-s}
1847flags. For example, the following command returns a list of board
1848games:
1849
1850@example
1851$ guix package -s '\<board\>' -s game | recsel -p name
1852name: gnubg
1853@dots{}
1854@end example
1855
1856If we were to omit @code{-s game}, we would also get software packages
1857that deal with printed circuit boards; removing the angle brackets
1858around @code{board} would further add packages that have to do with
1859keyboards.
1860
b110869d
LC
1861And now for a more elaborate example. The following command searches
1862for cryptographic libraries, filters out Haskell, Perl, Python, and Ruby
1863libraries, and prints the name and synopsis of the matching packages:
1864
1865@example
1866$ guix package -s crypto -s library | \
1867 recsel -e '! (name ~ "^(ghc|perl|python|ruby)")' -p name,synopsis
1868@end example
1869
1870@noindent
1871@xref{Selection Expressions,,, recutils, GNU recutils manual}, for more
1872information on @dfn{selection expressions} for @code{recsel -e}.
1873
2aa6efb0
CR
1874@item --show=@var{package}
1875Show details about @var{package}, taken from the list of available packages, in
1876@code{recutils} format (@pxref{Top, GNU recutils databases,, recutils, GNU
1877recutils manual}).
1878
1879@example
1880$ guix package --show=python | recsel -p name,version
1881name: python
1882version: 2.7.6
1883
1884name: python
1885version: 3.3.5
1886@end example
1887
1888You may also specify the full name of a package to only get details about a
1889specific version of it:
1890@example
ea206df4 1891$ guix package --show=python@@3.4 | recsel -p name,version
2aa6efb0 1892name: python
ea206df4 1893version: 3.4.3
2aa6efb0
CR
1894@end example
1895
1896
1897
733b4130
LC
1898@item --list-installed[=@var{regexp}]
1899@itemx -I [@var{regexp}]
bd9bde1c
LC
1900List the currently installed packages in the specified profile, with the
1901most recently installed packages shown last. When @var{regexp} is
1902specified, list only installed packages whose name matches @var{regexp}.
733b4130
LC
1903
1904For each installed package, print the following items, separated by
1905tabs: the package name, its version string, the part of the package that
1906is installed (for instance, @code{out} for the default output,
1907@code{include} for its headers, etc.), and the path of this package in
1908the store.
1909
64fc89b6
LC
1910@item --list-available[=@var{regexp}]
1911@itemx -A [@var{regexp}]
5763ad92 1912List packages currently available in the distribution for this system
a1ba8475
LC
1913(@pxref{GNU Distribution}). When @var{regexp} is specified, list only
1914installed packages whose name matches @var{regexp}.
64fc89b6
LC
1915
1916For each package, print the following items separated by tabs: its name,
6e721c4d
LC
1917its version string, the parts of the package (@pxref{Packages with
1918Multiple Outputs}), and the source location of its definition.
64fc89b6 1919
f566d765
LC
1920@item --list-generations[=@var{pattern}]
1921@itemx -l [@var{pattern}]
e32171ee 1922@cindex generations
f566d765
LC
1923Return a list of generations along with their creation dates; for each
1924generation, show the installed packages, with the most recently
4b2bc804
NK
1925installed packages shown last. Note that the zeroth generation is never
1926shown.
f566d765
LC
1927
1928For each installed package, print the following items, separated by
1929tabs: the name of a package, its version string, the part of the package
1930that is installed (@pxref{Packages with Multiple Outputs}), and the
1931location of this package in the store.
1932
1933When @var{pattern} is used, the command returns only matching
1934generations. Valid patterns include:
1935
1936@itemize
1937@item @emph{Integers and comma-separated integers}. Both patterns denote
1938generation numbers. For instance, @code{--list-generations=1} returns
1939the first one.
1940
1941And @code{--list-generations=1,8,2} outputs three generations in the
1942specified order. Neither spaces nor trailing commas are allowed.
1943
1944@item @emph{Ranges}. @code{--list-generations=2..9} prints the
1945specified generations and everything in between. Note that the start of
f97c9175 1946a range must be smaller than its end.
f566d765
LC
1947
1948It is also possible to omit the endpoint. For example,
1949@code{--list-generations=2..}, returns all generations starting from the
1950second one.
1951
1952@item @emph{Durations}. You can also get the last @emph{N}@tie{}days, weeks,
1953or months by passing an integer along with the first letter of the
d7ddb257
LC
1954duration. For example, @code{--list-generations=20d} lists generations
1955that are up to 20 days old.
f566d765
LC
1956@end itemize
1957
b7884ca3
NK
1958@item --delete-generations[=@var{pattern}]
1959@itemx -d [@var{pattern}]
d7ddb257
LC
1960When @var{pattern} is omitted, delete all generations except the current
1961one.
b7884ca3
NK
1962
1963This command accepts the same patterns as @option{--list-generations}.
d7ddb257
LC
1964When @var{pattern} is specified, delete the matching generations. When
1965@var{pattern} specifies a duration, generations @emph{older} than the
1966specified duration match. For instance, @code{--delete-generations=1m}
1967deletes generations that are more than one month old.
1968
391bdd8f
LC
1969If the current generation matches, it is @emph{not} deleted. Also, the
1970zeroth generation is never deleted.
b7884ca3 1971
f97c9175 1972Note that deleting generations prevents rolling back to them.
1bb9900a
LC
1973Consequently, this command must be used with care.
1974
733b4130 1975@end table
eeaf4427 1976
70ee5642 1977Finally, since @command{guix package} may actually start build
ccd7158d 1978processes, it supports all the common build options (@pxref{Common Build
f97c9175 1979Options}). It also supports package transformation options, such as
b8638f03
LC
1980@option{--with-source} (@pxref{Package Transformation Options}).
1981However, note that package transformations are lost when upgrading; to
f97c9175 1982preserve transformations across upgrades, you should define your own
b8638f03
LC
1983package variant in a Guile module and add it to @code{GUIX_PACKAGE_PATH}
1984(@pxref{Defining Packages}).
1985
70ee5642 1986
c4202d60
LC
1987@node Substitutes
1988@section Substitutes
1989
1990@cindex substitutes
1991@cindex pre-built binaries
1992Guix supports transparent source/binary deployment, which means that it
1993can either build things locally, or download pre-built items from a
1994server. We call these pre-built items @dfn{substitutes}---they are
1995substitutes for local build results. In many cases, downloading a
1996substitute is much faster than building things locally.
1997
1998Substitutes can be anything resulting from a derivation build
1999(@pxref{Derivations}). Of course, in the common case, they are
2000pre-built package binaries, but source tarballs, for instance, which
2001also result from derivation builds, can be available as substitutes.
2002
2003The @code{hydra.gnu.org} server is a front-end to a build farm that
2004builds packages from the GNU distribution continuously for some
deb6276d 2005architectures, and makes them available as substitutes. This is the
f8a8e0fe
LC
2006default source of substitutes; it can be overridden by passing the
2007@option{--substitute-urls} option either to @command{guix-daemon}
2008(@pxref{daemon-substitute-urls,, @code{guix-daemon --substitute-urls}})
2009or to client tools such as @command{guix package}
2010(@pxref{client-substitute-urls,, client @option{--substitute-urls}
2011option}).
c4202d60 2012
1dbe3a8d 2013Substitute URLs can be either HTTP or HTTPS.
9b7bd1b1
LC
2014HTTPS is recommended because communications are encrypted; conversely,
2015using HTTP makes all communications visible to an eavesdropper, who
2016could use the information gathered to determine, for instance, whether
2017your system has unpatched security vulnerabilities.
2018
c4202d60
LC
2019@cindex security
2020@cindex digital signatures
e32171ee 2021@cindex substitutes, authorization thereof
df061d07
LC
2022To allow Guix to download substitutes from @code{hydra.gnu.org} or a
2023mirror thereof, you
c4202d60
LC
2024must add its public key to the access control list (ACL) of archive
2025imports, using the @command{guix archive} command (@pxref{Invoking guix
2026archive}). Doing so implies that you trust @code{hydra.gnu.org} to not
2027be compromised and to serve genuine substitutes.
2028
2029This public key is installed along with Guix, in
2030@code{@var{prefix}/share/guix/hydra.gnu.org.pub}, where @var{prefix} is
2031the installation prefix of Guix. If you installed Guix from source,
2032make sure you checked the GPG signature of
2033@file{guix-@value{VERSION}.tar.gz}, which contains this public key file.
2034Then, you can run something like this:
2035
2036@example
2037# guix archive --authorize < hydra.gnu.org.pub
2038@end example
2039
2040Once this is in place, the output of a command like @code{guix build}
2041should change from something like:
2042
2043@example
2044$ guix build emacs --dry-run
2045The following derivations would be built:
2046 /gnu/store/yr7bnx8xwcayd6j95r2clmkdl1qh688w-emacs-24.3.drv
2047 /gnu/store/x8qsh1hlhgjx6cwsjyvybnfv2i37z23w-dbus-1.6.4.tar.gz.drv
2048 /gnu/store/1ixwp12fl950d15h2cj11c73733jay0z-alsa-lib-1.0.27.1.tar.bz2.drv
2049 /gnu/store/nlma1pw0p603fpfiqy7kn4zm105r5dmw-util-linux-2.21.drv
2050@dots{}
2051@end example
2052
2053@noindent
2054to something like:
2055
2056@example
2057$ guix build emacs --dry-run
2058The following files would be downloaded:
2059 /gnu/store/pk3n22lbq6ydamyymqkkz7i69wiwjiwi-emacs-24.3
2060 /gnu/store/2ygn4ncnhrpr61rssa6z0d9x22si0va3-libjpeg-8d
2061 /gnu/store/71yz6lgx4dazma9dwn2mcjxaah9w77jq-cairo-1.12.16
2062 /gnu/store/7zdhgp0n1518lvfn8mb96sxqfmvqrl7v-libxrender-0.9.7
2063@dots{}
2064@end example
2065
2066@noindent
2067This indicates that substitutes from @code{hydra.gnu.org} are usable and
2068will be downloaded, when possible, for future builds.
2069
2070Guix ignores substitutes that are not signed, or that are not signed by
ef27aa9c 2071one of the keys listed in the ACL. It also detects and raises an error
c4202d60
LC
2072when attempting to use a substitute that has been tampered with.
2073
e0c941fe 2074@vindex http_proxy
9b7bd1b1
LC
2075Substitutes are downloaded over HTTP or HTTPS.
2076The @code{http_proxy} environment
e0c941fe
LC
2077variable can be set in the environment of @command{guix-daemon} and is
2078honored for downloads of substitutes. Note that the value of
2079@code{http_proxy} in the environment where @command{guix build},
2080@command{guix package}, and other client commands are run has
2081@emph{absolutely no effect}.
2082
9b7bd1b1
LC
2083When using HTTPS, the server's X.509 certificate is @emph{not} validated
2084(in other words, the server is not authenticated), contrary to what
2085HTTPS clients such as Web browsers usually do. This is because Guix
2086authenticates substitute information itself, as explained above, which
2087is what we care about (whereas X.509 certificates are about
2088authenticating bindings between domain names and public keys.)
2089
c4202d60
LC
2090The substitute mechanism can be disabled globally by running
2091@code{guix-daemon} with @code{--no-substitutes} (@pxref{Invoking
2092guix-daemon}). It can also be disabled temporarily by passing the
2093@code{--no-substitutes} option to @command{guix package}, @command{guix
2094build}, and other command-line tools.
2095
2096
9b7bd1b1
LC
2097@unnumberedsubsec On Trusting Binaries
2098
c4202d60
LC
2099Today, each individual's control over their own computing is at the
2100mercy of institutions, corporations, and groups with enough power and
2101determination to subvert the computing infrastructure and exploit its
2102weaknesses. While using @code{hydra.gnu.org} substitutes can be
2103convenient, we encourage users to also build on their own, or even run
2104their own build farm, such that @code{hydra.gnu.org} is less of an
8ce229fc
LC
2105interesting target. One way to help is by publishing the software you
2106build using @command{guix publish} so that others have one more choice
2107of server to download substitutes from (@pxref{Invoking guix publish}).
c4202d60
LC
2108
2109Guix has the foundations to maximize build reproducibility
2110(@pxref{Features}). In most cases, independent builds of a given
2111package or derivation should yield bit-identical results. Thus, through
2112a diverse set of independent package builds, we can strengthen the
d23c20f1
LC
2113integrity of our systems. The @command{guix challenge} command aims to
2114help users assess substitute servers, and to assist developers in
2115finding out about non-deterministic package builds (@pxref{Invoking guix
a8d65643
LC
2116challenge}). Similarly, the @option{--check} option of @command{guix
2117build} allows users to check whether previously-installed substitutes
2118are genuine by rebuilding them locally (@pxref{build-check,
2119@command{guix build --check}}).
c4202d60
LC
2120
2121In the future, we want Guix to have support to publish and retrieve
2122binaries to/from other users, in a peer-to-peer fashion. If you would
2123like to discuss this project, join us on @email{guix-devel@@gnu.org}.
2124
2125
6e721c4d
LC
2126@node Packages with Multiple Outputs
2127@section Packages with Multiple Outputs
2128
2129@cindex multiple-output packages
2130@cindex package outputs
e32171ee 2131@cindex outputs
6e721c4d
LC
2132
2133Often, packages defined in Guix have a single @dfn{output}---i.e., the
f97c9175 2134source package leads to exactly one directory in the store. When running
6e721c4d
LC
2135@command{guix package -i glibc}, one installs the default output of the
2136GNU libc package; the default output is called @code{out}, but its name
2137can be omitted as shown in this command. In this particular case, the
2138default output of @code{glibc} contains all the C header files, shared
2139libraries, static libraries, Info documentation, and other supporting
2140files.
2141
2142Sometimes it is more appropriate to separate the various types of files
2143produced from a single source package into separate outputs. For
2144instance, the GLib C library (used by GTK+ and related packages)
2145installs more than 20 MiB of reference documentation as HTML pages.
2146To save space for users who do not need it, the documentation goes to a
2147separate output, called @code{doc}. To install the main GLib output,
2148which contains everything but the documentation, one would run:
2149
2150@example
2151guix package -i glib
2152@end example
2153
e32171ee 2154@cindex documentation
6e721c4d
LC
2155The command to install its documentation is:
2156
2157@example
2158guix package -i glib:doc
2159@end example
2160
2161Some packages install programs with different ``dependency footprints''.
f97c9175 2162For instance, the WordNet package installs both command-line tools and
6e721c4d
LC
2163graphical user interfaces (GUIs). The former depend solely on the C
2164library, whereas the latter depend on Tcl/Tk and the underlying X
2165libraries. In this case, we leave the command-line tools in the default
2166output, whereas the GUIs are in a separate output. This allows users
fcc58db6
LC
2167who do not need the GUIs to save space. The @command{guix size} command
2168can help find out about such situations (@pxref{Invoking guix size}).
88856916 2169@command{guix graph} can also be helpful (@pxref{Invoking guix graph}).
6e721c4d
LC
2170
2171There are several such multiple-output packages in the GNU distribution.
91ef73d4
LC
2172Other conventional output names include @code{lib} for libraries and
2173possibly header files, @code{bin} for stand-alone programs, and
2174@code{debug} for debugging information (@pxref{Installing Debugging
2175Files}). The outputs of a packages are listed in the third column of
2176the output of @command{guix package --list-available} (@pxref{Invoking
2177guix package}).
6e721c4d 2178
eeaf4427 2179
e49951eb
MW
2180@node Invoking guix gc
2181@section Invoking @command{guix gc}
fe8ff028
LC
2182
2183@cindex garbage collector
e32171ee 2184@cindex disk space
f97c9175 2185Packages that are installed, but not used, may be @dfn{garbage-collected}.
e49951eb 2186The @command{guix gc} command allows users to explicitly run the garbage
c22eb992
LC
2187collector to reclaim space from the @file{/gnu/store} directory. It is
2188the @emph{only} way to remove files from @file{/gnu/store}---removing
2189files or directories manually may break it beyond repair!
fe8ff028
LC
2190
2191The garbage collector has a set of known @dfn{roots}: any file under
834129e0 2192@file{/gnu/store} reachable from a root is considered @dfn{live} and
fe8ff028
LC
2193cannot be deleted; any other file is considered @dfn{dead} and may be
2194deleted. The set of garbage collector roots includes default user
e49951eb
MW
2195profiles, and may be augmented with @command{guix build --root}, for
2196example (@pxref{Invoking guix build}).
fe8ff028 2197
1bb9900a
LC
2198Prior to running @code{guix gc --collect-garbage} to make space, it is
2199often useful to remove old generations from user profiles; that way, old
2200package builds referenced by those generations can be reclaimed. This
2201is achieved by running @code{guix package --delete-generations}
2202(@pxref{Invoking guix package}).
2203
e49951eb 2204The @command{guix gc} command has three modes of operation: it can be
fe8ff028 2205used to garbage-collect any dead files (the default), to delete specific
7770aafc
LC
2206files (the @code{--delete} option), to print garbage-collector
2207information, or for more advanced queries. The garbage collection
2208options are as follows:
fe8ff028
LC
2209
2210@table @code
2211@item --collect-garbage[=@var{min}]
2212@itemx -C [@var{min}]
834129e0 2213Collect garbage---i.e., unreachable @file{/gnu/store} files and
fe8ff028
LC
2214sub-directories. This is the default operation when no option is
2215specified.
2216
2217When @var{min} is given, stop once @var{min} bytes have been collected.
2218@var{min} may be a number of bytes, or it may include a unit as a
4a44d7bb
LC
2219suffix, such as @code{MiB} for mebibytes and @code{GB} for gigabytes
2220(@pxref{Block size, size specifications,, coreutils, GNU Coreutils}).
fe8ff028
LC
2221
2222When @var{min} is omitted, collect all the garbage.
2223
0054e470
LC
2224@item --free-space=@var{free}
2225@itemx -F @var{free}
2226Collect garbage until @var{free} space is available under
2227@file{/gnu/store}, if possible; @var{free} denotes storage space, such
2228as @code{500MiB}, as described above.
2229
2230When @var{free} or more is already available in @file{/gnu/store}, do
2231nothing and exit immediately.
2232
fe8ff028
LC
2233@item --delete
2234@itemx -d
2235Attempt to delete all the store files and directories specified as
2236arguments. This fails if some of the files are not in the store, or if
2237they are still live.
2238
30d9aa54
LC
2239@item --list-failures
2240List store items corresponding to cached build failures.
2241
2242This prints nothing unless the daemon was started with
2243@option{--cache-failures} (@pxref{Invoking guix-daemon,
2244@option{--cache-failures}}).
2245
2246@item --clear-failures
2247Remove the specified store items from the failed-build cache.
2248
2249Again, this option only makes sense when the daemon is started with
2250@option{--cache-failures}. Otherwise, it does nothing.
2251
fe8ff028
LC
2252@item --list-dead
2253Show the list of dead files and directories still present in the
2254store---i.e., files and directories no longer reachable from any root.
2255
2256@item --list-live
2257Show the list of live store files and directories.
ba8b732d
LC
2258
2259@end table
2260
2261In addition, the references among existing store files can be queried:
2262
2263@table @code
2264
2265@item --references
2266@itemx --referrers
e32171ee 2267@cindex package dependencies
ba8b732d
LC
2268List the references (respectively, the referrers) of store files given
2269as arguments.
2270
8e59fdd5
LC
2271@item --requisites
2272@itemx -R
fcc58db6 2273@cindex closure
8e59fdd5
LC
2274List the requisites of the store files passed as arguments. Requisites
2275include the store files themselves, their references, and the references
2276of these, recursively. In other words, the returned list is the
2277@dfn{transitive closure} of the store files.
2278
f97c9175
AE
2279@xref{Invoking guix size}, for a tool to profile the size of the closure
2280of an element. @xref{Invoking guix graph}, for a tool to visualize
88856916 2281the graph of references.
fcc58db6 2282
fe8ff028
LC
2283@end table
2284
7770aafc
LC
2285Lastly, the following options allow you to check the integrity of the
2286store and to control disk usage.
2287
2288@table @option
2289
2290@item --verify[=@var{options}]
2291@cindex integrity, of the store
2292@cindex integrity checking
2293Verify the integrity of the store.
2294
2295By default, make sure that all the store items marked as valid in the
f97c9175 2296database of the daemon actually exist in @file{/gnu/store}.
7770aafc 2297
f97c9175 2298When provided, @var{options} must be a comma-separated list containing one
7770aafc
LC
2299or more of @code{contents} and @code{repair}.
2300
7414de0a 2301When passing @option{--verify=contents}, the daemon computes the
f97c9175 2302content hash of each store item and compares it against its hash in the
7770aafc
LC
2303database. Hash mismatches are reported as data corruptions. Because it
2304traverses @emph{all the files in the store}, this command can take a
2305long time, especially on systems with a slow disk drive.
2306
2307@cindex repairing the store
6da5bb7b 2308@cindex corruption, recovering from
7770aafc
LC
2309Using @option{--verify=repair} or @option{--verify=contents,repair}
2310causes the daemon to try to repair corrupt store items by fetching
2311substitutes for them (@pxref{Substitutes}). Because repairing is not
2312atomic, and thus potentially dangerous, it is available only to the
6da5bb7b
LC
2313system administrator. A lightweight alternative, when you know exactly
2314which items in the store are corrupt, is @command{guix build --repair}
2315(@pxref{Invoking guix build}).
7770aafc
LC
2316
2317@item --optimize
2318@cindex deduplication
2319Optimize the store by hard-linking identical files---this is
2320@dfn{deduplication}.
2321
2322The daemon performs deduplication after each successful build or archive
2323import, unless it was started with @code{--disable-deduplication}
2324(@pxref{Invoking guix-daemon, @code{--disable-deduplication}}). Thus,
2325this option is primarily useful when the daemon was running with
2326@code{--disable-deduplication}.
2327
2328@end table
eeaf4427 2329
f651b477
LC
2330@node Invoking guix pull
2331@section Invoking @command{guix pull}
2332
e32171ee 2333@cindex upgrading Guix
7fcf2a0b 2334@cindex updating Guix
e32171ee
JD
2335@cindex @command{guix pull}
2336@cindex pull
f651b477
LC
2337Packages are installed or upgraded to the latest version available in
2338the distribution currently available on your local machine. To update
2339that distribution, along with the Guix tools, you must run @command{guix
2340pull}: the command downloads the latest Guix source code and package
2341descriptions, and deploys it.
2342
2343On completion, @command{guix package} will use packages and package
2344versions from this just-retrieved copy of Guix. Not only that, but all
2345the Guix commands and Scheme modules will also be taken from that latest
2346version. New @command{guix} sub-commands added by the update also
cb05108a
LC
2347become available.
2348
2349Any user can update their Guix copy using @command{guix pull}, and the
2350effect is limited to the user who run @command{guix pull}. For
2351instance, when user @code{root} runs @command{guix pull}, this has no
2352effect on the version of Guix that user @code{alice} sees, and vice
2353versa@footnote{Under the hood, @command{guix pull} updates the
2354@file{~/.config/guix/latest} symbolic link to point to the latest Guix,
5e2017ed
CM
2355and the @command{guix} command loads code from there. Currently, the
2356only way to roll back an invocation of @command{guix pull} is to
2357manually update this symlink to point to the previous Guix.}.
f651b477
LC
2358
2359The @command{guix pull} command is usually invoked with no arguments,
2360but it supports the following options:
2361
2362@table @code
2363@item --verbose
2364Produce verbose output, writing build logs to the standard error output.
2365
ab5d72ad
LC
2366@item --url=@var{url}
2367Download the source tarball of Guix from @var{url}.
2368
2369By default, the tarball is taken from its canonical address at
2370@code{gnu.org}, for the stable branch of Guix.
2371
8a9cffb2
LF
2372With some Git servers, this can be used to deploy any version of Guix.
2373For example, to download and deploy version 0.12.0 of Guix from the
2374canonical Git repo:
2375
2376@example
2377guix pull --url=http://git.savannah.gnu.org/cgit/guix.git/snapshot/v0.12.0.tar.gz
2378@end example
2379
2380It can also be used to deploy arbitrary Git revisions:
2381
2382@example
2383guix pull --url=http://git.savannah.gnu.org/cgit/guix.git/snapshot/74d862e8a.tar.gz
2384@end example
2385
f651b477
LC
2386@item --bootstrap
2387Use the bootstrap Guile to build the latest Guix. This option is only
2388useful to Guix developers.
2389@end table
2390
760c60d6 2391
239c2266
LC
2392@node Invoking guix pack
2393@section Invoking @command{guix pack}
2394
2395Occasionally you want to pass software to people who are not (yet!)
2396lucky enough to be using Guix. You'd tell them to run @command{guix
2397package -i @var{something}}, but that's not possible in this case. This
2398is where @command{guix pack} comes in.
2399
2400@cindex pack
2401@cindex bundle
2402@cindex application bundle
2403@cindex software bundle
2404The @command{guix pack} command creates a shrink-wrapped @dfn{pack} or
2405@dfn{software bundle}: it creates a tarball or some other archive
2406containing the binaries of the software you're interested in, and all
2407its dependencies. The resulting archive can be used on any machine that
2408does not have Guix, and people can run the exact same binaries as those
107b8da6
LC
2409you have with Guix. The pack itself is created in a bit-reproducible
2410fashion, so anyone can verify that it really contains the build results
2411that you pretend to be shipping.
239c2266
LC
2412
2413For example, to create a bundle containing Guile, Emacs, Geiser, and all
2414their dependencies, you can run:
2415
2416@example
2417$ guix pack guile emacs geiser
2418@dots{}
2419/gnu/store/@dots{}-pack.tar.gz
2420@end example
2421
2422The result here is a tarball containing a @file{/gnu/store} directory
2423with all the relevant packages. The resulting tarball contains a
2424@dfn{profile} with the three packages of interest; the profile is the
2425same as would be created by @command{guix package -i}. It is this
2426mechanism that is used to create Guix's own standalone binary tarball
2427(@pxref{Binary Installation}).
2428
5895ec8a
LC
2429Users of this pack would have to run
2430@file{/gnu/store/@dots{}-profile/bin/guile} to run Guile, which you may
2431find inconvenient. To work around it, you can create, say, a
2432@file{/opt/gnu/bin} symlink to the profile:
2433
2434@example
2435guix pack -S /opt/gnu/bin=bin guile emacs geiser
2436@end example
2437
2438@noindent
2439That way, users can happily type @file{/opt/gnu/bin/guile} and enjoy.
2440
708b54a9
LC
2441Alternatively, you can produce a pack in the Docker image format using
2442the following command:
b1edfbc3
LC
2443
2444@example
2445guix pack -f docker guile emacs geiser
2446@end example
2447
2448@noindent
2449The result is a tarball that can be passed to the @command{docker load}
2450command. See the
2451@uref{https://docs.docker.com/engine/reference/commandline/load/, Docker
2452documentation} for more information.
2453
239c2266
LC
2454Several command-line options allow you to customize your pack:
2455
2456@table @code
708b54a9
LC
2457@item --format=@var{format}
2458@itemx -f @var{format}
2459Produce a pack in the given @var{format}.
2460
2461The available formats are:
2462
2463@table @code
2464@item tarball
2465This is the default format. It produces a tarball containing all the
2466specifies binaries and symlinks.
2467
2468@item docker
2469This produces a tarball that follows the
2470@uref{https://github.com/docker/docker/blob/master/image/spec/v1.2.md,
2471Docker Image Specification}.
2472@end table
2473
239c2266
LC
2474@item --system=@var{system}
2475@itemx -s @var{system}
2476Attempt to build for @var{system}---e.g., @code{i686-linux}---instead of
2477the system type of the build host.
2478
5461115e
LC
2479@item --target=@var{triplet}
2480@cindex cross-compilation
2481Cross-build for @var{triplet}, which must be a valid GNU triplet, such
2482as @code{"mips64el-linux-gnu"} (@pxref{Specifying target triplets, GNU
2483configuration triplets,, autoconf, Autoconf}).
2484
239c2266
LC
2485@item --compression=@var{tool}
2486@itemx -C @var{tool}
2487Compress the resulting tarball using @var{tool}---one of @code{gzip},
2488@code{bzip2}, @code{xz}, or @code{lzip}.
6b63c43e 2489
5895ec8a
LC
2490@item --symlink=@var{spec}
2491@itemx -S @var{spec}
2492Add the symlinks specified by @var{spec} to the pack. This option can
2493appear several times.
2494
2495@var{spec} has the form @code{@var{source}=@var{target}}, where
2496@var{source} is the symlink that will be created and @var{target} is the
2497symlink target.
2498
2499For instance, @code{-S /opt/gnu/bin=bin} creates a @file{/opt/gnu/bin}
2500symlink pointing to the @file{bin} sub-directory of the profile.
2501
6b63c43e
LC
2502@item --localstatedir
2503Include the ``local state directory'', @file{/var/guix}, in the
2504resulting pack.
2505
2506@file{/var/guix} contains the store database (@pxref{The Store}) as well
2507as garbage-collector roots (@pxref{Invoking guix gc}). Providing it in
2508the pack means that the store is ``complete'' and manageable by Guix;
2509not providing it pack means that the store is ``dead'': items cannot be
2510added to it or removed from it after extraction of the pack.
2511
2512One use case for this is the Guix self-contained binary tarball
2513(@pxref{Binary Installation}).
239c2266
LC
2514@end table
2515
2516In addition, @command{guix pack} supports all the common build options
2517(@pxref{Common Build Options}) and all the package transformation
2518options (@pxref{Package Transformation Options}).
2519
2520
760c60d6
LC
2521@node Invoking guix archive
2522@section Invoking @command{guix archive}
2523
e32171ee
JD
2524@cindex @command{guix archive}
2525@cindex archive
760c60d6
LC
2526The @command{guix archive} command allows users to @dfn{export} files
2527from the store into a single archive, and to later @dfn{import} them.
2528In particular, it allows store files to be transferred from one machine
4d4c4816
AE
2529to the store on another machine.
2530
e32171ee 2531@cindex exporting store items
4d4c4816
AE
2532To export store files as an archive to standard output, run:
2533
2534@example
2535guix archive --export @var{options} @var{specifications}...
2536@end example
2537
2538@var{specifications} may be either store file names or package
2539specifications, as for @command{guix package} (@pxref{Invoking guix
2540package}). For instance, the following command creates an archive
2541containing the @code{gui} output of the @code{git} package and the main
2542output of @code{emacs}:
2543
2544@example
2545guix archive --export git:gui /gnu/store/...-emacs-24.3 > great.nar
2546@end example
2547
2548If the specified packages are not built yet, @command{guix archive}
2549automatically builds them. The build process may be controlled with the
2550common build options (@pxref{Common Build Options}).
2551
2552To transfer the @code{emacs} package to a machine connected over SSH,
2553one would run:
760c60d6
LC
2554
2555@example
56607088 2556guix archive --export -r emacs | ssh the-machine guix archive --import
760c60d6
LC
2557@end example
2558
87236aed 2559@noindent
56607088
LC
2560Similarly, a complete user profile may be transferred from one machine
2561to another like this:
2562
2563@example
2564guix archive --export -r $(readlink -f ~/.guix-profile) | \
2565 ssh the-machine guix-archive --import
2566@end example
2567
2568@noindent
2569However, note that, in both examples, all of @code{emacs} and the
2570profile as well as all of their dependencies are transferred (due to
f97c9175
AE
2571@code{-r}), regardless of what is already available in the store on the
2572target machine. The @code{--missing} option can help figure out which
f11c444d
LC
2573items are missing from the target store. The @command{guix copy}
2574command simplifies and optimizes this whole process, so this is probably
2575what you should use in this case (@pxref{Invoking guix copy}).
87236aed 2576
5597b3ae
LC
2577@cindex nar, archive format
2578@cindex normalized archive (nar)
b1edfbc3 2579Archives are stored in the ``normalized archive'' or ``nar'' format, which is
5597b3ae 2580comparable in spirit to `tar', but with differences
0dbd88db 2581that make it more appropriate for our purposes. First, rather than
5597b3ae 2582recording all Unix metadata for each file, the nar format only mentions
0dbd88db
LC
2583the file type (regular, directory, or symbolic link); Unix permissions
2584and owner/group are dismissed. Second, the order in which directory
2585entries are stored always follows the order of file names according to
2586the C locale collation order. This makes archive production fully
2587deterministic.
2588
2589When exporting, the daemon digitally signs the contents of the archive,
2590and that digital signature is appended. When importing, the daemon
2591verifies the signature and rejects the import in case of an invalid
2592signature or if the signing key is not authorized.
760c60d6
LC
2593@c FIXME: Add xref to daemon doc about signatures.
2594
2595The main options are:
2596
2597@table @code
2598@item --export
2599Export the specified store files or packages (see below.) Write the
2600resulting archive to the standard output.
2601
56607088
LC
2602Dependencies are @emph{not} included in the output, unless
2603@code{--recursive} is passed.
2604
2605@item -r
2606@itemx --recursive
2607When combined with @code{--export}, this instructs @command{guix
2608archive} to include dependencies of the given items in the archive.
2609Thus, the resulting archive is self-contained: it contains the closure
2610of the exported store items.
2611
760c60d6
LC
2612@item --import
2613Read an archive from the standard input, and import the files listed
2614therein into the store. Abort if the archive has an invalid digital
f82cc5fd
LC
2615signature, or if it is signed by a public key not among the authorized
2616keys (see @code{--authorize} below.)
554f26ec 2617
87236aed
LC
2618@item --missing
2619Read a list of store file names from the standard input, one per line,
2620and write on the standard output the subset of these files missing from
2621the store.
2622
554f26ec 2623@item --generate-key[=@var{parameters}]
f82cc5fd 2624@cindex signing, archives
f97c9175 2625Generate a new key pair for the daemon. This is a prerequisite before
554f26ec
LC
2626archives can be exported with @code{--export}. Note that this operation
2627usually takes time, because it needs to gather enough entropy to
2628generate the key pair.
2629
2630The generated key pair is typically stored under @file{/etc/guix}, in
2631@file{signing-key.pub} (public key) and @file{signing-key.sec} (private
867d8473
LC
2632key, which must be kept secret.) When @var{parameters} is omitted,
2633an ECDSA key using the Ed25519 curve is generated, or, for Libgcrypt
2634versions before 1.6.0, it is a 4096-bit RSA key.
f97c9175 2635Alternatively, @var{parameters} can specify
554f26ec
LC
2636@code{genkey} parameters suitable for Libgcrypt (@pxref{General
2637public-key related Functions, @code{gcry_pk_genkey},, gcrypt, The
2638Libgcrypt Reference Manual}).
f82cc5fd
LC
2639
2640@item --authorize
2641@cindex authorizing, archives
2642Authorize imports signed by the public key passed on standard input.
2643The public key must be in ``s-expression advanced format''---i.e., the
2644same format as the @file{signing-key.pub} file.
2645
2646The list of authorized keys is kept in the human-editable file
2647@file{/etc/guix/acl}. The file contains
2648@url{http://people.csail.mit.edu/rivest/Sexp.txt, ``advanced-format
2649s-expressions''} and is structured as an access-control list in the
2650@url{http://theworld.com/~cme/spki.txt, Simple Public-Key Infrastructure
2651(SPKI)}.
c6f8e9dd
LC
2652
2653@item --extract=@var{directory}
2654@itemx -x @var{directory}
2655Read a single-item archive as served by substitute servers
2656(@pxref{Substitutes}) and extract it to @var{directory}. This is a
2657low-level operation needed in only very narrow use cases; see below.
2658
2659For example, the following command extracts the substitute for Emacs
2660served by @code{hydra.gnu.org} to @file{/tmp/emacs}:
2661
2662@example
2663$ wget -O - \
df061d07 2664 https://hydra.gnu.org/nar/@dots{}-emacs-24.5 \
c6f8e9dd
LC
2665 | bunzip2 | guix archive -x /tmp/emacs
2666@end example
2667
2668Single-item archives are different from multiple-item archives produced
2669by @command{guix archive --export}; they contain a single store item,
2670and they do @emph{not} embed a signature. Thus this operation does
2671@emph{no} signature verification and its output should be considered
2672unsafe.
2673
2674The primary purpose of this operation is to facilitate inspection of
2675archive contents coming from possibly untrusted substitute servers.
2676
760c60d6
LC
2677@end table
2678
568717fd
LC
2679@c *********************************************************************
2680@node Programming Interface
2681@chapter Programming Interface
2682
3dc1970d
LC
2683GNU Guix provides several Scheme programming interfaces (APIs) to
2684define, build, and query packages. The first interface allows users to
2685write high-level package definitions. These definitions refer to
2686familiar packaging concepts, such as the name and version of a package,
2687its build system, and its dependencies. These definitions can then be
2688turned into concrete build actions.
2689
ba55b1cb 2690Build actions are performed by the Guix daemon, on behalf of users. In a
3dc1970d 2691standard setup, the daemon has write access to the store---the
834129e0 2692@file{/gnu/store} directory---whereas users do not. The recommended
3dc1970d
LC
2693setup also has the daemon perform builds in chroots, under a specific
2694build users, to minimize interference with the rest of the system.
2695
2696@cindex derivation
2697Lower-level APIs are available to interact with the daemon and the
2698store. To instruct the daemon to perform a build action, users actually
2699provide it with a @dfn{derivation}. A derivation is a low-level
2700representation of the build actions to be taken, and the environment in
2701which they should occur---derivations are to package definitions what
49ad317a
LC
2702assembly is to C programs. The term ``derivation'' comes from the fact
2703that build results @emph{derive} from them.
3dc1970d
LC
2704
2705This chapter describes all these APIs in turn, starting from high-level
2706package definitions.
2707
568717fd 2708@menu
b860f382 2709* Defining Packages:: Defining new packages.
7458bd0a 2710* Build Systems:: Specifying how packages are built.
b860f382
LC
2711* The Store:: Manipulating the package store.
2712* Derivations:: Low-level interface to package derivations.
2713* The Store Monad:: Purely functional interface to the store.
21b679f6 2714* G-Expressions:: Manipulating build expressions.
568717fd
LC
2715@end menu
2716
2717@node Defining Packages
2718@section Defining Packages
2719
3dc1970d
LC
2720The high-level interface to package definitions is implemented in the
2721@code{(guix packages)} and @code{(guix build-system)} modules. As an
2722example, the package definition, or @dfn{recipe}, for the GNU Hello
2723package looks like this:
2724
2725@example
e7f34eb0
LC
2726(define-module (gnu packages hello)
2727 #:use-module (guix packages)
2728 #:use-module (guix download)
2729 #:use-module (guix build-system gnu)
a6dcdcac
SB
2730 #:use-module (guix licenses)
2731 #:use-module (gnu packages gawk))
b22a12fd 2732
79f5dd59 2733(define-public hello
3dc1970d
LC
2734 (package
2735 (name "hello")
17d8e33f 2736 (version "2.10")
3dc1970d 2737 (source (origin
17d8e33f
ML
2738 (method url-fetch)
2739 (uri (string-append "mirror://gnu/hello/hello-" version
2740 ".tar.gz"))
2741 (sha256
2742 (base32
2743 "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i"))))
3dc1970d 2744 (build-system gnu-build-system)
654c0d97 2745 (arguments '(#:configure-flags '("--enable-silent-rules")))
3dc1970d 2746 (inputs `(("gawk" ,gawk)))
7458bd0a
LC
2747 (synopsis "Hello, GNU world: An example GNU package")
2748 (description "Guess what GNU Hello prints!")
3dc1970d 2749 (home-page "http://www.gnu.org/software/hello/")
b22a12fd 2750 (license gpl3+)))
3dc1970d
LC
2751@end example
2752
2753@noindent
2754Without being a Scheme expert, the reader may have guessed the meaning
f97c9175
AE
2755of the various fields here. This expression binds the variable
2756@code{hello} to a @code{<package>} object, which is essentially a record
3dc1970d
LC
2757(@pxref{SRFI-9, Scheme records,, guile, GNU Guile Reference Manual}).
2758This package object can be inspected using procedures found in the
2759@code{(guix packages)} module; for instance, @code{(package-name hello)}
2760returns---surprise!---@code{"hello"}.
2761
2f7d2d91
LC
2762With luck, you may be able to import part or all of the definition of
2763the package you are interested in from another repository, using the
2764@code{guix import} command (@pxref{Invoking guix import}).
2765
f97c9175 2766In the example above, @var{hello} is defined in a module of its own,
e7f34eb0
LC
2767@code{(gnu packages hello)}. Technically, this is not strictly
2768necessary, but it is convenient to do so: all the packages defined in
2769modules under @code{(gnu packages @dots{})} are automatically known to
2770the command-line tools (@pxref{Package Modules}).
2771
3dc1970d
LC
2772There are a few points worth noting in the above package definition:
2773
2774@itemize
2775@item
a2bf4907
LC
2776The @code{source} field of the package is an @code{<origin>} object
2777(@pxref{origin Reference}, for the complete reference).
3dc1970d
LC
2778Here, the @code{url-fetch} method from @code{(guix download)} is used,
2779meaning that the source is a file to be downloaded over FTP or HTTP.
2780
2781The @code{mirror://gnu} prefix instructs @code{url-fetch} to use one of
2782the GNU mirrors defined in @code{(guix download)}.
2783
2784The @code{sha256} field specifies the expected SHA256 hash of the file
2785being downloaded. It is mandatory, and allows Guix to check the
2786integrity of the file. The @code{(base32 @dots{})} form introduces the
6c365eca 2787base32 representation of the hash. You can obtain this information with
210cc920
LC
2788@code{guix download} (@pxref{Invoking guix download}) and @code{guix
2789hash} (@pxref{Invoking guix hash}).
3dc1970d 2790
f9cc8971
LC
2791@cindex patches
2792When needed, the @code{origin} form can also have a @code{patches} field
2793listing patches to be applied, and a @code{snippet} field giving a
2794Scheme expression to modify the source code.
2795
3dc1970d
LC
2796@item
2797@cindex GNU Build System
7458bd0a
LC
2798The @code{build-system} field specifies the procedure to build the
2799package (@pxref{Build Systems}). Here, @var{gnu-build-system}
2800represents the familiar GNU Build System, where packages may be
2801configured, built, and installed with the usual @code{./configure &&
2802make && make check && make install} command sequence.
2803
2804@item
2805The @code{arguments} field specifies options for the build system
2806(@pxref{Build Systems}). Here it is interpreted by
2807@var{gnu-build-system} as a request run @file{configure} with the
2808@code{--enable-silent-rules} flag.
3dc1970d 2809
654c0d97
LC
2810@cindex quote
2811@cindex quoting
2812@findex '
2813@findex quote
2814What about these quote (@code{'}) characters? They are Scheme syntax to
2815introduce a literal list; @code{'} is synonymous with @code{quote}.
2816@xref{Expression Syntax, quoting,, guile, GNU Guile Reference Manual},
2817for details. Here the value of the @code{arguments} field is a list of
2818arguments passed to the build system down the road, as with @code{apply}
2819(@pxref{Fly Evaluation, @code{apply},, guile, GNU Guile Reference
2820Manual}).
2821
2822The hash-colon (@code{#:}) sequence defines a Scheme @dfn{keyword}
2823(@pxref{Keywords,,, guile, GNU Guile Reference Manual}), and
2824@code{#:configure-flags} is a keyword used to pass a keyword argument
2825to the build system (@pxref{Coding With Keywords,,, guile, GNU Guile
2826Reference Manual}).
2827
3dc1970d
LC
2828@item
2829The @code{inputs} field specifies inputs to the build process---i.e.,
2830build-time or run-time dependencies of the package. Here, we define an
2831input called @code{"gawk"} whose value is that of the @var{gawk}
2832variable; @var{gawk} is itself bound to a @code{<package>} object.
2833
654c0d97
LC
2834@cindex backquote (quasiquote)
2835@findex `
2836@findex quasiquote
2837@cindex comma (unquote)
2838@findex ,
2839@findex unquote
2840@findex ,@@
2841@findex unquote-splicing
2842Again, @code{`} (a backquote, synonymous with @code{quasiquote}) allows
2843us to introduce a literal list in the @code{inputs} field, while
2844@code{,} (a comma, synonymous with @code{unquote}) allows us to insert a
2845value in that list (@pxref{Expression Syntax, unquote,, guile, GNU Guile
2846Reference Manual}).
2847
3dc1970d
LC
2848Note that GCC, Coreutils, Bash, and other essential tools do not need to
2849be specified as inputs here. Instead, @var{gnu-build-system} takes care
7458bd0a 2850of ensuring that they are present (@pxref{Build Systems}).
3dc1970d
LC
2851
2852However, any other dependencies need to be specified in the
2853@code{inputs} field. Any dependency not specified here will simply be
2854unavailable to the build process, possibly leading to a build failure.
2855@end itemize
2856
87eafdbd
TUBK
2857@xref{package Reference}, for a full description of possible fields.
2858
2f7d2d91 2859Once a package definition is in place, the
e49951eb 2860package may actually be built using the @code{guix build} command-line
39bee8a2
LC
2861tool (@pxref{Invoking guix build}). You can easily jump back to the
2862package definition using the @command{guix edit} command
2863(@pxref{Invoking guix edit}).
2864@xref{Packaging Guidelines}, for
b4f5e0e8
CR
2865more information on how to test package definitions, and
2866@ref{Invoking guix lint}, for information on how to check a definition
2867for style conformance.
2868
f97c9175 2869Finally, updating the package definition to a new upstream version
7458bd0a
LC
2870can be partly automated by the @command{guix refresh} command
2871(@pxref{Invoking guix refresh}).
3dc1970d
LC
2872
2873Behind the scenes, a derivation corresponding to the @code{<package>}
2874object is first computed by the @code{package-derivation} procedure.
834129e0 2875That derivation is stored in a @code{.drv} file under @file{/gnu/store}.
ba55b1cb 2876The build actions it prescribes may then be realized by using the
3dc1970d
LC
2877@code{build-derivations} procedure (@pxref{The Store}).
2878
2879@deffn {Scheme Procedure} package-derivation @var{store} @var{package} [@var{system}]
59688fc4
LC
2880Return the @code{<derivation>} object of @var{package} for @var{system}
2881(@pxref{Derivations}).
3dc1970d
LC
2882
2883@var{package} must be a valid @code{<package>} object, and @var{system}
2884must be a string denoting the target system type---e.g.,
2885@code{"x86_64-linux"} for an x86_64 Linux-based GNU system. @var{store}
2886must be a connection to the daemon, which operates on the store
2887(@pxref{The Store}).
2888@end deffn
568717fd 2889
9c1edabd
LC
2890@noindent
2891@cindex cross-compilation
2892Similarly, it is possible to compute a derivation that cross-builds a
2893package for some other system:
2894
2895@deffn {Scheme Procedure} package-cross-derivation @var{store} @
2896 @var{package} @var{target} [@var{system}]
59688fc4
LC
2897Return the @code{<derivation>} object of @var{package} cross-built from
2898@var{system} to @var{target}.
9c1edabd
LC
2899
2900@var{target} must be a valid GNU triplet denoting the target hardware
2901and operating system, such as @code{"mips64el-linux-gnu"}
2902(@pxref{Configuration Names, GNU configuration triplets,, configure, GNU
2903Configure and Build System}).
2904@end deffn
2905
2a75b0b6
LC
2906@cindex package transformations
2907@cindex input rewriting
2908@cindex dependency tree rewriting
2909Packages can be manipulated in arbitrary ways. An example of a useful
2910transformation is @dfn{input rewriting}, whereby the dependency tree of
2911a package is rewritten by replacing specific inputs by others:
2912
2913@deffn {Scheme Procedure} package-input-rewriting @var{replacements} @
2914 [@var{rewrite-name}]
2915Return a procedure that, when passed a package, replaces its direct and
2916indirect dependencies (but not its implicit inputs) according to
2917@var{replacements}. @var{replacements} is a list of package pairs; the
2918first element of each pair is the package to replace, and the second one
2919is the replacement.
2920
2921Optionally, @var{rewrite-name} is a one-argument procedure that takes
2922the name of a package and returns its new name after rewrite.
2923@end deffn
2924
2925@noindent
2926Consider this example:
2927
2928@example
2929(define libressl-instead-of-openssl
2930 ;; This is a procedure to replace OPENSSL by LIBRESSL,
2931 ;; recursively.
2932 (package-input-rewriting `((,openssl . ,libressl))))
2933
2934(define git-with-libressl
2935 (libressl-instead-of-openssl git))
2936@end example
2937
2938@noindent
2939Here we first define a rewriting procedure that replaces @var{openssl}
2940with @var{libressl}. Then we use it to define a @dfn{variant} of the
2941@var{git} package that uses @var{libressl} instead of @var{openssl}.
2942This is exactly what the @option{--with-input} command-line option does
2943(@pxref{Package Transformation Options, @option{--with-input}}).
2944
87eafdbd
TUBK
2945@menu
2946* package Reference :: The package data type.
2947* origin Reference:: The origin data type.
2948@end menu
2949
2950
2951@node package Reference
2952@subsection @code{package} Reference
2953
2954This section summarizes all the options available in @code{package}
2955declarations (@pxref{Defining Packages}).
2956
2957@deftp {Data Type} package
2958This is the data type representing a package recipe.
2959
2960@table @asis
2961@item @code{name}
2962The name of the package, as a string.
2963
2964@item @code{version}
2965The version of the package, as a string.
2966
2967@item @code{source}
da675305
LC
2968An object telling how the source code for the package should be
2969acquired. Most of the time, this is an @code{origin} object, which
2970denotes a file fetched from the Internet (@pxref{origin Reference}). It
2971can also be any other ``file-like'' object such as a @code{local-file},
2972which denotes a file from the local file system (@pxref{G-Expressions,
2973@code{local-file}}).
87eafdbd
TUBK
2974
2975@item @code{build-system}
2976The build system that should be used to build the package (@pxref{Build
2977Systems}).
2978
2979@item @code{arguments} (default: @code{'()})
2980The arguments that should be passed to the build system. This is a
2981list, typically containing sequential keyword-value pairs.
2982
2983@item @code{inputs} (default: @code{'()})
70650c68
LC
2984@itemx @code{native-inputs} (default: @code{'()})
2985@itemx @code{propagated-inputs} (default: @code{'()})
2986@cindex inputs, of packages
2987These fields list dependencies of the package. Each one is a list of
2988tuples, where each tuple has a label for the input (a string) as its
2989first element, a package, origin, or derivation as its second element,
2990and optionally the name of the output thereof that should be used, which
2991defaults to @code{"out"} (@pxref{Packages with Multiple Outputs}, for
f97c9175 2992more on package outputs). For example, the list below specifies three
70650c68 2993inputs:
87eafdbd 2994
70650c68
LC
2995@example
2996`(("libffi" ,libffi)
2997 ("libunistring" ,libunistring)
2998 ("glib:bin" ,glib "bin")) ;the "bin" output of Glib
2999@end example
3000
3001@cindex cross compilation, package dependencies
3002The distinction between @code{native-inputs} and @code{inputs} is
3003necessary when considering cross-compilation. When cross-compiling,
3004dependencies listed in @code{inputs} are built for the @emph{target}
3005architecture; conversely, dependencies listed in @code{native-inputs}
3006are built for the architecture of the @emph{build} machine.
3007
f97c9175
AE
3008@code{native-inputs} is typically used to list tools needed at
3009build time, but not at run time, such as Autoconf, Automake, pkg-config,
70650c68
LC
3010Gettext, or Bison. @command{guix lint} can report likely mistakes in
3011this area (@pxref{Invoking guix lint}).
3012
3013@anchor{package-propagated-inputs}
3014Lastly, @code{propagated-inputs} is similar to @code{inputs}, but the
f97c9175
AE
3015specified packages will be automatically installed alongside the package
3016they belong to (@pxref{package-cmd-propagated-inputs, @command{guix
70650c68
LC
3017package}}, for information on how @command{guix package} deals with
3018propagated inputs.)
21461f27 3019
e0508b6b
LC
3020For example this is necessary when a C/C++ library needs headers of
3021another library to compile, or when a pkg-config file refers to another
3022one @i{via} its @code{Requires} field.
3023
f97c9175
AE
3024Another example where @code{propagated-inputs} is useful is for languages
3025that lack a facility to record the run-time search path akin to the
c8ebb4c4 3026@code{RUNPATH} of ELF files; this includes Guile, Python, Perl, and
e0508b6b
LC
3027more. To ensure that libraries written in those languages can find
3028library code they depend on at run time, run-time dependencies must be
3029listed in @code{propagated-inputs} rather than @code{inputs}.
87eafdbd 3030
87eafdbd
TUBK
3031@item @code{self-native-input?} (default: @code{#f})
3032This is a Boolean field telling whether the package should use itself as
3033a native input when cross-compiling.
3034
3035@item @code{outputs} (default: @code{'("out")})
3036The list of output names of the package. @xref{Packages with Multiple
3037Outputs}, for typical uses of additional outputs.
3038
3039@item @code{native-search-paths} (default: @code{'()})
3040@itemx @code{search-paths} (default: @code{'()})
3041A list of @code{search-path-specification} objects describing
3042search-path environment variables honored by the package.
3043
3044@item @code{replacement} (default: @code{#f})
f97c9175 3045This must be either @code{#f} or a package object that will be used as a
87eafdbd
TUBK
3046@dfn{replacement} for this package. @xref{Security Updates, grafts},
3047for details.
3048
3049@item @code{synopsis}
3050A one-line description of the package.
3051
3052@item @code{description}
3053A more elaborate description of the package.
3054
3055@item @code{license}
e32171ee 3056@cindex license, of packages
f97c9175
AE
3057The license of the package; a value from @code{(guix licenses)},
3058or a list of such values.
87eafdbd
TUBK
3059
3060@item @code{home-page}
3061The URL to the home-page of the package, as a string.
3062
3063@item @code{supported-systems} (default: @var{%supported-systems})
3064The list of systems supported by the package, as strings of the form
3065@code{architecture-kernel}, for example @code{"x86_64-linux"}.
3066
3067@item @code{maintainers} (default: @code{'()})
3068The list of maintainers of the package, as @code{maintainer} objects.
3069
3070@item @code{location} (default: source location of the @code{package} form)
f97c9175 3071The source location of the package. It is useful to override this when
87eafdbd
TUBK
3072inheriting from another package, in which case this field is not
3073automatically corrected.
3074@end table
3075@end deftp
3076
3077
3078@node origin Reference
3079@subsection @code{origin} Reference
3080
3081This section summarizes all the options available in @code{origin}
3082declarations (@pxref{Defining Packages}).
3083
3084@deftp {Data Type} origin
3085This is the data type representing a source code origin.
3086
3087@table @asis
3088@item @code{uri}
3089An object containing the URI of the source. The object type depends on
3090the @code{method} (see below). For example, when using the
3091@var{url-fetch} method of @code{(guix download)}, the valid @code{uri}
3092values are: a URL represented as a string, or a list thereof.
3093
3094@item @code{method}
f97c9175 3095A procedure that handles the URI.
87eafdbd
TUBK
3096
3097Examples include:
3098
3099@table @asis
3100@item @var{url-fetch} from @code{(guix download)}
f97c9175 3101download a file from the HTTP, HTTPS, or FTP URL specified in the
87eafdbd
TUBK
3102@code{uri} field;
3103
db97a03a 3104@vindex git-fetch
87eafdbd
TUBK
3105@item @var{git-fetch} from @code{(guix git-download)}
3106clone the Git version control repository, and check out the revision
3107specified in the @code{uri} field as a @code{git-reference} object; a
3108@code{git-reference} looks like this:
3109
3110@example
3111(git-reference
3112 (url "git://git.debian.org/git/pkg-shadow/shadow")
3113 (commit "v4.1.5.1"))
3114@end example
3115@end table
3116
3117@item @code{sha256}
3118A bytevector containing the SHA-256 hash of the source. Typically the
3119@code{base32} form is used here to generate the bytevector from a
3120base-32 string.
3121
db97a03a
LC
3122You can obtain this information using @code{guix download}
3123(@pxref{Invoking guix download}) or @code{guix hash} (@pxref{Invoking
3124guix hash}).
3125
87eafdbd
TUBK
3126@item @code{file-name} (default: @code{#f})
3127The file name under which the source code should be saved. When this is
3128@code{#f}, a sensible default value will be used in most cases. In case
3129the source is fetched from a URL, the file name from the URL will be
f97c9175 3130used. For version control checkouts, it is recommended to provide the
87eafdbd
TUBK
3131file name explicitly because the default is not very descriptive.
3132
3133@item @code{patches} (default: @code{'()})
3134A list of file names containing patches to be applied to the source.
3135
0dfebdaa
LC
3136This list of patches must be unconditional. In particular, it cannot
3137depend on the value of @code{%current-system} or
3138@code{%current-target-system}.
3139
87eafdbd 3140@item @code{snippet} (default: @code{#f})
1929fdba
LC
3141A G-expression (@pxref{G-Expressions}) or S-expression that will be run
3142in the source directory. This is a convenient way to modify the source,
3143sometimes more convenient than a patch.
87eafdbd
TUBK
3144
3145@item @code{patch-flags} (default: @code{'("-p1")})
3146A list of command-line flags that should be passed to the @code{patch}
3147command.
3148
3149@item @code{patch-inputs} (default: @code{#f})
3150Input packages or derivations to the patching process. When this is
3151@code{#f}, the usual set of inputs necessary for patching are provided,
3152such as GNU@tie{}Patch.
3153
3154@item @code{modules} (default: @code{'()})
3155A list of Guile modules that should be loaded during the patching
3156process and while running the code in the @code{snippet} field.
3157
87eafdbd
TUBK
3158@item @code{patch-guile} (default: @code{#f})
3159The Guile package that should be used in the patching process. When
3160this is @code{#f}, a sensible default is used.
3161@end table
3162@end deftp
3163
9c1edabd 3164
7458bd0a
LC
3165@node Build Systems
3166@section Build Systems
3167
3168@cindex build system
3169Each package definition specifies a @dfn{build system} and arguments for
3170that build system (@pxref{Defining Packages}). This @code{build-system}
f97c9175 3171field represents the build procedure of the package, as well as implicit
7458bd0a
LC
3172dependencies of that build procedure.
3173
3174Build systems are @code{<build-system>} objects. The interface to
3175create and manipulate them is provided by the @code{(guix build-system)}
3176module, and actual build systems are exported by specific modules.
3177
f5fd4fd2 3178@cindex bag (low-level package representation)
0d5a559f
LC
3179Under the hood, build systems first compile package objects to
3180@dfn{bags}. A @dfn{bag} is like a package, but with less
3181ornamentation---in other words, a bag is a lower-level representation of
3182a package, which includes all the inputs of that package, including some
3183that were implicitly added by the build system. This intermediate
3184representation is then compiled to a derivation (@pxref{Derivations}).
3185
7458bd0a
LC
3186Build systems accept an optional list of @dfn{arguments}. In package
3187definitions, these are passed @i{via} the @code{arguments} field
3188(@pxref{Defining Packages}). They are typically keyword arguments
3189(@pxref{Optional Arguments, keyword arguments in Guile,, guile, GNU
3190Guile Reference Manual}). The value of these arguments is usually
3191evaluated in the @dfn{build stratum}---i.e., by a Guile process launched
3192by the daemon (@pxref{Derivations}).
3193
3194The main build system is @var{gnu-build-system}, which implements the
f97c9175 3195standard build procedure for GNU and many other packages. It
7458bd0a
LC
3196is provided by the @code{(guix build-system gnu)} module.
3197
3198@defvr {Scheme Variable} gnu-build-system
3199@var{gnu-build-system} represents the GNU Build System, and variants
3200thereof (@pxref{Configuration, configuration and makefile conventions,,
3201standards, GNU Coding Standards}).
3202
3203@cindex build phases
f97c9175 3204In a nutshell, packages using it are configured, built, and installed with
7458bd0a
LC
3205the usual @code{./configure && make && make check && make install}
3206command sequence. In practice, a few additional steps are often needed.
3207All these steps are split up in separate @dfn{phases},
3208notably@footnote{Please see the @code{(guix build gnu-build-system)}
3209modules for more details about the build phases.}:
3210
3211@table @code
3212@item unpack
3213Unpack the source tarball, and change the current directory to the
3214extracted source tree. If the source is actually a directory, copy it
3215to the build tree, and enter that directory.
3216
3217@item patch-source-shebangs
3218Patch shebangs encountered in source files so they refer to the right
3219store file names. For instance, this changes @code{#!/bin/sh} to
3220@code{#!/gnu/store/@dots{}-bash-4.3/bin/sh}.
3221
3222@item configure
3223Run the @file{configure} script with a number of default options, such
3224as @code{--prefix=/gnu/store/@dots{}}, as well as the options specified
3225by the @code{#:configure-flags} argument.
3226
3227@item build
3228Run @code{make} with the list of flags specified with
0917e80e 3229@code{#:make-flags}. If the @code{#:parallel-build?} argument is true
7458bd0a
LC
3230(the default), build with @code{make -j}.
3231
3232@item check
3233Run @code{make check}, or some other target specified with
3234@code{#:test-target}, unless @code{#:tests? #f} is passed. If the
3235@code{#:parallel-tests?} argument is true (the default), run @code{make
3236check -j}.
3237
3238@item install
3239Run @code{make install} with the flags listed in @code{#:make-flags}.
3240
3241@item patch-shebangs
3242Patch shebangs on the installed executable files.
3243
3244@item strip
3245Strip debugging symbols from ELF files (unless @code{#:strip-binaries?}
3246is false), copying them to the @code{debug} output when available
3247(@pxref{Installing Debugging Files}).
3248@end table
3249
3250@vindex %standard-phases
3251The build-side module @code{(guix build gnu-build-system)} defines
3252@var{%standard-phases} as the default list of build phases.
3253@var{%standard-phases} is a list of symbol/procedure pairs, where the
3254procedure implements the actual phase.
3255
3256The list of phases used for a particular package can be changed with the
3257@code{#:phases} parameter. For instance, passing:
3258
3259@example
c2c5dc79 3260#:phases (modify-phases %standard-phases (delete 'configure))
7458bd0a
LC
3261@end example
3262
9bf404e9 3263means that all the phases described above will be used, except the
7458bd0a
LC
3264@code{configure} phase.
3265
3266In addition, this build system ensures that the ``standard'' environment
3267for GNU packages is available. This includes tools such as GCC, libc,
3268Coreutils, Bash, Make, Diffutils, grep, and sed (see the @code{(guix
f97c9175
AE
3269build-system gnu)} module for a complete list). We call these the
3270@dfn{implicit inputs} of a package, because package definitions do not
7458bd0a
LC
3271have to mention them.
3272@end defvr
3273
3274Other @code{<build-system>} objects are defined to support other
3275conventions and tools used by free software packages. They inherit most
3276of @var{gnu-build-system}, and differ mainly in the set of inputs
3277implicitly added to the build process, and in the list of phases
3278executed. Some of these build systems are listed below.
3279
5f7a1a4d
RW
3280@defvr {Scheme Variable} ant-build-system
3281This variable is exported by @code{(guix build-system ant)}. It
3282implements the build procedure for Java packages that can be built with
3283@url{http://ant.apache.org/, Ant build tool}.
3284
3285It adds both @code{ant} and the @dfn{Java Development Kit} (JDK) as
3286provided by the @code{icedtea} package to the set of inputs. Different
3287packages can be specified with the @code{#:ant} and @code{#:jdk}
3288parameters, respectively.
3289
3290When the original package does not provide a suitable Ant build file,
3291the parameter @code{#:jar-name} can be used to generate a minimal Ant
3292build file @file{build.xml} with tasks to build the specified jar
3293archive.
3294
3295The parameter @code{#:build-target} can be used to specify the Ant task
3296that should be run during the @code{build} phase. By default the
3297``jar'' task will be run.
3298
3299@end defvr
3300
a1b30f99
AP
3301@defvr {Scheme Variable} asdf-build-system/source
3302@defvrx {Scheme Variable} asdf-build-system/sbcl
3303@defvrx {Scheme Variable} asdf-build-system/ecl
3304
3305These variables, exported by @code{(guix build-system asdf)}, implement
3306build procedures for Common Lisp packages using
3307@url{https://common-lisp.net/project/asdf/, ``ASDF''}. ASDF is a system
3308definition facility for Common Lisp programs and libraries.
3309
3310The @code{asdf-build-system/source} system installs the packages in
3311source form, and can be loaded using any common lisp implementation, via
3312ASDF. The others, such as @code{asdf-build-system/sbcl}, install binary
3313systems in the format which a particular implementation understands.
3314These build systems can also be used to produce executable programs, or
3315lisp images which contain a set of packages pre-loaded.
3316
3317The build system uses naming conventions. For binary packages, the
3318package itself as well as its run-time dependencies should begin their
3319name with the lisp implementation, such as @code{sbcl-} for
3320@code{asdf-build-system/sbcl}. Beginning the input name with this
3321prefix will allow the build system to encode its location into the
3322resulting library, so that the input can be found at run-time.
3323
3324If dependencies are used only for tests, it is convenient to use a
3325different prefix in order to avoid having a run-time dependency on such
3326systems. For example,
3327
3328@example
3329(define-public sbcl-bordeaux-threads
3330 (package
3331 ...
3332 (native-inputs `(("tests:cl-fiveam" ,sbcl-fiveam)))
3333 ...))
3334@end example
3335
3336Additionally, the corresponding source package should be labeled using
3337the same convention as python packages (see @ref{Python Modules}), using
3338the @code{cl-} prefix.
3339
3340For binary packages, each system should be defined as a Guix package.
3341If one package @code{origin} contains several systems, package variants
3342can be created in order to build all the systems. Source packages,
3343which use @code{asdf-build-system/source}, may contain several systems.
3344
3345In order to create executable programs and images, the build-side
3346procedures @code{build-program} and @code{build-image} can be used.
3347They should be called in a build phase after the @code{create-symlinks}
3348phase, so that the system which was just built can be used within the
3349resulting image. @code{build-program} requires a list of Common Lisp
3350expressions to be passed as the @code{#:entry-program} argument.
3351
3352If the system is not defined within its own @code{.asd} file of the same
3353name, then the @code{#:asd-file} parameter should be used to specify
3354which file the system is defined in.
3355
3356@end defvr
3357
1ec34dd7
LC
3358@defvr {Scheme Variable} cargo-build-system
3359@cindex Rust programming language
3360@cindex Cargo (Rust build system)
3361This variable is exported by @code{(guix build-system cargo)}. It
3362supports builds of packages using Cargo, the build tool of the
3363@uref{https://www.rust-lang.org, Rust programming language}.
3364
3365In its @code{configure} phase, this build system replaces dependencies
3366specified in the @file{Carto.toml} file with inputs to the Guix package.
3367The @code{install} phase installs the binaries, and it also installs the
3368source code and @file{Cargo.toml} file.
3369@end defvr
3370
7458bd0a
LC
3371@defvr {Scheme Variable} cmake-build-system
3372This variable is exported by @code{(guix build-system cmake)}. It
3373implements the build procedure for packages using the
3374@url{http://www.cmake.org, CMake build tool}.
3375
3376It automatically adds the @code{cmake} package to the set of inputs.
3377Which package is used can be specified with the @code{#:cmake}
3378parameter.
9849cfc1
LC
3379
3380The @code{#:configure-flags} parameter is taken as a list of flags
3381passed to the @command{cmake} command. The @code{#:build-type}
3382parameter specifies in abstract terms the flags passed to the compiler;
3383it defaults to @code{"RelWithDebInfo"} (short for ``release mode with
3384debugging information''), which roughly means that code is compiled with
3385@code{-O2 -g}, as is the case for Autoconf-based packages by default.
7458bd0a
LC
3386@end defvr
3387
3afcf52b
FB
3388@defvr {Scheme Variable} glib-or-gtk-build-system
3389This variable is exported by @code{(guix build-system glib-or-gtk)}. It
3390is intended for use with packages making use of GLib or GTK+.
3391
3392This build system adds the following two phases to the ones defined by
3393@var{gnu-build-system}:
3394
3395@table @code
3396@item glib-or-gtk-wrap
f97c9175
AE
3397The phase @code{glib-or-gtk-wrap} ensures that programs in
3398@file{bin/} are able to find GLib ``schemas'' and
3afcf52b
FB
3399@uref{https://developer.gnome.org/gtk3/stable/gtk-running.html, GTK+
3400modules}. This is achieved by wrapping the programs in launch scripts
3401that appropriately set the @code{XDG_DATA_DIRS} and @code{GTK_PATH}
3402environment variables.
3403
73aa8ddb
LC
3404It is possible to exclude specific package outputs from that wrapping
3405process by listing their names in the
3406@code{#:glib-or-gtk-wrap-excluded-outputs} parameter. This is useful
3407when an output is known not to contain any GLib or GTK+ binaries, and
3408where wrapping would gratuitously add a dependency of that output on
3409GLib and GTK+.
3410
3afcf52b 3411@item glib-or-gtk-compile-schemas
f97c9175 3412The phase @code{glib-or-gtk-compile-schemas} makes sure that all
3afcf52b 3413@uref{https://developer.gnome.org/gio/stable/glib-compile-schemas.html,
f97c9175 3414GSettings schemas} of GLib are compiled. Compilation is performed by the
3afcf52b
FB
3415@command{glib-compile-schemas} program. It is provided by the package
3416@code{glib:bin} which is automatically imported by the build system.
3417The @code{glib} package providing @command{glib-compile-schemas} can be
3418specified with the @code{#:glib} parameter.
3419@end table
3420
3421Both phases are executed after the @code{install} phase.
3422@end defvr
3423
3184f14a
JL
3424@defvr {Scheme Variable} ocaml-build-system
3425This variable is exported by @code{(guix build-sytem ocaml)}. It implements
3426a build procedure for @uref{https://ocaml.org, OCaml} packages, which consists
3427of choosing the correct set of commands to run for each package. OCaml
3428packages can expect many different commands to be run. This build system will
3429try some of them.
3430
3431When the package has a @file{setup.ml} file present at the top-level, it will
3432run @code{ocaml setup.ml -configure}, @code{ocaml setup.ml -build} and
3433@code{ocaml setup.ml -install}. The build system will assume that this file
3434was generated by @uref{http://oasis.forge.ocamlcore.org/, OASIS} and will take
3435care of setting the prefix and enabling tests if they are not disabled. You
3436can pass configure and build flags with the @code{#:configure-flags} and
3437@code{#:build-flags}. The @code{#:test-flags} key can be passed to change the
3438set of flags used to enable tests. The @code{#:use-make?} key can be used to
3439bypass this system in the build and install phases.
3440
3441When the package has a @file{configure} file, it is assumed that it is a
3442hand-made configure script that requires a different argument format than
3443in the @code{gnu-build-system}. You can add more flags with the
3444@code{#:configure-flags} key.
3445
3446When the package has a @file{Makefile} file (or @code{#:use-make?} is
3447@code{#t}), it will be used and more flags can be passed to the build and
3448install phases with the @code{#:make-flags} key.
3449
3450Finally, some packages do not have these files and use a somewhat standard
3451location for its build system. In that case, the build system will run
3452@code{ocaml pkg/pkg.ml} or @code{ocaml pkg/build.ml} and take care of
3453providing the path to the required findlib module. Additional flags can
3454be passed via the @code{#:build-flags} key. Install is taken care of by
3455@command{opam-installer}. In this case, the @code{opam} package must
3456be added to the @code{native-inputs} field of the package definition.
3457
3458Note that most OCaml packages assume they will be installed in the same
88ba7852 3459directory as OCaml, which is not what we want in guix. In particular, they
3184f14a 3460will install @file{.so} files in their module's directory, which is usually
88ba7852 3461fine because it is in the OCaml compiler directory. In guix though, these
3184f14a
JL
3462libraries cannot be found and we use @code{CAML_LD_LIBRARY_PATH}. This
3463variable points to @file{lib/ocaml/site-lib/stubslibs} and this is where
3464@file{.so} libraries should be installed.
3465@end defvr
3466
7458bd0a
LC
3467@defvr {Scheme Variable} python-build-system
3468This variable is exported by @code{(guix build-system python)}. It
3469implements the more or less standard build procedure used by Python
3470packages, which consists in running @code{python setup.py build} and
3471then @code{python setup.py install --prefix=/gnu/store/@dots{}}.
3472
3473For packages that install stand-alone Python programs under @code{bin/},
f97c9175 3474it takes care of wrapping these programs so that their @code{PYTHONPATH}
7458bd0a
LC
3475environment variable points to all the Python libraries they depend on.
3476
8a46205b
CM
3477Which Python package is used to perform the build can be specified with
3478the @code{#:python} parameter. This is a useful way to force a package
3479to be built for a specific version of the Python interpreter, which
3480might be necessary if the package is only compatible with a single
3481interpreter version.
5f7565d1
HG
3482
3483By default guix calls @code{setup.py} under control of
3484@code{setuptools}, much like @command{pip} does. Some packages are not
3485compatible with setuptools (and pip), thus you can disable this by
3486setting the @code{#:use-setuptools} parameter to @code{#f}.
7458bd0a
LC
3487@end defvr
3488
3489@defvr {Scheme Variable} perl-build-system
3490This variable is exported by @code{(guix build-system perl)}. It
2d2a53fc
EB
3491implements the standard build procedure for Perl packages, which either
3492consists in running @code{perl Build.PL --prefix=/gnu/store/@dots{}},
3493followed by @code{Build} and @code{Build install}; or in running
3494@code{perl Makefile.PL PREFIX=/gnu/store/@dots{}}, followed by
f97c9175 3495@code{make} and @code{make install}, depending on which of
2d2a53fc
EB
3496@code{Build.PL} or @code{Makefile.PL} is present in the package
3497distribution. Preference is given to the former if both @code{Build.PL}
3498and @code{Makefile.PL} exist in the package distribution. This
3499preference can be reversed by specifying @code{#t} for the
3500@code{#:make-maker?} parameter.
3501
3502The initial @code{perl Makefile.PL} or @code{perl Build.PL} invocation
3503passes flags specified by the @code{#:make-maker-flags} or
3504@code{#:module-build-flags} parameter, respectively.
7458bd0a
LC
3505
3506Which Perl package is used can be specified with @code{#:perl}.
3507@end defvr
3508
f8f3bef6
RW
3509@defvr {Scheme Variable} r-build-system
3510This variable is exported by @code{(guix build-system r)}. It
3511implements the build procedure used by @uref{http://r-project.org, R}
3512packages, which essentially is little more than running @code{R CMD
3513INSTALL --library=/gnu/store/@dots{}} in an environment where
3514@code{R_LIBS_SITE} contains the paths to all R package inputs. Tests
3515are run after installation using the R function
3516@code{tools::testInstalledPackage}.
3517@end defvr
3518
c08f9818
DT
3519@defvr {Scheme Variable} ruby-build-system
3520This variable is exported by @code{(guix build-system ruby)}. It
3521implements the RubyGems build procedure used by Ruby packages, which
3522involves running @code{gem build} followed by @code{gem install}.
3523
5dc87623
DT
3524The @code{source} field of a package that uses this build system
3525typically references a gem archive, since this is the format that Ruby
3526developers use when releasing their software. The build system unpacks
3527the gem archive, potentially patches the source, runs the test suite,
3528repackages the gem, and installs it. Additionally, directories and
3529tarballs may be referenced to allow building unreleased gems from Git or
3530a traditional source release tarball.
e83c6d00 3531
c08f9818 3532Which Ruby package is used can be specified with the @code{#:ruby}
6e9f2913
PP
3533parameter. A list of additional flags to be passed to the @command{gem}
3534command can be specified with the @code{#:gem-flags} parameter.
c08f9818 3535@end defvr
7458bd0a 3536
a677c726
RW
3537@defvr {Scheme Variable} waf-build-system
3538This variable is exported by @code{(guix build-system waf)}. It
3539implements a build procedure around the @code{waf} script. The common
3540phases---@code{configure}, @code{build}, and @code{install}---are
3541implemented by passing their names as arguments to the @code{waf}
3542script.
3543
3544The @code{waf} script is executed by the Python interpreter. Which
3545Python package is used to run the script can be specified with the
3546@code{#:python} parameter.
3547@end defvr
3548
14dfdf2e
FB
3549@defvr {Scheme Variable} haskell-build-system
3550This variable is exported by @code{(guix build-system haskell)}. It
3551implements the Cabal build procedure used by Haskell packages, which
3552involves running @code{runhaskell Setup.hs configure
3553--prefix=/gnu/store/@dots{}} and @code{runhaskell Setup.hs build}.
3554Instead of installing the package by running @code{runhaskell Setup.hs
3555install}, to avoid trying to register libraries in the read-only
3556compiler store directory, the build system uses @code{runhaskell
3557Setup.hs copy}, followed by @code{runhaskell Setup.hs register}. In
3558addition, the build system generates the package documentation by
3559running @code{runhaskell Setup.hs haddock}, unless @code{#:haddock? #f}
3560is passed. Optional Haddock parameters can be passed with the help of
3561the @code{#:haddock-flags} parameter. If the file @code{Setup.hs} is
3562not found, the build system looks for @code{Setup.lhs} instead.
3563
3564Which Haskell compiler is used can be specified with the @code{#:haskell}
a54bd6d7 3565parameter which defaults to @code{ghc}.
14dfdf2e
FB
3566@end defvr
3567
65e862d1
DM
3568@defvr {Scheme Variable} dub-build-system
3569This variable is exported by @code{(guix build-system dub)}. It
3570implements the Dub build procedure used by D packages, which
3571involves running @code{dub build} and @code{dub run}.
3572Installation is done by copying the files manually.
3573
3574Which D compiler is used can be specified with the @code{#:ldc}
3575parameter which defaults to @code{ldc}.
3576@end defvr
3577
e9137a53
FB
3578@defvr {Scheme Variable} emacs-build-system
3579This variable is exported by @code{(guix build-system emacs)}. It
f97c9175
AE
3580implements an installation procedure similar to the packaging system
3581of Emacs itself (@pxref{Packages,,, emacs, The GNU Emacs Manual}).
e9137a53
FB
3582
3583It first creates the @code{@var{package}-autoloads.el} file, then it
3584byte compiles all Emacs Lisp files. Differently from the Emacs
3585packaging system, the Info documentation files are moved to the standard
3586documentation directory and the @file{dir} file is deleted. Each
3587package is installed in its own directory under
3588@file{share/emacs/site-lisp/guix.d}.
3589@end defvr
3590
7458bd0a
LC
3591Lastly, for packages that do not need anything as sophisticated, a
3592``trivial'' build system is provided. It is trivial in the sense that
3593it provides basically no support: it does not pull any implicit inputs,
3594and does not have a notion of build phases.
3595
3596@defvr {Scheme Variable} trivial-build-system
3597This variable is exported by @code{(guix build-system trivial)}.
3598
3599This build system requires a @code{#:builder} argument. This argument
f97c9175 3600must be a Scheme expression that builds the package output(s)---as
7458bd0a
LC
3601with @code{build-expression->derivation} (@pxref{Derivations,
3602@code{build-expression->derivation}}).
3603@end defvr
3604
568717fd
LC
3605@node The Store
3606@section The Store
3607
e531ac2a 3608@cindex store
1ddee424 3609@cindex store items
e531ac2a
LC
3610@cindex store paths
3611
f97c9175
AE
3612Conceptually, the @dfn{store} is the place where derivations that have
3613been built successfully are stored---by default, @file{/gnu/store}.
1ddee424
LC
3614Sub-directories in the store are referred to as @dfn{store items} or
3615sometimes @dfn{store paths}. The store has an associated database that
3616contains information such as the store paths referred to by each store
3617path, and the list of @emph{valid} store items---results of successful
ef5f5c86
LC
3618builds. This database resides in @file{@var{localstatedir}/guix/db},
3619where @var{localstatedir} is the state directory specified @i{via}
3620@option{--localstatedir} at configure time, usually @file{/var}.
1ddee424
LC
3621
3622The store is @emph{always} accessed by the daemon on behalf of its clients
e531ac2a 3623(@pxref{Invoking guix-daemon}). To manipulate the store, clients
f97c9175
AE
3624connect to the daemon over a Unix-domain socket, send requests to it,
3625and read the result---these are remote procedure calls, or RPCs.
e531ac2a 3626
1ddee424
LC
3627@quotation Note
3628Users must @emph{never} modify files under @file{/gnu/store} directly.
3629This would lead to inconsistencies and break the immutability
3630assumptions of Guix's functional model (@pxref{Introduction}).
3631
3632@xref{Invoking guix gc, @command{guix gc --verify}}, for information on
3633how to check the integrity of the store and attempt recovery from
3634accidental modifications.
3635@end quotation
3636
e531ac2a
LC
3637The @code{(guix store)} module provides procedures to connect to the
3638daemon, and to perform RPCs. These are described below.
3639
3640@deffn {Scheme Procedure} open-connection [@var{file}] [#:reserve-space? #t]
3641Connect to the daemon over the Unix-domain socket at @var{file}. When
3642@var{reserve-space?} is true, instruct it to reserve a little bit of
3643extra space on the file system so that the garbage collector can still
f97c9175 3644operate should the disk become full. Return a server object.
e531ac2a
LC
3645
3646@var{file} defaults to @var{%default-socket-path}, which is the normal
3647location given the options that were passed to @command{configure}.
3648@end deffn
3649
3650@deffn {Scheme Procedure} close-connection @var{server}
3651Close the connection to @var{server}.
3652@end deffn
3653
3654@defvr {Scheme Variable} current-build-output-port
3655This variable is bound to a SRFI-39 parameter, which refers to the port
3656where build and error logs sent by the daemon should be written.
3657@end defvr
3658
3659Procedures that make RPCs all take a server object as their first
3660argument.
3661
3662@deffn {Scheme Procedure} valid-path? @var{server} @var{path}
06b76acc
LC
3663@cindex invalid store items
3664Return @code{#t} when @var{path} designates a valid store item and
3665@code{#f} otherwise (an invalid item may exist on disk but still be
3666invalid, for instance because it is the result of an aborted or failed
3667build.)
3668
3669A @code{&nix-protocol-error} condition is raised if @var{path} is not
3670prefixed by the store directory (@file{/gnu/store}).
e531ac2a
LC
3671@end deffn
3672
cfbf9160 3673@deffn {Scheme Procedure} add-text-to-store @var{server} @var{name} @var{text} [@var{references}]
e531ac2a
LC
3674Add @var{text} under file @var{name} in the store, and return its store
3675path. @var{references} is the list of store paths referred to by the
3676resulting store path.
3677@end deffn
3678
874e6874 3679@deffn {Scheme Procedure} build-derivations @var{server} @var{derivations}
59688fc4
LC
3680Build @var{derivations} (a list of @code{<derivation>} objects or
3681derivation paths), and return when the worker is done building them.
3682Return @code{#t} on success.
874e6874
LC
3683@end deffn
3684
b860f382
LC
3685Note that the @code{(guix monads)} module provides a monad as well as
3686monadic versions of the above procedures, with the goal of making it
3687more convenient to work with code that accesses the store (@pxref{The
3688Store Monad}).
3689
e531ac2a
LC
3690@c FIXME
3691@i{This section is currently incomplete.}
568717fd
LC
3692
3693@node Derivations
3694@section Derivations
3695
874e6874
LC
3696@cindex derivations
3697Low-level build actions and the environment in which they are performed
70458ed5 3698are represented by @dfn{derivations}. A derivation contains the
874e6874
LC
3699following pieces of information:
3700
3701@itemize
3702@item
3703The outputs of the derivation---derivations produce at least one file or
3704directory in the store, but may produce more.
3705
3706@item
3707The inputs of the derivations, which may be other derivations or plain
3708files in the store (patches, build scripts, etc.)
3709
3710@item
3711The system type targeted by the derivation---e.g., @code{x86_64-linux}.
3712
3713@item
3714The file name of a build script in the store, along with the arguments
3715to be passed.
3716
3717@item
3718A list of environment variables to be defined.
3719
3720@end itemize
3721
3722@cindex derivation path
3723Derivations allow clients of the daemon to communicate build actions to
3724the store. They exist in two forms: as an in-memory representation,
3725both on the client- and daemon-side, and as files in the store whose
3726name end in @code{.drv}---these files are referred to as @dfn{derivation
3727paths}. Derivations paths can be passed to the @code{build-derivations}
3728procedure to perform the build actions they prescribe (@pxref{The
3729Store}).
3730
3731The @code{(guix derivations)} module provides a representation of
3732derivations as Scheme objects, along with procedures to create and
3733otherwise manipulate derivations. The lowest-level primitive to create
3734a derivation is the @code{derivation} procedure:
3735
1909431c
LC
3736@deffn {Scheme Procedure} derivation @var{store} @var{name} @var{builder} @
3737 @var{args} [#:outputs '("out")] [#:hash #f] [#:hash-algo #f] @
2096ef47 3738 [#:recursive? #f] [#:inputs '()] [#:env-vars '()] @
1909431c 3739 [#:system (%current-system)] [#:references-graphs #f] @
35b5ca78
LC
3740 [#:allowed-references #f] [#:disallowed-references #f] @
3741 [#:leaked-env-vars #f] [#:local-build? #f] @
4a6aeb67 3742 [#:substitutable? #t]
59688fc4
LC
3743Build a derivation with the given arguments, and return the resulting
3744@code{<derivation>} object.
874e6874 3745
2096ef47 3746When @var{hash} and @var{hash-algo} are given, a
874e6874 3747@dfn{fixed-output derivation} is created---i.e., one whose result is
36bbbbd1
LC
3748known in advance, such as a file download. If, in addition,
3749@var{recursive?} is true, then that fixed output may be an executable
3750file or a directory and @var{hash} must be the hash of an archive
3751containing this output.
5b0c9d16 3752
858e9282 3753When @var{references-graphs} is true, it must be a list of file
5b0c9d16
LC
3754name/store path pairs. In that case, the reference graph of each store
3755path is exported in the build environment in the corresponding file, in
3756a simple text format.
1909431c 3757
b53be755 3758When @var{allowed-references} is true, it must be a list of store items
35b5ca78
LC
3759or outputs that the derivation's output may refer to. Likewise,
3760@var{disallowed-references}, if true, must be a list of things the
3761outputs may @emph{not} refer to.
b53be755 3762
c0468155
LC
3763When @var{leaked-env-vars} is true, it must be a list of strings
3764denoting environment variables that are allowed to ``leak'' from the
3765daemon's environment to the build environment. This is only applicable
3766to fixed-output derivations---i.e., when @var{hash} is true. The main
3767use is to allow variables such as @code{http_proxy} to be passed to
3768derivations that download files.
3769
1909431c
LC
3770When @var{local-build?} is true, declare that the derivation is not a
3771good candidate for offloading and should rather be built locally
3772(@pxref{Daemon Offload Setup}). This is the case for small derivations
3773where the costs of data transfers would outweigh the benefits.
4a6aeb67
LC
3774
3775When @var{substitutable?} is false, declare that substitutes of the
3776derivation's output should not be used (@pxref{Substitutes}). This is
3777useful, for instance, when building packages that capture details of the
3778host CPU instruction set.
874e6874
LC
3779@end deffn
3780
3781@noindent
3782Here's an example with a shell script as its builder, assuming
3783@var{store} is an open connection to the daemon, and @var{bash} points
3784to a Bash executable in the store:
3785
3786@lisp
3787(use-modules (guix utils)
3788 (guix store)
3789 (guix derivations))
3790
59688fc4
LC
3791(let ((builder ; add the Bash script to the store
3792 (add-text-to-store store "my-builder.sh"
3793 "echo hello world > $out\n" '())))
3794 (derivation store "foo"
3795 bash `("-e" ,builder)
21b679f6 3796 #:inputs `((,bash) (,builder))
59688fc4 3797 #:env-vars '(("HOME" . "/homeless"))))
834129e0 3798@result{} #<derivation /gnu/store/@dots{}-foo.drv => /gnu/store/@dots{}-foo>
874e6874
LC
3799@end lisp
3800
21b679f6
LC
3801As can be guessed, this primitive is cumbersome to use directly. A
3802better approach is to write build scripts in Scheme, of course! The
3803best course of action for that is to write the build code as a
3804``G-expression'', and to pass it to @code{gexp->derivation}. For more
6621cdb6 3805information, @pxref{G-Expressions}.
21b679f6 3806
f2fadbc1
AE
3807Once upon a time, @code{gexp->derivation} did not exist and constructing
3808derivations with build code written in Scheme was achieved with
3809@code{build-expression->derivation}, documented below. This procedure
3810is now deprecated in favor of the much nicer @code{gexp->derivation}.
3811
3812@deffn {Scheme Procedure} build-expression->derivation @var{store} @
3813 @var{name} @var{exp} @
3814 [#:system (%current-system)] [#:inputs '()] @
3815 [#:outputs '("out")] [#:hash #f] [#:hash-algo #f] @
3816 [#:recursive? #f] [#:env-vars '()] [#:modules '()] @
3817 [#:references-graphs #f] [#:allowed-references #f] @
35b5ca78 3818 [#:disallowed-references #f] @
f2fadbc1
AE
3819 [#:local-build? #f] [#:substitutable? #t] [#:guile-for-build #f]
3820Return a derivation that executes Scheme expression @var{exp} as a
3821builder for derivation @var{name}. @var{inputs} must be a list of
3822@code{(name drv-path sub-drv)} tuples; when @var{sub-drv} is omitted,
3823@code{"out"} is assumed. @var{modules} is a list of names of Guile
3824modules from the current search path to be copied in the store,
3825compiled, and made available in the load path during the execution of
3826@var{exp}---e.g., @code{((guix build utils) (guix build
3827gnu-build-system))}.
3828
3829@var{exp} is evaluated in an environment where @code{%outputs} is bound
3830to a list of output/path pairs, and where @code{%build-inputs} is bound
3831to a list of string/output-path pairs made from @var{inputs}.
3832Optionally, @var{env-vars} is a list of string pairs specifying the name
3833and value of environment variables visible to the builder. The builder
3834terminates by passing the result of @var{exp} to @code{exit}; thus, when
3835@var{exp} returns @code{#f}, the build is considered to have failed.
3836
3837@var{exp} is built using @var{guile-for-build} (a derivation). When
3838@var{guile-for-build} is omitted or is @code{#f}, the value of the
3839@code{%guile-for-build} fluid is used instead.
3840
3841See the @code{derivation} procedure for the meaning of
35b5ca78
LC
3842@var{references-graphs}, @var{allowed-references},
3843@var{disallowed-references}, @var{local-build?}, and
3844@var{substitutable?}.
f2fadbc1
AE
3845@end deffn
3846
3847@noindent
3848Here's an example of a single-output derivation that creates a directory
3849containing one file:
3850
3851@lisp
3852(let ((builder '(let ((out (assoc-ref %outputs "out")))
3853 (mkdir out) ; create /gnu/store/@dots{}-goo
3854 (call-with-output-file (string-append out "/test")
3855 (lambda (p)
3856 (display '(hello guix) p))))))
3857 (build-expression->derivation store "goo" builder))
3858
3859@result{} #<derivation /gnu/store/@dots{}-goo.drv => @dots{}>
3860@end lisp
3861
568717fd 3862
b860f382
LC
3863@node The Store Monad
3864@section The Store Monad
3865
3866@cindex monad
3867
3868The procedures that operate on the store described in the previous
3869sections all take an open connection to the build daemon as their first
3870argument. Although the underlying model is functional, they either have
3871side effects or depend on the current state of the store.
3872
3873The former is inconvenient: the connection to the build daemon has to be
3874carried around in all those functions, making it impossible to compose
3875functions that do not take that parameter with functions that do. The
3876latter can be problematic: since store operations have side effects
3877and/or depend on external state, they have to be properly sequenced.
3878
3879@cindex monadic values
3880@cindex monadic functions
3881This is where the @code{(guix monads)} module comes in. This module
3882provides a framework for working with @dfn{monads}, and a particularly
3883useful monad for our uses, the @dfn{store monad}. Monads are a
3884construct that allows two things: associating ``context'' with values
3885(in our case, the context is the store), and building sequences of
4827b36d 3886computations (here computations include accesses to the store). Values
b860f382
LC
3887in a monad---values that carry this additional context---are called
3888@dfn{monadic values}; procedures that return such values are called
3889@dfn{monadic procedures}.
3890
3891Consider this ``normal'' procedure:
3892
3893@example
45adbd62
LC
3894(define (sh-symlink store)
3895 ;; Return a derivation that symlinks the 'bash' executable.
3896 (let* ((drv (package-derivation store bash))
3897 (out (derivation->output-path drv))
3898 (sh (string-append out "/bin/bash")))
3899 (build-expression->derivation store "sh"
3900 `(symlink ,sh %output))))
b860f382
LC
3901@end example
3902
c6f30b81
LC
3903Using @code{(guix monads)} and @code{(guix gexp)}, it may be rewritten
3904as a monadic function:
b860f382
LC
3905
3906@example
45adbd62 3907(define (sh-symlink)
b860f382 3908 ;; Same, but return a monadic value.
c6f30b81
LC
3909 (mlet %store-monad ((drv (package->derivation bash)))
3910 (gexp->derivation "sh"
3911 #~(symlink (string-append #$drv "/bin/bash")
3912 #$output))))
b860f382
LC
3913@end example
3914
4827b36d 3915There are several things to note in the second version: the @code{store}
c6f30b81
LC
3916parameter is now implicit and is ``threaded'' in the calls to the
3917@code{package->derivation} and @code{gexp->derivation} monadic
3918procedures, and the monadic value returned by @code{package->derivation}
3919is @dfn{bound} using @code{mlet} instead of plain @code{let}.
3920
3921As it turns out, the call to @code{package->derivation} can even be
3922omitted since it will take place implicitly, as we will see later
3923(@pxref{G-Expressions}):
3924
3925@example
3926(define (sh-symlink)
3927 (gexp->derivation "sh"
3928 #~(symlink (string-append #$bash "/bin/bash")
3929 #$output)))
3930@end example
b860f382 3931
7ce21611 3932@c See
a01ad638 3933@c <https://syntaxexclamation.wordpress.com/2014/06/26/escaping-continuations/>
7ce21611
LC
3934@c for the funny quote.
3935Calling the monadic @code{sh-symlink} has no effect. As someone once
3936said, ``you exit a monad like you exit a building on fire: by running''.
3937So, to exit the monad and get the desired effect, one must use
3938@code{run-with-store}:
b860f382
LC
3939
3940@example
8e9aa37f
CAW
3941(run-with-store (open-connection) (sh-symlink))
3942@result{} /gnu/store/...-sh-symlink
b860f382
LC
3943@end example
3944
f97c9175 3945Note that the @code{(guix monad-repl)} module extends the Guile REPL with
b9b86078 3946new ``meta-commands'' to make it easier to deal with monadic procedures:
f97c9175 3947@code{run-in-store}, and @code{enter-store-monad}. The former is used
b9b86078
LC
3948to ``run'' a single monadic value through the store:
3949
3950@example
3951scheme@@(guile-user)> ,run-in-store (package->derivation hello)
3952$1 = #<derivation /gnu/store/@dots{}-hello-2.9.drv => @dots{}>
3953@end example
3954
3955The latter enters a recursive REPL, where all the return values are
3956automatically run through the store:
3957
3958@example
3959scheme@@(guile-user)> ,enter-store-monad
3960store-monad@@(guile-user) [1]> (package->derivation hello)
3961$2 = #<derivation /gnu/store/@dots{}-hello-2.9.drv => @dots{}>
3962store-monad@@(guile-user) [1]> (text-file "foo" "Hello!")
3963$3 = "/gnu/store/@dots{}-foo"
3964store-monad@@(guile-user) [1]> ,q
3965scheme@@(guile-user)>
3966@end example
3967
3968@noindent
3969Note that non-monadic values cannot be returned in the
3970@code{store-monad} REPL.
3971
e87f0591
LC
3972The main syntactic forms to deal with monads in general are provided by
3973the @code{(guix monads)} module and are described below.
b860f382
LC
3974
3975@deffn {Scheme Syntax} with-monad @var{monad} @var{body} ...
3976Evaluate any @code{>>=} or @code{return} forms in @var{body} as being
3977in @var{monad}.
3978@end deffn
3979
3980@deffn {Scheme Syntax} return @var{val}
3981Return a monadic value that encapsulates @var{val}.
3982@end deffn
3983
751630c9 3984@deffn {Scheme Syntax} >>= @var{mval} @var{mproc} ...
b860f382 3985@dfn{Bind} monadic value @var{mval}, passing its ``contents'' to monadic
751630c9
LC
3986procedures @var{mproc}@dots{}@footnote{This operation is commonly
3987referred to as ``bind'', but that name denotes an unrelated procedure in
3988Guile. Thus we use this somewhat cryptic symbol inherited from the
3989Haskell language.}. There can be one @var{mproc} or several of them, as
3990in this example:
3991
3992@example
3993(run-with-state
3994 (with-monad %state-monad
3995 (>>= (return 1)
3996 (lambda (x) (return (+ 1 x)))
3997 (lambda (x) (return (* 2 x)))))
3998 'some-state)
3999
4000@result{} 4
4001@result{} some-state
4002@end example
b860f382
LC
4003@end deffn
4004
4005@deffn {Scheme Syntax} mlet @var{monad} ((@var{var} @var{mval}) ...) @
4006 @var{body} ...
4007@deffnx {Scheme Syntax} mlet* @var{monad} ((@var{var} @var{mval}) ...) @
4008 @var{body} ...
4009Bind the variables @var{var} to the monadic values @var{mval} in
4010@var{body}. The form (@var{var} -> @var{val}) binds @var{var} to the
4011``normal'' value @var{val}, as per @code{let}.
4012
4013@code{mlet*} is to @code{mlet} what @code{let*} is to @code{let}
4014(@pxref{Local Bindings,,, guile, GNU Guile Reference Manual}).
4015@end deffn
4016
405a9d4e
LC
4017@deffn {Scheme System} mbegin @var{monad} @var{mexp} ...
4018Bind @var{mexp} and the following monadic expressions in sequence,
4019returning the result of the last expression.
4020
4021This is akin to @code{mlet}, except that the return values of the
4022monadic expressions are ignored. In that sense, it is analogous to
4023@code{begin}, but applied to monadic expressions.
4024@end deffn
4025
561fb6c3
LC
4026@cindex state monad
4027The @code{(guix monads)} module provides the @dfn{state monad}, which
4028allows an additional value---the state---to be @emph{threaded} through
4029monadic procedure calls.
4030
4031@defvr {Scheme Variable} %state-monad
4032The state monad. Procedures in the state monad can access and change
4033the state that is threaded.
4034
4035Consider the example below. The @code{square} procedure returns a value
4036in the state monad. It returns the square of its argument, but also
4037increments the current state value:
4038
4039@example
4040(define (square x)
4041 (mlet %state-monad ((count (current-state)))
4042 (mbegin %state-monad
4043 (set-current-state (+ 1 count))
4044 (return (* x x)))))
4045
4046(run-with-state (sequence %state-monad (map square (iota 3))) 0)
4047@result{} (0 1 4)
4048@result{} 3
4049@end example
4050
4051When ``run'' through @var{%state-monad}, we obtain that additional state
4052value, which is the number of @code{square} calls.
4053@end defvr
4054
4055@deffn {Monadic Procedure} current-state
4056Return the current state as a monadic value.
4057@end deffn
4058
4059@deffn {Monadic Procedure} set-current-state @var{value}
4060Set the current state to @var{value} and return the previous state as a
4061monadic value.
4062@end deffn
4063
4064@deffn {Monadic Procedure} state-push @var{value}
4065Push @var{value} to the current state, which is assumed to be a list,
4066and return the previous state as a monadic value.
4067@end deffn
4068
4069@deffn {Monadic Procedure} state-pop
4070Pop a value from the current state and return it as a monadic value.
4071The state is assumed to be a list.
4072@end deffn
4073
4074@deffn {Scheme Procedure} run-with-state @var{mval} [@var{state}]
4075Run monadic value @var{mval} starting with @var{state} as the initial
4076state. Return two values: the resulting value, and the resulting state.
4077@end deffn
4078
e87f0591
LC
4079The main interface to the store monad, provided by the @code{(guix
4080store)} module, is as follows.
b860f382
LC
4081
4082@defvr {Scheme Variable} %store-monad
561fb6c3
LC
4083The store monad---an alias for @var{%state-monad}.
4084
4085Values in the store monad encapsulate accesses to the store. When its
4086effect is needed, a value of the store monad must be ``evaluated'' by
4087passing it to the @code{run-with-store} procedure (see below.)
b860f382
LC
4088@end defvr
4089
4090@deffn {Scheme Procedure} run-with-store @var{store} @var{mval} [#:guile-for-build] [#:system (%current-system)]
4091Run @var{mval}, a monadic value in the store monad, in @var{store}, an
4092open store connection.
4093@end deffn
4094
ad372953 4095@deffn {Monadic Procedure} text-file @var{name} @var{text} [@var{references}]
b860f382 4096Return as a monadic value the absolute file name in the store of the file
ad372953
LC
4097containing @var{text}, a string. @var{references} is a list of store items that the
4098resulting text file refers to; it defaults to the empty list.
45adbd62
LC
4099@end deffn
4100
0a90af15 4101@deffn {Monadic Procedure} interned-file @var{file} [@var{name}] @
1ec32f4a 4102 [#:recursive? #t] [#:select? (const #t)]
0a90af15
LC
4103Return the name of @var{file} once interned in the store. Use
4104@var{name} as its store name, or the basename of @var{file} if
4105@var{name} is omitted.
4106
4107When @var{recursive?} is true, the contents of @var{file} are added
4108recursively; if @var{file} designates a flat file and @var{recursive?}
4109is true, its contents are added, and its permission bits are kept.
4110
1ec32f4a
LC
4111When @var{recursive?} is true, call @code{(@var{select?} @var{file}
4112@var{stat})} for each directory entry, where @var{file} is the entry's
4113absolute file name and @var{stat} is the result of @code{lstat}; exclude
4114entries for which @var{select?} does not return true.
4115
0a90af15
LC
4116The example below adds a file to the store, under two different names:
4117
4118@example
4119(run-with-store (open-connection)
4120 (mlet %store-monad ((a (interned-file "README"))
4121 (b (interned-file "README" "LEGU-MIN")))
4122 (return (list a b))))
4123
4124@result{} ("/gnu/store/rwm@dots{}-README" "/gnu/store/44i@dots{}-LEGU-MIN")
4125@end example
4126
4127@end deffn
4128
e87f0591
LC
4129The @code{(guix packages)} module exports the following package-related
4130monadic procedures:
4131
b860f382 4132@deffn {Monadic Procedure} package-file @var{package} [@var{file}] @
4231f05b 4133 [#:system (%current-system)] [#:target #f] @
f97c9175
AE
4134 [#:output "out"]
4135Return as a monadic
b860f382
LC
4136value in the absolute file name of @var{file} within the @var{output}
4137directory of @var{package}. When @var{file} is omitted, return the name
4231f05b
LC
4138of the @var{output} directory of @var{package}. When @var{target} is
4139true, use it as a cross-compilation target triplet.
b860f382
LC
4140@end deffn
4141
b860f382 4142@deffn {Monadic Procedure} package->derivation @var{package} [@var{system}]
4231f05b
LC
4143@deffnx {Monadic Procedure} package->cross-derivation @var{package} @
4144 @var{target} [@var{system}]
4145Monadic version of @code{package-derivation} and
4146@code{package-cross-derivation} (@pxref{Defining Packages}).
b860f382
LC
4147@end deffn
4148
4149
21b679f6
LC
4150@node G-Expressions
4151@section G-Expressions
4152
4153@cindex G-expression
4154@cindex build code quoting
4155So we have ``derivations'', which represent a sequence of build actions
4156to be performed to produce an item in the store (@pxref{Derivations}).
f97c9175 4157These build actions are performed when asking the daemon to actually
21b679f6
LC
4158build the derivations; they are run by the daemon in a container
4159(@pxref{Invoking guix-daemon}).
4160
4161@cindex strata of code
f97c9175 4162It should come as no surprise that we like to write these build actions
21b679f6
LC
4163in Scheme. When we do that, we end up with two @dfn{strata} of Scheme
4164code@footnote{The term @dfn{stratum} in this context was coined by
ef4ab0a4
LC
4165Manuel Serrano et al.@: in the context of their work on Hop. Oleg
4166Kiselyov, who has written insightful
4167@url{http://okmij.org/ftp/meta-programming/#meta-scheme, essays and code
4168on this topic}, refers to this kind of code generation as
4169@dfn{staging}.}: the ``host code''---code that defines packages, talks
4170to the daemon, etc.---and the ``build code''---code that actually
4171performs build actions, such as making directories, invoking
4172@command{make}, etc.
21b679f6
LC
4173
4174To describe a derivation and its build actions, one typically needs to
4175embed build code inside host code. It boils down to manipulating build
f97c9175 4176code as data, and the homoiconicity of Scheme---code has a direct
21b679f6 4177representation as data---comes in handy for that. But we need more than
f97c9175 4178the normal @code{quasiquote} mechanism in Scheme to construct build
21b679f6
LC
4179expressions.
4180
4181The @code{(guix gexp)} module implements @dfn{G-expressions}, a form of
4182S-expressions adapted to build expressions. G-expressions, or
f97c9175 4183@dfn{gexps}, consist essentially of three syntactic forms: @code{gexp},
21b679f6 4184@code{ungexp}, and @code{ungexp-splicing} (or simply: @code{#~},
f97c9175
AE
4185@code{#$}, and @code{#$@@}), which are comparable to
4186@code{quasiquote}, @code{unquote}, and @code{unquote-splicing},
4827b36d 4187respectively (@pxref{Expression Syntax, @code{quasiquote},, guile,
f97c9175 4188GNU Guile Reference Manual}). However, there are major differences:
21b679f6
LC
4189
4190@itemize
4191@item
4192Gexps are meant to be written to a file and run or manipulated by other
4193processes.
4194
4195@item
b39fc6f7
LC
4196When a high-level object such as a package or derivation is unquoted
4197inside a gexp, the result is as if its output file name had been
4198introduced.
ff40e9b7 4199
21b679f6
LC
4200@item
4201Gexps carry information about the packages or derivations they refer to,
4202and these dependencies are automatically added as inputs to the build
4203processes that use them.
4204@end itemize
4205
c2b84676 4206@cindex lowering, of high-level objects in gexps
343eacbe
LC
4207This mechanism is not limited to package and derivation
4208objects: @dfn{compilers} able to ``lower'' other high-level objects to
c2b84676
LC
4209derivations or files in the store can be defined,
4210such that these objects can also be inserted
f97c9175 4211into gexps. For example, a useful type of high-level objects that can be
343eacbe 4212inserted in a gexp is ``file-like objects'', which make it easy to
f97c9175 4213add files to the store and to refer to them in
558e8b11
LC
4214derivations and such (see @code{local-file} and @code{plain-file}
4215below.)
b39fc6f7 4216
21b679f6
LC
4217To illustrate the idea, here is an example of a gexp:
4218
4219@example
4220(define build-exp
4221 #~(begin
4222 (mkdir #$output)
4223 (chdir #$output)
aff8ce7c 4224 (symlink (string-append #$coreutils "/bin/ls")
21b679f6
LC
4225 "list-files")))
4226@end example
4227
4228This gexp can be passed to @code{gexp->derivation}; we obtain a
4229derivation that builds a directory containing exactly one symlink to
4230@file{/gnu/store/@dots{}-coreutils-8.22/bin/ls}:
4231
4232@example
4233(gexp->derivation "the-thing" build-exp)
4234@end example
4235
e20fd1bf 4236As one would expect, the @code{"/gnu/store/@dots{}-coreutils-8.22"} string is
21b679f6
LC
4237substituted to the reference to the @var{coreutils} package in the
4238actual build code, and @var{coreutils} is automatically made an input to
4239the derivation. Likewise, @code{#$output} (equivalent to @code{(ungexp
f97c9175
AE
4240output)}) is replaced by a string containing the directory name of the
4241output of the derivation.
667b2508
LC
4242
4243@cindex cross compilation
4244In a cross-compilation context, it is useful to distinguish between
4245references to the @emph{native} build of a package---that can run on the
4246host---versus references to cross builds of a package. To that end, the
4247@code{#+} plays the same role as @code{#$}, but is a reference to a
4248native package build:
4249
4250@example
4251(gexp->derivation "vi"
4252 #~(begin
4253 (mkdir #$output)
4254 (system* (string-append #+coreutils "/bin/ln")
4255 "-s"
4256 (string-append #$emacs "/bin/emacs")
4257 (string-append #$output "/bin/vi")))
4a3b6aa5 4258 #:target "mips64el-linux-gnu")
667b2508
LC
4259@end example
4260
4261@noindent
4262In the example above, the native build of @var{coreutils} is used, so
4263that @command{ln} can actually run on the host; but then the
4264cross-compiled build of @var{emacs} is referenced.
4265
0bb9929e
LC
4266@cindex imported modules, for gexps
4267@findex with-imported-modules
4268Another gexp feature is @dfn{imported modules}: sometimes you want to be
4269able to use certain Guile modules from the ``host environment'' in the
4270gexp, so those modules should be imported in the ``build environment''.
4271The @code{with-imported-modules} form allows you to express that:
4272
4273@example
4274(let ((build (with-imported-modules '((guix build utils))
4275 #~(begin
4276 (use-modules (guix build utils))
4277 (mkdir-p (string-append #$output "/bin"))))))
4278 (gexp->derivation "empty-dir"
4279 #~(begin
4280 #$build
4281 (display "success!\n")
4282 #t)))
4283@end example
4284
4285@noindent
4286In this example, the @code{(guix build utils)} module is automatically
4287pulled into the isolated build environment of our gexp, such that
4288@code{(use-modules (guix build utils))} works as expected.
4289
7ca87354
LC
4290@cindex module closure
4291@findex source-module-closure
4292Usually you want the @emph{closure} of the module to be imported---i.e.,
4293the module itself and all the modules it depends on---rather than just
4294the module; failing to do that, attempts to use the module will fail
4295because of missing dependent modules. The @code{source-module-closure}
4296procedure computes the closure of a module by looking at its source file
4297headers, which comes in handy in this case:
4298
4299@example
4300(use-modules (guix modules)) ;for 'source-module-closure'
4301
4302(with-imported-modules (source-module-closure
4303 '((guix build utils)
4304 (gnu build vm)))
4305 (gexp->derivation "something-with-vms"
4306 #~(begin
4307 (use-modules (guix build utils)
4308 (gnu build vm))
4309 @dots{})))
4310@end example
4311
667b2508 4312The syntactic form to construct gexps is summarized below.
21b679f6
LC
4313
4314@deffn {Scheme Syntax} #~@var{exp}
4315@deffnx {Scheme Syntax} (gexp @var{exp})
4316Return a G-expression containing @var{exp}. @var{exp} may contain one
4317or more of the following forms:
4318
4319@table @code
4320@item #$@var{obj}
4321@itemx (ungexp @var{obj})
b39fc6f7
LC
4322Introduce a reference to @var{obj}. @var{obj} may have one of the
4323supported types, for example a package or a
21b679f6
LC
4324derivation, in which case the @code{ungexp} form is replaced by its
4325output file name---e.g., @code{"/gnu/store/@dots{}-coreutils-8.22}.
4326
b39fc6f7
LC
4327If @var{obj} is a list, it is traversed and references to supported
4328objects are substituted similarly.
21b679f6
LC
4329
4330If @var{obj} is another gexp, its contents are inserted and its
4331dependencies are added to those of the containing gexp.
4332
4333If @var{obj} is another kind of object, it is inserted as is.
4334
b39fc6f7
LC
4335@item #$@var{obj}:@var{output}
4336@itemx (ungexp @var{obj} @var{output})
21b679f6 4337This is like the form above, but referring explicitly to the
b39fc6f7
LC
4338@var{output} of @var{obj}---this is useful when @var{obj} produces
4339multiple outputs (@pxref{Packages with Multiple Outputs}).
21b679f6 4340
667b2508
LC
4341@item #+@var{obj}
4342@itemx #+@var{obj}:output
4343@itemx (ungexp-native @var{obj})
4344@itemx (ungexp-native @var{obj} @var{output})
4345Same as @code{ungexp}, but produces a reference to the @emph{native}
4346build of @var{obj} when used in a cross compilation context.
4347
21b679f6
LC
4348@item #$output[:@var{output}]
4349@itemx (ungexp output [@var{output}])
4350Insert a reference to derivation output @var{output}, or to the main
4351output when @var{output} is omitted.
4352
4353This only makes sense for gexps passed to @code{gexp->derivation}.
4354
4355@item #$@@@var{lst}
4356@itemx (ungexp-splicing @var{lst})
4357Like the above, but splices the contents of @var{lst} inside the
4358containing list.
4359
667b2508
LC
4360@item #+@@@var{lst}
4361@itemx (ungexp-native-splicing @var{lst})
4362Like the above, but refers to native builds of the objects listed in
4363@var{lst}.
4364
21b679f6
LC
4365@end table
4366
4367G-expressions created by @code{gexp} or @code{#~} are run-time objects
4368of the @code{gexp?} type (see below.)
4369@end deffn
4370
0bb9929e
LC
4371@deffn {Scheme Syntax} with-imported-modules @var{modules} @var{body}@dots{}
4372Mark the gexps defined in @var{body}@dots{} as requiring @var{modules}
d938a58b
LC
4373in their execution environment.
4374
4375Each item in @var{modules} can be the name of a module, such as
4376@code{(guix build utils)}, or it can be a module name, followed by an
4377arrow, followed by a file-like object:
4378
4379@example
4380`((guix build utils)
4381 (guix gcrypt)
4382 ((guix config) => ,(scheme-file "config.scm"
4383 #~(define-module @dots{}))))
4384@end example
4385
4386@noindent
4387In the example above, the first two modules are taken from the search
4388path, and the last one is created from the given file-like object.
0bb9929e
LC
4389
4390This form has @emph{lexical} scope: it has an effect on the gexps
4391directly defined in @var{body}@dots{}, but not on those defined, say, in
4392procedures called from @var{body}@dots{}.
4393@end deffn
4394
21b679f6
LC
4395@deffn {Scheme Procedure} gexp? @var{obj}
4396Return @code{#t} if @var{obj} is a G-expression.
4397@end deffn
4398
4399G-expressions are meant to be written to disk, either as code building
4400some derivation, or as plain files in the store. The monadic procedures
4401below allow you to do that (@pxref{The Store Monad}, for more
4402information about monads.)
4403
4404@deffn {Monadic Procedure} gexp->derivation @var{name} @var{exp} @
ce45eb4c 4405 [#:system (%current-system)] [#:target #f] [#:graft? #t] @
21b679f6
LC
4406 [#:hash #f] [#:hash-algo #f] @
4407 [#:recursive? #f] [#:env-vars '()] [#:modules '()] @
4684f301 4408 [#:module-path @var{%load-path}] @
c8351d9a 4409 [#:references-graphs #f] [#:allowed-references #f] @
3f4ecf32 4410 [#:disallowed-references #f] @
c0468155 4411 [#:leaked-env-vars #f] @
0309e1b0 4412 [#:script-name (string-append @var{name} "-builder")] @
4a6aeb67 4413 [#:local-build? #f] [#:substitutable? #t] [#:guile-for-build #f]
21b679f6 4414Return a derivation @var{name} that runs @var{exp} (a gexp) with
0309e1b0
LC
4415@var{guile-for-build} (a derivation) on @var{system}; @var{exp} is
4416stored in a file called @var{script-name}. When @var{target} is true,
4417it is used as the cross-compilation target triplet for packages referred
4418to by @var{exp}.
21b679f6 4419
0bb9929e
LC
4420@var{modules} is deprecated in favor of @code{with-imported-modules}.
4421Its meaning is to
4422make @var{modules} available in the evaluation context of @var{exp};
ce45eb4c
LC
4423@var{modules} is a list of names of Guile modules searched in
4424@var{module-path} to be copied in the store, compiled, and made available in
21b679f6
LC
4425the load path during the execution of @var{exp}---e.g., @code{((guix
4426build utils) (guix build gnu-build-system))}.
4427
ce45eb4c
LC
4428@var{graft?} determines whether packages referred to by @var{exp} should be grafted when
4429applicable.
4430
b53833b2
LC
4431When @var{references-graphs} is true, it must be a list of tuples of one of the
4432following forms:
4433
4434@example
4435(@var{file-name} @var{package})
4436(@var{file-name} @var{package} @var{output})
4437(@var{file-name} @var{derivation})
4438(@var{file-name} @var{derivation} @var{output})
4439(@var{file-name} @var{store-item})
4440@end example
4441
4442The right-hand-side of each element of @var{references-graphs} is automatically made
4443an input of the build process of @var{exp}. In the build environment, each
4444@var{file-name} contains the reference graph of the corresponding item, in a simple
4445text format.
4446
c8351d9a
LC
4447@var{allowed-references} must be either @code{#f} or a list of output names and packages.
4448In the latter case, the list denotes store items that the result is allowed to
4449refer to. Any reference to another store item will lead to a build error.
3f4ecf32
LC
4450Similarly for @var{disallowed-references}, which can list items that must not be
4451referenced by the outputs.
c8351d9a 4452
e20fd1bf 4453The other arguments are as for @code{derivation} (@pxref{Derivations}).
21b679f6
LC
4454@end deffn
4455
343eacbe 4456@cindex file-like objects
e1c153e0
LC
4457The @code{local-file}, @code{plain-file}, @code{computed-file},
4458@code{program-file}, and @code{scheme-file} procedures below return
4459@dfn{file-like objects}. That is, when unquoted in a G-expression,
4460these objects lead to a file in the store. Consider this G-expression:
343eacbe
LC
4461
4462@example
a9e5e92f 4463#~(system* #$(file-append glibc "/sbin/nscd") "-f"
343eacbe
LC
4464 #$(local-file "/tmp/my-nscd.conf"))
4465@end example
4466
4467The effect here is to ``intern'' @file{/tmp/my-nscd.conf} by copying it
4468to the store. Once expanded, for instance @i{via}
4469@code{gexp->derivation}, the G-expression refers to that copy under
4470@file{/gnu/store}; thus, modifying or removing the file in @file{/tmp}
4471does not have any effect on what the G-expression does.
4472@code{plain-file} can be used similarly; it differs in that the file
4473content is directly passed as a string.
4474
d9ae938f 4475@deffn {Scheme Procedure} local-file @var{file} [@var{name}] @
0687fc9c 4476 [#:recursive? #f] [#:select? (const #t)]
d9ae938f 4477Return an object representing local file @var{file} to add to the store; this
9d3994f7
LC
4478object can be used in a gexp. If @var{file} is a relative file name, it is looked
4479up relative to the source file where this form appears. @var{file} will be added to
4480the store under @var{name}--by default the base name of @var{file}.
d9ae938f
LC
4481
4482When @var{recursive?} is true, the contents of @var{file} are added recursively; if @var{file}
4483designates a flat file and @var{recursive?} is true, its contents are added, and its
4484permission bits are kept.
4485
0687fc9c
LC
4486When @var{recursive?} is true, call @code{(@var{select?} @var{file}
4487@var{stat})} for each directory entry, where @var{file} is the entry's
4488absolute file name and @var{stat} is the result of @code{lstat}; exclude
4489entries for which @var{select?} does not return true.
4490
d9ae938f
LC
4491This is the declarative counterpart of the @code{interned-file} monadic
4492procedure (@pxref{The Store Monad, @code{interned-file}}).
4493@end deffn
4494
558e8b11
LC
4495@deffn {Scheme Procedure} plain-file @var{name} @var{content}
4496Return an object representing a text file called @var{name} with the given
4497@var{content} (a string) to be added to the store.
4498
4499This is the declarative counterpart of @code{text-file}.
4500@end deffn
4501
91937029 4502@deffn {Scheme Procedure} computed-file @var{name} @var{gexp} @
a769bffb 4503 [#:options '(#:local-build? #t)]
91937029 4504Return an object representing the store item @var{name}, a file or
a769bffb 4505directory computed by @var{gexp}. @var{options}
91937029
LC
4506is a list of additional arguments to pass to @code{gexp->derivation}.
4507
4508This is the declarative counterpart of @code{gexp->derivation}.
4509@end deffn
4510
21b679f6
LC
4511@deffn {Monadic Procedure} gexp->script @var{name} @var{exp}
4512Return an executable script @var{name} that runs @var{exp} using
9c14a487 4513@var{guile}, with @var{exp}'s imported modules in its search path.
21b679f6
LC
4514
4515The example below builds a script that simply invokes the @command{ls}
4516command:
4517
4518@example
4519(use-modules (guix gexp) (gnu packages base))
4520
4521(gexp->script "list-files"
a9e5e92f 4522 #~(execl #$(file-append coreutils "/bin/ls")
21b679f6
LC
4523 "ls"))
4524@end example
4525
4526When ``running'' it through the store (@pxref{The Store Monad,
e20fd1bf 4527@code{run-with-store}}), we obtain a derivation that produces an
21b679f6
LC
4528executable file @file{/gnu/store/@dots{}-list-files} along these lines:
4529
4530@example
4531#!/gnu/store/@dots{}-guile-2.0.11/bin/guile -ds
4532!#
a9e5e92f 4533(execl "/gnu/store/@dots{}-coreutils-8.22"/bin/ls" "ls")
21b679f6
LC
4534@end example
4535@end deffn
4536
15a01c72 4537@deffn {Scheme Procedure} program-file @var{name} @var{exp} @
9c14a487 4538 [#:guile #f]
15a01c72
LC
4539Return an object representing the executable store item @var{name} that
4540runs @var{gexp}. @var{guile} is the Guile package used to execute that
9c14a487 4541script.
15a01c72
LC
4542
4543This is the declarative counterpart of @code{gexp->script}.
4544@end deffn
4545
2b418579
LC
4546@deffn {Monadic Procedure} gexp->file @var{name} @var{exp} @
4547 [#:set-load-path? #t]
21b679f6 4548Return a derivation that builds a file @var{name} containing @var{exp}.
2b418579
LC
4549When @var{set-load-path?} is true, emit code in the resulting file to
4550set @code{%load-path} and @code{%load-compiled-path} to honor
4551@var{exp}'s imported modules.
21b679f6
LC
4552
4553The resulting file holds references to all the dependencies of @var{exp}
4554or a subset thereof.
4555@end deffn
1ed19464 4556
e1c153e0
LC
4557@deffn {Scheme Procedure} scheme-file @var{name} @var{exp}
4558Return an object representing the Scheme file @var{name} that contains
4559@var{exp}.
4560
4561This is the declarative counterpart of @code{gexp->file}.
4562@end deffn
4563
1ed19464
LC
4564@deffn {Monadic Procedure} text-file* @var{name} @var{text} @dots{}
4565Return as a monadic value a derivation that builds a text file
4566containing all of @var{text}. @var{text} may list, in addition to
d9ae938f
LC
4567strings, objects of any type that can be used in a gexp: packages,
4568derivations, local file objects, etc. The resulting store file holds
4569references to all these.
1ed19464
LC
4570
4571This variant should be preferred over @code{text-file} anytime the file
4572to create will reference items from the store. This is typically the
4573case when building a configuration file that embeds store file names,
4574like this:
4575
4576@example
4577(define (profile.sh)
4578 ;; Return the name of a shell script in the store that
4579 ;; initializes the 'PATH' environment variable.
4580 (text-file* "profile.sh"
4581 "export PATH=" coreutils "/bin:"
4582 grep "/bin:" sed "/bin\n"))
4583@end example
4584
4585In this example, the resulting @file{/gnu/store/@dots{}-profile.sh} file
b7899749 4586will reference @var{coreutils}, @var{grep}, and @var{sed}, thereby
1ed19464
LC
4587preventing them from being garbage-collected during its lifetime.
4588@end deffn
21b679f6 4589
b751cde3
LC
4590@deffn {Scheme Procedure} mixed-text-file @var{name} @var{text} @dots{}
4591Return an object representing store file @var{name} containing
4592@var{text}. @var{text} is a sequence of strings and file-like objects,
4593as in:
4594
4595@example
4596(mixed-text-file "profile"
4597 "export PATH=" coreutils "/bin:" grep "/bin")
4598@end example
4599
4600This is the declarative counterpart of @code{text-file*}.
4601@end deffn
4602
a9e5e92f
LC
4603@deffn {Scheme Procedure} file-append @var{obj} @var{suffix} @dots{}
4604Return a file-like object that expands to the concatenation of @var{obj}
4605and @var{suffix}, where @var{obj} is a lowerable object and each
4606@var{suffix} is a string.
4607
4608As an example, consider this gexp:
4609
4610@example
4611(gexp->script "run-uname"
4612 #~(system* #$(file-append coreutils
4613 "/bin/uname")))
4614@end example
4615
4616The same effect could be achieved with:
4617
4618@example
4619(gexp->script "run-uname"
4620 #~(system* (string-append #$coreutils
4621 "/bin/uname")))
4622@end example
4623
4624There is one difference though: in the @code{file-append} case, the
4625resulting script contains the absolute file name as a string, whereas in
4626the second case, the resulting script contains a @code{(string-append
4627@dots{})} expression to construct the file name @emph{at run time}.
4628@end deffn
4629
4630
21b679f6
LC
4631Of course, in addition to gexps embedded in ``host'' code, there are
4632also modules containing build tools. To make it clear that they are
4633meant to be used in the build stratum, these modules are kept in the
4634@code{(guix build @dots{})} name space.
4635
c2b84676
LC
4636@cindex lowering, of high-level objects in gexps
4637Internally, high-level objects are @dfn{lowered}, using their compiler,
4638to either derivations or store items. For instance, lowering a package
4639yields a derivation, and lowering a @code{plain-file} yields a store
4640item. This is achieved using the @code{lower-object} monadic procedure.
4641
4642@deffn {Monadic Procedure} lower-object @var{obj} [@var{system}] @
4643 [#:target #f]
4644Return as a value in @var{%store-monad} the derivation or store item
4645corresponding to @var{obj} for @var{system}, cross-compiling for
4646@var{target} if @var{target} is true. @var{obj} must be an object that
4647has an associated gexp compiler, such as a @code{<package>}.
4648@end deffn
4649
21b679f6 4650
568717fd
LC
4651@c *********************************************************************
4652@node Utilities
4653@chapter Utilities
4654
6f773606
LC
4655This section describes Guix command-line utilities. Some of them are
4656primarily targeted at developers and users who write new package
4657definitions, while others are more generally useful. They complement
4658the Scheme programming interface of Guix in a convenient way.
210cc920 4659
568717fd 4660@menu
37166310 4661* Invoking guix build:: Building packages from the command line.
39bee8a2 4662* Invoking guix edit:: Editing package definitions.
210cc920 4663* Invoking guix download:: Downloading a file and printing its hash.
37166310 4664* Invoking guix hash:: Computing the cryptographic hash of a file.
2f7d2d91 4665* Invoking guix import:: Importing package definitions.
37166310 4666* Invoking guix refresh:: Updating package definitions.
b4f5e0e8 4667* Invoking guix lint:: Finding errors in package definitions.
fcc58db6 4668* Invoking guix size:: Profiling disk usage.
88856916 4669* Invoking guix graph:: Visualizing the graph of packages.
372c4bbc 4670* Invoking guix environment:: Setting up development environments.
aff8ce7c 4671* Invoking guix publish:: Sharing substitutes.
d23c20f1 4672* Invoking guix challenge:: Challenging substitute servers.
f11c444d 4673* Invoking guix copy:: Copying to and from a remote store.
32efa254 4674* Invoking guix container:: Process isolation.
568717fd
LC
4675@end menu
4676
e49951eb
MW
4677@node Invoking guix build
4678@section Invoking @command{guix build}
568717fd 4679
e32171ee
JD
4680@cindex package building
4681@cindex @command{guix build}
e49951eb 4682The @command{guix build} command builds packages or derivations and
6798a8e4
LC
4683their dependencies, and prints the resulting store paths. Note that it
4684does not modify the user's profile---this is the job of the
e49951eb 4685@command{guix package} command (@pxref{Invoking guix package}). Thus,
6798a8e4
LC
4686it is mainly useful for distribution developers.
4687
4688The general syntax is:
c78bd12b
LC
4689
4690@example
e49951eb 4691guix build @var{options} @var{package-or-derivation}@dots{}
c78bd12b
LC
4692@end example
4693
f97c9175 4694As an example, the following command builds the latest versions of Emacs
ccd7158d
LC
4695and of Guile, displays their build logs, and finally displays the
4696resulting directories:
4697
4698@example
4699guix build emacs guile
4700@end example
4701
4702Similarly, the following command builds all the available packages:
4703
4704@example
5284339d 4705guix build --quiet --keep-going \
ccd7158d
LC
4706 `guix package -A | cut -f1,2 --output-delimiter=@@`
4707@end example
4708
c78bd12b 4709@var{package-or-derivation} may be either the name of a package found in
5401dd75 4710the software distribution such as @code{coreutils} or
e1a65ae5 4711@code{coreutils@@8.20}, or a derivation such as
834129e0 4712@file{/gnu/store/@dots{}-coreutils-8.19.drv}. In the former case, a
e7f34eb0
LC
4713package with the corresponding name (and optionally version) is searched
4714for among the GNU distribution modules (@pxref{Package Modules}).
4715
4716Alternatively, the @code{--expression} option may be used to specify a
4717Scheme expression that evaluates to a package; this is useful when
b7899749 4718disambiguating among several same-named packages or package variants is
e7f34eb0 4719needed.
c78bd12b 4720
ccd7158d
LC
4721There may be zero or more @var{options}. The available options are
4722described in the subsections below.
4723
4724@menu
4725* Common Build Options:: Build options for most commands.
f11c444d 4726* Package Transformation Options:: Creating variants of packages.
ccd7158d
LC
4727* Additional Build Options:: Options specific to 'guix build'.
4728@end menu
4729
4730@node Common Build Options
4731@subsection Common Build Options
4732
4733A number of options that control the build process are common to
4734@command{guix build} and other commands that can spawn builds, such as
4735@command{guix package} or @command{guix archive}. These are the
4736following:
4737
4738@table @code
4739
4740@item --load-path=@var{directory}
4741@itemx -L @var{directory}
4742Add @var{directory} to the front of the package module search path
4743(@pxref{Package Modules}).
4744
4745This allows users to define their own packages and make them visible to
4746the command-line tools.
4747
4748@item --keep-failed
4749@itemx -K
b7899749 4750Keep the build tree of failed builds. Thus, if a build fails, its build
ccd7158d
LC
4751tree is kept under @file{/tmp}, in a directory whose name is shown at
4752the end of the build log. This is useful when debugging build issues.
4753
4754@item --keep-going
4755@itemx -k
4756Keep going when some of the derivations fail to build; return only once
4757all the builds have either completed or failed.
4758
4759The default behavior is to stop as soon as one of the specified
4760derivations has failed.
4761
4762@item --dry-run
4763@itemx -n
4764Do not build the derivations.
4765
4766@item --fallback
4767When substituting a pre-built binary fails, fall back to building
4768packages locally.
4769
4770@item --substitute-urls=@var{urls}
4771@anchor{client-substitute-urls}
4772Consider @var{urls} the whitespace-separated list of substitute source
4773URLs, overriding the default list of URLs of @command{guix-daemon}
4774(@pxref{daemon-substitute-urls,, @command{guix-daemon} URLs}).
4775
4776This means that substitutes may be downloaded from @var{urls}, provided
4777they are signed by a key authorized by the system administrator
4778(@pxref{Substitutes}).
4779
71e2065a
LC
4780When @var{urls} is the empty string, substitutes are effectively
4781disabled.
4782
ccd7158d
LC
4783@item --no-substitutes
4784Do not use substitutes for build products. That is, always build things
4785locally instead of allowing downloads of pre-built binaries
4786(@pxref{Substitutes}).
4787
7573d30f
LC
4788@item --no-grafts
4789Do not ``graft'' packages. In practice, this means that package updates
4790available as grafts are not applied. @xref{Security Updates}, for more
4791information on grafts.
4792
ccd7158d
LC
4793@item --rounds=@var{n}
4794Build each derivation @var{n} times in a row, and raise an error if
4795consecutive build results are not bit-for-bit identical.
4796
4797This is a useful way to detect non-deterministic builds processes.
4798Non-deterministic build processes are a problem because they make it
4799practically impossible for users to @emph{verify} whether third-party
4800binaries are genuine. @xref{Invoking guix challenge}, for more.
4801
4802Note that, currently, the differing build results are not kept around,
4803so you will have to manually investigate in case of an error---e.g., by
e66d1f59
ML
4804stashing one of the build results with @code{guix archive --export}
4805(@pxref{Invoking guix archive}), then rebuilding, and finally comparing
4806the two results.
ccd7158d
LC
4807
4808@item --no-build-hook
f97c9175 4809Do not attempt to offload builds @i{via} the ``build hook'' of the daemon
ccd7158d
LC
4810(@pxref{Daemon Offload Setup}). That is, always build things locally
4811instead of offloading builds to remote machines.
4812
4813@item --max-silent-time=@var{seconds}
4814When the build or substitution process remains silent for more than
4815@var{seconds}, terminate it and report a build failure.
4816
4817@item --timeout=@var{seconds}
4818Likewise, when the build or substitution process lasts for more than
4819@var{seconds}, terminate it and report a build failure.
4820
4821By default there is no timeout. This behavior can be restored with
4822@code{--timeout=0}.
4823
4824@item --verbosity=@var{level}
4825Use the given verbosity level. @var{level} must be an integer between 0
4826and 5; higher means more verbose output. Setting a level of 4 or more
4827may be helpful when debugging setup issues with the build daemon.
4828
4829@item --cores=@var{n}
4830@itemx -c @var{n}
4831Allow the use of up to @var{n} CPU cores for the build. The special
4832value @code{0} means to use as many CPU cores as available.
4833
4834@item --max-jobs=@var{n}
4835@itemx -M @var{n}
4836Allow at most @var{n} build jobs in parallel. @xref{Invoking
4837guix-daemon, @code{--max-jobs}}, for details about this option and the
4838equivalent @command{guix-daemon} option.
4839
4840@end table
4841
4842Behind the scenes, @command{guix build} is essentially an interface to
4843the @code{package-derivation} procedure of the @code{(guix packages)}
4844module, and to the @code{build-derivations} procedure of the @code{(guix
4845derivations)} module.
4846
4847In addition to options explicitly passed on the command line,
4848@command{guix build} and other @command{guix} commands that support
4849building honor the @code{GUIX_BUILD_OPTIONS} environment variable.
4850
4851@defvr {Environment Variable} GUIX_BUILD_OPTIONS
4852Users can define this variable to a list of command line options that
4853will automatically be used by @command{guix build} and other
4854@command{guix} commands that can perform builds, as in the example
4855below:
4856
4857@example
4858$ export GUIX_BUILD_OPTIONS="--no-substitutes -c 2 -L /foo/bar"
4859@end example
4860
4861These options are parsed independently, and the result is appended to
4862the parsed command-line options.
4863@end defvr
4864
88ad6ded
LC
4865
4866@node Package Transformation Options
4867@subsection Package Transformation Options
4868
4869@cindex package variants
4870Another set of command-line options supported by @command{guix build}
b8638f03 4871and also @command{guix package} are @dfn{package transformation
f97c9175 4872options}. These are options that make it possible to define @dfn{package
b8638f03
LC
4873variants}---for instance, packages built from different source code.
4874This is a convenient way to create customized packages on the fly
4875without having to type in the definitions of package variants
4876(@pxref{Defining Packages}).
88ad6ded
LC
4877
4878@table @code
4879
4880@item --with-source=@var{source}
4881Use @var{source} as the source of the corresponding package.
4882@var{source} must be a file name or a URL, as for @command{guix
4883download} (@pxref{Invoking guix download}).
4884
f97c9175
AE
4885The ``corresponding package'' is taken to be the one specified on the
4886command line the name of which matches the base of @var{source}---e.g.,
4887if @var{source} is @code{/src/guile-2.0.10.tar.gz}, the corresponding
88ad6ded 4888package is @code{guile}. Likewise, the version string is inferred from
f97c9175 4889@var{source}; in the previous example, it is @code{2.0.10}.
88ad6ded
LC
4890
4891This option allows users to try out versions of packages other than the
4892one provided by the distribution. The example below downloads
4893@file{ed-1.7.tar.gz} from a GNU mirror and uses that as the source for
4894the @code{ed} package:
4895
4896@example
4897guix build ed --with-source=mirror://gnu/ed/ed-1.7.tar.gz
4898@end example
4899
4900As a developer, @code{--with-source} makes it easy to test release
4901candidates:
4902
4903@example
4904guix build guile --with-source=../guile-2.0.9.219-e1bb7.tar.xz
4905@end example
4906
4907@dots{} or to build from a checkout in a pristine environment:
4908
4909@example
4910$ git clone git://git.sv.gnu.org/guix.git
4911$ guix build guix --with-source=./guix
4912@end example
4913
47c0f92c
LC
4914@item --with-input=@var{package}=@var{replacement}
4915Replace dependency on @var{package} by a dependency on
4916@var{replacement}. @var{package} must be a package name, and
4917@var{replacement} must be a package specification such as @code{guile}
4918or @code{guile@@1.8}.
4919
f97c9175 4920For instance, the following command builds Guix, but replaces its
47c0f92c
LC
4921dependency on the current stable version of Guile with a dependency on
4922the development version of Guile, @code{guile-next}:
4923
4924@example
4925guix build --with-input=guile=guile-next guix
4926@end example
4927
4928This is a recursive, deep replacement. So in this example, both
4929@code{guix} and its dependency @code{guile-json} (which also depends on
4930@code{guile}) get rebuilt against @code{guile-next}.
4931
2a75b0b6
LC
4932This is implemented using the @code{package-input-rewriting} Scheme
4933procedure (@pxref{Defining Packages, @code{package-input-rewriting}}).
645b9df8
LC
4934
4935@item --with-graft=@var{package}=@var{replacement}
4936This is similar to @code{--with-input} but with an important difference:
9b4ec573 4937instead of rebuilding the whole dependency chain, @var{replacement} is
645b9df8
LC
4938built and then @dfn{grafted} onto the binaries that were initially
4939referring to @var{package}. @xref{Security Updates}, for more
4940information on grafts.
4941
4942For example, the command below grafts version 3.5.4 of GnuTLS onto Wget
4943and all its dependencies, replacing references to the version of GnuTLS
4944they currently refer to:
4945
4946@example
4947guix build --with-graft=gnutls=gnutls@@3.5.4 wget
4948@end example
4949
4950This has the advantage of being much faster than rebuilding everything.
4951But there is a caveat: it works if and only if @var{package} and
4952@var{replacement} are strictly compatible---for example, if they provide
4953a library, the application binary interface (ABI) of those libraries
4954must be compatible. If @var{replacement} is somehow incompatible with
4955@var{package}, then the resulting package may be unusable. Use with
4956care!
4957
88ad6ded
LC
4958@end table
4959
ccd7158d
LC
4960@node Additional Build Options
4961@subsection Additional Build Options
4962
4963The command-line options presented below are specific to @command{guix
4964build}.
c78bd12b
LC
4965
4966@table @code
4967
5284339d
LC
4968@item --quiet
4969@itemx -q
4970Build quietly, without displaying the build log. Upon completion, the
4971build log is kept in @file{/var} (or similar) and can always be
4972retrieved using the @option{--log-file} option.
4973
34a1783f
DT
4974@item --file=@var{file}
4975@itemx -f @var{file}
4976
4977Build the package or derivation that the code within @var{file}
4978evaluates to.
4979
4980As an example, @var{file} might contain a package definition like this
4981(@pxref{Defining Packages}):
4982
4983@example
4984@verbatiminclude package-hello.scm
4985@end example
4986
c78bd12b
LC
4987@item --expression=@var{expr}
4988@itemx -e @var{expr}
ac5de156 4989Build the package or derivation @var{expr} evaluates to.
c78bd12b 4990
5401dd75 4991For example, @var{expr} may be @code{(@@ (gnu packages guile)
c78bd12b
LC
4992guile-1.8)}, which unambiguously designates this specific variant of
4993version 1.8 of Guile.
4994
f97c9175 4995Alternatively, @var{expr} may be a G-expression, in which case it is used
56b82106
LC
4996as a build program passed to @code{gexp->derivation}
4997(@pxref{G-Expressions}).
4998
4999Lastly, @var{expr} may refer to a zero-argument monadic procedure
ac5de156
LC
5000(@pxref{The Store Monad}). The procedure must return a derivation as a
5001monadic value, which is then passed through @code{run-with-store}.
5002
c78bd12b
LC
5003@item --source
5004@itemx -S
f97c9175 5005Build the source derivations of the packages, rather than the packages
c78bd12b
LC
5006themselves.
5007
e49951eb 5008For instance, @code{guix build -S gcc} returns something like
f97c9175
AE
5009@file{/gnu/store/@dots{}-gcc-4.7.2.tar.bz2}, which is the GCC
5010source tarball.
c78bd12b 5011
f9cc8971 5012The returned source tarball is the result of applying any patches and
f97c9175 5013code snippets specified in the package @code{origin} (@pxref{Defining
f9cc8971
LC
5014Packages}).
5015
2cdfe13d
EB
5016@item --sources
5017Fetch and return the source of @var{package-or-derivation} and all their
5018dependencies, recursively. This is a handy way to obtain a local copy
5019of all the source code needed to build @var{packages}, allowing you to
5020eventually build them even without network access. It is an extension
5021of the @code{--source} option and can accept one of the following
5022optional argument values:
5023
5024@table @code
5025@item package
5026This value causes the @code{--sources} option to behave in the same way
5027as the @code{--source} option.
5028
5029@item all
f97c9175
AE
5030Build the source derivations of all packages, including any source that
5031might be listed as @code{inputs}. This is the default value.
2cdfe13d
EB
5032
5033@example
5034$ guix build --sources tzdata
5035The following derivations will be built:
5036 /gnu/store/@dots{}-tzdata2015b.tar.gz.drv
5037 /gnu/store/@dots{}-tzcode2015b.tar.gz.drv
5038@end example
5039
5040@item transitive
f97c9175
AE
5041Build the source derivations of all packages, as well of all transitive
5042inputs to the packages. This can be used e.g. to
2cdfe13d
EB
5043prefetch package source for later offline building.
5044
5045@example
5046$ guix build --sources=transitive tzdata
5047The following derivations will be built:
5048 /gnu/store/@dots{}-tzcode2015b.tar.gz.drv
5049 /gnu/store/@dots{}-findutils-4.4.2.tar.xz.drv
5050 /gnu/store/@dots{}-grep-2.21.tar.xz.drv
5051 /gnu/store/@dots{}-coreutils-8.23.tar.xz.drv
5052 /gnu/store/@dots{}-make-4.1.tar.xz.drv
5053 /gnu/store/@dots{}-bash-4.3.tar.xz.drv
5054@dots{}
5055@end example
5056
5057@end table
5058
c78bd12b
LC
5059@item --system=@var{system}
5060@itemx -s @var{system}
5061Attempt to build for @var{system}---e.g., @code{i686-linux}---instead of
f97c9175 5062the system type of the build host.
c78bd12b
LC
5063
5064An example use of this is on Linux-based systems, which can emulate
5065different personalities. For instance, passing
5066@code{--system=i686-linux} on an @code{x86_64-linux} system allows users
5067to build packages in a complete 32-bit environment.
5068
e55ec43d
LC
5069@item --target=@var{triplet}
5070@cindex cross-compilation
5071Cross-build for @var{triplet}, which must be a valid GNU triplet, such
5461115e
LC
5072as @code{"mips64el-linux-gnu"} (@pxref{Specifying target triplets, GNU
5073configuration triplets,, autoconf, Autoconf}).
e55ec43d 5074
a8d65643
LC
5075@anchor{build-check}
5076@item --check
5077@cindex determinism, checking
5078@cindex reproducibility, checking
5079Rebuild @var{package-or-derivation}, which are already available in the
5080store, and raise an error if the build results are not bit-for-bit
5081identical.
5082
f97c9175
AE
5083This mechanism allows you to check whether previously installed
5084substitutes are genuine (@pxref{Substitutes}), or whether the build result
5085of a package is deterministic. @xref{Invoking guix challenge}, for more
a8d65643
LC
5086background information and tools.
5087
7f3b2510
ED
5088When used in conjunction with @option{--keep-failed}, the differing
5089output is kept in the store, under @file{/gnu/store/@dots{}-check}.
5090This makes it easy to look for differences between the two results.
5091
6da5bb7b
LC
5092@item --repair
5093@cindex repairing store items
5094@cindex corruption, recovering from
5095Attempt to repair the specified store items, if they are corrupt, by
5096re-downloading or rebuilding them.
5097
5098This operation is not atomic and thus restricted to @code{root}.
5099
c78bd12b
LC
5100@item --derivations
5101@itemx -d
5102Return the derivation paths, not the output paths, of the given
5103packages.
5104
70ee5642
LC
5105@item --root=@var{file}
5106@itemx -r @var{file}
5107Make @var{file} a symlink to the result, and register it as a garbage
5108collector root.
5109
5110@item --log-file
3f208ad7 5111Return the build log file names or URLs for the given
f97c9175 5112@var{package-or-derivation}, or raise an error if build logs are
70ee5642
LC
5113missing.
5114
5115This works regardless of how packages or derivations are specified. For
5116instance, the following invocations are equivalent:
5117
5118@example
5119guix build --log-file `guix build -d guile`
5120guix build --log-file `guix build guile`
5121guix build --log-file guile
5122guix build --log-file -e '(@@ (gnu packages guile) guile-2.0)'
5123@end example
5124
3f208ad7
LC
5125If a log is unavailable locally, and unless @code{--no-substitutes} is
5126passed, the command looks for a corresponding log on one of the
5127substitute servers (as specified with @code{--substitute-urls}.)
70ee5642 5128
f97c9175
AE
5129So for instance, imagine you want to see the build log of GDB on MIPS,
5130but you are actually on an @code{x86_64} machine:
3f208ad7
LC
5131
5132@example
a01ad638 5133$ guix build --log-file gdb -s mips64el-linux
df061d07 5134https://hydra.gnu.org/log/@dots{}-gdb-7.10
3f208ad7
LC
5135@end example
5136
5137You can freely access a huge library of build logs!
70ee5642
LC
5138@end table
5139
16eb115e 5140
39bee8a2
LC
5141@node Invoking guix edit
5142@section Invoking @command{guix edit}
5143
e32171ee 5144@cindex @command{guix edit}
39bee8a2
LC
5145@cindex package definition, editing
5146So many packages, so many source files! The @command{guix edit} command
424a323e
GC
5147facilitates the life of users and packagers by pointing their editor at
5148the source file containing the definition of the specified packages.
5149For instance:
39bee8a2
LC
5150
5151@example
7b9a66e5 5152guix edit gcc@@4.9 vim
39bee8a2
LC
5153@end example
5154
5155@noindent
6237b9fa 5156launches the program specified in the @code{VISUAL} or in the
424a323e 5157@code{EDITOR} environment variable to view the recipe of GCC@tie{}4.9.3
6237b9fa 5158and that of Vim.
39bee8a2 5159
424a323e
GC
5160If you are using a Guix Git checkout (@pxref{Building from Git}), or
5161have created your own packages on @code{GUIX_PACKAGE_PATH}
5162(@pxref{Defining Packages}), you will be able to edit the package
5163recipes. Otherwise, you will be able to examine the read-only recipes
5164for packages currently in the store.
5165
39bee8a2 5166
210cc920
LC
5167@node Invoking guix download
5168@section Invoking @command{guix download}
5169
e32171ee
JD
5170@cindex @command{guix download}
5171@cindex downloading package sources
210cc920 5172When writing a package definition, developers typically need to download
f97c9175 5173a source tarball, compute its SHA256 hash, and write that
210cc920
LC
5174hash in the package definition (@pxref{Defining Packages}). The
5175@command{guix download} tool helps with this task: it downloads a file
5176from the given URI, adds it to the store, and prints both its file name
5177in the store and its SHA256 hash.
5178
5179The fact that the downloaded file is added to the store saves bandwidth:
5180when the developer eventually tries to build the newly defined package
5181with @command{guix build}, the source tarball will not have to be
5182downloaded again because it is already in the store. It is also a
5183convenient way to temporarily stash files, which may be deleted
5184eventually (@pxref{Invoking guix gc}).
5185
5186The @command{guix download} command supports the same URIs as used in
5187package definitions. In particular, it supports @code{mirror://} URIs.
5188@code{https} URIs (HTTP over TLS) are supported @emph{provided} the
5189Guile bindings for GnuTLS are available in the user's environment; when
537c8bb3
LC
5190they are not available, an error is raised. @xref{Guile Preparations,
5191how to install the GnuTLS bindings for Guile,, gnutls-guile,
5192GnuTLS-Guile}, for more information.
210cc920 5193
bc3c41ce
LC
5194@command{guix download} verifies HTTPS server certificates by loading
5195the certificates of X.509 authorities from the directory pointed to by
5196the @code{SSL_CERT_DIR} environment variable (@pxref{X.509
64b8695c 5197Certificates}), unless @option{--no-check-certificate} is used.
bc3c41ce 5198
64b8695c 5199The following options are available:
210cc920
LC
5200
5201@table @code
5202@item --format=@var{fmt}
5203@itemx -f @var{fmt}
5204Write the hash in the format specified by @var{fmt}. For more
081145cf 5205information on the valid values for @var{fmt}, @pxref{Invoking guix hash}.
64b8695c
LC
5206
5207@item --no-check-certificate
5208Do not validate the X.509 certificates of HTTPS servers.
5209
5210When using this option, you have @emph{absolutely no guarantee} that you
5211are communicating with the authentic server responsible for the given
5212URL, which makes you vulnerable to ``man-in-the-middle'' attacks.
5213
1bcc87bb
LC
5214@item --output=@var{file}
5215@itemx -o @var{file}
5216Save the downloaded file to @var{file} instead of adding it to the
5217store.
210cc920
LC
5218@end table
5219
6c365eca
NK
5220@node Invoking guix hash
5221@section Invoking @command{guix hash}
5222
e32171ee 5223@cindex @command{guix hash}
210cc920 5224The @command{guix hash} command computes the SHA256 hash of a file.
6c365eca
NK
5225It is primarily a convenience tool for anyone contributing to the
5226distribution: it computes the cryptographic hash of a file, which can be
5227used in the definition of a package (@pxref{Defining Packages}).
5228
5229The general syntax is:
5230
5231@example
5232guix hash @var{option} @var{file}
5233@end example
5234
343dc117
LC
5235When @var{file} is @code{-} (a hyphen), @command{guix hash} computes the
5236hash of data read from standard input. @command{guix hash} has the
5237following options:
6c365eca
NK
5238
5239@table @code
5240
5241@item --format=@var{fmt}
5242@itemx -f @var{fmt}
210cc920 5243Write the hash in the format specified by @var{fmt}.
6c365eca
NK
5244
5245Supported formats: @code{nix-base32}, @code{base32}, @code{base16}
5246(@code{hex} and @code{hexadecimal} can be used as well).
5247
5248If the @option{--format} option is not specified, @command{guix hash}
5249will output the hash in @code{nix-base32}. This representation is used
5250in the definitions of packages.
5251
3140f2df
LC
5252@item --recursive
5253@itemx -r
5254Compute the hash on @var{file} recursively.
5255
5256In this case, the hash is computed on an archive containing @var{file},
f97c9175
AE
5257including its children if it is a directory. Some of the metadata of
5258@var{file} is part of the archive; for instance, when @var{file} is a
3140f2df 5259regular file, the hash is different depending on whether @var{file} is
f97c9175 5260executable or not. Metadata such as time stamps has no impact on the
3140f2df
LC
5261hash (@pxref{Invoking guix archive}).
5262@c FIXME: Replace xref above with xref to an ``Archive'' section when
5263@c it exists.
5264
392a4e12
JN
5265@item --exclude-vcs
5266@itemx -x
5267When combined with @option{--recursive}, exclude version control system
5268directories (@file{.bzr}, @file{.git}, @file{.hg}, etc.)
5269
db97a03a
LC
5270@vindex git-fetch
5271As an example, here is how you would compute the hash of a Git checkout,
5272which is useful when using the @code{git-fetch} method (@pxref{origin
5273Reference}):
5274
5275@example
5276$ git clone http://example.org/foo.git
5277$ cd foo
392a4e12 5278$ guix hash -rx .
db97a03a 5279@end example
6c365eca
NK
5280@end table
5281
2f7d2d91
LC
5282@node Invoking guix import
5283@section Invoking @command{guix import}
5284
5285@cindex importing packages
5286@cindex package import
5287@cindex package conversion
e32171ee 5288@cindex Invoking @command{guix import}
f97c9175
AE
5289The @command{guix import} command is useful for people who would like to
5290add a package to the distribution with as little work as
5291possible---a legitimate demand. The command knows of a few
5292repositories from which it can ``import'' package metadata. The result
2f7d2d91
LC
5293is a package definition, or a template thereof, in the format we know
5294(@pxref{Defining Packages}).
5295
5296The general syntax is:
5297
5298@example
5299guix import @var{importer} @var{options}@dots{}
5300@end example
5301
5302@var{importer} specifies the source from which to import package
f97c9175 5303metadata, and @var{options} specifies a package identifier and other
2f7d2d91
LC
5304options specific to @var{importer}. Currently, the available
5305``importers'' are:
5306
5307@table @code
5308@item gnu
f97c9175 5309Import metadata for the given GNU package. This provides a template
2f7d2d91
LC
5310for the latest version of that GNU package, including the hash of its
5311source tarball, and its canonical synopsis and description.
5312
f97c9175 5313Additional information such as the package dependencies and its
2f7d2d91
LC
5314license needs to be figured out manually.
5315
5316For example, the following command returns a package definition for
5317GNU@tie{}Hello:
5318
5319@example
5320guix import gnu hello
5321@end example
5322
5323Specific command-line options are:
5324
5325@table @code
5326@item --key-download=@var{policy}
5327As for @code{guix refresh}, specify the policy to handle missing OpenPGP
f97c9175 5328keys when verifying the package signature. @xref{Invoking guix
2f7d2d91
LC
5329refresh, @code{--key-download}}.
5330@end table
5331
5332@item pypi
5333@cindex pypi
f97c9175 5334Import metadata from the @uref{https://pypi.python.org/, Python Package
2f7d2d91
LC
5335Index}@footnote{This functionality requires Guile-JSON to be installed.
5336@xref{Requirements}.}. Information is taken from the JSON-formatted
5337description available at @code{pypi.python.org} and usually includes all
266785d2
CR
5338the relevant information, including package dependencies. For maximum
5339efficiency, it is recommended to install the @command{unzip} utility, so
5340that the importer can unzip Python wheels and gather data from them.
2f7d2d91 5341
f97c9175 5342The command below imports metadata for the @code{itsdangerous} Python
2f7d2d91
LC
5343package:
5344
5345@example
5346guix import pypi itsdangerous
5347@end example
5348
3aae8145
DT
5349@item gem
5350@cindex gem
f97c9175 5351Import metadata from @uref{https://rubygems.org/,
3aae8145
DT
5352RubyGems}@footnote{This functionality requires Guile-JSON to be
5353installed. @xref{Requirements}.}. Information is taken from the
5354JSON-formatted description available at @code{rubygems.org} and includes
5355most relevant information, including runtime dependencies. There are
f97c9175 5356some caveats, however. The metadata doesn't distinguish between
3aae8145
DT
5357synopses and descriptions, so the same string is used for both fields.
5358Additionally, the details of non-Ruby dependencies required to build
5359native extensions is unavailable and left as an exercise to the
5360packager.
5361
f97c9175 5362The command below imports metadata for the @code{rails} Ruby package:
3aae8145
DT
5363
5364@example
5365guix import gem rails
5366@end example
5367
d45dc6da
EB
5368@item cpan
5369@cindex CPAN
3c192e4e
AE
5370Import metadata from @uref{https://www.metacpan.org/, MetaCPAN}@footnote{This
5371functionality requires Guile-JSON to be installed.
5372@xref{Requirements}.}.
f97c9175 5373Information is taken from the JSON-formatted metadata provided through
d45dc6da 5374@uref{https://api.metacpan.org/, MetaCPAN's API} and includes most
66392e47
EB
5375relevant information, such as module dependencies. License information
5376should be checked closely. If Perl is available in the store, then the
5377@code{corelist} utility will be used to filter core modules out of the
5378list of dependencies.
d45dc6da 5379
f97c9175 5380The command command below imports metadata for the @code{Acme::Boolean}
d45dc6da
EB
5381Perl module:
5382
5383@example
5384guix import cpan Acme::Boolean
5385@end example
5386
e1248602
RW
5387@item cran
5388@cindex CRAN
d0bd632f 5389@cindex Bioconductor
f97c9175 5390Import metadata from @uref{http://cran.r-project.org/, CRAN}, the
e1248602
RW
5391central repository for the @uref{http://r-project.org, GNU@tie{}R
5392statistical and graphical environment}.
5393
f97c9175 5394Information is extracted from the @code{DESCRIPTION} file of the package.
e1248602 5395
f97c9175 5396The command command below imports metadata for the @code{Cairo}
e1248602
RW
5397R package:
5398
5399@example
5400guix import cran Cairo
5401@end example
5402
64ce53eb
RW
5403When @code{--recursive} is added, the importer will traverse the
5404dependency graph of the given upstream package recursively and generate
5405package expressions for all those packages that are not yet in Guix.
5406
f97c9175 5407When @code{--archive=bioconductor} is added, metadata is imported from
d0bd632f
RW
5408@uref{http://www.bioconductor.org/, Bioconductor}, a repository of R
5409packages for for the analysis and comprehension of high-throughput
5410genomic data in bioinformatics.
5411
f97c9175 5412Information is extracted from the @code{DESCRIPTION} file of a package
d0bd632f
RW
5413published on the web interface of the Bioconductor SVN repository.
5414
f97c9175 5415The command below imports metadata for the @code{GenomicRanges}
d0bd632f
RW
5416R package:
5417
5418@example
5419guix import cran --archive=bioconductor GenomicRanges
5420@end example
5421
2f7d2d91 5422@item nix
f97c9175 5423Import metadata from a local copy of the source of the
2f7d2d91
LC
5424@uref{http://nixos.org/nixpkgs/, Nixpkgs distribution}@footnote{This
5425relies on the @command{nix-instantiate} command of
5426@uref{http://nixos.org/nix/, Nix}.}. Package definitions in Nixpkgs are
5427typically written in a mixture of Nix-language and Bash code. This
5428command only imports the high-level package structure that is written in
5429the Nix language. It normally includes all the basic fields of a
5430package definition.
5431
5432When importing a GNU package, the synopsis and descriptions are replaced
5433by their canonical upstream variant.
5434
961d0d2d
LC
5435Usually, you will first need to do:
5436
5437@example
5438export NIX_REMOTE=daemon
5439@end example
5440
5441@noindent
5442so that @command{nix-instantiate} does not try to open the Nix database.
5443
2f7d2d91
LC
5444As an example, the command below imports the package definition of
5445LibreOffice (more precisely, it imports the definition of the package
5446bound to the @code{libreoffice} top-level attribute):
5447
5448@example
5449guix import nix ~/path/to/nixpkgs libreoffice
5450@end example
863af4e1
FB
5451
5452@item hackage
5453@cindex hackage
f97c9175 5454Import metadata from the Haskell community's central package archive
863af4e1
FB
5455@uref{https://hackage.haskell.org/, Hackage}. Information is taken from
5456Cabal files and includes all the relevant information, including package
5457dependencies.
5458
5459Specific command-line options are:
5460
5461@table @code
a4154748
FB
5462@item --stdin
5463@itemx -s
f97c9175 5464Read a Cabal file from standard input.
863af4e1
FB
5465@item --no-test-dependencies
5466@itemx -t
f97c9175 5467Do not include dependencies required only by the test suites.
a4154748
FB
5468@item --cabal-environment=@var{alist}
5469@itemx -e @var{alist}
5470@var{alist} is a Scheme alist defining the environment in which the
5471Cabal conditionals are evaluated. The accepted keys are: @code{os},
5472@code{arch}, @code{impl} and a string representing the name of a flag.
5473The value associated with a flag has to be either the symbol
5474@code{true} or @code{false}. The value associated with other keys
5475has to conform to the Cabal file format definition. The default value
5476associated with the keys @code{os}, @code{arch} and @code{impl} is
f97c9175 5477@samp{linux}, @samp{x86_64} and @samp{ghc}, respectively.
863af4e1
FB
5478@end table
5479
f97c9175 5480The command below imports metadata for the latest version of the
a4154748
FB
5481@code{HTTP} Haskell package without including test dependencies and
5482specifying the value of the flag @samp{network-uri} as @code{false}:
863af4e1
FB
5483
5484@example
a4154748 5485guix import hackage -t -e "'((\"network-uri\" . false))" HTTP
863af4e1
FB
5486@end example
5487
5488A specific package version may optionally be specified by following the
1b846da8 5489package name by an at-sign and a version number as in the following example:
863af4e1
FB
5490
5491@example
1b846da8 5492guix import hackage mtl@@2.1.3.1
863af4e1 5493@end example
7f74a931 5494
bc5844d1
FB
5495@item stackage
5496@cindex stackage
5497The @code{stackage} importer is a wrapper around the @code{hackage} one.
5498It takes a package name, looks up the package version included in a
5499long-term support (LTS) @uref{https://www.stackage.org, Stackage}
5500release and uses the @code{hackage} importer to retrieve its metadata.
5501Note that it is up to you to select an LTS release compatible with the
5502GHC compiler used by Guix.
5503
5504Specific command-line options are:
5505
5506@table @code
5507@item --no-test-dependencies
5508@itemx -t
5509Do not include dependencies required only by the test suites.
5510@item --lts-version=@var{version}
5511@itemx -r @var{version}
5512@var{version} is the desired LTS release version. If omitted the latest
5513release is used.
5514@end table
5515
5516The command below imports metadata for the @code{HTTP} Haskell package
5517included in the LTS Stackage release version 7.18:
5518
5519@example
5520guix import stackage --lts-version=7.18 HTTP
5521@end example
5522
7f74a931
FB
5523@item elpa
5524@cindex elpa
f97c9175 5525Import metadata from an Emacs Lisp Package Archive (ELPA) package
7f74a931
FB
5526repository (@pxref{Packages,,, emacs, The GNU Emacs Manual}).
5527
5528Specific command-line options are:
5529
5530@table @code
5531@item --archive=@var{repo}
5532@itemx -a @var{repo}
5533@var{repo} identifies the archive repository from which to retrieve the
5534information. Currently the supported repositories and their identifiers
5535are:
5536@itemize -
5537@item
840bd1d3 5538@uref{http://elpa.gnu.org/packages, GNU}, selected by the @code{gnu}
7f74a931
FB
5539identifier. This is the default.
5540
624144e0
LC
5541Packages from @code{elpa.gnu.org} are signed with one of the keys
5542contained in the GnuPG keyring at
5543@file{share/emacs/25.1/etc/package-keyring.gpg} (or similar) in the
5544@code{emacs} package (@pxref{Package Installation, ELPA package
5545signatures,, emacs, The GNU Emacs Manual}).
5546
7f74a931 5547@item
840bd1d3 5548@uref{http://stable.melpa.org/packages, MELPA-Stable}, selected by the
7f74a931
FB
5549@code{melpa-stable} identifier.
5550
5551@item
840bd1d3 5552@uref{http://melpa.org/packages, MELPA}, selected by the @code{melpa}
7f74a931
FB
5553identifier.
5554@end itemize
5555@end table
3e0c0365
DC
5556
5557@item crate
5558@cindex crate
5559Import metadata from the crates.io Rust package repository
5560@uref{https://crates.io, crates.io}.
2f7d2d91
LC
5561@end table
5562
5563The structure of the @command{guix import} code is modular. It would be
5564useful to have more importers for other package formats, and your help
5565is welcome here (@pxref{Contributing}).
5566
37166310
LC
5567@node Invoking guix refresh
5568@section Invoking @command{guix refresh}
5569
e32171ee 5570@cindex @command {guix refresh}
37166310
LC
5571The primary audience of the @command{guix refresh} command is developers
5572of the GNU software distribution. By default, it reports any packages
5573provided by the distribution that are outdated compared to the latest
5574upstream version, like this:
5575
5576@example
5577$ guix refresh
5578gnu/packages/gettext.scm:29:13: gettext would be upgraded from 0.18.1.1 to 0.18.2.1
5579gnu/packages/glib.scm:77:12: glib would be upgraded from 2.34.3 to 2.37.0
5580@end example
5581
e9c72306
LC
5582Alternately, one can specify packages to consider, in which case a
5583warning is emitted for packages that lack an updater:
5584
5585@example
5586$ guix refresh coreutils guile guile-ssh
5587gnu/packages/ssh.scm:205:2: warning: no updater for guile-ssh
5588gnu/packages/guile.scm:136:12: guile would be upgraded from 2.0.12 to 2.0.13
5589@end example
5590
5591@command{guix refresh} browses the upstream repository of each package and determines
5592the highest version number of the releases therein. The command
bcb571cb 5593knows how to update specific types of packages: GNU packages, ELPA
e9c72306 5594packages, etc.---see the documentation for @option{--type} below. There
bcb571cb
LC
5595are many packages, though, for which it lacks a method to determine
5596whether a new upstream release is available. However, the mechanism is
5597extensible, so feel free to get in touch with us to add a new method!
37166310
LC
5598
5599When passed @code{--update}, it modifies distribution source files to
f97c9175 5600update the version numbers and source tarball hashes of those package
37166310
LC
5601recipes (@pxref{Defining Packages}). This is achieved by downloading
5602each package's latest source tarball and its associated OpenPGP
5603signature, authenticating the downloaded tarball against its signature
5604using @command{gpg}, and finally computing its hash. When the public
5605key used to sign the tarball is missing from the user's keyring, an
5606attempt is made to automatically retrieve it from a public key server;
f97c9175 5607when this is successful, the key is added to the user's keyring; otherwise,
37166310
LC
5608@command{guix refresh} reports an error.
5609
5610The following options are supported:
5611
5612@table @code
5613
2d7fc7da
LC
5614@item --expression=@var{expr}
5615@itemx -e @var{expr}
5616Consider the package @var{expr} evaluates to.
5617
5618This is useful to precisely refer to a package, as in this example:
5619
5620@example
5621guix refresh -l -e '(@@@@ (gnu packages commencement) glibc-final)'
5622@end example
5623
5624This command lists the dependents of the ``final'' libc (essentially all
5625the packages.)
5626
37166310
LC
5627@item --update
5628@itemx -u
38e16b49
LC
5629Update distribution source files (package recipes) in place. This is
5630usually run from a checkout of the Guix source tree (@pxref{Running
5631Guix Before It Is Installed}):
5632
5633@example
e9c72306 5634$ ./pre-inst-env guix refresh -s non-core -u
38e16b49
LC
5635@end example
5636
081145cf 5637@xref{Defining Packages}, for more information on package definitions.
37166310
LC
5638
5639@item --select=[@var{subset}]
5640@itemx -s @var{subset}
5641Select all the packages in @var{subset}, one of @code{core} or
5642@code{non-core}.
5643
5644The @code{core} subset refers to all the packages at the core of the
5645distribution---i.e., packages that are used to build ``everything
5646else''. This includes GCC, libc, Binutils, Bash, etc. Usually,
5647changing one of these packages in the distribution entails a rebuild of
5648all the others. Thus, such updates are an inconvenience to users in
5649terms of build time or bandwidth used to achieve the upgrade.
5650
5651The @code{non-core} subset refers to the remaining packages. It is
5652typically useful in cases where an update of the core packages would be
5653inconvenient.
5654
bcb571cb
LC
5655@item --type=@var{updater}
5656@itemx -t @var{updater}
7191adc5
AK
5657Select only packages handled by @var{updater} (may be a comma-separated
5658list of updaters). Currently, @var{updater} may be one of:
bcb571cb
LC
5659
5660@table @code
5661@item gnu
5662the updater for GNU packages;
e80c0f85
LC
5663@item gnome
5664the updater for GNOME packages;
9c97afe8
DC
5665@item kde
5666the updater for KDE packages;
62061d6b
AW
5667@item xorg
5668the updater for X.org packages;
2fd370e8
LC
5669@item kernel.org
5670the updater for packages hosted on kernel.org;
bcb571cb 5671@item elpa
d882c235
LC
5672the updater for @uref{http://elpa.gnu.org/, ELPA} packages;
5673@item cran
b9d044ef 5674the updater for @uref{http://cran.r-project.org/, CRAN} packages;
d0bd632f
RW
5675@item bioconductor
5676the updater for @uref{http://www.bioconductor.org/, Bioconductor} R packages;
200cdf81
EB
5677@item cpan
5678the updater for @uref{http://www.cpan.org/, CPAN} packages;
bab020d7 5679@item pypi
b9d044ef 5680the updater for @uref{https://pypi.python.org, PyPI} packages.
fbc5b815
BW
5681@item gem
5682the updater for @uref{https://rubygems.org, RubyGems} packages.
917a2a58
BW
5683@item github
5684the updater for @uref{https://github.com, GitHub} packages.
42efe27a
EB
5685@item hackage
5686the updater for @uref{https://hackage.haskell.org, Hackage} packages.
bc5844d1
FB
5687@item stackage
5688the updater for @uref{https://www.stackage.org, Stackage} packages.
8ac52987
DC
5689@item crate
5690the updater for @uref{https://crates.io, Crates} packages.
bcb571cb
LC
5691@end table
5692
f97c9175
AE
5693For instance, the following command only checks for updates of Emacs
5694packages hosted at @code{elpa.gnu.org} and for updates of CRAN packages:
bcb571cb
LC
5695
5696@example
7191adc5 5697$ guix refresh --type=elpa,cran
d882c235 5698gnu/packages/statistics.scm:819:13: r-testthat would be upgraded from 0.10.0 to 0.11.0
bcb571cb
LC
5699gnu/packages/emacs.scm:856:13: emacs-auctex would be upgraded from 11.88.6 to 11.88.9
5700@end example
5701
37166310
LC
5702@end table
5703
5704In addition, @command{guix refresh} can be passed one or more package
5705names, as in this example:
5706
5707@example
e9c72306 5708$ ./pre-inst-env guix refresh -u emacs idutils gcc@@4.8
37166310
LC
5709@end example
5710
5711@noindent
5712The command above specifically updates the @code{emacs} and
5713@code{idutils} packages. The @code{--select} option would have no
5714effect in this case.
5715
7d193ec3
EB
5716When considering whether to upgrade a package, it is sometimes
5717convenient to know which packages would be affected by the upgrade and
5718should be checked for compatibility. For this the following option may
5719be used when passing @command{guix refresh} one or more package names:
5720
5721@table @code
5722
6ffa706b
AK
5723@item --list-updaters
5724@itemx -L
5725List available updaters and exit (see @option{--type} above.)
5726
3676f892
LC
5727For each updater, display the fraction of packages it covers; at the
5728end, display the fraction of packages covered by all these updaters.
5729
7d193ec3
EB
5730@item --list-dependent
5731@itemx -l
5732List top-level dependent packages that would need to be rebuilt as a
5733result of upgrading one or more packages.
5734
b96a0640
LC
5735@xref{Invoking guix graph, the @code{reverse-package} type of
5736@command{guix graph}}, for information on how to visualize the list of
5737dependents of a package.
5738
7d193ec3
EB
5739@end table
5740
5741Be aware that the @code{--list-dependent} option only
5742@emph{approximates} the rebuilds that would be required as a result of
5743an upgrade. More rebuilds might be required under some circumstances.
5744
5745@example
7779ab61
LC
5746$ guix refresh --list-dependent flex
5747Building the following 120 packages would ensure 213 dependent packages are rebuilt:
5748hop-2.4.0 geiser-0.4 notmuch-0.18 mu-0.9.9.5 cflow-1.4 idutils-4.6 @dots{}
7d193ec3
EB
5749@end example
5750
5751The command above lists a set of packages that could be built to check
5752for compatibility with an upgraded @code{flex} package.
5753
f9230085
LC
5754The following options can be used to customize GnuPG operation:
5755
5756@table @code
5757
f9230085
LC
5758@item --gpg=@var{command}
5759Use @var{command} as the GnuPG 2.x command. @var{command} is searched
5760for in @code{$PATH}.
5761
2bc53ba9
LC
5762@item --key-download=@var{policy}
5763Handle missing OpenPGP keys according to @var{policy}, which may be one
5764of:
5765
5766@table @code
5767@item always
5768Always download missing OpenPGP keys from the key server, and add them
5769to the user's GnuPG keyring.
5770
5771@item never
5772Never try to download missing OpenPGP keys. Instead just bail out.
5773
5774@item interactive
5775When a package signed with an unknown OpenPGP key is encountered, ask
5776the user whether to download it or not. This is the default behavior.
5777@end table
5778
5779@item --key-server=@var{host}
5780Use @var{host} as the OpenPGP key server when importing a public key.
5781
f9230085
LC
5782@end table
5783
917a2a58
BW
5784The @code{github} updater uses the
5785@uref{https://developer.github.com/v3/, GitHub API} to query for new
5786releases. When used repeatedly e.g. when refreshing all packages,
5787GitHub will eventually refuse to answer any further API requests. By
5788default 60 API requests per hour are allowed, and a full refresh on all
5789GitHub packages in Guix requires more than this. Authentication with
5790GitHub through the use of an API token alleviates these limits. To use
5791an API token, set the environment variable @code{GUIX_GITHUB_TOKEN} to a
5792token procured from @uref{https://github.com/settings/tokens} or
5793otherwise.
5794
5795
b4f5e0e8
CR
5796@node Invoking guix lint
5797@section Invoking @command{guix lint}
e32171ee
JD
5798
5799@cindex @command{guix lint}
5800@cindex package, checking for errors
f97c9175
AE
5801The @command{guix lint} command is meant to help package developers avoid
5802common errors and use a consistent style. It runs a number of checks on
5803a given set of packages in order to find common mistakes in their
873c4085
LC
5804definitions. Available @dfn{checkers} include (see
5805@code{--list-checkers} for a complete list):
5806
5807@table @code
5808@item synopsis
5809@itemx description
5810Validate certain typographical and stylistic rules about package
5811descriptions and synopses.
5812
5813@item inputs-should-be-native
5814Identify inputs that should most likely be native inputs.
5815
5816@item source
5817@itemx home-page
fac46e3f 5818@itemx mirror-url
50f5c46d 5819@itemx source-file-name
873c4085 5820Probe @code{home-page} and @code{source} URLs and report those that are
fac46e3f
LC
5821invalid. Suggest a @code{mirror://} URL when applicable. Check that
5822the source file name is meaningful, e.g. is not
f97c9175
AE
5823just a version number or ``git-checkout'', without a declared
5824@code{file-name} (@pxref{origin Reference}).
40a7d4e5 5825
5432734b 5826@item cve
09866b39
LC
5827@cindex security vulnerabilities
5828@cindex CVE, Common Vulnerabilities and Exposures
5432734b 5829Report known vulnerabilities found in the Common Vulnerabilities and
09866b39 5830Exposures (CVE) databases of the current and past year
5432734b
LC
5831@uref{https://nvd.nist.gov/download.cfm#CVE_FEED, published by the US
5832NIST}.
5833
09866b39
LC
5834To view information about a particular vulnerability, visit pages such as:
5835
5836@itemize
5837@item
5838@indicateurl{https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-YYYY-ABCD}
5839@item
5840@indicateurl{https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-YYYY-ABCD}
5841@end itemize
5842
5843@noindent
5844where @code{CVE-YYYY-ABCD} is the CVE identifier---e.g.,
5845@code{CVE-2015-7554}.
5846
99effc8f
LC
5847Package developers can specify in package recipes the
5848@uref{https://nvd.nist.gov/cpe.cfm,Common Platform Enumeration (CPE)}
5849name and version of the package when they differ from the name that Guix
5850uses, as in this example:
5851
5852@example
5853(package
5854 (name "grub")
5855 ;; @dots{}
5856 ;; CPE calls this package "grub2".
5857 (properties '((cpe-name . "grub2"))))
5858@end example
5859
40a7d4e5
LC
5860@item formatting
5861Warn about obvious source code formatting issues: trailing white space,
5862use of tabulations, etc.
873c4085 5863@end table
b4f5e0e8
CR
5864
5865The general syntax is:
5866
5867@example
5868guix lint @var{options} @var{package}@dots{}
5869@end example
5870
5871If no package is given on the command line, then all packages are checked.
5872The @var{options} may be zero or more of the following:
5873
5874@table @code
f97c9175
AE
5875@item --list-checkers
5876@itemx -l
5877List and describe all the available checkers that will be run on packages
5878and exit.
b4f5e0e8 5879
dd7c013d
CR
5880@item --checkers
5881@itemx -c
5882Only enable the checkers specified in a comma-separated list using the
5883names returned by @code{--list-checkers}.
5884
b4f5e0e8 5885@end table
37166310 5886
fcc58db6
LC
5887@node Invoking guix size
5888@section Invoking @command{guix size}
5889
e32171ee
JD
5890@cindex size
5891@cindex package size
5892@cindex closure
5893@cindex @command{guix size}
fcc58db6
LC
5894The @command{guix size} command helps package developers profile the
5895disk usage of packages. It is easy to overlook the impact of an
5896additional dependency added to a package, or the impact of using a
5897single output for a package that could easily be split (@pxref{Packages
f97c9175 5898with Multiple Outputs}). Such are the typical issues that
fcc58db6
LC
5899@command{guix size} can highlight.
5900
e1a65ae5 5901The command can be passed a package specification such as @code{gcc@@4.8}
fcc58db6
LC
5902or @code{guile:debug}, or a file name in the store. Consider this
5903example:
5904
5905@example
5906$ guix size coreutils
5907store item total self
5908/gnu/store/@dots{}-coreutils-8.23 70.0 13.9 19.8%
5909/gnu/store/@dots{}-gmp-6.0.0a 55.3 2.5 3.6%
5910/gnu/store/@dots{}-acl-2.2.52 53.7 0.5 0.7%
5911/gnu/store/@dots{}-attr-2.4.46 53.2 0.3 0.5%
5912/gnu/store/@dots{}-gcc-4.8.4-lib 52.9 15.7 22.4%
5913/gnu/store/@dots{}-glibc-2.21 37.2 37.2 53.1%
5914@end example
5915
5916@cindex closure
5917The store items listed here constitute the @dfn{transitive closure} of
5918Coreutils---i.e., Coreutils and all its dependencies, recursively---as
5919would be returned by:
5920
5921@example
5922$ guix gc -R /gnu/store/@dots{}-coreutils-8.23
5923@end example
5924
f97c9175 5925Here the output shows three columns next to store items. The first column,
fcc58db6
LC
5926labeled ``total'', shows the size in mebibytes (MiB) of the closure of
5927the store item---that is, its own size plus the size of all its
5928dependencies. The next column, labeled ``self'', shows the size of the
f97c9175
AE
5929item itself. The last column shows the ratio of the size of the item
5930itself to the space occupied by all the items listed here.
fcc58db6
LC
5931
5932In this example, we see that the closure of Coreutils weighs in at
593370@tie{}MiB, half of which is taken by libc. (That libc represents a
5934large fraction of the closure is not a problem @i{per se} because it is
5935always available on the system anyway.)
5936
5937When the package passed to @command{guix size} is available in the
5938store, @command{guix size} queries the daemon to determine its
5939dependencies, and measures its size in the store, similar to @command{du
5940-ms --apparent-size} (@pxref{du invocation,,, coreutils, GNU
5941Coreutils}).
5942
5943When the given package is @emph{not} in the store, @command{guix size}
f97c9175
AE
5944reports information based on the available substitutes
5945(@pxref{Substitutes}). This makes it possible it to profile disk usage of
5946store items that are not even on disk, only available remotely.
fcc58db6 5947
db761534
LC
5948You can also specify several package names:
5949
5950@example
5951$ guix size coreutils grep sed bash
5952store item total self
5953/gnu/store/@dots{}-coreutils-8.24 77.8 13.8 13.4%
5954/gnu/store/@dots{}-grep-2.22 73.1 0.8 0.8%
5955/gnu/store/@dots{}-bash-4.3.42 72.3 4.7 4.6%
5956/gnu/store/@dots{}-readline-6.3 67.6 1.2 1.2%
5957@dots{}
5958total: 102.3 MiB
5959@end example
5960
5961@noindent
5962In this example we see that the combination of the four packages takes
5963102.3@tie{}MiB in total, which is much less than the sum of each closure
5964since they have a lot of dependencies in common.
5965
a8f996c6 5966The available options are:
fcc58db6
LC
5967
5968@table @option
5969
d490d06e
LC
5970@item --substitute-urls=@var{urls}
5971Use substitute information from @var{urls}.
5972@xref{client-substitute-urls, the same option for @code{guix build}}.
5973
a8f996c6 5974@item --map-file=@var{file}
f97c9175 5975Write a graphical map of disk usage in PNG format to @var{file}.
a8f996c6
LC
5976
5977For the example above, the map looks like this:
5978
5979@image{images/coreutils-size-map,5in,, map of Coreutils disk usage
5980produced by @command{guix size}}
5981
5982This option requires that
5983@uref{http://wingolog.org/software/guile-charting/, Guile-Charting} be
5984installed and visible in Guile's module search path. When that is not
5985the case, @command{guix size} fails as it tries to load it.
5986
fcc58db6
LC
5987@item --system=@var{system}
5988@itemx -s @var{system}
5989Consider packages for @var{system}---e.g., @code{x86_64-linux}.
5990
5991@end table
5992
88856916
LC
5993@node Invoking guix graph
5994@section Invoking @command{guix graph}
5995
5996@cindex DAG
e32171ee
JD
5997@cindex @command{guix graph}
5998@cindex package dependencies
88856916
LC
5999Packages and their dependencies form a @dfn{graph}, specifically a
6000directed acyclic graph (DAG). It can quickly become difficult to have a
f97c9175 6001mental model of the package DAG, so the @command{guix graph} command
9ea36197
LC
6002provides a visual representation of the DAG. By default,
6003@command{guix graph} emits a DAG representation in the input format of
88856916 6004@uref{http://www.graphviz.org/, Graphviz}, so its output can be passed
9ea36197
LC
6005directly to the @command{dot} command of Graphviz. It can also emit an
6006HTML page with embedded JavaScript code to display a ``chord diagram''
6007in a Web browser, using the @uref{https://d3js.org/, d3.js} library.
6008The general syntax is:
88856916
LC
6009
6010@example
6011guix graph @var{options} @var{package}@dots{}
6012@end example
6013
6014For example, the following command generates a PDF file representing the
6015package DAG for the GNU@tie{}Core Utilities, showing its build-time
6016dependencies:
6017
6018@example
6019guix graph coreutils | dot -Tpdf > dag.pdf
6020@end example
6021
6022The output looks like this:
6023
6024@image{images/coreutils-graph,2in,,Dependency graph of the GNU Coreutils}
6025
6026Nice little graph, no?
6027
f97c9175 6028But there is more than one graph! The one above is concise: it is the
88856916 6029graph of package objects, omitting implicit inputs such as GCC, libc,
f97c9175
AE
6030grep, etc. It is often useful to have such a concise graph, but
6031sometimes one may want to see more details. @command{guix graph} supports
6032several types of graphs, allowing you to choose the level of detail:
88856916
LC
6033
6034@table @code
6035@item package
f97c9175 6036This is the default type used in the example above. It shows the DAG of
88856916
LC
6037package objects, excluding implicit dependencies. It is concise, but
6038filters out many details.
6039
b96a0640
LC
6040@item reverse-package
6041This shows the @emph{reverse} DAG of packages. For example:
6042
6043@example
6044guix graph --type=reverse-package ocaml
6045@end example
6046
6047... yields the graph of packages that depend on OCaml.
6048
6049Note that for core packages this can yield huge graphs. If all you want
6050is to know the number of packages that depend on a given package, use
6051@command{guix refresh --list-dependent} (@pxref{Invoking guix refresh,
6052@option{--list-dependent}}).
6053
88856916
LC
6054@item bag-emerged
6055This is the package DAG, @emph{including} implicit inputs.
6056
6057For instance, the following command:
6058
6059@example
6060guix graph --type=bag-emerged coreutils | dot -Tpdf > dag.pdf
6061@end example
6062
6063... yields this bigger graph:
6064
6065@image{images/coreutils-bag-graph,,5in,Detailed dependency graph of the GNU Coreutils}
6066
6067At the bottom of the graph, we see all the implicit inputs of
6068@var{gnu-build-system} (@pxref{Build Systems, @code{gnu-build-system}}).
6069
f97c9175 6070Now, note that the dependencies of these implicit inputs---that is, the
88856916
LC
6071@dfn{bootstrap dependencies} (@pxref{Bootstrapping})---are not shown
6072here, for conciseness.
6073
6074@item bag
6075Similar to @code{bag-emerged}, but this time including all the bootstrap
6076dependencies.
6077
38b92daa
LC
6078@item bag-with-origins
6079Similar to @code{bag}, but also showing origins and their dependencies.
6080
88856916
LC
6081@item derivations
6082This is the most detailed representation: It shows the DAG of
6083derivations (@pxref{Derivations}) and plain store items. Compared to
6084the above representation, many additional nodes are visible, including
f97c9175 6085build scripts, patches, Guile modules, etc.
88856916 6086
a773c314
LC
6087For this type of graph, it is also possible to pass a @file{.drv} file
6088name instead of a package name, as in:
6089
6090@example
6091guix graph -t derivation `guix system build -d my-config.scm`
6092@end example
88856916
LC
6093@end table
6094
f97c9175 6095All the types above correspond to @emph{build-time dependencies}. The
88856916
LC
6096following graph type represents the @emph{run-time dependencies}:
6097
6098@table @code
6099@item references
6100This is the graph of @dfn{references} of a package output, as returned
6101by @command{guix gc --references} (@pxref{Invoking guix gc}).
6102
6103If the given package output is not available in the store, @command{guix
6104graph} attempts to obtain dependency information from substitutes.
a773c314
LC
6105
6106Here you can also pass a store file name instead of a package name. For
6107example, the command below produces the reference graph of your profile
6108(which can be big!):
6109
6110@example
6111guix graph -t references `readlink -f ~/.guix-profile`
6112@end example
7f8fec0f
LC
6113
6114@item referrers
6115This is the graph of the @dfn{referrers} of a store item, as returned by
6116@command{guix gc --referrers} (@pxref{Invoking guix gc}).
6117
6118This relies exclusively on local information from your store. For
6119instance, let us suppose that the current Inkscape is available in 10
6120profiles on your machine; @command{guix graph -t referrers inkscape}
6121will show a graph rooted at Inkscape and with those 10 profiles linked
6122to it.
6123
6124It can help determine what is preventing a store item from being garbage
6125collected.
6126
88856916
LC
6127@end table
6128
6129The available options are the following:
6130
6131@table @option
6132@item --type=@var{type}
6133@itemx -t @var{type}
6134Produce a graph output of @var{type}, where @var{type} must be one of
6135the values listed above.
6136
6137@item --list-types
6138List the supported graph types.
4c8f997a 6139
642339dc
RW
6140@item --backend=@var{backend}
6141@itemx -b @var{backend}
6142Produce a graph using the selected @var{backend}.
6143
6144@item --list-backends
6145List the supported graph backends.
6146
9ea36197
LC
6147Currently, the available backends are Graphviz and d3.js.
6148
4c8f997a
LC
6149@item --expression=@var{expr}
6150@itemx -e @var{expr}
6151Consider the package @var{expr} evaluates to.
6152
6153This is useful to precisely refer to a package, as in this example:
6154
6155@example
6156guix graph -e '(@@@@ (gnu packages commencement) gnu-make-final)'
6157@end example
88856916
LC
6158@end table
6159
6160
372c4bbc
DT
6161@node Invoking guix environment
6162@section Invoking @command{guix environment}
6163
f5fd4fd2 6164@cindex reproducible build environments
fe36d84e 6165@cindex development environments
e32171ee
JD
6166@cindex @command{guix environment}
6167@cindex environment, package build environment
372c4bbc
DT
6168The purpose of @command{guix environment} is to assist hackers in
6169creating reproducible development environments without polluting their
6170package profile. The @command{guix environment} tool takes one or more
f97c9175 6171packages, builds all of their inputs, and creates a shell
372c4bbc
DT
6172environment to use them.
6173
6174The general syntax is:
6175
6176@example
6177guix environment @var{options} @var{package}@dots{}
6178@end example
6179
fe36d84e
LC
6180The following example spawns a new shell set up for the development of
6181GNU@tie{}Guile:
372c4bbc
DT
6182
6183@example
6184guix environment guile
6185@end example
6186
f97c9175
AE
6187If the needed dependencies are not built yet, @command{guix environment}
6188automatically builds them. The environment of the new shell is an augmented
372c4bbc
DT
6189version of the environment that @command{guix environment} was run in.
6190It contains the necessary search paths for building the given package
6191added to the existing environment variables. To create a ``pure''
f97c9175 6192environment, in which the original environment variables have been unset,
50500f7c
LC
6193use the @code{--pure} option@footnote{Users sometimes wrongfully augment
6194environment variables such as @code{PATH} in their @file{~/.bashrc}
6195file. As a consequence, when @code{guix environment} launches it, Bash
6196may read @file{~/.bashrc}, thereby introducing ``impurities'' in these
6197environment variables. It is an error to define such environment
6198variables in @file{.bashrc}; instead, they should be defined in
6199@file{.bash_profile}, which is sourced only by log-in shells.
6200@xref{Bash Startup Files,,, bash, The GNU Bash Reference Manual}, for
6201details on Bash start-up files.}.
372c4bbc 6202
28de8d25
LC
6203@vindex GUIX_ENVIRONMENT
6204@command{guix environment} defines the @code{GUIX_ENVIRONMENT}
20185522
LC
6205variable in the shell it spawns; its value is the file name of the
6206profile of this environment. This allows users to, say, define a
28de8d25
LC
6207specific prompt for development environments in their @file{.bashrc}
6208(@pxref{Bash Startup Files,,, bash, The GNU Bash Reference Manual}):
6209
6210@example
6211if [ -n "$GUIX_ENVIRONMENT" ]
6212then
6213 export PS1="\u@@\h \w [dev]\$ "
6214fi
6215@end example
6216
20185522
LC
6217@noindent
6218... or to browse the profile:
6219
6220@example
6221$ ls "$GUIX_ENVIRONMENT/bin"
6222@end example
6223
372c4bbc
DT
6224Additionally, more than one package may be specified, in which case the
6225union of the inputs for the given packages are used. For example, the
6226command below spawns a shell where all of the dependencies of both Guile
6227and Emacs are available:
6228
6229@example
6230guix environment guile emacs
6231@end example
6232
1de2fe95
DT
6233Sometimes an interactive shell session is not desired. An arbitrary
6234command may be invoked by placing the @code{--} token to separate the
6235command from the rest of the arguments:
372c4bbc
DT
6236
6237@example
1de2fe95 6238guix environment guile -- make -j4
372c4bbc
DT
6239@end example
6240
fe36d84e
LC
6241In other situations, it is more convenient to specify the list of
6242packages needed in the environment. For example, the following command
6243runs @command{python} from an environment containing Python@tie{}2.7 and
6244NumPy:
6245
6246@example
1de2fe95 6247guix environment --ad-hoc python2-numpy python-2.7 -- python
fe36d84e
LC
6248@end example
6249
cc90fbbf
DT
6250Furthermore, one might want the dependencies of a package and also some
6251additional packages that are not build-time or runtime dependencies, but
6252are useful when developing nonetheless. Because of this, the
6253@code{--ad-hoc} flag is positional. Packages appearing before
6254@code{--ad-hoc} are interpreted as packages whose dependencies will be
6255added to the environment. Packages appearing after are interpreted as
6256packages that will be added to the environment directly. For example,
6257the following command creates a Guix development environment that
6258additionally includes Git and strace:
6259
6260@example
6261guix environment guix --ad-hoc git strace
6262@end example
6263
f535dcbe
DT
6264Sometimes it is desirable to isolate the environment as much as
6265possible, for maximal purity and reproducibility. In particular, when
6266using Guix on a host distro that is not GuixSD, it is desirable to
6267prevent access to @file{/usr/bin} and other system-wide resources from
6268the development environment. For example, the following command spawns
6269a Guile REPL in a ``container'' where only the store and the current
6270working directory are mounted:
6271
6272@example
6273guix environment --ad-hoc --container guile -- guile
6274@end example
6275
0f252e26 6276@quotation Note
cfd35b4e 6277The @code{--container} option requires Linux-libre 3.19 or newer.
0f252e26
DT
6278@end quotation
6279
fe36d84e 6280The available options are summarized below.
372c4bbc
DT
6281
6282@table @code
f943c317
LC
6283@item --root=@var{file}
6284@itemx -r @var{file}
6285@cindex persistent environment
6286@cindex garbage collector root, for environments
6287Make @var{file} a symlink to the profile for this environment, and
6288register it as a garbage collector root.
6289
6290This is useful if you want to protect your environment from garbage
6291collection, to make it ``persistent''.
6292
6293When this option is omitted, the environment is protected from garbage
6294collection only for the duration of the @command{guix environment}
6295session. This means that next time you recreate the same environment,
6296you could have to rebuild or re-download packages.
6297
372c4bbc
DT
6298@item --expression=@var{expr}
6299@itemx -e @var{expr}
c9c282ce
DT
6300Create an environment for the package or list of packages that
6301@var{expr} evaluates to.
372c4bbc 6302
fe36d84e
LC
6303For example, running:
6304
6305@example
6306guix environment -e '(@@ (gnu packages maths) petsc-openmpi)'
6307@end example
6308
6309starts a shell with the environment for this specific variant of the
6310PETSc package.
6311
c9c282ce
DT
6312Running:
6313
6314@example
5c2b2f00 6315guix environment --ad-hoc -e '(@@ (gnu) %base-packages)'
c9c282ce
DT
6316@end example
6317
6318starts a shell with all the GuixSD base packages available.
6319
fa445d64 6320The above commands only use the default output of the given packages.
779aa003
DT
6321To select other outputs, two element tuples can be specified:
6322
6323@example
6324guix environment --ad-hoc -e '(list (@ (gnu packages bash) bash) "include")'
6325@end example
6326
372c4bbc
DT
6327@item --load=@var{file}
6328@itemx -l @var{file}
c9c282ce
DT
6329Create an environment for the package or list of packages that the code
6330within @var{file} evaluates to.
372c4bbc 6331
fe36d84e
LC
6332As an example, @var{file} might contain a definition like this
6333(@pxref{Defining Packages}):
6334
6335@example
6336@verbatiminclude environment-gdb.scm
6337@end example
6338
a54bd6d7
DT
6339@item --ad-hoc
6340Include all specified packages in the resulting environment, as if an
6341@i{ad hoc} package were defined with them as inputs. This option is
6342useful for quickly creating an environment without having to write a
6343package expression to contain the desired inputs.
6344
6345For instance, the command:
6346
6347@example
1de2fe95 6348guix environment --ad-hoc guile guile-sdl -- guile
a54bd6d7
DT
6349@end example
6350
6351runs @command{guile} in an environment where Guile and Guile-SDL are
6352available.
6353
417c39f1 6354Note that this example implicitly asks for the default output of
f97c9175 6355@code{guile} and @code{guile-sdl}, but it is possible to ask for a
417c39f1
LC
6356specific output---e.g., @code{glib:bin} asks for the @code{bin} output
6357of @code{glib} (@pxref{Packages with Multiple Outputs}).
6358
cc90fbbf
DT
6359This option may be composed with the default behavior of @command{guix
6360environment}. Packages appearing before @code{--ad-hoc} are interpreted
6361as packages whose dependencies will be added to the environment, the
6362default behavior. Packages appearing after are interpreted as packages
6363that will be added to the environment directly.
6364
372c4bbc
DT
6365@item --pure
6366Unset existing environment variables when building the new environment.
6367This has the effect of creating an environment in which search paths
6368only contain package inputs.
6369
6370@item --search-paths
6371Display the environment variable definitions that make up the
6372environment.
ce367ef3
LC
6373
6374@item --system=@var{system}
6375@itemx -s @var{system}
6376Attempt to build for @var{system}---e.g., @code{i686-linux}.
f535dcbe
DT
6377
6378@item --container
6379@itemx -C
6380@cindex container
6381Run @var{command} within an isolated container. The current working
a01ad638
DT
6382directory outside the container is mapped inside the container.
6383Additionally, a dummy home directory is created that matches the current
6384user's home directory, and @file{/etc/passwd} is configured accordingly.
6385The spawned process runs as the current user outside the container, but
6386has root privileges in the context of the container.
f535dcbe
DT
6387
6388@item --network
6389@itemx -N
6390For containers, share the network namespace with the host system.
6391Containers created without this flag only have access to the loopback
6392device.
6393
6394@item --expose=@var{source}[=@var{target}]
6395For containers, expose the file system @var{source} from the host system
6396as the read-only file system @var{target} within the container. If
6397@var{target} is not specified, @var{source} is used as the target mount
6398point in the container.
6399
6400The example below spawns a Guile REPL in a container in which the user's
6401home directory is accessible read-only via the @file{/exchange}
6402directory:
6403
6404@example
6405guix environment --container --expose=$HOME=/exchange guile -- guile
6406@end example
6407
5c2b2f00 6408@item --share=@var{source}[=@var{target}]
f535dcbe
DT
6409For containers, share the file system @var{source} from the host system
6410as the writable file system @var{target} within the container. If
6411@var{target} is not specified, @var{source} is used as the target mount
6412point in the container.
6413
6414The example below spawns a Guile REPL in a container in which the user's
6415home directory is accessible for both reading and writing via the
6416@file{/exchange} directory:
6417
6418@example
6419guix environment --container --share=$HOME=/exchange guile -- guile
6420@end example
372c4bbc
DT
6421@end table
6422
6423It also supports all of the common build options that @command{guix
ccd7158d 6424build} supports (@pxref{Common Build Options}).
372c4bbc 6425
aff8ce7c
DT
6426@node Invoking guix publish
6427@section Invoking @command{guix publish}
6428
e32171ee 6429@cindex @command{guix publish}
aff8ce7c 6430The purpose of @command{guix publish} is to enable users to easily share
f97c9175 6431their store with others, who can then use it as a substitute server
8ce229fc
LC
6432(@pxref{Substitutes}).
6433
6434When @command{guix publish} runs, it spawns an HTTP server which allows
6435anyone with network access to obtain substitutes from it. This means
6436that any machine running Guix can also act as if it were a build farm,
6437since the HTTP interface is compatible with Hydra, the software behind
6438the @code{hydra.gnu.org} build farm.
aff8ce7c
DT
6439
6440For security, each substitute is signed, allowing recipients to check
6441their authenticity and integrity (@pxref{Substitutes}). Because
f97c9175 6442@command{guix publish} uses the signing key of the system, which is only
5463fe51
LC
6443readable by the system administrator, it must be started as root; the
6444@code{--user} option makes it drop root privileges early on.
aff8ce7c 6445
b18812b6
LC
6446The signing key pair must be generated before @command{guix publish} is
6447launched, using @command{guix archive --generate-key} (@pxref{Invoking
6448guix archive}).
6449
aff8ce7c
DT
6450The general syntax is:
6451
6452@example
6453guix publish @var{options}@dots{}
6454@end example
6455
6456Running @command{guix publish} without any additional arguments will
6457spawn an HTTP server on port 8080:
6458
6459@example
6460guix publish
6461@end example
6462
6463Once a publishing server has been authorized (@pxref{Invoking guix
6464archive}), the daemon may download substitutes from it:
6465
6466@example
6467guix-daemon --substitute-urls=http://example.org:8080
6468@end example
6469
ff6638d1
LC
6470As a bonus, @command{guix publish} also serves as a content-addressed
6471mirror for source files referenced in @code{origin} records
6472(@pxref{origin Reference}). For instance, assuming @command{guix
6473publish} is running on @code{example.org}, the following URL returns the
6474raw @file{hello-2.10.tar.gz} file with the given SHA256 hash
6475(represented in @code{nix-base32} format, @pxref{Invoking guix hash}):
6476
6477@example
6478http://example.org/file/hello-2.10.tar.gz/sha256/0ssi1@dots{}ndq1i
6479@end example
6480
6481Obviously, these URLs only work for files that are in the store; in
6482other cases, they return 404 (``Not Found'').
6483
aff8ce7c
DT
6484The following options are available:
6485
6486@table @code
6487@item --port=@var{port}
6488@itemx -p @var{port}
6489Listen for HTTP requests on @var{port}.
6490
9e2292ef
LC
6491@item --listen=@var{host}
6492Listen on the network interface for @var{host}. The default is to
6493accept connections from any interface.
6494
5463fe51
LC
6495@item --user=@var{user}
6496@itemx -u @var{user}
6497Change privileges to @var{user} as soon as possible---i.e., once the
6498server socket is open and the signing key has been read.
6499
4a1fc562
LC
6500@item --compression[=@var{level}]
6501@itemx -C [@var{level}]
6502Compress data using the given @var{level}. When @var{level} is zero,
6503disable compression. The range 1 to 9 corresponds to different gzip
6504compression levels: 1 is the fastest, and 9 is the best (CPU-intensive).
6505The default is 3.
6506
4591c02e 6507Compression occurs on the fly and the compressed streams are not
4a1fc562
LC
6508cached. Thus, to reduce load on the machine that runs @command{guix
6509publish}, it may be a good idea to choose a low compression level, or to
6510run @command{guix publish} behind a caching proxy.
6511
e4c7a5f7
LC
6512@item --ttl=@var{ttl}
6513Produce @code{Cache-Control} HTTP headers that advertise a time-to-live
6514(TTL) of @var{ttl}. @var{ttl} must denote a duration: @code{5d} means 5
6515days, @code{1m} means 1 month, and so on.
6516
6517This allows the user's Guix to keep substitute information in cache for
6518@var{ttl}. However, note that @code{guix publish} does not itself
6519guarantee that the store items it provides will indeed remain available
6520for as long as @var{ttl}.
6521
aff8ce7c
DT
6522@item --repl[=@var{port}]
6523@itemx -r [@var{port}]
6524Spawn a Guile REPL server (@pxref{REPL Servers,,, guile, GNU Guile
8ce229fc
LC
6525Reference Manual}) on @var{port} (37146 by default). This is used
6526primarily for debugging a running @command{guix publish} server.
aff8ce7c
DT
6527@end table
6528
1c52181f
LC
6529Enabling @command{guix publish} on a GuixSD system is a one-liner: just
6530add a call to @code{guix-publish-service} in the @code{services} field
6531of the @code{operating-system} declaration (@pxref{guix-publish-service,
6532@code{guix-publish-service}}).
6533
332d7903
HG
6534If you are instead running Guix on a ``foreign distro'', follow these
6535instructions:”
6536
6537@itemize
6538@item
6539If your host distro uses the systemd init system:
6540
6541@example
6542# ln -s ~root/.guix-profile/lib/systemd/system/guix-publish.service \
6543 /etc/systemd/system/
6544# systemctl start guix-publish && systemctl enable guix-publish
6545@end example
6546
6547@item
6548If your host distro uses the Upstart init system:
6549
6550@example
6551# ln -s ~root/.guix-profile/lib/upstart/system/guix-publish.conf /etc/init/
6552# start guix-publish
6553@end example
6554
6555@item
6556Otherwise, proceed similarly with your distro's init system.
6557@end itemize
d23c20f1
LC
6558
6559@node Invoking guix challenge
6560@section Invoking @command{guix challenge}
6561
6562@cindex reproducible builds
6563@cindex verifiable builds
e32171ee
JD
6564@cindex @command{guix challenge}
6565@cindex challenge
d23c20f1 6566Do the binaries provided by this server really correspond to the source
f97c9175 6567code it claims to build? Is a package build process deterministic?
d23c20f1
LC
6568These are the questions the @command{guix challenge} command attempts to
6569answer.
6570
6571The former is obviously an important question: Before using a substitute
f97c9175 6572server (@pxref{Substitutes}), one had better @emph{verify} that it
d23c20f1
LC
6573provides the right binaries, and thus @emph{challenge} it. The latter
6574is what enables the former: If package builds are deterministic, then
6575independent builds of the package should yield the exact same result,
6576bit for bit; if a server provides a binary different from the one
6577obtained locally, it may be either corrupt or malicious.
6578
6579We know that the hash that shows up in @file{/gnu/store} file names is
6580the hash of all the inputs of the process that built the file or
6581directory---compilers, libraries, build scripts,
6582etc. (@pxref{Introduction}). Assuming deterministic build processes,
6583one store file name should map to exactly one build output.
6584@command{guix challenge} checks whether there is, indeed, a single
6585mapping by comparing the build outputs of several independent builds of
6586any given store item.
6587
f97c9175 6588The command output looks like this:
d23c20f1
LC
6589
6590@smallexample
ddbc7f7d
LC
6591$ guix challenge --substitute-urls="https://hydra.gnu.org https://guix.example.org"
6592updating list of substitutes from 'https://hydra.gnu.org'... 100.0%
6593updating list of substitutes from 'https://guix.example.org'... 100.0%
d23c20f1
LC
6594/gnu/store/@dots{}-openssl-1.0.2d contents differ:
6595 local hash: 0725l22r5jnzazaacncwsvp9kgf42266ayyp814v7djxs7nk963q
ddbc7f7d
LC
6596 https://hydra.gnu.org/nar/@dots{}-openssl-1.0.2d: 0725l22r5jnzazaacncwsvp9kgf42266ayyp814v7djxs7nk963q
6597 https://guix.example.org/nar/@dots{}-openssl-1.0.2d: 1zy4fmaaqcnjrzzajkdn3f5gmjk754b43qkq47llbyak9z0qjyim
d23c20f1
LC
6598/gnu/store/@dots{}-git-2.5.0 contents differ:
6599 local hash: 00p3bmryhjxrhpn2gxs2fy0a15lnip05l97205pgbk5ra395hyha
ddbc7f7d
LC
6600 https://hydra.gnu.org/nar/@dots{}-git-2.5.0: 069nb85bv4d4a6slrwjdy8v1cn4cwspm3kdbmyb81d6zckj3nq9f
6601 https://guix.example.org/nar/@dots{}-git-2.5.0: 0mdqa9w1p6cmli6976v4wi0sw9r4p5prkj7lzfd1877wk11c9c73
d23c20f1
LC
6602/gnu/store/@dots{}-pius-2.1.1 contents differ:
6603 local hash: 0k4v3m9z1zp8xzzizb7d8kjj72f9172xv078sq4wl73vnq9ig3ax
ddbc7f7d
LC
6604 https://hydra.gnu.org/nar/@dots{}-pius-2.1.1: 0k4v3m9z1zp8xzzizb7d8kjj72f9172xv078sq4wl73vnq9ig3ax
6605 https://guix.example.org/nar/@dots{}-pius-2.1.1: 1cy25x1a4fzq5rk0pmvc8xhwyffnqz95h2bpvqsz2mpvlbccy0gs
d23c20f1
LC
6606@end smallexample
6607
6608@noindent
6609In this example, @command{guix challenge} first scans the store to
6610determine the set of locally-built derivations---as opposed to store
6611items that were downloaded from a substitute server---and then queries
6612all the substitute servers. It then reports those store items for which
6613the servers obtained a result different from the local build.
6614
6615@cindex non-determinism, in package builds
6616As an example, @code{guix.example.org} always gets a different answer.
6617Conversely, @code{hydra.gnu.org} agrees with local builds, except in the
6618case of Git. This might indicate that the build process of Git is
6619non-deterministic, meaning that its output varies as a function of
6620various things that Guix does not fully control, in spite of building
6621packages in isolated environments (@pxref{Features}). Most common
6622sources of non-determinism include the addition of timestamps in build
6623results, the inclusion of random numbers, and directory listings sorted
a70a5004 6624by inode number. See @uref{https://reproducible-builds.org/docs/}, for
d23c20f1
LC
6625more information.
6626
f97c9175 6627To find out what is wrong with this Git binary, we can do something along
d23c20f1
LC
6628these lines (@pxref{Invoking guix archive}):
6629
6630@example
ddbc7f7d 6631$ wget -q -O - https://hydra.gnu.org/nar/@dots{}-git-2.5.0 \
d23c20f1 6632 | guix archive -x /tmp/git
043f4698 6633$ diff -ur --no-dereference /gnu/store/@dots{}-git.2.5.0 /tmp/git
d23c20f1
LC
6634@end example
6635
6636This command shows the difference between the files resulting from the
6637local build, and the files resulting from the build on
6638@code{hydra.gnu.org} (@pxref{Overview, Comparing and Merging Files,,
6639diffutils, Comparing and Merging Files}). The @command{diff} command
6640works great for text files. When binary files differ, a better option
ddbc7f7d 6641is @uref{https://diffoscope.org/, Diffoscope}, a tool that helps
d23c20f1
LC
6642visualize differences for all kinds of files.
6643
f97c9175 6644Once you have done that work, you can tell whether the differences are due
d23c20f1
LC
6645to a non-deterministic build process or to a malicious server. We try
6646hard to remove sources of non-determinism in packages to make it easier
f97c9175
AE
6647to verify substitutes, but of course, this is a process that
6648involves not just Guix, but a large part of the free software community.
d23c20f1
LC
6649In the meantime, @command{guix challenge} is one tool to help address
6650the problem.
6651
6652If you are writing packages for Guix, you are encouraged to check
6653whether @code{hydra.gnu.org} and other substitute servers obtain the
6654same build result as you did with:
6655
6656@example
6657$ guix challenge @var{package}
6658@end example
6659
6660@noindent
f97c9175 6661where @var{package} is a package specification such as
7cffaeb6 6662@code{guile@@2.0} or @code{glibc:debug}.
d23c20f1
LC
6663
6664The general syntax is:
6665
6666@example
6667guix challenge @var{options} [@var{packages}@dots{}]
6668@end example
6669
7cffaeb6
LC
6670When a difference is found between the hash of a locally-built item and
6671that of a server-provided substitute, or among substitutes provided by
6672different servers, the command displays it as in the example above and
a17417a8
LC
6673its exit code is 2 (other non-zero exit codes denote other kinds of
6674errors.)
7cffaeb6 6675
d23c20f1
LC
6676The one option that matters is:
6677
6678@table @code
6679
6680@item --substitute-urls=@var{urls}
6681Consider @var{urls} the whitespace-separated list of substitute source
6682URLs to compare to.
6683
153b6295
LC
6684@item --verbose
6685@itemx -v
6686Show details about matches (identical contents) in addition to
6687information about mismatches.
6688
d23c20f1
LC
6689@end table
6690
f11c444d
LC
6691@node Invoking guix copy
6692@section Invoking @command{guix copy}
6693
6694@cindex copy, of store items, over SSH
6695@cindex SSH, copy of store items
6696@cindex sharing store items across machines
6697@cindex transferring store items across machines
6698The @command{guix copy} command copies items from the store of one
6699machine to that of another machine over a secure shell (SSH)
6700connection@footnote{This command is available only when Guile-SSH was
6701found. @xref{Requirements}, for details.}. For example, the following
6702command copies the @code{coreutils} package, the user's profile, and all
6703their dependencies over to @var{host}, logged in as @var{user}:
6704
6705@example
6706guix copy --to=@var{user}@@@var{host} \
6707 coreutils `readlink -f ~/.guix-profile`
6708@end example
6709
6710If some of the items to be copied are already present on @var{host},
6711they are not actually sent.
6712
6713The command below retrieves @code{libreoffice} and @code{gimp} from
6714@var{host}, assuming they are available there:
6715
6716@example
6717guix copy --from=@var{host} libreoffice gimp
6718@end example
6719
6720The SSH connection is established using the Guile-SSH client, which is
6721compatible with OpenSSH: it honors @file{~/.ssh/known_hosts} and
6722@file{~/.ssh/config}, and uses the SSH agent for authentication.
6723
6724The key used to sign items that are sent must be accepted by the remote
6725machine. Likewise, the key used by the remote machine to sign items you
6726are retrieving must be in @file{/etc/guix/acl} so it is accepted by your
6727own daemon. @xref{Invoking guix archive}, for more information about
6728store item authentication.
6729
6730The general syntax is:
6731
6732@example
6733guix copy [--to=@var{spec}|--from=@var{spec}] @var{items}@dots{}
6734@end example
6735
6736You must always specify one of the following options:
6737
6738@table @code
6739@item --to=@var{spec}
6740@itemx --from=@var{spec}
6741Specify the host to send to or receive from. @var{spec} must be an SSH
6742spec such as @code{example.org}, @code{charlie@@example.org}, or
6743@code{charlie@@example.org:2222}.
6744@end table
6745
6746The @var{items} can be either package names, such as @code{gimp}, or
6747store items, such as @file{/gnu/store/@dots{}-idutils-4.6}.
6748
6749When specifying the name of a package to send, it is first built if
6750needed, unless @option{--dry-run} was specified. Common build options
6751are supported (@pxref{Common Build Options}).
6752
d23c20f1 6753
32efa254
DT
6754@node Invoking guix container
6755@section Invoking @command{guix container}
6756@cindex container
e32171ee 6757@cindex @command{guix container}
32efa254
DT
6758@quotation Note
6759As of version @value{VERSION}, this tool is experimental. The interface
6760is subject to radical change in the future.
6761@end quotation
6762
6763The purpose of @command{guix container} is to manipulate processes
6764running within an isolated environment, commonly known as a
46c36586 6765``container'', typically created by the @command{guix environment}
32efa254
DT
6766(@pxref{Invoking guix environment}) and @command{guix system container}
6767(@pxref{Invoking guix system}) commands.
6768
6769The general syntax is:
6770
6771@example
6772guix container @var{action} @var{options}@dots{}
6773@end example
6774
6775@var{action} specifies the operation to perform with a container, and
6776@var{options} specifies the context-specific arguments for the action.
6777
6778The following actions are available:
6779
6780@table @code
6781@item exec
6782Execute a command within the context of a running container.
6783
6784The syntax is:
6785
6786@example
6787guix container exec @var{pid} @var{program} @var{arguments}@dots{}
6788@end example
6789
6790@var{pid} specifies the process ID of the running container.
f97c9175
AE
6791@var{program} specifies an executable file name within the root file
6792system of the container. @var{arguments} are the additional options that
6793will be passed to @var{program}.
32efa254
DT
6794
6795The following command launches an interactive login shell inside a
6796GuixSD container, started by @command{guix system container}, and whose
6797process ID is 9001:
6798
6799@example
6800guix container exec 9001 /run/current-system/profile/bin/bash --login
6801@end example
6802
6803Note that the @var{pid} cannot be the parent process of a container. It
f97c9175 6804must be PID 1 of the container or one of its child processes.
32efa254
DT
6805
6806@end table
6807
a1ba8475
LC
6808@c *********************************************************************
6809@node GNU Distribution
6810@chapter GNU Distribution
6811
3ca2731c 6812@cindex Guix System Distribution
4705641f 6813@cindex GuixSD
3ca2731c
LC
6814Guix comes with a distribution of the GNU system consisting entirely of
6815free software@footnote{The term ``free'' here refers to the
a1ba8475 6816@url{http://www.gnu.org/philosophy/free-sw.html,freedom provided to
3ca2731c 6817users of that software}.}. The
35ed9306
LC
6818distribution can be installed on its own (@pxref{System Installation}),
6819but it is also possible to install Guix as a package manager on top of
6820an installed GNU/Linux system (@pxref{Installation}). To distinguish
3ca2731c 6821between the two, we refer to the standalone distribution as the Guix
4705641f 6822System Distribution, or GuixSD.
35ed9306
LC
6823
6824The distribution provides core GNU packages such as GNU libc, GCC, and
6825Binutils, as well as many GNU and non-GNU applications. The complete
6826list of available packages can be browsed
093ae1be 6827@url{http://www.gnu.org/software/guix/packages,on-line} or by
d03bb653 6828running @command{guix package} (@pxref{Invoking guix package}):
a1ba8475
LC
6829
6830@example
e49951eb 6831guix package --list-available
a1ba8475
LC
6832@end example
6833
f97c9175 6834Our goal is to provide a practical 100% free software distribution of
401c53c4
LC
6835Linux-based and other variants of GNU, with a focus on the promotion and
6836tight integration of GNU components, and an emphasis on programs and
6837tools that help users exert that freedom.
6838
3ca2731c 6839Packages are currently available on the following platforms:
c320011d
LC
6840
6841@table @code
6842
6843@item x86_64-linux
6844Intel/AMD @code{x86_64} architecture, Linux-Libre kernel;
6845
6846@item i686-linux
6847Intel 32-bit architecture (IA32), Linux-Libre kernel;
6848
aa1e1947 6849@item armhf-linux
aa725117 6850ARMv7-A architecture with hard float, Thumb-2 and NEON,
f97c9175
AE
6851using the EABI hard-float application binary interface (ABI),
6852and Linux-Libre kernel.
aa1e1947 6853
c320011d
LC
6854@item mips64el-linux
6855little-endian 64-bit MIPS processors, specifically the Loongson series,
f97c9175 6856n32 ABI, and Linux-Libre kernel.
c320011d
LC
6857
6858@end table
6859
4705641f 6860GuixSD itself is currently only available on @code{i686} and @code{x86_64}.
3ca2731c 6861
c320011d
LC
6862@noindent
6863For information on porting to other architectures or kernels,
f97c9175 6864@pxref{Porting}.
c320011d 6865
401c53c4 6866@menu
5af6de3e 6867* System Installation:: Installing the whole operating system.
35ed9306 6868* System Configuration:: Configuring the operating system.
91ef73d4 6869* Installing Debugging Files:: Feeding the debugger.
05962f29 6870* Security Updates:: Deploying security fixes quickly.
401c53c4 6871* Package Modules:: Packages from the programmer's viewpoint.
da7cabd4 6872* Packaging Guidelines:: Growing the distribution.
401c53c4 6873* Bootstrapping:: GNU/Linux built from scratch.
8b315a6d 6874* Porting:: Targeting another platform or kernel.
401c53c4
LC
6875@end menu
6876
6877Building this distribution is a cooperative effort, and you are invited
081145cf 6878to join! @xref{Contributing}, for information about how you can help.
401c53c4 6879
5af6de3e
LC
6880@node System Installation
6881@section System Installation
6882
e32171ee 6883@cindex installing GuixSD
3ca2731c 6884@cindex Guix System Distribution
c8b54374 6885This section explains how to install the Guix System Distribution (GuixSD)
3ca2731c 6886on a machine. The Guix package manager can
35ed9306
LC
6887also be installed on top of a running GNU/Linux system,
6888@pxref{Installation}.
5af6de3e
LC
6889
6890@ifinfo
9c18cf9b 6891@quotation Note
5af6de3e
LC
6892@c This paragraph is for people reading this from tty2 of the
6893@c installation image.
1068f26b 6894You are reading this documentation with an Info reader. For details on
5af6de3e 6895how to use it, hit the @key{RET} key (``return'' or ``enter'') on the
de341e7c
LC
6896link that follows: @pxref{Top, Info reader,, info-stnd, Stand-alone GNU
6897Info}. Hit @kbd{l} afterwards to come back here.
9c18cf9b
LC
6898
6899Alternately, run @command{info info} in another tty to keep the manual
6900available.
6901@end quotation
5af6de3e
LC
6902@end ifinfo
6903
dedb8d5e 6904@menu
e3009f60
LC
6905* Limitations:: What you can expect.
6906* Hardware Considerations:: Supported hardware.
6907* USB Stick Installation:: Preparing the installation medium.
6908* Preparing for Installation:: Networking, partitioning, etc.
6909* Proceeding with the Installation:: The real thing.
c8b54374 6910* Installing GuixSD in a VM:: GuixSD playground.
e3009f60 6911* Building the Installation Image:: How this comes to be.
dedb8d5e
LC
6912@end menu
6913
6914@node Limitations
8aaaae38
LC
6915@subsection Limitations
6916
4705641f 6917As of version @value{VERSION}, the Guix System Distribution (GuixSD) is
3ca2731c 6918not production-ready. It may contain bugs and lack important
8aaaae38
LC
6919features. Thus, if you are looking for a stable production system that
6920respects your freedom as a computer user, a good solution at this point
6921is to consider @url{http://www.gnu.org/distros/free-distros.html, one of
f97c9175 6922the more established GNU/Linux distributions}. We hope you can soon switch
4705641f 6923to the GuixSD without fear, of course. In the meantime, you can
8aaaae38
LC
6924also keep using your distribution and try out the package manager on top
6925of it (@pxref{Installation}).
6926
6927Before you proceed with the installation, be aware of the following
6928noteworthy limitations applicable to version @value{VERSION}:
6929
6930@itemize
6931@item
6932The installation process does not include a graphical user interface and
6933requires familiarity with GNU/Linux (see the following subsections to
6934get a feel of what that means.)
6935
8aaaae38 6936@item
dbcb0ab1 6937Support for the Logical Volume Manager (LVM) is missing.
8aaaae38
LC
6938
6939@item
6940Few system services are currently supported out-of-the-box
6941(@pxref{Services}).
6942
6943@item
4018745a 6944More than 5,000 packages are available, but you may
8aaaae38 6945occasionally find that a useful package is missing.
5fe01c2d
LC
6946
6947@item
6948GNOME, Xfce, and Enlightenment are available (@pxref{Desktop Services}),
6949as well as a number of X11 window managers. However, some graphical
6950applications may be missing, as well as KDE.
8aaaae38
LC
6951@end itemize
6952
f97c9175
AE
6953You have been warned! But more than a disclaimer, this is an invitation
6954to report issues (and success stories!), and to join us in improving it.
8aaaae38 6955@xref{Contributing}, for more info.
5af6de3e 6956
e3009f60
LC
6957
6958@node Hardware Considerations
6959@subsection Hardware Considerations
6960
6961@cindex hardware support on GuixSD
6962GNU@tie{}GuixSD focuses on respecting the user's computing freedom. It
6963builds around the kernel Linux-libre, which means that only hardware for
e0b3f97e 6964which free software drivers and firmware exist is supported. Nowadays,
e3009f60
LC
6965a wide range of off-the-shelf hardware is supported on
6966GNU/Linux-libre---from keyboards to graphics cards to scanners and
6967Ethernet controllers. Unfortunately, there are still areas where
6968hardware vendors deny users control over their own computing, and such
6969hardware is not supported on GuixSD.
6970
6971@cindex WiFi, hardware support
e0b3f97e 6972One of the main areas where free drivers or firmware are lacking is WiFi
e3009f60
LC
6973devices. WiFi devices known to work include those using Atheros chips
6974(AR9271 and AR7010), which corresponds to the @code{ath9k} Linux-libre
52db41af
EB
6975driver, and those using Broadcom/AirForce chips (BCM43xx with
6976Wireless-Core Revision 5), which corresponds to the @code{b43-open}
6977Linux-libre driver. Free firmware exists for both and is available
e3009f60
LC
6978out-of-the-box on GuixSD, as part of @var{%base-firmware}
6979(@pxref{operating-system Reference, @code{firmware}}).
6980
6981@cindex RYF, Respects Your Freedom
6982The @uref{https://www.fsf.org/, Free Software Foundation} runs
e0b3f97e 6983@uref{https://www.fsf.org/ryf, @dfn{Respects Your Freedom}} (RYF), a
e3009f60
LC
6984certification program for hardware products that respect your freedom
6985and your privacy and ensure that you have control over your device. We
e0b3f97e 6986encourage you to check the list of RYF-certified devices.
e3009f60
LC
6987
6988Another useful resource is the @uref{https://www.h-node.org/, H-Node}
6989web site. It contains a catalog of hardware devices with information
6990about their support in GNU/Linux.
6991
6992
dedb8d5e 6993@node USB Stick Installation
5af6de3e
LC
6994@subsection USB Stick Installation
6995
6996An installation image for USB sticks can be downloaded from
4705641f 6997@indicateurl{ftp://alpha.gnu.org/gnu/guix/guixsd-usb-install-@value{VERSION}.@var{system}.xz},
5af6de3e
LC
6998where @var{system} is one of:
6999
7000@table @code
7001@item x86_64-linux
7002for a GNU/Linux system on Intel/AMD-compatible 64-bit CPUs;
7003
7004@item i686-linux
7005for a 32-bit GNU/Linux system on Intel-compatible CPUs.
7006@end table
7007
debc6360
LC
7008@c start duplication of authentication part from ``Binary Installation''
7009Make sure to download the associated @file{.sig} file and to verify the
7010authenticity of the image against it, along these lines:
7011
7012@example
7013$ wget ftp://alpha.gnu.org/gnu/guix/guixsd-usb-install-@value{VERSION}.@var{system}.xz.sig
7014$ gpg --verify guixsd-usb-install-@value{VERSION}.@var{system}.xz.sig
7015@end example
7016
7017If that command fails because you do not have the required public key,
7018then run this command to import it:
7019
7020@example
7021$ gpg --keyserver pgp.mit.edu --recv-keys @value{OPENPGP-SIGNING-KEY-ID}
7022@end example
7023
7024@noindent
7025and rerun the @code{gpg --verify} command.
7026@c end duplication
7027
5af6de3e
LC
7028This image contains a single partition with the tools necessary for an
7029installation. It is meant to be copied @emph{as is} to a large-enough
7030USB stick.
7031
7032To copy the image to a USB stick, follow these steps:
7033
7034@enumerate
7035@item
7036Decompress the image using the @command{xz} command:
7037
7038@example
4705641f 7039xz -d guixsd-usb-install-@value{VERSION}.@var{system}.xz
5af6de3e
LC
7040@end example
7041
7042@item
f97c9175
AE
7043Insert a USB stick of 1@tie{}GiB or more into your machine, and determine
7044its device name. Assuming that the USB stick is known as @file{/dev/sdX},
5af6de3e
LC
7045copy the image with:
7046
7047@example
4705641f 7048dd if=guixsd-usb-install-@value{VERSION}.x86_64 of=/dev/sdX
5af6de3e
LC
7049@end example
7050
7051Access to @file{/dev/sdX} usually requires root privileges.
7052@end enumerate
7053
7054Once this is done, you should be able to reboot the system and boot from
7055the USB stick. The latter usually requires you to get in the BIOS' boot
7056menu, where you can choose to boot from the USB stick.
7057
c8b54374
VL
7058@xref{Installing GuixSD in a VM}, if, instead, you would like to install
7059GuixSD in a virtual machine (VM).
7060
dedb8d5e 7061@node Preparing for Installation
5af6de3e
LC
7062@subsection Preparing for Installation
7063
7064Once you have successfully booted the image on the USB stick, you should
7065end up with a root prompt. Several console TTYs are configured and can
7066be used to run commands as root. TTY2 shows this documentation,
de341e7c
LC
7067browsable using the Info reader commands (@pxref{Top,,, info-stnd,
7068Stand-alone GNU Info}). The installation system runs the GPM mouse
7069daemon, which allows you to select text with the left mouse button and
7070to paste it with the middle button.
5af6de3e 7071
ff925d37
LC
7072@quotation Note
7073Installation requires access to the Internet so that any missing
7074dependencies of your system configuration can be downloaded. See the
7075``Networking'' section below.
7076@end quotation
7077
0e69cf67
LC
7078The installation system includes many common tools needed for this task.
7079But it is also a full-blown GuixSD system, which means that you can
7080install additional packages, should you need it, using @command{guix
7081package} (@pxref{Invoking guix package}).
7082
dedb8d5e 7083@subsubsection Keyboard Layout
5af6de3e 7084
dedb8d5e
LC
7085@cindex keyboard layout
7086The installation image uses the US qwerty keyboard layout. If you want
7087to change it, you can use the @command{loadkeys} command. For example,
7088the following command selects the Dvorak keyboard layout:
5af6de3e 7089
dedb8d5e
LC
7090@example
7091loadkeys dvorak
7092@end example
7093
7094See the files under @file{/run/current-system/profile/share/keymaps} for
7095a list of available keyboard layouts. Run @command{man loadkeys} for
7096more information.
7097
7098@subsubsection Networking
7099
7100Run the following command see what your network interfaces are called:
235cba85
LC
7101
7102@example
dedb8d5e 7103ifconfig -a
235cba85
LC
7104@end example
7105
1713c37f
LC
7106@noindent
7107@dots{} or, using the GNU/Linux-specific @command{ip} command:
7108
7109@example
7110ip a
7111@end example
7112
95c559c1 7113@c http://cgit.freedesktop.org/systemd/systemd/tree/src/udev/udev-builtin-net_id.c#n20
dedb8d5e
LC
7114Wired interfaces have a name starting with @samp{e}; for example, the
7115interface corresponding to the first on-board Ethernet controller is
7116called @samp{eno1}. Wireless interfaces have a name starting with
7117@samp{w}, like @samp{w1p2s0}.
7118
7119@table @asis
7120@item Wired connection
7121To configure a wired network run the following command, substituting
7122@var{interface} with the name of the wired interface you want to use.
7123
7124@example
7125ifconfig @var{interface} up
7126@end example
7127
7128@item Wireless connection
e32171ee
JD
7129@cindex wireless
7130@cindex WiFi
dedb8d5e
LC
7131To configure wireless networking, you can create a configuration file
7132for the @command{wpa_supplicant} configuration tool (its location is not
7133important) using one of the available text editors such as
7134@command{zile}:
7135
7136@example
7137zile wpa_supplicant.conf
7138@end example
7139
7140As an example, the following stanza can go to this file and will work
7141for many wireless networks, provided you give the actual SSID and
7142passphrase for the network you are connecting to:
7143
7144@example
7145network=@{
ae768308 7146 ssid="@var{my-ssid}"
dedb8d5e
LC
7147 key_mgmt=WPA-PSK
7148 psk="the network's secret passphrase"
7149@}
7150@end example
7151
7152Start the wireless service and run it in the background with the
7153following command (substitute @var{interface} with the name of the
7154network interface you want to use):
7155
7156@example
7157wpa_supplicant -c wpa_supplicant.conf -i @var{interface} -B
7158@end example
7159
641d0518 7160Run @command{man wpa_supplicant} for more information.
dedb8d5e
LC
7161@end table
7162
e32171ee 7163@cindex DHCP
dedb8d5e
LC
7164At this point, you need to acquire an IP address. On a network where IP
7165addresses are automatically assigned @i{via} DHCP, you can run:
7166
7167@example
15650ac2 7168dhclient -v @var{interface}
dedb8d5e 7169@end example
5af6de3e 7170
dedb8d5e
LC
7171Try to ping a server to see if networking is up and running:
7172
7173@example
7174ping -c 3 gnu.org
7175@end example
5af6de3e
LC
7176
7177Setting up network access is almost always a requirement because the
7178image does not contain all the software and tools that may be needed.
7179
dedb8d5e
LC
7180@subsubsection Disk Partitioning
7181
7182Unless this has already been done, the next step is to partition, and
7183then format the target partition(s).
7184
7185The installation image includes several partitioning tools, including
7186Parted (@pxref{Overview,,, parted, GNU Parted User Manual}),
7187@command{fdisk}, and @command{cfdisk}. Run it and set up your disk with
7188the partition layout you want:
7189
7190@example
7191cfdisk
7192@end example
7193
d918d79f
SB
7194If your disk uses the GUID Partition Table (GPT) format and you plan to
7195install BIOS-based GRUB (which is the default), make sure a BIOS Boot
7196Partition is available (@pxref{BIOS installation,,, grub, GNU GRUB
7197manual}).
7198
dedb8d5e
LC
7199Once you are done partitioning the target hard disk drive, you have to
7200create a file system on the relevant partition(s)@footnote{Currently
b1a505ba
DC
7201GuixSD only supports ext4 and btrfs file systems. In particular, code
7202that reads partition UUIDs and labels only works for these file system
7203types.}.
5af6de3e 7204
7ab44369
LC
7205Preferably, assign partitions a label so that you can easily and
7206reliably refer to them in @code{file-system} declarations (@pxref{File
7207Systems}). This is typically done using the @code{-L} option of
dedb8d5e
LC
7208@command{mkfs.ext4} and related commands. So, assuming the target root
7209partition lives at @file{/dev/sda1}, a file system with the label
7210@code{my-root} can be created with:
7ab44369 7211
dedb8d5e
LC
7212@example
7213mkfs.ext4 -L my-root /dev/sda1
7214@end example
dd816355 7215
13fb1bd9
LC
7216@cindex encrypted disk
7217If you are instead planning to encrypt the root partition, you can use
7218the Cryptsetup/LUKS utilities to do that (see @inlinefmtifelse{html,
7219@uref{https://linux.die.net/man/8/cryptsetup, @code{man cryptsetup}},
7220@code{man cryptsetup}} for more information.) Assuming you want to
7221store the root partition on @file{/dev/sda1}, the command sequence would
7222be along these lines:
6d6e6281 7223
13fb1bd9
LC
7224@example
7225cryptsetup luksFormat /dev/sda1
7226cryptsetup open --type luks /dev/sda1 my-partition
7227mkfs.ext4 -L my-root /dev/mapper/my-partition
7228@end example
5af6de3e 7229
dedb8d5e 7230Once that is done, mount the target root partition under @file{/mnt}
13fb1bd9
LC
7231with a command like (again, assuming @code{my-root} is the label of the
7232root partition):
83a17b62 7233
dedb8d5e 7234@example
13fb1bd9 7235mount LABEL=my-root /mnt
dedb8d5e 7236@end example
83a17b62 7237
31b6cdf8
LC
7238Finally, if you plan to use one or more swap partitions (@pxref{Memory
7239Concepts, swap space,, libc, The GNU C Library Reference Manual}), make
7240sure to initialize them with @command{mkswap}. Assuming you have one
7241swap partition on @file{/dev/sda2}, you would run:
7242
7243@example
7244mkswap /dev/sda2
b2ff76a0 7245swapon /dev/sda2
31b6cdf8
LC
7246@end example
7247
a4ca4362
CM
7248Alternatively, you may use a swap file. For example, assuming that in
7249the new system you want to use the file @file{/swapfile} as a swap file,
7250you would run@footnote{This example will work for many types of file
7251systems (e.g., ext4). However, for copy-on-write file systems (e.g.,
7252btrfs), the required steps may be different. For details, see the
7253manual pages for @command{mkswap} and @command{swapon}.}:
7254
7255@example
7256# This is 10 GiB of swap space. Adjust "count" to change the size.
7257dd if=/dev/zero of=/mnt/swapfile bs=1MiB count=10240
7258# For security, make the file readable and writable only by root.
7259chmod 600 /mnt/swapfile
7260mkswap /mnt/swapfile
7261swapon /mnt/swapfile
7262@end example
7263
7264Note that if you have encrypted the root partition and created a swap
7265file in its file system as described above, then the encryption also
7266protects the swap file, just like any other file in that file system.
7267
dedb8d5e
LC
7268@node Proceeding with the Installation
7269@subsection Proceeding with the Installation
83a17b62 7270
dedb8d5e
LC
7271With the target partitions ready and the target root mounted on
7272@file{/mnt}, we're ready to go. First, run:
5af6de3e 7273
dedb8d5e
LC
7274@example
7275herd start cow-store /mnt
7276@end example
5af6de3e 7277
b397c0d5
LC
7278This makes @file{/gnu/store} copy-on-write, such that packages added to it
7279during the installation phase are written to the target disk on @file{/mnt}
7280rather than kept in memory. This is necessary because the first phase of
7281the @command{guix system init} command (see below) entails downloads or
7282builds to @file{/gnu/store} which, initially, is an in-memory file system.
5af6de3e 7283
dedb8d5e 7284Next, you have to edit a file and
5af6de3e 7285provide the declaration of the operating system to be installed. To
a8cb87ab
LC
7286that end, the installation system comes with three text editors: GNU nano
7287(@pxref{Top,,, nano, GNU nano Manual}), GNU Zile (an Emacs clone), and
7288nvi (a clone of the original BSD @command{vi} editor).
efa77c6c
LC
7289We strongly recommend storing that file on the target root file system, say,
7290as @file{/mnt/etc/config.scm}. Failing to do that, you will have lost your
7291configuration file once you have rebooted into the newly-installed system.
5af6de3e 7292
dedb8d5e
LC
7293@xref{Using the Configuration System}, for an overview of the
7294configuration file. The example configurations discussed in that
7295section are available under @file{/etc/configuration} in the
7296installation image. Thus, to get started with a system configuration
7297providing a graphical display server (a ``desktop'' system), you can run
7298something along these lines:
7299
7300@example
7301# mkdir /mnt/etc
7302# cp /etc/configuration/desktop.scm /mnt/etc/config.scm
7303# zile /mnt/etc/config.scm
7304@end example
7305
7306You should pay attention to what your configuration file contains, and
7307in particular:
7308
7309@itemize
7310@item
7311Make sure the @code{grub-configuration} form refers to the device you
7312want to install GRUB on.
7313
7314@item
7315Be sure that your partition labels match the value of their respective
7316@code{device} fields in your @code{file-system} configuration, assuming
7317your @code{file-system} configuration sets the value of @code{title} to
7318@code{'label}.
13fb1bd9
LC
7319
7320@item
7321If there are encrypted or RAID partitions, make sure to add a
7322@code{mapped-devices} field to describe them (@pxref{Mapped Devices}).
dedb8d5e 7323@end itemize
5af6de3e 7324
dd51caac
LC
7325Once you are done preparing the configuration file, the new system must
7326be initialized (remember that the target root file system is mounted
7327under @file{/mnt}):
5af6de3e
LC
7328
7329@example
7330guix system init /mnt/etc/config.scm /mnt
7331@end example
7332
7333@noindent
dedb8d5e 7334This copies all the necessary files and installs GRUB on
5af6de3e 7335@file{/dev/sdX}, unless you pass the @option{--no-grub} option. For
6621cdb6 7336more information, @pxref{Invoking guix system}. This command may trigger
5af6de3e
LC
7337downloads or builds of missing packages, which can take some time.
7338
1bd4e6db
LC
7339Once that command has completed---and hopefully succeeded!---you can run
7340@command{reboot} and boot into the new system. The @code{root} password
7341in the new system is initially empty; other users' passwords need to be
7342initialized by running the @command{passwd} command as @code{root},
7343unless your configuration specifies otherwise
7344(@pxref{user-account-password, user account passwords}).
7345
7fcf2a0b
LC
7346@cindex upgrading GuixSD
7347From then on, you can update GuixSD whenever you want by running
7348@command{guix pull} as @code{root} (@pxref{Invoking guix pull}), and
7349then running @command{guix system reconfigure} to build a new system
7350generation with the latest packages and services (@pxref{Invoking guix
7351system}). We recommend doing that regularly so that your system
7352includes the latest security updates (@pxref{Security Updates}).
7353
1bd4e6db 7354Join us on @code{#guix} on the Freenode IRC network or on
5af6de3e
LC
7355@file{guix-devel@@gnu.org} to share your experience---good or not so
7356good.
7357
c8b54374
VL
7358@node Installing GuixSD in a VM
7359@subsection Installing GuixSD in a Virtual Machine
7360
7361@cindex virtual machine, GuixSD installation
7362If you'd like to install GuixSD in a virtual machine (VM) rather than on
7363your beloved machine, this section is for you.
7364
7365To boot a @uref{http://qemu.org/,QEMU} VM for installing GuixSD in a
7366disk image, follow these steps:
7367
7368@enumerate
7369@item
a0885414
LF
7370First, retrieve and decompress the GuixSD installation image as
7371described previously (@pxref{USB Stick Installation}).
c8b54374
VL
7372
7373@item
7374Create a disk image that will hold the installed system. To make a
7375qcow2-formatted disk image, use the @command{qemu-img} command:
7376
7377@example
7378qemu-img create -f qcow2 guixsd.img 5G
7379@end example
7380
7381This will create a 5GB file.
7382
7383@item
7384Boot the USB installation image in an VM:
7385
7386@example
7387qemu-system-x86_64 -m 1024 -smp 1 \
d36b8457 7388 -net user -net nic,model=virtio -boot menu=on \
c8b54374
VL
7389 -drive file=guixsd.img \
7390 -drive file=guixsd-usb-install-@value{VERSION}.@var{system}
7391@end example
7392
7393In the VM console, quickly press the @kbd{F12} key to enter the boot
7394menu. Then press the @kbd{2} key and the @kbd{RET} key to validate your
7395selection.
7396
7397@item
7398You're now root in the VM, proceed with the installation process.
7399@xref{Preparing for Installation}, and follow the instructions.
7400@end enumerate
7401
7402Once installation is complete, you can boot the system that's on your
7403@file{guixsd.img} image. @xref{Running GuixSD in a VM}, for how to do
7404that.
7405
dedb8d5e 7406@node Building the Installation Image
5af6de3e
LC
7407@subsection Building the Installation Image
7408
e32171ee 7409@cindex installation image
5af6de3e
LC
7410The installation image described above was built using the @command{guix
7411system} command, specifically:
7412
622b2304 7413@c FIXME: 1G is too much; see <http://bugs.gnu.org/23077>.
5af6de3e 7414@example
622b2304 7415guix system disk-image --image-size=1G gnu/system/install.scm
5af6de3e
LC
7416@end example
7417
6e6a0401
AE
7418Have a look at @file{gnu/system/install.scm} in the source tree,
7419and see also @ref{Invoking guix system} for more information
5af6de3e
LC
7420about the installation image.
7421
cf4a9129
LC
7422@node System Configuration
7423@section System Configuration
b208a005 7424
cf4a9129 7425@cindex system configuration
3ca2731c 7426The Guix System Distribution supports a consistent whole-system configuration
cf4a9129
LC
7427mechanism. By that we mean that all aspects of the global system
7428configuration---such as the available system services, timezone and
7429locale settings, user accounts---are declared in a single place. Such
7430a @dfn{system configuration} can be @dfn{instantiated}---i.e., effected.
91ef73d4 7431
cf4a9129
LC
7432One of the advantages of putting all the system configuration under the
7433control of Guix is that it supports transactional system upgrades, and
1068f26b 7434makes it possible to roll back to a previous system instantiation,
cf4a9129 7435should something go wrong with the new one (@pxref{Features}). Another
1068f26b 7436advantage is that it makes it easy to replicate the exact same configuration
cf4a9129
LC
7437across different machines, or at different points in time, without
7438having to resort to additional administration tools layered on top of
1068f26b 7439the own tools of the system.
cf4a9129 7440@c Yes, we're talking of Puppet, Chef, & co. here. ↑
91ef73d4 7441
cf4a9129
LC
7442This section describes this mechanism. First we focus on the system
7443administrator's viewpoint---explaining how the system is configured and
7444instantiated. Then we show how this mechanism can be extended, for
7445instance to support new system services.
91ef73d4 7446
cf4a9129
LC
7447@menu
7448* Using the Configuration System:: Customizing your GNU system.
7313a52e 7449* operating-system Reference:: Detail of operating-system declarations.
cf4a9129 7450* File Systems:: Configuring file system mounts.
510f9d86 7451* Mapped Devices:: Block device extra processing.
cf4a9129 7452* User Accounts:: Specifying user accounts.
598e19dc 7453* Locales:: Language and cultural convention settings.
cf4a9129 7454* Services:: Specifying system services.
0ae8c15a 7455* Setuid Programs:: Programs running with root privileges.
efb5e833 7456* X.509 Certificates:: Authenticating HTTPS servers.
996ed739 7457* Name Service Switch:: Configuring libc's name service switch.
fd1b1fa2 7458* Initial RAM Disk:: Linux-Libre bootstrapping.
88faf933 7459* GRUB Configuration:: Configuring the boot loader.
cf4a9129 7460* Invoking guix system:: Instantiating a system configuration.
97d76250 7461* Running GuixSD in a VM:: How to run GuixSD in a virtual machine.
cf4a9129
LC
7462* Defining Services:: Adding new service definitions.
7463@end menu
91ef73d4 7464
cf4a9129
LC
7465@node Using the Configuration System
7466@subsection Using the Configuration System
64d76fa6 7467
cf4a9129
LC
7468The operating system is configured by providing an
7469@code{operating-system} declaration in a file that can then be passed to
7470the @command{guix system} command (@pxref{Invoking guix system}). A
7471simple setup, with the default system services, the default Linux-Libre
7472kernel, initial RAM disk, and boot loader looks like this:
91ef73d4 7473
cf4a9129
LC
7474@findex operating-system
7475@lisp
dd51caac 7476@include os-config-bare-bones.texi
cf4a9129 7477@end lisp
401c53c4 7478
cf4a9129
LC
7479This example should be self-describing. Some of the fields defined
7480above, such as @code{host-name} and @code{bootloader}, are mandatory.
7481Others, such as @code{packages} and @code{services}, can be omitted, in
7482which case they get a default value.
e7f34eb0 7483
5d94ac51
LC
7484Below we discuss the effect of some of the most important fields
7485(@pxref{operating-system Reference}, for details about all the available
7486fields), and how to @dfn{instantiate} the operating system using
7487@command{guix system}.
7488
7489@unnumberedsubsubsec Globally-Visible Packages
7490
cf4a9129 7491@vindex %base-packages
5d94ac51
LC
7492The @code{packages} field lists packages that will be globally visible
7493on the system, for all user accounts---i.e., in every user's @code{PATH}
7494environment variable---in addition to the per-user profiles
7495(@pxref{Invoking guix package}). The @var{%base-packages} variable
7496provides all the tools one would expect for basic user and administrator
7497tasks---including the GNU Core Utilities, the GNU Networking Utilities,
7498the GNU Zile lightweight text editor, @command{find}, @command{grep},
7499etc. The example above adds tcpdump to those, taken from the @code{(gnu
7500packages admin)} module (@pxref{Package Modules}).
e7f34eb0 7501
f6c9fb1b
LC
7502@findex specification->package
7503Referring to packages by variable name, like @var{tcpdump} above, has
7504the advantage of being unambiguous; it also allows typos and such to be
7505diagnosed right away as ``unbound variables''. The downside is that one
7506needs to know which module defines which package, and to augment the
7507@code{use-package-modules} line accordingly. To avoid that, one can use
7508the @code{specification->package} procedure of the @code{(gnu packages)}
7509module, which returns the best package for a given name or name and
7510version:
7511
7512@lisp
7513(use-modules (gnu packages))
7514
7515(operating-system
7516 ;; ...
7517 (packages (append (map specification->package
d5e59248 7518 '("tcpdump" "htop" "gnupg@@2.0"))
f6c9fb1b
LC
7519 %base-packages)))
7520@end lisp
7521
5d94ac51
LC
7522@unnumberedsubsubsec System Services
7523
e32171ee 7524@cindex services
cf4a9129
LC
7525@vindex %base-services
7526The @code{services} field lists @dfn{system services} to be made
7527available when the system starts (@pxref{Services}).
7528The @code{operating-system} declaration above specifies that, in
7529addition to the basic services, we want the @command{lshd} secure shell
cd6f6c22
LC
7530daemon listening on port 2222 (@pxref{Networking Services,
7531@code{lsh-service}}). Under the hood,
cf4a9129
LC
7532@code{lsh-service} arranges so that @code{lshd} is started with the
7533right command-line options, possibly with supporting configuration files
cd6f6c22
LC
7534generated as needed (@pxref{Defining Services}).
7535
7536@cindex customization, of services
7537@findex modify-services
7538Occasionally, instead of using the base services as is, you will want to
4d343a14
CM
7539customize them. To do this, use @code{modify-services} (@pxref{Service
7540Reference, @code{modify-services}}) to modify the list.
7541
7542For example, suppose you want to modify @code{guix-daemon} and Mingetty
7543(the console log-in) in the @var{%base-services} list (@pxref{Base
7544Services, @code{%base-services}}). To do that, you can write the
7545following in your operating system declaration:
cd6f6c22
LC
7546
7547@lisp
4d343a14
CM
7548(define %my-services
7549 ;; My very own list of services.
7550 (modify-services %base-services
7551 (guix-service-type config =>
7552 (guix-configuration
7553 (inherit config)
7554 (use-substitutes? #f)
7555 (extra-options '("--gc-keep-derivations"))))
7556 (mingetty-service-type config =>
7557 (mingetty-configuration
317d3b47 7558 (inherit config)))))
4d343a14
CM
7559
7560(operating-system
7561 ;; @dots{}
7562 (services %my-services))
cd6f6c22
LC
7563@end lisp
7564
4d343a14
CM
7565This changes the configuration---i.e., the service parameters---of the
7566@code{guix-service-type} instance, and that of all the
7567@code{mingetty-service-type} instances in the @var{%base-services} list.
7568Observe how this is accomplished: first, we arrange for the original
7569configuration to be bound to the identifier @code{config} in the
7570@var{body}, and then we write the @var{body} so that it evaluates to the
7571desired configuration. In particular, notice how we use @code{inherit}
7572to create a new configuration which has the same values as the old
7573configuration, but with a few modifications.
a1ba8475 7574
13fb1bd9
LC
7575@cindex encrypted disk
7576The configuration for a typical ``desktop'' usage, with an encrypted
7577root partition, the X11 display
d038b674
LC
7578server, GNOME and Xfce (users can choose which of these desktop
7579environments to use at the log-in screen by pressing @kbd{F1}), network
7580management, power management, and more, would look like this:
dd51caac
LC
7581
7582@lisp
7583@include os-config-desktop.texi
7584@end lisp
7585
d038b674
LC
7586A graphical environment with a choice of lightweight window managers
7587instead of full-blown desktop environments would look like this:
7588
7589@lisp
7590@include os-config-lightweight-desktop.texi
7591@end lisp
7592
dd51caac 7593@xref{Desktop Services}, for the exact list of services provided by
efb5e833
LC
7594@var{%desktop-services}. @xref{X.509 Certificates}, for background
7595information about the @code{nss-certs} package that is used here.
dd51caac 7596
5d94ac51
LC
7597Again, @var{%desktop-services} is just a list of service objects. If
7598you want to remove services from there, you can do so using the
7599procedures for list filtering (@pxref{SRFI-1 Filtering and
7600Partitioning,,, guile, GNU Guile Reference Manual}). For instance, the
7601following expression returns a list that contains all the services in
7602@var{%desktop-services} minus the Avahi service:
7603
7604@example
7605(remove (lambda (service)
7606 (eq? (service-kind service) avahi-service-type))
7607 %desktop-services)
7608@end example
7609
7610@unnumberedsubsubsec Instantiating the System
7611
7612Assuming the @code{operating-system} declaration
7613is stored in the @file{my-system-config.scm}
cf4a9129
LC
7614file, the @command{guix system reconfigure my-system-config.scm} command
7615instantiates that configuration, and makes it the default GRUB boot
65797bff
LC
7616entry (@pxref{Invoking guix system}).
7617
1068f26b 7618The normal way to change the system configuration is by updating this
65797bff 7619file and re-running @command{guix system reconfigure}. One should never
8b499030 7620have to touch files in @file{/etc} or to run commands that modify the
65797bff
LC
7621system state such as @command{useradd} or @command{grub-install}. In
7622fact, you must avoid that since that would not only void your warranty
7623but also prevent you from rolling back to previous versions of your
7624system, should you ever need to.
7625
7626@cindex roll-back, of the operating system
7627Speaking of roll-back, each time you run @command{guix system
7628reconfigure}, a new @dfn{generation} of the system is created---without
7629modifying or deleting previous generations. Old system generations get
7630an entry in the GRUB boot menu, allowing you to boot them in case
7631something went wrong with the latest generation. Reassuring, no? The
7632@command{guix system list-generations} command lists the system
067a2e2d
CM
7633generations available on disk. It is also possible to roll back the
7634system via the commands @command{guix system roll-back} and
7635@command{guix system switch-generation}.
7636
7637Although the command @command{guix system reconfigure} will not modify
7638previous generations, must take care when the current generation is not
7639the latest (e.g., after invoking @command{guix system roll-back}), since
7640the operation might overwrite a later generation (@pxref{Invoking guix
7641system}).
b81e1947 7642
5d94ac51
LC
7643@unnumberedsubsubsec The Programming Interface
7644
cf4a9129
LC
7645At the Scheme level, the bulk of an @code{operating-system} declaration
7646is instantiated with the following monadic procedure (@pxref{The Store
7647Monad}):
b81e1947 7648
cf4a9129
LC
7649@deffn {Monadic Procedure} operating-system-derivation os
7650Return a derivation that builds @var{os}, an @code{operating-system}
7651object (@pxref{Derivations}).
b81e1947 7652
cf4a9129
LC
7653The output of the derivation is a single directory that refers to all
7654the packages, configuration files, and other supporting files needed to
7655instantiate @var{os}.
7656@end deffn
b81e1947 7657
5d94ac51
LC
7658This procedure is provided by the @code{(gnu system)} module. Along
7659with @code{(gnu services)} (@pxref{Services}), this module contains the
7660guts of GuixSD. Make sure to visit it!
7661
7662
7313a52e
LC
7663@node operating-system Reference
7664@subsection @code{operating-system} Reference
7665
7666This section summarizes all the options available in
7667@code{operating-system} declarations (@pxref{Using the Configuration
7668System}).
7669
7670@deftp {Data Type} operating-system
7671This is the data type representing an operating system configuration.
7672By that, we mean all the global system configuration, not per-user
7673configuration (@pxref{Using the Configuration System}).
7674
7675@table @asis
7676@item @code{kernel} (default: @var{linux-libre})
fbb25e56 7677The package object of the operating system kernel to use@footnote{Currently
7313a52e
LC
7678only the Linux-libre kernel is supported. In the future, it will be
7679possible to use the GNU@tie{}Hurd.}.
7680
ee2a6304
LC
7681@item @code{kernel-arguments} (default: @code{'()})
7682List of strings or gexps representing additional arguments to pass on
1068f26b 7683the command-line of the kernel---e.g., @code{("console=ttyS0")}.
ee2a6304 7684
7313a52e 7685@item @code{bootloader}
88faf933 7686The system bootloader configuration object. @xref{GRUB Configuration}.
7313a52e
LC
7687
7688@item @code{initrd} (default: @code{base-initrd})
e32171ee
JD
7689@cindex initrd
7690@cindex initial RAM disk
7313a52e
LC
7691A two-argument monadic procedure that returns an initial RAM disk for
7692the Linux kernel. @xref{Initial RAM Disk}.
7693
f34c56be
LC
7694@item @code{firmware} (default: @var{%base-firmware})
7695@cindex firmware
7696List of firmware packages loadable by the operating system kernel.
7697
52db41af
EB
7698The default includes firmware needed for Atheros- and Broadcom-based
7699WiFi devices (Linux-libre modules @code{ath9k} and @code{b43-open},
7700respectively). @xref{Hardware Considerations}, for more info on
7701supported hardware.
f34c56be 7702
7313a52e
LC
7703@item @code{host-name}
7704The host name.
7705
7706@item @code{hosts-file}
7707@cindex hosts file
24e02c28 7708A file-like object (@pxref{G-Expressions, file-like objects}) for use as
7313a52e 7709@file{/etc/hosts} (@pxref{Host Names,,, libc, The GNU C Library
24e02c28 7710Reference Manual}). The default is a file with entries for
7313a52e
LC
7711@code{localhost} and @var{host-name}.
7712
7713@item @code{mapped-devices} (default: @code{'()})
7714A list of mapped devices. @xref{Mapped Devices}.
7715
7716@item @code{file-systems}
7717A list of file systems. @xref{File Systems}.
7718
7719@item @code{swap-devices} (default: @code{'()})
7720@cindex swap devices
a4ca4362
CM
7721A list of strings identifying devices or files to be used for ``swap
7722space'' (@pxref{Memory Concepts,,, libc, The GNU C Library Reference
7723Manual}). For example, @code{'("/dev/sda3")} or @code{'("/swapfile")}.
7724It is possible to specify a swap file in a file system on a mapped
7725device, provided that the necessary device mapping and file system are
7726also specified. @xref{Mapped Devices} and @ref{File Systems}.
7313a52e 7727
bf87f38a 7728@item @code{users} (default: @code{%base-user-accounts})
7313a52e
LC
7729@itemx @code{groups} (default: @var{%base-groups})
7730List of user accounts and groups. @xref{User Accounts}.
7731
7732@item @code{skeletons} (default: @code{(default-skeletons)})
e9dffec1
LC
7733A list target file name/file-like object tuples (@pxref{G-Expressions,
7734file-like objects}). These are the skeleton files that will be added to
7735the home directory of newly-created user accounts.
7313a52e
LC
7736
7737For instance, a valid value may look like this:
7738
7739@example
e9dffec1
LC
7740`((".bashrc" ,(plain-file "bashrc" "echo Hello\n"))
7741 (".guile" ,(plain-file "guile"
7742 "(use-modules (ice-9 readline))
7743 (activate-readline)")))
7313a52e
LC
7744@end example
7745
7746@item @code{issue} (default: @var{%default-issue})
7747A string denoting the contents of the @file{/etc/issue} file, which is
1068f26b 7748displayed when users log in on a text console.
7313a52e
LC
7749
7750@item @code{packages} (default: @var{%base-packages})
7751The set of packages installed in the global profile, which is accessible
7752at @file{/run/current-system/profile}.
7753
1068f26b 7754The default set includes core utilities and it is good practice to
7313a52e
LC
7755install non-core utilities in user profiles (@pxref{Invoking guix
7756package}).
7757
7758@item @code{timezone}
7759A timezone identifying string---e.g., @code{"Europe/Paris"}.
7760
17c20385
LC
7761You can run the @command{tzselect} command to find out which timezone
7762string corresponds to your region. Choosing an invalid timezone name
7763causes @command{guix system} to fail.
7764
598e19dc
LC
7765@item @code{locale} (default: @code{"en_US.utf8"})
7766The name of the default locale (@pxref{Locale Names,,, libc, The GNU C
7767Library Reference Manual}). @xref{Locales}, for more information.
7768
7769@item @code{locale-definitions} (default: @var{%default-locale-definitions})
7770The list of locale definitions to be compiled and that may be used at
7771run time. @xref{Locales}.
7313a52e 7772
34760ae7
LC
7773@item @code{locale-libcs} (default: @code{(list @var{glibc})})
7774The list of GNU@tie{}libc packages whose locale data and tools are used
7775to build the locale definitions. @xref{Locales}, for compatibility
7776considerations that justify this option.
7777
996ed739 7778@item @code{name-service-switch} (default: @var{%default-nss})
1068f26b 7779Configuration of the libc name service switch (NSS)---a
996ed739
LC
7780@code{<name-service-switch>} object. @xref{Name Service Switch}, for
7781details.
7782
7313a52e 7783@item @code{services} (default: @var{%base-services})
28d939af 7784A list of service objects denoting system services. @xref{Services}.
7313a52e
LC
7785
7786@item @code{pam-services} (default: @code{(base-pam-services)})
7787@cindex PAM
7788@cindex pluggable authentication modules
7789Linux @dfn{pluggable authentication module} (PAM) services.
7790@c FIXME: Add xref to PAM services section.
7791
7792@item @code{setuid-programs} (default: @var{%setuid-programs})
7793List of string-valued G-expressions denoting setuid programs.
7794@xref{Setuid Programs}.
7795
f5a9ffa0
AK
7796@item @code{sudoers-file} (default: @var{%sudoers-specification})
7797@cindex sudoers file
84765839
LC
7798The contents of the @file{/etc/sudoers} file as a file-like object
7799(@pxref{G-Expressions, @code{local-file} and @code{plain-file}}).
7313a52e
LC
7800
7801This file specifies which users can use the @command{sudo} command, what
7802they are allowed to do, and what privileges they may gain. The default
7803is that only @code{root} and members of the @code{wheel} group may use
7804@code{sudo}.
7805
7806@end table
7807@end deftp
7808
cf4a9129
LC
7809@node File Systems
7810@subsection File Systems
b81e1947 7811
cf4a9129 7812The list of file systems to be mounted is specified in the
1068f26b 7813@code{file-systems} field of the operating system declaration
cf4a9129
LC
7814(@pxref{Using the Configuration System}). Each file system is declared
7815using the @code{file-system} form, like this:
b81e1947
LC
7816
7817@example
cf4a9129
LC
7818(file-system
7819 (mount-point "/home")
7820 (device "/dev/sda3")
7821 (type "ext4"))
b81e1947
LC
7822@end example
7823
cf4a9129
LC
7824As usual, some of the fields are mandatory---those shown in the example
7825above---while others can be omitted. These are described below.
b81e1947 7826
cf4a9129
LC
7827@deftp {Data Type} file-system
7828Objects of this type represent file systems to be mounted. They
7829contain the following members:
5ff3c4b8 7830
cf4a9129
LC
7831@table @asis
7832@item @code{type}
7833This is a string specifying the type of the file system---e.g.,
7834@code{"ext4"}.
5ff3c4b8 7835
cf4a9129
LC
7836@item @code{mount-point}
7837This designates the place where the file system is to be mounted.
b81e1947 7838
cf4a9129
LC
7839@item @code{device}
7840This names the ``source'' of the file system. By default it is the name
7841of a node under @file{/dev}, but its meaning depends on the @code{title}
7842field described below.
401c53c4 7843
cf4a9129
LC
7844@item @code{title} (default: @code{'device})
7845This is a symbol that specifies how the @code{device} field is to be
7846interpreted.
401c53c4 7847
cf4a9129
LC
7848When it is the symbol @code{device}, then the @code{device} field is
7849interpreted as a file name; when it is @code{label}, then @code{device}
7850is interpreted as a partition label name; when it is @code{uuid},
7851@code{device} is interpreted as a partition unique identifier (UUID).
da7cabd4 7852
661a1d79 7853UUIDs may be converted from their string representation (as shown by the
0767f6a6
LC
7854@command{tune2fs -l} command) using the @code{uuid} form@footnote{The
7855@code{uuid} form expects 16-byte UUIDs as defined in
7856@uref{https://tools.ietf.org/html/rfc4122, RFC@tie{}4122}. This is the
7857form of UUID used by the ext2 family of file systems and others, but it
7858is different from ``UUIDs'' found in FAT file systems, for instance.},
7859like this:
661a1d79
LC
7860
7861@example
7862(file-system
7863 (mount-point "/home")
7864 (type "ext4")
7865 (title 'uuid)
7866 (device (uuid "4dab5feb-d176-45de-b287-9b0a6e4c01cb")))
7867@end example
7868
cf4a9129 7869The @code{label} and @code{uuid} options offer a way to refer to disk
661a1d79
LC
7870partitions without having to hard-code their actual device
7871name@footnote{Note that, while it is tempting to use
7872@file{/dev/disk/by-uuid} and similar device names to achieve the same
7873result, this is not recommended: These special device nodes are created
7874by the udev daemon and may be unavailable at the time the device is
7875mounted.}.
da7cabd4 7876
1068f26b 7877However, when the source of a file system is a mapped device (@pxref{Mapped
5f86a66e
LC
7878Devices}), its @code{device} field @emph{must} refer to the mapped
7879device name---e.g., @file{/dev/mapper/root-partition}---and consequently
7880@code{title} must be set to @code{'device}. This is required so that
7881the system knows that mounting the file system depends on having the
7882corresponding device mapping established.
7883
cf4a9129
LC
7884@item @code{flags} (default: @code{'()})
7885This is a list of symbols denoting mount flags. Recognized flags
2c071ce9
LC
7886include @code{read-only}, @code{bind-mount}, @code{no-dev} (disallow
7887access to special files), @code{no-suid} (ignore setuid and setgid
7888bits), and @code{no-exec} (disallow program execution.)
da7cabd4 7889
cf4a9129
LC
7890@item @code{options} (default: @code{#f})
7891This is either @code{#f}, or a string denoting mount options.
da7cabd4 7892
be21979d
LC
7893@item @code{mount?} (default: @code{#t})
7894This value indicates whether to automatically mount the file system when
7895the system is brought up. When set to @code{#f}, the file system gets
7896an entry in @file{/etc/fstab} (read by the @command{mount} command) but
7897is not automatically mounted.
7898
cf4a9129
LC
7899@item @code{needed-for-boot?} (default: @code{#f})
7900This Boolean value indicates whether the file system is needed when
7901booting. If that is true, then the file system is mounted when the
7902initial RAM disk (initrd) is loaded. This is always the case, for
7903instance, for the root file system.
da7cabd4 7904
cf4a9129
LC
7905@item @code{check?} (default: @code{#t})
7906This Boolean indicates whether the file system needs to be checked for
7907errors before being mounted.
f9cc8971 7908
4e469051
LC
7909@item @code{create-mount-point?} (default: @code{#f})
7910When true, the mount point is created if it does not exist yet.
7911
e51710d1 7912@item @code{dependencies} (default: @code{'()})
13fb1bd9
LC
7913This is a list of @code{<file-system>} or @code{<mapped-device>} objects
7914representing file systems that must be mounted or mapped devices that
7915must be opened before (and unmounted or closed after) this one.
e51710d1
LC
7916
7917As an example, consider a hierarchy of mounts: @file{/sys/fs/cgroup} is
7918a dependency of @file{/sys/fs/cgroup/cpu} and
7919@file{/sys/fs/cgroup/memory}.
7920
13fb1bd9
LC
7921Another example is a file system that depends on a mapped device, for
7922example for an encrypted partition (@pxref{Mapped Devices}).
cf4a9129
LC
7923@end table
7924@end deftp
da7cabd4 7925
a69576ea
LC
7926The @code{(gnu system file-systems)} exports the following useful
7927variables.
7928
7929@defvr {Scheme Variable} %base-file-systems
7930These are essential file systems that are required on normal systems,
cc0e575a 7931such as @var{%pseudo-terminal-file-system} and @var{%immutable-store} (see
3392ce5d
LC
7932below.) Operating system declarations should always contain at least
7933these.
a69576ea
LC
7934@end defvr
7935
7f239fd3
LC
7936@defvr {Scheme Variable} %pseudo-terminal-file-system
7937This is the file system to be mounted as @file{/dev/pts}. It supports
7938@dfn{pseudo-terminals} created @i{via} @code{openpty} and similar
7939functions (@pxref{Pseudo-Terminals,,, libc, The GNU C Library Reference
7940Manual}). Pseudo-terminals are used by terminal emulators such as
7941@command{xterm}.
7942@end defvr
7943
db17ae5c
LC
7944@defvr {Scheme Variable} %shared-memory-file-system
7945This file system is mounted as @file{/dev/shm} and is used to support
7946memory sharing across processes (@pxref{Memory-mapped I/O,
7947@code{shm_open},, libc, The GNU C Library Reference Manual}).
7948@end defvr
7949
3392ce5d
LC
7950@defvr {Scheme Variable} %immutable-store
7951This file system performs a read-only ``bind mount'' of
7952@file{/gnu/store}, making it read-only for all the users including
7953@code{root}. This prevents against accidental modification by software
7954running as @code{root} or by system administrators.
7955
7956The daemon itself is still able to write to the store: it remounts it
7957read-write in its own ``name space.''
7958@end defvr
7959
a69576ea
LC
7960@defvr {Scheme Variable} %binary-format-file-system
7961The @code{binfmt_misc} file system, which allows handling of arbitrary
7962executable file types to be delegated to user space. This requires the
7963@code{binfmt.ko} kernel module to be loaded.
7964@end defvr
7965
7966@defvr {Scheme Variable} %fuse-control-file-system
7967The @code{fusectl} file system, which allows unprivileged users to mount
7968and unmount user-space FUSE file systems. This requires the
7969@code{fuse.ko} kernel module to be loaded.
7970@end defvr
7971
510f9d86
LC
7972@node Mapped Devices
7973@subsection Mapped Devices
7974
7975@cindex device mapping
7976@cindex mapped devices
7977The Linux kernel has a notion of @dfn{device mapping}: a block device,
7978such as a hard disk partition, can be @dfn{mapped} into another device,
97c8aef1 7979usually in @code{/dev/mapper/},
510f9d86
LC
7980with additional processing over the data that flows through
7981it@footnote{Note that the GNU@tie{}Hurd makes no difference between the
7982concept of a ``mapped device'' and that of a file system: both boil down
7983to @emph{translating} input/output operations made on a file to
7984operations on its backing store. Thus, the Hurd implements mapped
7985devices, like file systems, using the generic @dfn{translator} mechanism
7986(@pxref{Translators,,, hurd, The GNU Hurd Reference Manual}).}. A
7987typical example is encryption device mapping: all writes to the mapped
7988device are encrypted, and all reads are deciphered, transparently.
97c8aef1
AE
7989Guix extends this notion by considering any device or set of devices that
7990are @dfn{transformed} in some way to create a new device; for instance,
7991RAID devices are obtained by @dfn{assembling} several other devices, such
7992as hard disks or partitions, into a new one that behaves as one partition.
7993Other examples, not yet implemented, are LVM logical volumes.
510f9d86 7994
97c8aef1
AE
7995Mapped devices are declared using the @code{mapped-device} form,
7996defined as follows; for examples, see below.
510f9d86
LC
7997
7998@deftp {Data Type} mapped-device
7999Objects of this type represent device mappings that will be made when
8000the system boots up.
8001
9cb426b8
LC
8002@table @code
8003@item source
97c8aef1
AE
8004This is either a string specifying the name of the block device to be mapped,
8005such as @code{"/dev/sda3"}, or a list of such strings when several devices
8006need to be assembled for creating a new one.
510f9d86 8007
9cb426b8 8008@item target
97c8aef1
AE
8009This string specifies the name of the resulting mapped device. For
8010kernel mappers such as encrypted devices of type @code{luks-device-mapping},
8011specifying @code{"my-partition"} leads to the creation of
510f9d86 8012the @code{"/dev/mapper/my-partition"} device.
97c8aef1
AE
8013For RAID devices of type @code{raid-device-mapping}, the full device name
8014such as @code{"/dev/md0"} needs to be given.
510f9d86 8015
9cb426b8 8016@item type
510f9d86
LC
8017This must be a @code{mapped-device-kind} object, which specifies how
8018@var{source} is mapped to @var{target}.
8019@end table
8020@end deftp
8021
8022@defvr {Scheme Variable} luks-device-mapping
8023This defines LUKS block device encryption using the @command{cryptsetup}
1068f26b 8024command from the package with the same name. It relies on the
510f9d86
LC
8025@code{dm-crypt} Linux kernel module.
8026@end defvr
8027
97c8aef1
AE
8028@defvr {Scheme Variable} raid-device-mapping
8029This defines a RAID device, which is assembled using the @code{mdadm}
8030command from the package with the same name. It requires a Linux kernel
8031module for the appropriate RAID level to be loaded, such as @code{raid456}
8032for RAID-4, RAID-5 or RAID-6, or @code{raid10} for RAID-10.
8033@end defvr
8034
8035@cindex disk encryption
8036@cindex LUKS
8037The following example specifies a mapping from @file{/dev/sda3} to
8038@file{/dev/mapper/home} using LUKS---the
ddf1cd51 8039@url{https://gitlab.com/cryptsetup/cryptsetup,Linux Unified Key Setup}, a
97c8aef1
AE
8040standard mechanism for disk encryption.
8041The @file{/dev/mapper/home}
8042device can then be used as the @code{device} of a @code{file-system}
8043declaration (@pxref{File Systems}).
8044
8045@example
8046(mapped-device
8047 (source "/dev/sda3")
8048 (target "home")
8049 (type luks-device-mapping))
8050@end example
8051
8052Alternatively, to become independent of device numbering, one may obtain
8053the LUKS UUID (@dfn{unique identifier}) of the source device by a
8054command like:
8055
8056@example
8057cryptsetup luksUUID /dev/sda3
8058@end example
8059
8060and use it as follows:
8061
8062@example
8063(mapped-device
8064 (source (uuid "cb67fc72-0d54-4c88-9d4b-b225f30b0f44"))
8065 (target "home")
8066 (type luks-device-mapping))
8067@end example
8068
a4ca4362
CM
8069@cindex swap encryption
8070It is also desirable to encrypt swap space, since swap space may contain
8071sensitive data. One way to accomplish that is to use a swap file in a
8072file system on a device mapped via LUKS encryption. In this way, the
8073swap file is encrypted because the entire device is encrypted.
8074@xref{Preparing for Installation,,Disk Partitioning}, for an example.
8075
97c8aef1
AE
8076A RAID device formed of the partitions @file{/dev/sda1} and @file{/dev/sdb1}
8077may be declared as follows:
8078
8079@example
8080(mapped-device
8081 (source (list "/dev/sda1" "/dev/sdb1"))
8082 (target "/dev/md0")
8083 (type raid-device-mapping))
8084@end example
8085
8086The @file{/dev/md0} device can then be used as the @code{device} of a
8087@code{file-system} declaration (@pxref{File Systems}).
8088Note that the RAID level need not be given; it is chosen during the
8089initial creation and formatting of the RAID device and is determined
8090automatically later.
8091
8092
cf4a9129
LC
8093@node User Accounts
8094@subsection User Accounts
ee85f3db 8095
e32171ee
JD
8096@cindex users
8097@cindex accounts
8098@cindex user accounts
9bea87a5
LC
8099User accounts and groups are entirely managed through the
8100@code{operating-system} declaration. They are specified with the
8101@code{user-account} and @code{user-group} forms:
ee85f3db 8102
cf4a9129
LC
8103@example
8104(user-account
8105 (name "alice")
8106 (group "users")
24e752c0
LC
8107 (supplementary-groups '("wheel" ;allow use of sudo, etc.
8108 "audio" ;sound card
8109 "video" ;video devices such as webcams
8110 "cdrom")) ;the good ol' CD-ROM
cf4a9129
LC
8111 (comment "Bob's sister")
8112 (home-directory "/home/alice"))
8113@end example
25083588 8114
9bea87a5
LC
8115When booting or upon completion of @command{guix system reconfigure},
8116the system ensures that only the user accounts and groups specified in
8117the @code{operating-system} declaration exist, and with the specified
8118properties. Thus, account or group creations or modifications made by
8119directly invoking commands such as @command{useradd} are lost upon
8120reconfiguration or reboot. This ensures that the system remains exactly
8121as declared.
8122
cf4a9129
LC
8123@deftp {Data Type} user-account
8124Objects of this type represent user accounts. The following members may
8125be specified:
ee85f3db 8126
cf4a9129
LC
8127@table @asis
8128@item @code{name}
8129The name of the user account.
ee85f3db 8130
cf4a9129 8131@item @code{group}
e32171ee 8132@cindex groups
cf4a9129
LC
8133This is the name (a string) or identifier (a number) of the user group
8134this account belongs to.
ee85f3db 8135
cf4a9129
LC
8136@item @code{supplementary-groups} (default: @code{'()})
8137Optionally, this can be defined as a list of group names that this
8138account belongs to.
ee85f3db 8139
cf4a9129
LC
8140@item @code{uid} (default: @code{#f})
8141This is the user ID for this account (a number), or @code{#f}. In the
8142latter case, a number is automatically chosen by the system when the
8143account is created.
ee85f3db 8144
cf4a9129 8145@item @code{comment} (default: @code{""})
1068f26b 8146A comment about the account, such as the account owner's full name.
c8c871d1 8147
cf4a9129
LC
8148@item @code{home-directory}
8149This is the name of the home directory for the account.
ee85f3db 8150
eb56ee02
LC
8151@item @code{create-home-directory?} (default: @code{#t})
8152Indicates whether the home directory of this account should be created
8153if it does not exist yet.
8154
cf4a9129
LC
8155@item @code{shell} (default: Bash)
8156This is a G-expression denoting the file name of a program to be used as
8157the shell (@pxref{G-Expressions}).
ee85f3db 8158
cf4a9129
LC
8159@item @code{system?} (default: @code{#f})
8160This Boolean value indicates whether the account is a ``system''
8161account. System accounts are sometimes treated specially; for instance,
8162graphical login managers do not list them.
ee85f3db 8163
1bd4e6db 8164@anchor{user-account-password}
cf4a9129 8165@item @code{password} (default: @code{#f})
eb59595c
LC
8166You would normally leave this field to @code{#f}, initialize user
8167passwords as @code{root} with the @command{passwd} command, and then let
9bea87a5
LC
8168users change it with @command{passwd}. Passwords set with
8169@command{passwd} are of course preserved across reboot and
8170reconfiguration.
eb59595c
LC
8171
8172If you @emph{do} want to have a preset password for an account, then
8173this field must contain the encrypted password, as a string.
5d1f1177
LC
8174@xref{crypt,,, libc, The GNU C Library Reference Manual}, for more information
8175on password encryption, and @ref{Encryption,,, guile, GNU Guile Reference
eb59595c 8176Manual}, for information on Guile's @code{crypt} procedure.
c8c871d1 8177
cf4a9129
LC
8178@end table
8179@end deftp
ee85f3db 8180
e32171ee 8181@cindex groups
cf4a9129 8182User group declarations are even simpler:
ee85f3db 8183
cf4a9129
LC
8184@example
8185(user-group (name "students"))
8186@end example
ee85f3db 8187
cf4a9129
LC
8188@deftp {Data Type} user-group
8189This type is for, well, user groups. There are just a few fields:
af8a56b8 8190
cf4a9129
LC
8191@table @asis
8192@item @code{name}
1068f26b 8193The name of the group.
ee85f3db 8194
cf4a9129
LC
8195@item @code{id} (default: @code{#f})
8196The group identifier (a number). If @code{#f}, a new number is
8197automatically allocated when the group is created.
ee85f3db 8198
c8fa3426
LC
8199@item @code{system?} (default: @code{#f})
8200This Boolean value indicates whether the group is a ``system'' group.
8201System groups have low numerical IDs.
8202
cf4a9129
LC
8203@item @code{password} (default: @code{#f})
8204What, user groups can have a password? Well, apparently yes. Unless
1068f26b 8205@code{#f}, this field specifies the password of the group.
ee85f3db 8206
cf4a9129
LC
8207@end table
8208@end deftp
401c53c4 8209
cf4a9129
LC
8210For convenience, a variable lists all the basic user groups one may
8211expect:
401c53c4 8212
cf4a9129
LC
8213@defvr {Scheme Variable} %base-groups
8214This is the list of basic user groups that users and/or packages expect
8215to be present on the system. This includes groups such as ``root'',
8216``wheel'', and ``users'', as well as groups used to control access to
8217specific devices such as ``audio'', ``disk'', and ``cdrom''.
8218@end defvr
401c53c4 8219
bf87f38a
LC
8220@defvr {Scheme Variable} %base-user-accounts
8221This is the list of basic system accounts that programs may expect to
8222find on a GNU/Linux system, such as the ``nobody'' account.
8223
8224Note that the ``root'' account is not included here. It is a
8225special-case and is automatically added whether or not it is specified.
8226@end defvr
8227
598e19dc
LC
8228@node Locales
8229@subsection Locales
8230
8231@cindex locale
8232A @dfn{locale} defines cultural conventions for a particular language
8233and region of the world (@pxref{Locales,,, libc, The GNU C Library
8234Reference Manual}). Each locale has a name that typically has the form
b2636518 8235@code{@var{language}_@var{territory}.@var{codeset}}---e.g.,
598e19dc
LC
8236@code{fr_LU.utf8} designates the locale for the French language, with
8237cultural conventions from Luxembourg, and using the UTF-8 encoding.
8238
8239@cindex locale definition
8240Usually, you will want to specify the default locale for the machine
8241using the @code{locale} field of the @code{operating-system} declaration
8242(@pxref{operating-system Reference, @code{locale}}).
8243
f5582b2c
LC
8244The selected locale is automatically added to the @dfn{locale
8245definitions} known to the system if needed, with its codeset inferred
8246from its name---e.g., @code{bo_CN.utf8} will be assumed to use the
8247@code{UTF-8} codeset. Additional locale definitions can be specified in
8248the @code{locale-definitions} slot of @code{operating-system}---this is
8249useful, for instance, if the codeset could not be inferred from the
8250locale name. The default set of locale definitions includes some widely
8251used locales, but not all the available locales, in order to save space.
8252
8253For instance, to add the North Frisian locale for Germany, the value of
8254that field may be:
598e19dc
LC
8255
8256@example
8257(cons (locale-definition
8258 (name "fy_DE.utf8") (source "fy_DE"))
8259 %default-locale-definitions)
8260@end example
8261
8262Likewise, to save space, one might want @code{locale-definitions} to
8263list only the locales that are actually used, as in:
8264
8265@example
8266(list (locale-definition
8267 (name "ja_JP.eucjp") (source "ja_JP")
8268 (charset "EUC-JP")))
8269@end example
8270
5c3c1427
LC
8271@vindex LOCPATH
8272The compiled locale definitions are available at
46bd6edd
LC
8273@file{/run/current-system/locale/X.Y}, where @code{X.Y} is the libc
8274version, which is the default location where the GNU@tie{}libc provided
8275by Guix looks for locale data. This can be overridden using the
8276@code{LOCPATH} environment variable (@pxref{locales-and-locpath,
5c3c1427
LC
8277@code{LOCPATH} and locale packages}).
8278
598e19dc
LC
8279The @code{locale-definition} form is provided by the @code{(gnu system
8280locale)} module. Details are given below.
8281
8282@deftp {Data Type} locale-definition
8283This is the data type of a locale definition.
8284
8285@table @asis
8286
8287@item @code{name}
8288The name of the locale. @xref{Locale Names,,, libc, The GNU C Library
8289Reference Manual}, for more information on locale names.
8290
8291@item @code{source}
8292The name of the source for that locale. This is typically the
8293@code{@var{language}_@var{territory}} part of the locale name.
8294
8295@item @code{charset} (default: @code{"UTF-8"})
8296The ``character set'' or ``code set'' for that locale,
8297@uref{http://www.iana.org/assignments/character-sets, as defined by
8298IANA}.
8299
8300@end table
8301@end deftp
8302
8303@defvr {Scheme Variable} %default-locale-definitions
1068f26b 8304A list of commonly used UTF-8 locales, used as the default
b2636518 8305value of the @code{locale-definitions} field of @code{operating-system}
598e19dc 8306declarations.
b2636518
LC
8307
8308@cindex locale name
8309@cindex normalized codeset in locale names
8310These locale definitions use the @dfn{normalized codeset} for the part
8311that follows the dot in the name (@pxref{Using gettextized software,
8312normalized codeset,, libc, The GNU C Library Reference Manual}). So for
8313instance it has @code{uk_UA.utf8} but @emph{not}, say,
8314@code{uk_UA.UTF-8}.
598e19dc 8315@end defvr
401c53c4 8316
34760ae7
LC
8317@subsubsection Locale Data Compatibility Considerations
8318
8319@cindex incompatibility, of locale data
8320@code{operating-system} declarations provide a @code{locale-libcs} field
8321to specify the GNU@tie{}libc packages that are used to compile locale
8322declarations (@pxref{operating-system Reference}). ``Why would I
8323care?'', you may ask. Well, it turns out that the binary format of
8324locale data is occasionally incompatible from one libc version to
8325another.
8326
8327@c See <https://sourceware.org/ml/libc-alpha/2015-09/msg00575.html>
8328@c and <https://lists.gnu.org/archive/html/guix-devel/2015-08/msg00737.html>.
8329For instance, a program linked against libc version 2.21 is unable to
8330read locale data produced with libc 2.22; worse, that program
8331@emph{aborts} instead of simply ignoring the incompatible locale
8332data@footnote{Versions 2.23 and later of GNU@tie{}libc will simply skip
8333the incompatible locale data, which is already an improvement.}.
8334Similarly, a program linked against libc 2.22 can read most, but not
201fff9e 8335all, of the locale data from libc 2.21 (specifically, @code{LC_COLLATE}
34760ae7
LC
8336data is incompatible); thus calls to @code{setlocale} may fail, but
8337programs will not abort.
8338
8339The ``problem'' in GuixSD is that users have a lot of freedom: They can
8340choose whether and when to upgrade software in their profiles, and might
8341be using a libc version different from the one the system administrator
8342used to build the system-wide locale data.
8343
8344Fortunately, unprivileged users can also install their own locale data
8345and define @var{GUIX_LOCPATH} accordingly (@pxref{locales-and-locpath,
8346@code{GUIX_LOCPATH} and locale packages}).
8347
8348Still, it is best if the system-wide locale data at
8349@file{/run/current-system/locale} is built for all the libc versions
8350actually in use on the system, so that all the programs can access
8351it---this is especially crucial on a multi-user system. To do that, the
8352administrator can specify several libc packages in the
8353@code{locale-libcs} field of @code{operating-system}:
8354
8355@example
8356(use-package-modules base)
8357
8358(operating-system
8359 ;; @dots{}
8360 (locale-libcs (list glibc-2.21 (canonical-package glibc))))
8361@end example
8362
8363This example would lead to a system containing locale definitions for
8364both libc 2.21 and the current version of libc in
8365@file{/run/current-system/locale}.
8366
8367
cf4a9129
LC
8368@node Services
8369@subsection Services
401c53c4 8370
cf4a9129
LC
8371@cindex system services
8372An important part of preparing an @code{operating-system} declaration is
8373listing @dfn{system services} and their configuration (@pxref{Using the
8374Configuration System}). System services are typically daemons launched
8375when the system boots, or other actions needed at that time---e.g.,
d8b94dbd
LC
8376configuring network access.
8377
e8b652d4
LC
8378GuixSD has a broad definition of ``service'' (@pxref{Service
8379Composition}), but many services are managed by the GNU@tie{}Shepherd
8380(@pxref{Shepherd Services}). On a running system, the @command{herd}
8381command allows you to list the available services, show their status,
8382start and stop them, or do other specific operations (@pxref{Jump
8383Start,,, shepherd, The GNU Shepherd Manual}). For example:
d8b94dbd
LC
8384
8385@example
dd17bc38 8386# herd status
d8b94dbd
LC
8387@end example
8388
8389The above command, run as @code{root}, lists the currently defined
dd17bc38 8390services. The @command{herd doc} command shows a synopsis of the given
d8b94dbd
LC
8391service:
8392
8393@example
dd17bc38 8394# herd doc nscd
d8b94dbd
LC
8395Run libc's name service cache daemon (nscd).
8396@end example
8397
8398The @command{start}, @command{stop}, and @command{restart} sub-commands
8399have the effect you would expect. For instance, the commands below stop
8400the nscd service and restart the Xorg display server:
8401
8402@example
dd17bc38 8403# herd stop nscd
d8b94dbd 8404Service nscd has been stopped.
dd17bc38 8405# herd restart xorg-server
d8b94dbd
LC
8406Service xorg-server has been stopped.
8407Service xorg-server has been started.
8408@end example
401c53c4 8409
cf4a9129 8410The following sections document the available services, starting with
d8b94dbd
LC
8411the core services, that may be used in an @code{operating-system}
8412declaration.
401c53c4 8413
cf4a9129
LC
8414@menu
8415* Base Services:: Essential system services.
c311089b 8416* Scheduled Job Execution:: The mcron service.
92c03a87 8417* Log Rotation:: The rottlog service.
cf4a9129
LC
8418* Networking Services:: Network setup, SSH daemon, etc.
8419* X Window:: Graphical display.
f2ec23d1 8420* Printing Services:: Local and remote printer support.
fe1a39d3 8421* Desktop Services:: D-Bus and desktop services.
105369a4 8422* Database Services:: SQL databases.
d8c18af8 8423* Mail Services:: IMAP, POP3, SMTP, and all that.
78cef99b 8424* Messaging Services:: Messaging services.
859e367d 8425* Kerberos Services:: Kerberos services.
58724c48 8426* Web Services:: Web servers.
2be1b471 8427* VPN Services:: VPN daemons.
eb419bc9 8428* Network File System:: NFS related services.
a7cf4eb6 8429* Continuous Integration:: The Cuirass service.
dbc6d370 8430* Miscellaneous Services:: Other services.
cf4a9129 8431@end menu
401c53c4 8432
cf4a9129
LC
8433@node Base Services
8434@subsubsection Base Services
a1ba8475 8435
cf4a9129
LC
8436The @code{(gnu services base)} module provides definitions for the basic
8437services that one expects from the system. The services exported by
8438this module are listed below.
401c53c4 8439
cf4a9129 8440@defvr {Scheme Variable} %base-services
31771497
LC
8441This variable contains a list of basic services (@pxref{Service Types
8442and Services}, for more information on service objects) one would
cf4a9129 8443expect from the system: a login service (mingetty) on each tty, syslogd,
1068f26b 8444the libc name service cache daemon (nscd), the udev device manager, and
cf4a9129 8445more.
401c53c4 8446
cf4a9129
LC
8447This is the default value of the @code{services} field of
8448@code{operating-system} declarations. Usually, when customizing a
8449system, you will want to append services to @var{%base-services}, like
8450this:
401c53c4 8451
cf4a9129 8452@example
fa1e31b8 8453(cons* (avahi-service) (lsh-service) %base-services)
cf4a9129
LC
8454@end example
8455@end defvr
401c53c4 8456
387e1754
LC
8457@defvr {Scheme Variable} special-files-service-type
8458This is the service that sets up ``special files'' such as
8459@file{/bin/sh}; an instance of it is part of @code{%base-services}.
8460
8461The value associated with @code{special-files-service-type} services
8462must be a list of tuples where the first element is the ``special file''
8463and the second element is its target. By default it is:
8464
8465@cindex @file{/bin/sh}
8466@cindex @file{sh}, in @file{/bin}
8467@example
8468`(("/bin/sh" ,(file-append @var{bash} "/bin/sh")))
8469@end example
8470
8471@cindex @file{/usr/bin/env}
8472@cindex @file{env}, in @file{/usr/bin}
8473If you want to add, say, @code{/usr/bin/env} to your system, you can
8474change it to:
8475
8476@example
8477`(("/bin/sh" ,(file-append @var{bash} "/bin/sh"))
8478 ("/usr/bin/env" ,(file-append @var{coreutils} "/bin/env")))
8479@end example
8480
8481Since this is part of @code{%base-services}, you can use
8482@code{modify-services} to customize the set of special files
8483(@pxref{Service Reference, @code{modify-services}}). But the simple way
8484to add a special file is @i{via} the @code{extra-special-file} procedure
8485(see below.)
8486@end defvr
8487
8488@deffn {Scheme Procedure} extra-special-file @var{file} @var{target}
8489Use @var{target} as the ``special file'' @var{file}.
8490
8491For example, adding the following lines to the @code{services} field of
8492your operating system declaration leads to a @file{/usr/bin/env}
8493symlink:
8494
8495@example
8496(extra-special-file "/usr/bin/env"
8497 (file-append coreutils "/bin/env"))
8498@end example
8499@end deffn
8500
be1c2c54 8501@deffn {Scheme Procedure} host-name-service @var{name}
cf4a9129
LC
8502Return a service that sets the host name to @var{name}.
8503@end deffn
401c53c4 8504
317d3b47
DC
8505@deffn {Scheme Procedure} login-service @var{config}
8506Return a service to run login according to @var{config}, a
8507@code{<login-configuration>} object, which specifies the message of the day,
8508among other things.
8509@end deffn
8510
8511@deftp {Data Type} login-configuration
8512This is the data type representing the configuration of login.
8513
8514@table @asis
8515
8516@item @code{motd}
e32171ee 8517@cindex message of the day
317d3b47
DC
8518A file-like object containing the ``message of the day''.
8519
8520@item @code{allow-empty-passwords?} (default: @code{#t})
8521Allow empty passwords by default so that first-time users can log in when
8522the 'root' account has just been created.
8523
8524@end table
8525@end deftp
8526
66e4f01c
LC
8527@deffn {Scheme Procedure} mingetty-service @var{config}
8528Return a service to run mingetty according to @var{config}, a
8529@code{<mingetty-configuration>} object, which specifies the tty to run, among
8530other things.
cf4a9129 8531@end deffn
401c53c4 8532
66e4f01c
LC
8533@deftp {Data Type} mingetty-configuration
8534This is the data type representing the configuration of Mingetty, which
9ee4c9ab 8535provides the default implementation of virtual console log-in.
66e4f01c
LC
8536
8537@table @asis
8538
8539@item @code{tty}
8540The name of the console this Mingetty runs on---e.g., @code{"tty1"}.
8541
66e4f01c
LC
8542@item @code{auto-login} (default: @code{#f})
8543When true, this field must be a string denoting the user name under
f9b9a033 8544which the system automatically logs in. When it is @code{#f}, a
66e4f01c
LC
8545user name and password must be entered to log in.
8546
8547@item @code{login-program} (default: @code{#f})
8548This must be either @code{#f}, in which case the default log-in program
8549is used (@command{login} from the Shadow tool suite), or a gexp denoting
8550the name of the log-in program.
8551
8552@item @code{login-pause?} (default: @code{#f})
8553When set to @code{#t} in conjunction with @var{auto-login}, the user
8554will have to press a key before the log-in shell is launched.
8555
8556@item @code{mingetty} (default: @var{mingetty})
8557The Mingetty package to use.
8558
8559@end table
8560@end deftp
8561
9ee4c9ab
LF
8562@deffn {Scheme Procedure} agetty-service @var{config}
8563Return a service to run agetty according to @var{config}, an
8564@code{<agetty-configuration>} object, which specifies the tty to run,
8565among other things.
8566@end deffn
8567
8568@deftp {Data Type} agetty-configuration
8569This is the data type representing the configuration of agetty, which
8570implements virtual and serial console log-in. See the @code{agetty(8)}
8571man page for more information.
8572
8573@table @asis
8574
8575@item @code{tty}
8576The name of the console this agetty runs on, as a string---e.g.,
8577@code{"ttyS0"}. This argument is mandatory.
8578
8579@item @code{baud-rate} (default: @code{#f})
8580A string containing a comma-separated list of one or more baud rates, in
8581descending order.
8582
8583@item @code{term} (default: @code{#f})
8584A string containing the value used for the @code{TERM} environment
8585variable.
8586
8587@item @code{eight-bits?} (default: @code{#f})
8588When @code{#t}, the tty is assumed to be 8-bit clean, and parity detection is
8589disabled.
8590
8591@item @code{auto-login} (default: @code{#f})
8592When passed a login name, as a string, the specified user will be logged
8593in automatically without prompting for their login name or password.
8594
8595@item @code{no-reset?} (default: @code{#f})
8596When @code{#t}, don't reset terminal cflags (control modes).
8597
8598@item @code{host} (default: @code{#f})
8599This accepts a string containing the "login_host", which will be written
8600into the @file{/var/run/utmpx} file.
8601
8602@item @code{remote?} (default: @code{#f})
8603When set to @code{#t} in conjunction with @var{host}, this will add an
8604@code{-r} fakehost option to the command line of the login program
8605specified in @var{login-program}.
8606
8607@item @code{flow-control?} (default: @code{#f})
8608When set to @code{#t}, enable hardware (RTS/CTS) flow control.
8609
8610@item @code{no-issue?} (default: @code{#f})
8611When set to @code{#t}, the contents of the @file{/etc/issue} file will
8612not be displayed before presenting the login prompt.
8613
8614@item @code{init-string} (default: @code{#f})
8615This accepts a string that will be sent to the tty or modem before
8616sending anything else. It can be used to initialize a modem.
8617
8618@item @code{no-clear?} (default: @code{#f})
8619When set to @code{#t}, agetty will not clear the screen before showing
8620the login prompt.
8621
8622@item @code{login-program} (default: (file-append shadow "/bin/login"))
8623This must be either a gexp denoting the name of a log-in program, or
8624unset, in which case the default value is the @command{login} from the
8625Shadow tool suite.
8626
8627@item @code{local-line} (default: @code{#f})
8628Control the CLOCAL line flag. This accepts one of three symbols as
8629arguments, @code{'auto}, @code{'always}, or @code{'never}. If @code{#f},
8630the default value chosen by agetty is @code{'auto}.
8631
8632@item @code{extract-baud?} (default: @code{#f})
8633When set to @code{#t}, instruct agetty to try to extract the baud rate
8634from the status messages produced by certain types of modems.
8635
8636@item @code{skip-login?} (default: @code{#f})
8637When set to @code{#t}, do not prompt the user for a login name. This
8638can be used with @var{login-program} field to use non-standard login
8639systems.
8640
8641@item @code{no-newline?} (default: @code{#f})
8642When set to @code{#t}, do not print a newline before printing the
8643@file{/etc/issue} file.
8644
8645@c Is this dangerous only when used with login-program, or always?
8646@item @code{login-options} (default: @code{#f})
8647This option accepts a string containing options that are passed to the
8648login program. When used with the @var{login-program}, be aware that a
8649malicious user could try to enter a login name containing embedded
8650options that could be parsed by the login program.
8651
8652@item @code{login-pause} (default: @code{#f})
8653When set to @code{#t}, wait for any key before showing the login prompt.
8654This can be used in conjunction with @var{auto-login} to save memory by
8655lazily spawning shells.
8656
8657@item @code{chroot} (default: @code{#f})
8658Change root to the specified directory. This option accepts a directory
8659path as a string.
8660
8661@item @code{hangup?} (default: @code{#f})
8662Use the Linux system call @code{vhangup} to do a virtual hangup of the
8663specified terminal.
8664
8665@item @code{keep-baud?} (default: @code{#f})
8666When set to @code{#t}, try to keep the existing baud rate. The baud
8667rates from @var{baud-rate} are used when agetty receives a @key{BREAK}
8668character.
8669
8670@item @code{timeout} (default: @code{#f})
8671When set to an integer value, terminate if no user name could be read
8672within @var{timeout} seconds.
8673
8674@item @code{detect-case?} (default: @code{#f})
8675When set to @code{#t}, turn on support for detecting an uppercase-only
8676terminal. This setting will detect a login name containing only
8677uppercase letters as indicating an uppercase-only terminal and turn on
8678some upper-to-lower case conversions. Note that this will not support
8679Unicode characters.
8680
8681@item @code{wait-cr?} (default: @code{#f})
8682When set to @code{#t}, wait for the user or modem to send a
8683carriage-return or linefeed character before displaying
8684@file{/etc/issue} or login prompt. This is typically used with the
8685@var{init-string} option.
8686
8687@item @code{no-hints?} (default: @code{#f})
8688When set to @code{#t}, do not print hints about Num, Caps, and Scroll
8689locks.
8690
8691@item @code{no-hostname?} (default: @code{#f})
8692By default, the hostname is printed. When this option is set to
8693@code{#t}, no hostname will be shown at all.
8694
8695@item @code{long-hostname?} (default: @code{#f})
8696By default, the hostname is only printed until the first dot. When this
8697option is set to @code{#t}, the fully qualified hostname by
8698@code{gethostname} or @code{getaddrinfo} is shown.
8699
8700@item @code{erase-characters} (default: @code{#f})
8701This option accepts a string of additional characters that should be
8702interpreted as backspace when the user types their login name.
8703
8704@item @code{kill-characters} (default: @code{#f})
8705This option accepts a string that should be interpreted to mean "ignore
8706all previous characters" (also called a "kill" character) when the types
8707their login name.
8708
8709@item @code{chdir} (default: @code{#f})
8710This option accepts, as a string, a directory path that will be changed
8711to before login.
8712
8713@item @code{delay} (default: @code{#f})
8714This options accepts, as an integer, the number of seconds to sleep
8715before opening the tty and displaying the login prompt.
8716
8717@item @code{nice} (default: @code{#f})
8718This option accepts, as an integer, the nice value with which to run the
8719@command{login} program.
8720
8721@item @code{extra-options} (default: @code{'()})
8722This option provides an "escape hatch" for the user to provide arbitrary
8723command-line arguments to @command{agetty} as a list of strings.
8724
8725@end table
8726@end deftp
8727
46ec2707
DC
8728@deffn {Scheme Procedure} kmscon-service-type @var{config}
8729Return a service to run @uref{https://www.freedesktop.org/wiki/Software/kmscon,kmscon}
8730according to @var{config}, a @code{<kmscon-configuration>} object, which
8731specifies the tty to run, among other things.
8732@end deffn
8733
8734@deftp {Data Type} kmscon-configuration
8735This is the data type representing the configuration of Kmscon, which
9ee4c9ab 8736implements virtual console log-in.
46ec2707
DC
8737
8738@table @asis
8739
8740@item @code{virtual-terminal}
8741The name of the console this Kmscon runs on---e.g., @code{"tty1"}.
8742
8743@item @code{login-program} (default: @code{#~(string-append #$shadow "/bin/login")})
8744A gexp denoting the name of the log-in program. The default log-in program is
8745@command{login} from the Shadow tool suite.
8746
8747@item @code{login-arguments} (default: @code{'("-p")})
8748A list of arguments to pass to @command{login}.
8749
8750@item @code{hardware-acceleration?} (default: #f)
8751Whether to use hardware acceleration.
8752
8753@item @code{kmscon} (default: @var{kmscon})
8754The Kmscon package to use.
8755
8756@end table
8757@end deftp
8758
6454b333
LC
8759@cindex name service cache daemon
8760@cindex nscd
be1c2c54 8761@deffn {Scheme Procedure} nscd-service [@var{config}] [#:glibc glibc] @
4aee6e60 8762 [#:name-services '()]
1068f26b 8763Return a service that runs the libc name service cache daemon (nscd) with the
b893f1ae
LC
8764given @var{config}---an @code{<nscd-configuration>} object. @xref{Name
8765Service Switch}, for an example.
cf4a9129 8766@end deffn
401c53c4 8767
6454b333
LC
8768@defvr {Scheme Variable} %nscd-default-configuration
8769This is the default @code{<nscd-configuration>} value (see below) used
1068f26b 8770by @code{nscd-service}. It uses the caches defined by
6454b333
LC
8771@var{%nscd-default-caches}; see below.
8772@end defvr
8773
8774@deftp {Data Type} nscd-configuration
1068f26b 8775This is the data type representing the name service cache daemon (nscd)
6454b333
LC
8776configuration.
8777
8778@table @asis
8779
b893f1ae
LC
8780@item @code{name-services} (default: @code{'()})
8781List of packages denoting @dfn{name services} that must be visible to
8782the nscd---e.g., @code{(list @var{nss-mdns})}.
8783
8784@item @code{glibc} (default: @var{glibc})
8785Package object denoting the GNU C Library providing the @command{nscd}
8786command.
8787
6454b333 8788@item @code{log-file} (default: @code{"/var/log/nscd.log"})
1068f26b 8789Name of the nscd log file. This is where debugging output goes when
6454b333
LC
8790@code{debug-level} is strictly positive.
8791
8792@item @code{debug-level} (default: @code{0})
1068f26b 8793Integer denoting the debugging levels. Higher numbers mean that more
6454b333
LC
8794debugging output is logged.
8795
8796@item @code{caches} (default: @var{%nscd-default-caches})
8797List of @code{<nscd-cache>} objects denoting things to be cached; see
8798below.
8799
8800@end table
8801@end deftp
8802
8803@deftp {Data Type} nscd-cache
8804Data type representing a cache database of nscd and its parameters.
8805
8806@table @asis
8807
8808@item @code{database}
8809This is a symbol representing the name of the database to be cached.
8810Valid values are @code{passwd}, @code{group}, @code{hosts}, and
8811@code{services}, which designate the corresponding NSS database
8812(@pxref{NSS Basics,,, libc, The GNU C Library Reference Manual}).
8813
8814@item @code{positive-time-to-live}
8815@itemx @code{negative-time-to-live} (default: @code{20})
8816A number representing the number of seconds during which a positive or
8817negative lookup result remains in cache.
8818
8819@item @code{check-files?} (default: @code{#t})
8820Whether to check for updates of the files corresponding to
8821@var{database}.
8822
8823For instance, when @var{database} is @code{hosts}, setting this flag
8824instructs nscd to check for updates in @file{/etc/hosts} and to take
8825them into account.
8826
8827@item @code{persistent?} (default: @code{#t})
8828Whether the cache should be stored persistently on disk.
8829
8830@item @code{shared?} (default: @code{#t})
8831Whether the cache should be shared among users.
8832
8833@item @code{max-database-size} (default: 32@tie{}MiB)
8834Maximum size in bytes of the database cache.
8835
8836@c XXX: 'suggested-size' and 'auto-propagate?' seem to be expert
8837@c settings, so leave them out.
8838
8839@end table
8840@end deftp
8841
8842@defvr {Scheme Variable} %nscd-default-caches
8843List of @code{<nscd-cache>} objects used by default by
1068f26b 8844@code{nscd-configuration} (see above).
6454b333
LC
8845
8846It enables persistent and aggressive caching of service and host name
8847lookups. The latter provides better host name lookup performance,
8848resilience in the face of unreliable name servers, and also better
8849privacy---often the result of host name lookups is in local cache, so
8850external name servers do not even need to be queried.
8851@end defvr
8852
ec2e2f6c 8853@anchor{syslog-configuration-type}
e32171ee
JD
8854@cindex syslog
8855@cindex logging
ec2e2f6c
DC
8856@deftp {Data Type} syslog-configuration
8857This data type represents the configuration of the syslog daemon.
6454b333 8858
ec2e2f6c
DC
8859@table @asis
8860@item @code{syslogd} (default: @code{#~(string-append #$inetutils "/libexec/syslogd")})
8861The syslog daemon to use.
8862
8863@item @code{config-file} (default: @code{%default-syslog.conf})
8864The syslog configuration file to use.
8865
8866@end table
8867@end deftp
8868
8869@anchor{syslog-service}
e32171ee 8870@cindex syslog
ec2e2f6c
DC
8871@deffn {Scheme Procedure} syslog-service @var{config}
8872Return a service that runs a syslog daemon according to @var{config}.
44abcb28
LC
8873
8874@xref{syslogd invocation,,, inetutils, GNU Inetutils}, for more
8875information on the configuration file syntax.
cf4a9129 8876@end deffn
401c53c4 8877
0adfe95a
LC
8878@anchor{guix-configuration-type}
8879@deftp {Data Type} guix-configuration
8880This data type represents the configuration of the Guix build daemon.
8881@xref{Invoking guix-daemon}, for more information.
8882
8883@table @asis
8884@item @code{guix} (default: @var{guix})
8885The Guix package to use.
401c53c4 8886
0adfe95a
LC
8887@item @code{build-group} (default: @code{"guixbuild"})
8888Name of the group for build user accounts.
401c53c4 8889
0adfe95a
LC
8890@item @code{build-accounts} (default: @code{10})
8891Number of build user accounts to create.
401c53c4 8892
0adfe95a 8893@item @code{authorize-key?} (default: @code{#t})
e32171ee 8894@cindex substitutes, authorization thereof
5b58c28b
LC
8895Whether to authorize the substitute keys listed in
8896@code{authorized-keys}---by default that of @code{hydra.gnu.org}
0adfe95a
LC
8897(@pxref{Substitutes}).
8898
5b58c28b
LC
8899@vindex %default-authorized-guix-keys
8900@item @code{authorized-keys} (default: @var{%default-authorized-guix-keys})
8901The list of authorized key files for archive imports, as a list of
8902string-valued gexps (@pxref{Invoking guix archive}). By default, it
8903contains that of @code{hydra.gnu.org} (@pxref{Substitutes}).
8904
0adfe95a
LC
8905@item @code{use-substitutes?} (default: @code{#t})
8906Whether to use substitutes.
8907
b0b9f6e0
LC
8908@item @code{substitute-urls} (default: @var{%default-substitute-urls})
8909The list of URLs where to look for substitutes by default.
8910
0adfe95a
LC
8911@item @code{extra-options} (default: @code{'()})
8912List of extra command-line options for @command{guix-daemon}.
8913
dc0ef095
LC
8914@item @code{log-file} (default: @code{"/var/log/guix-daemon.log"})
8915File where @command{guix-daemon}'s standard output and standard error
8916are written.
8917
0adfe95a 8918@item @code{lsof} (default: @var{lsof})
f78903f3 8919The lsof package to use.
0adfe95a 8920
93d32da9
LF
8921@item @code{http-proxy} (default: @code{#f})
8922The HTTP proxy used for downloading fixed-output derivations and
8923substitutes.
8924
b191f0a6
LF
8925@item @code{tmpdir} (default: @code{#f})
8926A directory path where the @command{guix-daemon} will perform builds.
8927
0adfe95a
LC
8928@end table
8929@end deftp
8930
8931@deffn {Scheme Procedure} guix-service @var{config}
8932Return a service that runs the Guix build daemon according to
8933@var{config}.
cf4a9129 8934@end deffn
a1ba8475 8935
be1c2c54 8936@deffn {Scheme Procedure} udev-service [#:udev udev]
cf4a9129
LC
8937Run @var{udev}, which populates the @file{/dev} directory dynamically.
8938@end deffn
401c53c4 8939
a535e122
LF
8940@deffn {Scheme Procedure} urandom-seed-service @var{#f}
8941Save some entropy in @var{%random-seed-file} to seed @file{/dev/urandom}
8942when rebooting.
8943@end deffn
8944
8945@defvr {Scheme Variable} %random-seed-file
8946This is the name of the file where some random bytes are saved by
8947@var{urandom-seed-service} to seed @file{/dev/urandom} when rebooting.
8948It defaults to @file{/var/lib/random-seed}.
8949@end defvr
8950
e32171ee
JD
8951@cindex keymap
8952@cindex keyboard
b3d05f48 8953@deffn {Scheme Procedure} console-keymap-service @var{files} ...
dedb8d5e 8954@cindex keyboard layout
b3d05f48
AK
8955Return a service to load console keymaps from @var{files} using
8956@command{loadkeys} command. Most likely, you want to load some default
8957keymap, which can be done like this:
8958
8959@example
8960(console-keymap-service "dvorak")
8961@end example
8962
8963Or, for example, for a Swedish keyboard, you may need to combine
8964the following keymaps:
8965@example
8966(console-keymap-service "se-lat6" "se-fi-lat6")
8967@end example
8968
8969Also you can specify a full file name (or file names) of your keymap(s).
8970See @code{man loadkeys} for details.
8971
5eca9459
AK
8972@end deffn
8973
e32171ee
JD
8974@cindex mouse
8975@cindex gpm
1aaf116d 8976@deffn {Scheme Procedure} gpm-service [#:gpm @var{gpm}] @
8664cc88
LC
8977 [#:options]
8978Run @var{gpm}, the general-purpose mouse daemon, with the given
8979command-line @var{options}. GPM allows users to use the mouse in the console,
8980notably to select, copy, and paste text. The default value of @var{options}
8981uses the @code{ps2} protocol, which works for both USB and PS/2 mice.
8982
8983This service is not part of @var{%base-services}.
8984@end deffn
8985
1c52181f
LC
8986@anchor{guix-publish-service}
8987@deffn {Scheme Procedure} guix-publish-service [#:guix @var{guix}] @
8988 [#:port 80] [#:host "localhost"]
8989Return a service that runs @command{guix publish} listening on @var{host}
8990and @var{port} (@pxref{Invoking guix publish}).
8991
8992This assumes that @file{/etc/guix} already contains a signing key pair as
8993created by @command{guix archive --generate-key} (@pxref{Invoking guix
8994archive}). If that is not the case, the service will fail to start.
8995@end deffn
8996
b58cbf9a
DC
8997@anchor{rngd-service}
8998@deffn {Scheme Procedure} rngd-service [#:rng-tools @var{rng-tools}] @
8999 [#:device "/dev/hwrng"]
9000Return a service that runs the @command{rngd} program from @var{rng-tools}
9001to add @var{device} to the kernel's entropy pool. The service will fail if
9002@var{device} does not exist.
9003@end deffn
a69576ea 9004
909147e4
RW
9005@anchor{pam-limits-service}
9006@cindex session limits
9007@cindex ulimit
9008@cindex priority
9009@deffn {Scheme Procedure} pam-limits-service [#:limits @var{limits}]
9010
9011Return a service that installs a configuration file for the
9012@uref{http://linux-pam.org/Linux-PAM-html/sag-pam_limits.html,
9013@code{pam_limits} module}. The procedure optionally takes a list of
9014@code{pam-limits-entry} values, which can be used to specify
9015@code{ulimit} limits and nice priority limits to user sessions.
9016
9017The following limits definition sets two hard and soft limits for all
9018login sessions of users in the @code{realtime} group:
9019
9020@example
9021(pam-limits-service
9022 (list
9023 (pam-limits-entry "@@realtime" 'both 'rtprio 99)
9024 (pam-limits-entry "@@realtime" 'both 'memlock 'unlimited)))
9025@end example
9026
9027The first entry increases the maximum realtime priority for
9028non-privileged processes; the second entry lifts any restriction of the
9029maximum address space that can be locked in memory. These settings are
9030commonly used for real-time audio systems.
9031@end deffn
9032
c311089b
LC
9033@node Scheduled Job Execution
9034@subsubsection Scheduled Job Execution
9035
9036@cindex cron
e32171ee 9037@cindex mcron
c311089b
LC
9038@cindex scheduling jobs
9039The @code{(gnu services mcron)} module provides an interface to
9040GNU@tie{}mcron, a daemon to run jobs at scheduled times (@pxref{Top,,,
9041mcron, GNU@tie{}mcron}). GNU@tie{}mcron is similar to the traditional
9042Unix @command{cron} daemon; the main difference is that it is
9043implemented in Guile Scheme, which provides a lot of flexibility when
9044specifying the scheduling of jobs and their actions.
9045
8ac6282c 9046The example below defines an operating system that runs the
c311089b 9047@command{updatedb} (@pxref{Invoking updatedb,,, find, Finding Files})
8ac6282c
LC
9048and the @command{guix gc} commands (@pxref{Invoking guix gc}) daily, as
9049well as the @command{mkid} command on behalf of an unprivileged user
9050(@pxref{mkid invocation,,, idutils, ID Database Utilities}). It uses
9051gexps to introduce job definitions that are passed to mcron
9052(@pxref{G-Expressions}).
c311089b
LC
9053
9054@lisp
9055(use-modules (guix) (gnu) (gnu services mcron))
8ac6282c 9056(use-package-modules base idutils)
c311089b
LC
9057
9058(define updatedb-job
8ac6282c
LC
9059 ;; Run 'updatedb' at 3AM every day. Here we write the
9060 ;; job's action as a Scheme procedure.
c311089b 9061 #~(job '(next-hour '(3))
8ac6282c
LC
9062 (lambda ()
9063 (execl (string-append #$findutils "/bin/updatedb")
9064 "updatedb"
9065 "--prunepaths=/tmp /var/tmp /gnu/store"))))
c311089b
LC
9066
9067(define garbage-collector-job
9068 ;; Collect garbage 5 minutes after midnight every day.
8ac6282c 9069 ;; The job's action is a shell command.
c311089b
LC
9070 #~(job "5 0 * * *" ;Vixie cron syntax
9071 "guix gc -F 1G"))
9072
80d944b7 9073(define idutils-job
8ac6282c
LC
9074 ;; Update the index database as user "charlie" at 12:15PM
9075 ;; and 19:15PM. This runs from the user's home directory.
9076 #~(job '(next-minute-from (next-hour '(12 19)) '(15))
9077 (string-append #$idutils "/bin/mkid src")
9078 #:user "charlie"))
9079
c311089b
LC
9080(operating-system
9081 ;; @dots{}
9082 (services (cons (mcron-service (list garbage-collector-job
8ac6282c
LC
9083 updatedb-job
9084 idutils-job))
c311089b
LC
9085 %base-services)))
9086@end lisp
9087
9088@xref{Guile Syntax, mcron job specifications,, mcron, GNU@tie{}mcron},
9089for more information on mcron job specifications. Below is the
9090reference of the mcron service.
9091
9092@deffn {Scheme Procedure} mcron-service @var{jobs} [#:mcron @var{mcron2}]
9093Return an mcron service running @var{mcron} that schedules @var{jobs}, a
9094list of gexps denoting mcron job specifications.
9095
9096This is a shorthand for:
9097@example
80d944b7
LC
9098(service mcron-service-type
9099 (mcron-configuration (mcron mcron) (jobs jobs)))
c311089b
LC
9100@end example
9101@end deffn
9102
9103@defvr {Scheme Variable} mcron-service-type
9104This is the type of the @code{mcron} service, whose value is an
9105@code{mcron-configuration} object.
9106
9107This service type can be the target of a service extension that provides
9108it additional job specifications (@pxref{Service Composition}). In
80d944b7 9109other words, it is possible to define services that provide additional
c311089b
LC
9110mcron jobs to run.
9111@end defvr
9112
9113@deftp {Data Type} mcron-configuration
9114Data type representing the configuration of mcron.
9115
9116@table @asis
9117@item @code{mcron} (default: @var{mcron2})
9118The mcron package to use.
9119
9120@item @code{jobs}
9121This is a list of gexps (@pxref{G-Expressions}), where each gexp
9122corresponds to an mcron job specification (@pxref{Syntax, mcron job
9123specifications,, mcron, GNU@tie{}mcron}).
9124@end table
9125@end deftp
9126
9127
92c03a87
JN
9128@node Log Rotation
9129@subsubsection Log Rotation
9130
9131@cindex rottlog
9132@cindex log rotation
e32171ee 9133@cindex logging
92c03a87
JN
9134Log files such as those found in @file{/var/log} tend to grow endlessly,
9135so it's a good idea to @dfn{rotate} them once in a while---i.e., archive
9136their contents in separate files, possibly compressed. The @code{(gnu
9137services admin)} module provides an interface to GNU@tie{}Rot[t]log, a
9138log rotation tool (@pxref{Top,,, rottlog, GNU Rot[t]log Manual}).
9139
9140The example below defines an operating system that provides log rotation
9141with the default settings.
9142
9143@lisp
9144(use-modules (guix) (gnu))
9145(use-service-modules admin mcron)
9146(use-package-modules base idutils)
9147
9148(operating-system
9149 ;; @dots{}
9150 (services (cons* (mcron-service)
9151 (service rottlog-service-type (rottlog-configuration))
9152 %base-services)))
9153@end lisp
9154
9155@defvr {Scheme Variable} rottlog-service-type
9156This is the type of the Rottlog service, whose value is a
9157@code{rottlog-configuration} object.
9158
9159This service type can define mcron jobs (@pxref{Scheduled Job
9160Execution}) to run the rottlog service.
9161@end defvr
9162
9163@deftp {Data Type} rottlog-configuration
9164Data type representing the configuration of rottlog.
9165
9166@table @asis
9167@item @code{rottlog} (default: @code{rottlog})
9168The Rottlog package to use.
9169
9170@item @code{rc-file} (default: @code{(file-append rottlog "/etc/rc")})
9171The Rottlog configuration file to use (@pxref{Mandatory RC Variables,,,
9172rottlog, GNU Rot[t]log Manual}).
9173
9174@item @code{periodic-rotations} (default: @code{`(("weekly" %default-rotatations))})
9175A list of Rottlog period-name/period-config tuples.
9176
9177For example, taking an example from the Rottlog manual (@pxref{Period
9178Related File Examples,,, rottlog, GNU Rot[t]log Manual}), a valid tuple
9179might be:
9180
9181@example
9182("daily" ,(plain-file "daily"
9183 "\
9184 /var/log/apache/* @{
9185 storedir apache-archives
9186 rotate 6
9187 notifempty
9188 nocompress
9189 @}"))
9190@end example
9191
9192@item @code{jobs}
9193This is a list of gexps where each gexp corresponds to an mcron job
9194specification (@pxref{Scheduled Job Execution}).
9195@end table
9196@end deftp
9197
9198@defvr {Scheme Variable} %default-rotations
9199Specifies weekly rotation of @var{%rotated-files} and
9200@code{"/var/log/shepherd.log"}.
9201@end defvr
9202
9203@defvr {Scheme Variable} %rotated-files
9204The list of syslog-controlled files to be rotated. By default it is:
9205@code{'("/var/log/messages" "/var/log/secure")}.
9206@end defvr
9207
cf4a9129
LC
9208@node Networking Services
9209@subsubsection Networking Services
401c53c4 9210
fa1e31b8 9211The @code{(gnu services networking)} module provides services to configure
cf4a9129 9212the network interface.
a1ba8475 9213
a023cca8 9214@cindex DHCP, networking service
be1c2c54 9215@deffn {Scheme Procedure} dhcp-client-service [#:dhcp @var{isc-dhcp}]
a023cca8
LC
9216Return a service that runs @var{dhcp}, a Dynamic Host Configuration
9217Protocol (DHCP) client, on all the non-loopback network interfaces.
9218@end deffn
9219
8de3e4b3
LC
9220@defvr {Scheme Variable} static-networking-service-type
9221This is the type for statically-configured network interfaces.
9222@c TODO Document <static-networking> data structures.
9223@end defvr
9224
be1c2c54 9225@deffn {Scheme Procedure} static-networking-service @var{interface} @var{ip} @
1f9803c2 9226 [#:netmask #f] [#:gateway #f] [#:name-servers @code{'()}]
cf4a9129 9227Return a service that starts @var{interface} with address @var{ip}. If
1f9803c2
LC
9228@var{netmask} is true, use it as the network mask. If @var{gateway} is true,
9229it must be a string specifying the default network gateway.
8de3e4b3
LC
9230
9231This procedure can be called several times, one for each network
9232interface of interest. Behind the scenes what it does is extend
9233@code{static-networking-service-type} with additional network interfaces
9234to handle.
cf4a9129 9235@end deffn
8b315a6d 9236
b7d0c494 9237@cindex wicd
e32171ee
JD
9238@cindex wireless
9239@cindex WiFi
87f40011 9240@cindex network management
be1c2c54 9241@deffn {Scheme Procedure} wicd-service [#:wicd @var{wicd}]
87f40011
LC
9242Return a service that runs @url{https://launchpad.net/wicd,Wicd}, a network
9243management daemon that aims to simplify wired and wireless networking.
9244
9245This service adds the @var{wicd} package to the global profile, providing
9246several commands to interact with the daemon and configure networking:
9247@command{wicd-client}, a graphical user interface, and the @command{wicd-cli}
9248and @command{wicd-curses} user interfaces.
b7d0c494
MW
9249@end deffn
9250
c0a9589d 9251@cindex NetworkManager
b726096b
CB
9252
9253@defvr {Scheme Variable} network-manager-service-type
9254This is the service type for the
9255@uref{https://wiki.gnome.org/Projects/NetworkManager, NetworkManager}
9256service. The value for this service type is a
9257@code{network-manager-configuration} record.
9258@end defvr
9259
9260@deftp {Data Type} network-manager-configuration
9261Data type representing the configuration of NetworkManager.
9262
9263@table @asis
9264@item @code{network-manager} (default: @code{network-manager})
9265The NetworkManager package to use.
9266
9267@item @code{dns} (default: @code{"default"})
9268Processing mode for DNS, which affects how NetworkManager uses the
9269@code{resolv.conf} configuration file.
9270
9271@table @samp
9272@item default
9273NetworkManager will update @code{resolv.conf} to reflect the nameservers
9274provided by currently active connections.
9275
9276@item dnsmasq
9277NetworkManager will run @code{dnsmasq} as a local caching nameserver,
9278using a "split DNS" configuration if you are connected to a VPN, and
9279then update @code{resolv.conf} to point to the local nameserver.
9280
9281@item none
9282NetworkManager will not modify @code{resolv.conf}.
9283@end table
9284
9285@end table
9286@end deftp
c0a9589d 9287
76192896 9288@cindex Connman
34d60c49
MO
9289@deffn {Scheme Variable} connman-service-type
9290This is the service type to run @url{https://01.org/connman,Connman},
9291a network connection manager.
9292
9293Its value must be an
9294@code{connman-configuration} record as in this example:
9295
9296@example
9297(service connman-service-type
9298 (connman-configuration
9299 (disable-vpn? #t)))
9300@end example
9301
9302See below for details about @code{connman-configuration}.
76192896
EF
9303@end deffn
9304
34d60c49
MO
9305@deftp {Data Type} connman-configuration
9306Data Type representing the configuration of connman.
9307
9308@table @asis
9309@item @code{connman} (default: @var{connman})
9310The connman package to use.
9311
9312@item @code{disable-vpn?} (default: @code{#f})
9313When true, enable connman's vpn plugin.
9314@end table
9315@end deftp
9316
2cccbc2a 9317@cindex WPA Supplicant
cbf1024e
LC
9318@defvr {Scheme Variable} wpa-supplicant-service-type
9319This is the service type to run @url{https://w1.fi/wpa_supplicant/,WPA
2cccbc2a 9320supplicant}, an authentication daemon required to authenticate against
cbf1024e 9321encrypted WiFi or ethernet networks. It is configured to listen for
2cccbc2a 9322requests on D-Bus.
cbf1024e
LC
9323
9324The value of this service is the @code{wpa-supplicant} package to use.
9325Thus, it can be instantiated like this:
9326
9327@lisp
9328(use-modules (gnu services networking)
9329 (gnu packages admin))
9330
9747d189 9331(service wpa-supplicant-service-type wpa-supplicant)
cbf1024e
LC
9332@end lisp
9333@end defvr
2cccbc2a 9334
e32171ee
JD
9335@cindex NTP
9336@cindex real time clock
be1c2c54 9337@deffn {Scheme Procedure} ntp-service [#:ntp @var{ntp}] @
dc0322b5
LC
9338 [#:servers @var{%ntp-servers}] @
9339 [#:allow-large-adjustment? #f]
63854bcb
LC
9340Return a service that runs the daemon from @var{ntp}, the
9341@uref{http://www.ntp.org, Network Time Protocol package}. The daemon will
9342keep the system clock synchronized with that of @var{servers}.
dc0322b5
LC
9343@var{allow-large-adjustment?} determines whether @command{ntpd} is allowed to
9344make an initial adjustment of more than 1,000 seconds.
63854bcb
LC
9345@end deffn
9346
9347@defvr {Scheme Variable} %ntp-servers
9348List of host names used as the default NTP servers.
9349@end defvr
9350
e32171ee 9351@cindex Tor
375c6108
LC
9352@deffn {Scheme Procedure} tor-service [@var{config-file}] [#:tor @var{tor}]
9353Return a service to run the @uref{https://torproject.org, Tor} anonymous
9354networking daemon.
8b315a6d 9355
375c6108 9356The daemon runs as the @code{tor} unprivileged user. It is passed
6331bde7
LC
9357@var{config-file}, a file-like object, with an additional @code{User tor} line
9358and lines for hidden services added via @code{tor-hidden-service}. Run
9359@command{man tor} for information about the configuration file.
9360@end deffn
9361
24a8ef3b 9362@cindex hidden service
6331bde7
LC
9363@deffn {Scheme Procedure} tor-hidden-service @var{name} @var{mapping}
9364Define a new Tor @dfn{hidden service} called @var{name} and implementing
9365@var{mapping}. @var{mapping} is a list of port/host tuples, such as:
9366
9367@example
24a8ef3b
LC
9368 '((22 "127.0.0.1:22")
9369 (80 "127.0.0.1:8080"))
6331bde7
LC
9370@end example
9371
9372In this example, port 22 of the hidden service is mapped to local port 22, and
9373port 80 is mapped to local port 8080.
9374
6629099a
LC
9375This creates a @file{/var/lib/tor/hidden-services/@var{name}} directory, where
9376the @file{hostname} file contains the @code{.onion} host name for the hidden
6331bde7
LC
9377service.
9378
9379See @uref{https://www.torproject.org/docs/tor-hidden-service.html.en, the Tor
9380project's documentation} for more information.
cf4a9129 9381@end deffn
8b315a6d 9382
be1c2c54 9383@deffn {Scheme Procedure} bitlbee-service [#:bitlbee bitlbee] @
4627a464
LC
9384 [#:interface "127.0.0.1"] [#:port 6667] @
9385 [#:extra-settings ""]
9386Return a service that runs @url{http://bitlbee.org,BitlBee}, a daemon that
9387acts as a gateway between IRC and chat networks.
9388
9389The daemon will listen to the interface corresponding to the IP address
9390specified in @var{interface}, on @var{port}. @code{127.0.0.1} means that only
9391local clients can connect, whereas @code{0.0.0.0} means that connections can
9392come from any networking interface.
9393
9394In addition, @var{extra-settings} specifies a string to append to the
9395configuration file.
9396@end deffn
9397
71b0601a 9398Furthermore, @code{(gnu services ssh)} provides the following services.
e32171ee
JD
9399@cindex SSH
9400@cindex SSH server
8b315a6d 9401
be1c2c54 9402@deffn {Scheme Procedure} lsh-service [#:host-key "/etc/lsh/host-key"] @
5833bf33 9403 [#:daemonic? #t] [#:interfaces '()] [#:port-number 22] @
cf4a9129
LC
9404 [#:allow-empty-passwords? #f] [#:root-login? #f] @
9405 [#:syslog-output? #t] [#:x11-forwarding? #t] @
9406 [#:tcp/ip-forwarding? #t] [#:password-authentication? #t] @
21cc905a 9407 [#:public-key-authentication? #t] [#:initialize? #t]
cf4a9129
LC
9408Run the @command{lshd} program from @var{lsh} to listen on port @var{port-number}.
9409@var{host-key} must designate a file containing the host key, and readable
9410only by root.
72e25e35 9411
5833bf33
DP
9412When @var{daemonic?} is true, @command{lshd} will detach from the
9413controlling terminal and log its output to syslogd, unless one sets
9414@var{syslog-output?} to false. Obviously, it also makes lsh-service
9415depend on existence of syslogd service. When @var{pid-file?} is true,
9416@command{lshd} writes its PID to the file called @var{pid-file}.
9417
cf4a9129
LC
9418When @var{initialize?} is true, automatically create the seed and host key
9419upon service activation if they do not exist yet. This may take long and
9420require interaction.
8b315a6d 9421
20dd519c
LC
9422When @var{initialize?} is false, it is up to the user to initialize the
9423randomness generator (@pxref{lsh-make-seed,,, lsh, LSH Manual}), and to create
9424a key pair with the private key stored in file @var{host-key} (@pxref{lshd
9425basics,,, lsh, LSH Manual}).
9426
cf4a9129
LC
9427When @var{interfaces} is empty, lshd listens for connections on all the
9428network interfaces; otherwise, @var{interfaces} must be a list of host names
9429or addresses.
9bf3c1a7 9430
20dd519c
LC
9431@var{allow-empty-passwords?} specifies whether to accept log-ins with empty
9432passwords, and @var{root-login?} specifies whether to accept log-ins as
cf4a9129 9433root.
4af2447e 9434
cf4a9129
LC
9435The other options should be self-descriptive.
9436@end deffn
4af2447e 9437
e32171ee
JD
9438@cindex SSH
9439@cindex SSH server
d8f31281
LC
9440@deffn {Scheme Variable} openssh-service-type
9441This is the type for the @uref{http://www.openssh.org, OpenSSH} secure
9442shell daemon, @command{sshd}. Its value must be an
9443@code{openssh-configuration} record as in this example:
9444
9445@example
9446(service openssh-service-type
9447 (openssh-configuration
9448 (x11-forwarding? #t)
9449 (permit-root-login 'without-password)))
9450@end example
9451
9452See below for details about @code{openssh-configuration}.
86d8f6d3
JL
9453@end deffn
9454
d8f31281
LC
9455@deftp {Data Type} openssh-configuration
9456This is the configuration record for OpenSSH's @command{sshd}.
9457
9458@table @asis
9459@item @code{pid-file} (default: @code{"/var/run/sshd.pid"})
9460Name of the file where @command{sshd} writes its PID.
9461
9462@item @code{port-number} (default: @code{22})
9463TCP port on which @command{sshd} listens for incoming connections.
9464
9465@item @code{permit-root-login} (default: @code{#f})
9466This field determines whether and when to allow logins as root. If
9467@code{#f}, root logins are disallowed; if @code{#t}, they are allowed.
9468If it's the symbol @code{'without-password}, then root logins are
9469permitted but not with password-based authentication.
9470
9471@item @code{allow-empty-passwords?} (default: @code{#f})
9472When true, users with empty passwords may log in. When false, they may
9473not.
9474
9475@item @code{password-authentication?} (default: @code{#t})
9476When true, users may log in with their password. When false, they have
9477other authentication methods.
9478
9479@item @code{public-key-authentication?} (default: @code{#t})
9480When true, users may log in using public key authentication. When
9481false, users have to use other authentication method.
9482
9483Authorized public keys are stored in @file{~/.ssh/authorized_keys}.
9484This is used only by protocol version 2.
9485
d8f31281
LC
9486@item @code{x11-forwarding?} (default: @code{#f})
9487When true, forwarding of X11 graphical client connections is
9488enabled---in other words, @command{ssh} options @option{-X} and
9489@option{-Y} will work.
9490
563c5d42
CL
9491@item @code{challenge-response-authentication?} (default: @code{#f})
9492Specifies whether challenge response authentication is allowed (e.g. via
9493PAM).
9494
9495@item @code{use-pam?} (default: @code{#t})
9496Enables the Pluggable Authentication Module interface. If set to
9497@code{#t}, this will enable PAM authentication using
9498@code{challenge-response-authentication?} and
9499@code{password-authentication?}, in addition to PAM account and session
9500module processing for all authentication types.
9501
9502Because PAM challenge response authentication usually serves an
9503equivalent role to password authentication, you should disable either
9504@code{challenge-response-authentication?} or
9505@code{password-authentication?}.
f895dce4
CL
9506
9507@item @code{print-last-log?} (default: @code{#t})
9508Specifies whether @command{sshd} should print the date and time of the
9509last user login when a user logs in interactively.
d8f31281
LC
9510@end table
9511@end deftp
9512
71b0601a
DC
9513@deffn {Scheme Procedure} dropbear-service [@var{config}]
9514Run the @uref{https://matt.ucc.asn.au/dropbear/dropbear.html,Dropbear SSH
9515daemon} with the given @var{config}, a @code{<dropbear-configuration>}
9516object.
9517
9518For example, to specify a Dropbear service listening on port 1234, add
9519this call to the operating system's @code{services} field:
9520
9521@example
9522(dropbear-service (dropbear-configuration
9523 (port-number 1234)))
9524@end example
9525@end deffn
9526
9527@deftp {Data Type} dropbear-configuration
9528This data type represents the configuration of a Dropbear SSH daemon.
9529
9530@table @asis
9531@item @code{dropbear} (default: @var{dropbear})
9532The Dropbear package to use.
9533
9534@item @code{port-number} (default: 22)
9535The TCP port where the daemon waits for incoming connections.
9536
9537@item @code{syslog-output?} (default: @code{#t})
9538Whether to enable syslog output.
9539
9540@item @code{pid-file} (default: @code{"/var/run/dropbear.pid"})
9541File name of the daemon's PID file.
9542
9543@item @code{root-login?} (default: @code{#f})
9544Whether to allow @code{root} logins.
9545
9546@item @code{allow-empty-passwords?} (default: @code{#f})
9547Whether to allow empty passwords.
9548
9549@item @code{password-authentication?} (default: @code{#t})
9550Whether to enable password-based authentication.
9551@end table
9552@end deftp
9553
fa0c1d61
LC
9554@defvr {Scheme Variable} %facebook-host-aliases
9555This variable contains a string for use in @file{/etc/hosts}
9556(@pxref{Host Names,,, libc, The GNU C Library Reference Manual}). Each
9557line contains a entry that maps a known server name of the Facebook
9558on-line service---e.g., @code{www.facebook.com}---to the local
9559host---@code{127.0.0.1} or its IPv6 equivalent, @code{::1}.
9560
9561This variable is typically used in the @code{hosts-file} field of an
7313a52e
LC
9562@code{operating-system} declaration (@pxref{operating-system Reference,
9563@file{/etc/hosts}}):
fa0c1d61
LC
9564
9565@example
9566(use-modules (gnu) (guix))
9567
9568(operating-system
9569 (host-name "mymachine")
9570 ;; ...
9571 (hosts-file
9572 ;; Create a /etc/hosts file with aliases for "localhost"
9573 ;; and "mymachine", as well as for Facebook servers.
24e02c28
LC
9574 (plain-file "hosts"
9575 (string-append (local-host-aliases host-name)
9576 %facebook-host-aliases))))
fa0c1d61
LC
9577@end example
9578
9579This mechanism can prevent programs running locally, such as Web
9580browsers, from accessing Facebook.
9581@end defvr
9582
965a7332
LC
9583The @code{(gnu services avahi)} provides the following definition.
9584
be1c2c54 9585@deffn {Scheme Procedure} avahi-service [#:avahi @var{avahi}] @
965a7332
LC
9586 [#:host-name #f] [#:publish? #t] [#:ipv4? #t] @
9587 [#:ipv6? #t] [#:wide-area? #f] @
c8695f32 9588 [#:domains-to-browse '()] [#:debug? #f]
965a7332
LC
9589Return a service that runs @command{avahi-daemon}, a system-wide
9590mDNS/DNS-SD responder that allows for service discovery and
cc9c1f39
LC
9591"zero-configuration" host name lookups (see @uref{http://avahi.org/}), and
9592extends the name service cache daemon (nscd) so that it can resolve
9593@code{.local} host names using
1065bed9
LC
9594@uref{http://0pointer.de/lennart/projects/nss-mdns/, nss-mdns}. Additionally,
9595add the @var{avahi} package to the system profile so that commands such as
9596@command{avahi-browse} are directly usable.
965a7332
LC
9597
9598If @var{host-name} is different from @code{#f}, use that as the host name to
9599publish for this machine; otherwise, use the machine's actual host name.
9600
9601When @var{publish?} is true, publishing of host names and services is allowed;
9602in particular, avahi-daemon will publish the machine's host name and IP
9603address via mDNS on the local network.
9604
9605When @var{wide-area?} is true, DNS-SD over unicast DNS is enabled.
9606
9607Boolean values @var{ipv4?} and @var{ipv6?} determine whether to use IPv4/IPv6
9608sockets.
9609@end deffn
9610
c32d02fe
SB
9611@deffn {Scheme Variable} openvswitch-service-type
9612This is the type of the @uref{http://www.openvswitch.org, Open vSwitch}
9613service, whose value should be an @code{openvswitch-configuration}
9614object.
9615@end deffn
9616
9617@deftp {Data Type} openvswitch-configuration
9618Data type representing the configuration of Open vSwitch, a multilayer
9619virtual switch which is designed to enable massive network automation
9620through programmatic extension.
9621
9622@table @asis
9623@item @code{package} (default: @var{openvswitch})
9624Package object of the Open vSwitch.
9625
9626@end table
9627@end deftp
965a7332 9628
cf4a9129
LC
9629@node X Window
9630@subsubsection X Window
68ad877c 9631
e32171ee
JD
9632@cindex X11
9633@cindex X Window System
cf4a9129
LC
9634Support for the X Window graphical display system---specifically
9635Xorg---is provided by the @code{(gnu services xorg)} module. Note that
9636there is no @code{xorg-service} procedure. Instead, the X server is
9637started by the @dfn{login manager}, currently SLiM.
4af2447e 9638
935644c0
DC
9639@deftp {Data Type} sddm-configuration
9640This is the data type representing the sddm service configuration.
9641
9642@table @asis
9643@item @code{display-server} (default: "x11")
9644Select display server to use for the greeter. Valid values are "x11"
9645or "wayland".
9646
9647@item @code{numlock} (default: "on")
9648Valid values are "on", "off" or "none".
9649
9650@item @code{halt-command} (default @code{#~(string-apppend #$shepherd "/sbin/halt")})
9651Command to run when halting.
9652
9653@item @code{reboot-command} (default @code{#~(string-append #$shepherd "/sbin/reboot")})
9654Command to run when rebooting.
9655
9656@item @code{theme} (default "maldives")
9657Theme to use. Default themes provided by SDDM are "elarun" or "maldives".
9658
9659@item @code{themes-directory} (default "/run/current-system/profile/share/sddm/themes")
9660Directory to look for themes.
9661
9662@item @code{faces-directory} (default "/run/current-system/profile/share/sddm/faces")
9663Directory to look for faces.
9664
9665@item @code{default-path} (default "/run/current-system/profile/bin")
9666Default PATH to use.
9667
9668@item @code{minimum-uid} (default 1000)
9669Minimum UID to display in SDDM.
9670
9671@item @code{maximum-uid} (default 2000)
9672Maximum UID to display in SDDM
9673
9674@item @code{remember-last-user?} (default #t)
9675Remember last user.
9676
9677@item @code{remember-last-session?} (default #t)
9678Remember last session.
9679
9680@item @code{hide-users} (default "")
9681Usernames to hide from SDDM greeter.
9682
9683@item @code{hide-shells} (default @code{#~(string-append #$shadow "/sbin/nologin")})
9684Users with shells listed will be hidden from the SDDM greeter.
9685
9686@item @code{session-command} (default @code{#~(string-append #$sddm "/share/sddm/scripts/wayland-session")})
9687Script to run before starting a wayland session.
9688
9689@item @code{sessions-directory} (default "/run/current-system/profile/share/wayland-sessions")
9690Directory to look for desktop files starting wayland sessions.
9691
9692@item @code{xorg-server-path} (default @code{xorg-start-command})
9693Path to xorg-server.
9694
9695@item @code{xauth-path} (default @code{#~(string-append #$xauth "/bin/xauth")})
9696Path to xauth.
9697
9698@item @code{xephyr-path} (default @code{#~(string-append #$xorg-server "/bin/Xephyr")})
9699Path to Xephyr.
9700
9701@item @code{xdisplay-start} (default @code{#~(string-append #$sddm "/share/sddm/scripts/Xsetup")})
9702Script to run after starting xorg-server.
9703
9704@item @code{xdisplay-stop} (default @code{#~(string-append #$sddm "/share/sddm/scripts/Xstop")})
9705Script to run before stopping xorg-server.
9706
9707@item @code{xsession-command} (default: @code{xinitr })
9708Script to run before starting a X session.
9709
9710@item @code{xsessions-directory} (default: "/run/current-system/profile/share/xsessions")
9711Directory to look for desktop files starting X sessions.
9712
9713@item @code{minimum-vt} (default: 7)
9714Minimum VT to use.
9715
9716@item @code{xserver-arguments} (default "-nolisten tcp")
9717Arguments to pass to xorg-server.
9718
9719@item @code{auto-login-user} (default "")
9720User to use for auto-login.
9721
9722@item @code{auto-login-session} (default "")
9723Desktop file to use for auto-login.
9724
9725@item @code{relogin?} (default #f)
9726Relogin after logout.
9727
9728@end table
9729@end deftp
9730
e32171ee 9731@cindex login manager
935644c0
DC
9732@deffn {Scheme Procedure} sddm-service config
9733Return a service that spawns the SDDM graphical login manager for config of
9734type @code{<sddm-configuration>}.
9735
9736@example
9737 (sddm-service (sddm-configuration
9738 (auto-login-user "Alice")
9739 (auto-login-session "xfce.desktop")))
9740@end example
9741@end deffn
9742
be1c2c54 9743@deffn {Scheme Procedure} slim-service [#:allow-empty-passwords? #f] @
0ecc3bf3
LC
9744 [#:auto-login? #f] [#:default-user ""] [#:startx] @
9745 [#:theme @var{%default-slim-theme}] @
4bd43bbe 9746 [#:theme-name @var{%default-slim-theme-name}]
cf4a9129
LC
9747Return a service that spawns the SLiM graphical login manager, which in
9748turn starts the X display server with @var{startx}, a command as returned by
9749@code{xorg-start-command}.
4af2447e 9750
04e4e6ab
LC
9751@cindex X session
9752
9753SLiM automatically looks for session types described by the @file{.desktop}
9754files in @file{/run/current-system/profile/share/xsessions} and allows users
9755to choose a session from the log-in screen using @kbd{F1}. Packages such as
9756@var{xfce}, @var{sawfish}, and @var{ratpoison} provide @file{.desktop} files;
9757adding them to the system-wide set of packages automatically makes them
9758available at the log-in screen.
9759
9760In addition, @file{~/.xsession} files are honored. When available,
9761@file{~/.xsession} must be an executable that starts a window manager
9762and/or other X clients.
9763
cf4a9129
LC
9764When @var{allow-empty-passwords?} is true, allow logins with an empty
9765password. When @var{auto-login?} is true, log in automatically as
9766@var{default-user}.
0ecc3bf3 9767
1068f26b 9768If @var{theme} is @code{#f}, use the default log-in theme; otherwise
0ecc3bf3
LC
9769@var{theme} must be a gexp denoting the name of a directory containing the
9770theme to use. In that case, @var{theme-name} specifies the name of the
9771theme.
cf4a9129 9772@end deffn
4af2447e 9773
0ecc3bf3
LC
9774@defvr {Scheme Variable} %default-theme
9775@defvrx {Scheme Variable} %default-theme-name
9776The G-Expression denoting the default SLiM theme and its name.
9777@end defvr
9778
be1c2c54 9779@deffn {Scheme Procedure} xorg-start-command [#:guile] @
d1cdd7ba 9780 [#:configuration-file #f] [#:xorg-server @var{xorg-server}]
f703413e 9781Return a derivation that builds a @var{guile} script to start the X server
d1cdd7ba
LC
9782from @var{xorg-server}. @var{configuration-file} is the server configuration
9783file or a derivation that builds it; when omitted, the result of
9784@code{xorg-configuration-file} is used.
9785
9786Usually the X server is started by a login manager.
9787@end deffn
9788
be1c2c54 9789@deffn {Scheme Procedure} xorg-configuration-file @
12422c9d 9790 [#:drivers '()] [#:resolutions '()] [#:extra-config '()]
d1cdd7ba
LC
9791Return a configuration file for the Xorg server containing search paths for
9792all the common drivers.
f703413e
LC
9793
9794@var{drivers} must be either the empty list, in which case Xorg chooses a
9795graphics driver automatically, or a list of driver names that will be tried in
d1cdd7ba 9796this order---e.g., @code{(\"modesetting\" \"vesa\")}.
d2e59637
LC
9797
9798Likewise, when @var{resolutions} is the empty list, Xorg chooses an
9799appropriate screen resolution; otherwise, it must be a list of
9800resolutions---e.g., @code{((1024 768) (640 480))}.
12422c9d
LC
9801
9802Last, @var{extra-config} is a list of strings or objects appended to the
9803@code{text-file*} argument list. It is used to pass extra text to be added
9804verbatim to the configuration file.
f703413e 9805@end deffn
4af2447e 9806
6726282b
LC
9807@deffn {Scheme Procedure} screen-locker-service @var{package} [@var{name}]
9808Add @var{package}, a package for a screen-locker or screen-saver whose
9809command is @var{program}, to the set of setuid programs and add a PAM entry
9810for it. For example:
9811
9812@lisp
9813(screen-locker-service xlockmore "xlock")
9814@end lisp
9815
9816makes the good ol' XlockMore usable.
9817@end deffn
9818
9819
f2ec23d1
AW
9820@node Printing Services
9821@subsubsection Printing Services
9822
de322a5d 9823@cindex printer support with CUPS
f2ec23d1
AW
9824The @code{(gnu services cups)} module provides a Guix service definition
9825for the CUPS printing service. To add printer support to a GuixSD
9826system, add a @code{cups-service} to the operating system definition:
9827
9828@deffn {Scheme Variable} cups-service-type
9829The service type for the CUPS print server. Its value should be a valid
9830CUPS configuration (see below). For example:
9831@example
9832(service cups-service-type (cups-configuration))
9833@end example
9834@end deffn
9835
9836The CUPS configuration controls the basic things about your CUPS
9837installation: what interfaces it listens on, what to do if a print job
9838fails, how much logging to do, and so on. To actually add a printer,
9839you have to visit the @url{http://localhost:631} URL, or use a tool such
9840as GNOME's printer configuration services. By default, configuring a
9841CUPS service will generate a self-signed certificate if needed, for
9842secure connections to the print server.
9843
de322a5d
LC
9844Suppose you want to enable the Web interface of CUPS and also add
9845support for HP printers @i{via} the @code{hplip} package. You can do
9846that directly, like this (you need to use the @code{(gnu packages cups)}
9847module):
f2ec23d1
AW
9848
9849@example
9850(service cups-service-type
9851 (cups-configuration
de322a5d
LC
9852 (web-interface? #t)
9853 (extensions
9854 (list cups-filters hplip))))
f2ec23d1
AW
9855@end example
9856
9857The available configuration parameters follow. Each parameter
9858definition is preceded by its type; for example, @samp{string-list foo}
9859indicates that the @code{foo} parameter should be specified as a list of
9860strings. There is also a way to specify the configuration as a string,
9861if you have an old @code{cupsd.conf} file that you want to port over
9862from some other system; see the end for more details.
9863
9864@c The following documentation was initially generated by
9865@c (generate-documentation) in (gnu services cups). Manually maintained
9866@c documentation is better, so we shouldn't hesitate to edit below as
9867@c needed. However if the change you want to make to this documentation
9868@c can be done in an automated way, it's probably easier to change
9869@c (generate-documentation) than to make it below and have to deal with
9870@c the churn as CUPS updates.
9871
9872
9873Available @code{cups-configuration} fields are:
9874
9875@deftypevr {@code{cups-configuration} parameter} package cups
9876The CUPS package.
9877@end deftypevr
9878
9879@deftypevr {@code{cups-configuration} parameter} package-list extensions
9880Drivers and other extensions to the CUPS package.
9881@end deftypevr
9882
9883@deftypevr {@code{cups-configuration} parameter} files-configuration files-configuration
9884Configuration of where to write logs, what directories to use for print
9885spools, and related privileged configuration parameters.
9886
9887Available @code{files-configuration} fields are:
9888
9889@deftypevr {@code{files-configuration} parameter} log-location access-log
9890Defines the access log filename. Specifying a blank filename disables
9891access log generation. The value @code{stderr} causes log entries to be
9892sent to the standard error file when the scheduler is running in the
9893foreground, or to the system log daemon when run in the background. The
9894value @code{syslog} causes log entries to be sent to the system log
9895daemon. The server name may be included in filenames using the string
9896@code{%s}, as in @code{/var/log/cups/%s-access_log}.
9897
9898Defaults to @samp{"/var/log/cups/access_log"}.
9899@end deftypevr
9900
9901@deftypevr {@code{files-configuration} parameter} file-name cache-dir
9902Where CUPS should cache data.
9903
9904Defaults to @samp{"/var/cache/cups"}.
9905@end deftypevr
9906
9907@deftypevr {@code{files-configuration} parameter} string config-file-perm
9908Specifies the permissions for all configuration files that the scheduler
9909writes.
9910
9911Note that the permissions for the printers.conf file are currently
9912masked to only allow access from the scheduler user (typically root).
9913This is done because printer device URIs sometimes contain sensitive
9914authentication information that should not be generally known on the
9915system. There is no way to disable this security feature.
9916
9917Defaults to @samp{"0640"}.
9918@end deftypevr
9919
9920@deftypevr {@code{files-configuration} parameter} log-location error-log
9921Defines the error log filename. Specifying a blank filename disables
9922access log generation. The value @code{stderr} causes log entries to be
9923sent to the standard error file when the scheduler is running in the
9924foreground, or to the system log daemon when run in the background. The
9925value @code{syslog} causes log entries to be sent to the system log
9926daemon. The server name may be included in filenames using the string
9927@code{%s}, as in @code{/var/log/cups/%s-error_log}.
9928
9929Defaults to @samp{"/var/log/cups/error_log"}.
9930@end deftypevr
9931
9932@deftypevr {@code{files-configuration} parameter} string fatal-errors
9933Specifies which errors are fatal, causing the scheduler to exit. The
9934kind strings are:
9935
9936@table @code
9937@item none
9938No errors are fatal.
9939
9940@item all
9941All of the errors below are fatal.
9942
9943@item browse
9944Browsing initialization errors are fatal, for example failed connections
9945to the DNS-SD daemon.
9946
9947@item config
9948Configuration file syntax errors are fatal.
9949
9950@item listen
9951Listen or Port errors are fatal, except for IPv6 failures on the
9952loopback or @code{any} addresses.
9953
9954@item log
9955Log file creation or write errors are fatal.
9956
9957@item permissions
9958Bad startup file permissions are fatal, for example shared TLS
9959certificate and key files with world-read permissions.
9960@end table
9961
9962Defaults to @samp{"all -browse"}.
9963@end deftypevr
9964
9965@deftypevr {@code{files-configuration} parameter} boolean file-device?
9966Specifies whether the file pseudo-device can be used for new printer
9967queues. The URI @uref{file:///dev/null} is always allowed.
9968
9969Defaults to @samp{#f}.
9970@end deftypevr
9971
9972@deftypevr {@code{files-configuration} parameter} string group
9973Specifies the group name or ID that will be used when executing external
9974programs.
9975
9976Defaults to @samp{"lp"}.
9977@end deftypevr
9978
9979@deftypevr {@code{files-configuration} parameter} string log-file-perm
9980Specifies the permissions for all log files that the scheduler writes.
9981
9982Defaults to @samp{"0644"}.
9983@end deftypevr
9984
9985@deftypevr {@code{files-configuration} parameter} log-location page-log
9986Defines the page log filename. Specifying a blank filename disables
9987access log generation. The value @code{stderr} causes log entries to be
9988sent to the standard error file when the scheduler is running in the
9989foreground, or to the system log daemon when run in the background. The
9990value @code{syslog} causes log entries to be sent to the system log
9991daemon. The server name may be included in filenames using the string
9992@code{%s}, as in @code{/var/log/cups/%s-page_log}.
9993
9994Defaults to @samp{"/var/log/cups/page_log"}.
9995@end deftypevr
9996
9997@deftypevr {@code{files-configuration} parameter} string remote-root
9998Specifies the username that is associated with unauthenticated accesses
9999by clients claiming to be the root user. The default is @code{remroot}.
10000
10001Defaults to @samp{"remroot"}.
10002@end deftypevr
10003
10004@deftypevr {@code{files-configuration} parameter} file-name request-root
10005Specifies the directory that contains print jobs and other HTTP request
10006data.
10007
10008Defaults to @samp{"/var/spool/cups"}.
10009@end deftypevr
10010
10011@deftypevr {@code{files-configuration} parameter} sandboxing sandboxing
10012Specifies the level of security sandboxing that is applied to print
10013filters, backends, and other child processes of the scheduler; either
10014@code{relaxed} or @code{strict}. This directive is currently only
10015used/supported on macOS.
10016
10017Defaults to @samp{strict}.
10018@end deftypevr
10019
10020@deftypevr {@code{files-configuration} parameter} file-name server-keychain
10021Specifies the location of TLS certificates and private keys. CUPS will
10022look for public and private keys in this directory: a @code{.crt} files
10023for PEM-encoded certificates and corresponding @code{.key} files for
10024PEM-encoded private keys.
10025
10026Defaults to @samp{"/etc/cups/ssl"}.
10027@end deftypevr
10028
10029@deftypevr {@code{files-configuration} parameter} file-name server-root
10030Specifies the directory containing the server configuration files.
10031
10032Defaults to @samp{"/etc/cups"}.
10033@end deftypevr
10034
10035@deftypevr {@code{files-configuration} parameter} boolean sync-on-close?
10036Specifies whether the scheduler calls fsync(2) after writing
10037configuration or state files.
10038
10039Defaults to @samp{#f}.
10040@end deftypevr
10041
10042@deftypevr {@code{files-configuration} parameter} space-separated-string-list system-group
10043Specifies the group(s) to use for @code{@@SYSTEM} group authentication.
10044@end deftypevr
10045
10046@deftypevr {@code{files-configuration} parameter} file-name temp-dir
10047Specifies the directory where temporary files are stored.
10048
10049Defaults to @samp{"/var/spool/cups/tmp"}.
10050@end deftypevr
10051
10052@deftypevr {@code{files-configuration} parameter} string user
10053Specifies the user name or ID that is used when running external
10054programs.
10055
10056Defaults to @samp{"lp"}.
10057@end deftypevr
10058@end deftypevr
10059
10060@deftypevr {@code{cups-configuration} parameter} access-log-level access-log-level
10061Specifies the logging level for the AccessLog file. The @code{config}
10062level logs when printers and classes are added, deleted, or modified and
10063when configuration files are accessed or updated. The @code{actions}
10064level logs when print jobs are submitted, held, released, modified, or
10065canceled, and any of the conditions for @code{config}. The @code{all}
10066level logs all requests.
10067
10068Defaults to @samp{actions}.
10069@end deftypevr
10070
10071@deftypevr {@code{cups-configuration} parameter} boolean auto-purge-jobs?
10072Specifies whether to purge job history data automatically when it is no
10073longer required for quotas.
10074
10075Defaults to @samp{#f}.
10076@end deftypevr
10077
10078@deftypevr {@code{cups-configuration} parameter} browse-local-protocols browse-local-protocols
10079Specifies which protocols to use for local printer sharing.
10080
10081Defaults to @samp{dnssd}.
10082@end deftypevr
10083
10084@deftypevr {@code{cups-configuration} parameter} boolean browse-web-if?
10085Specifies whether the CUPS web interface is advertised.
10086
10087Defaults to @samp{#f}.
10088@end deftypevr
10089
10090@deftypevr {@code{cups-configuration} parameter} boolean browsing?
10091Specifies whether shared printers are advertised.
10092
10093Defaults to @samp{#f}.
10094@end deftypevr
10095
10096@deftypevr {@code{cups-configuration} parameter} string classification
10097Specifies the security classification of the server. Any valid banner
10098name can be used, including "classified", "confidential", "secret",
10099"topsecret", and "unclassified", or the banner can be omitted to disable
10100secure printing functions.
10101
10102Defaults to @samp{""}.
10103@end deftypevr
10104
10105@deftypevr {@code{cups-configuration} parameter} boolean classify-override?
10106Specifies whether users may override the classification (cover page) of
10107individual print jobs using the @code{job-sheets} option.
10108
10109Defaults to @samp{#f}.
10110@end deftypevr
10111
10112@deftypevr {@code{cups-configuration} parameter} default-auth-type default-auth-type
10113Specifies the default type of authentication to use.
10114
10115Defaults to @samp{Basic}.
10116@end deftypevr
10117
10118@deftypevr {@code{cups-configuration} parameter} default-encryption default-encryption
10119Specifies whether encryption will be used for authenticated requests.
10120
10121Defaults to @samp{Required}.
10122@end deftypevr
10123
10124@deftypevr {@code{cups-configuration} parameter} string default-language
10125Specifies the default language to use for text and web content.
10126
10127Defaults to @samp{"en"}.
10128@end deftypevr
10129
10130@deftypevr {@code{cups-configuration} parameter} string default-paper-size
10131Specifies the default paper size for new print queues. @samp{"Auto"}
10132uses a locale-specific default, while @samp{"None"} specifies there is
10133no default paper size. Specific size names are typically
10134@samp{"Letter"} or @samp{"A4"}.
10135
10136Defaults to @samp{"Auto"}.
10137@end deftypevr
10138
10139@deftypevr {@code{cups-configuration} parameter} string default-policy
10140Specifies the default access policy to use.
10141
10142Defaults to @samp{"default"}.
10143@end deftypevr
10144
10145@deftypevr {@code{cups-configuration} parameter} boolean default-shared?
10146Specifies whether local printers are shared by default.
10147
10148Defaults to @samp{#t}.
10149@end deftypevr
10150
10151@deftypevr {@code{cups-configuration} parameter} non-negative-integer dirty-clean-interval
10152Specifies the delay for updating of configuration and state files, in
10153seconds. A value of 0 causes the update to happen as soon as possible,
10154typically within a few milliseconds.
10155
10156Defaults to @samp{30}.
10157@end deftypevr
10158
10159@deftypevr {@code{cups-configuration} parameter} error-policy error-policy
10160Specifies what to do when an error occurs. Possible values are
10161@code{abort-job}, which will discard the failed print job;
10162@code{retry-job}, which will retry the job at a later time;
10163@code{retry-this-job}, which retries the failed job immediately; and
10164@code{stop-printer}, which stops the printer.
10165
10166Defaults to @samp{stop-printer}.
10167@end deftypevr
10168
10169@deftypevr {@code{cups-configuration} parameter} non-negative-integer filter-limit
10170Specifies the maximum cost of filters that are run concurrently, which
10171can be used to minimize disk, memory, and CPU resource problems. A
10172limit of 0 disables filter limiting. An average print to a
10173non-PostScript printer needs a filter limit of about 200. A PostScript
10174printer needs about half that (100). Setting the limit below these
10175thresholds will effectively limit the scheduler to printing a single job
10176at any time.
10177
10178Defaults to @samp{0}.
10179@end deftypevr
10180
10181@deftypevr {@code{cups-configuration} parameter} non-negative-integer filter-nice
10182Specifies the scheduling priority of filters that are run to print a
10183job. The nice value ranges from 0, the highest priority, to 19, the
10184lowest priority.
10185
10186Defaults to @samp{0}.
10187@end deftypevr
10188
10189@deftypevr {@code{cups-configuration} parameter} host-name-lookups host-name-lookups
10190Specifies whether to do reverse lookups on connecting clients. The
10191@code{double} setting causes @code{cupsd} to verify that the hostname
10192resolved from the address matches one of the addresses returned for that
10193hostname. Double lookups also prevent clients with unregistered
10194addresses from connecting to your server. Only set this option to
10195@code{#t} or @code{double} if absolutely required.
10196
10197Defaults to @samp{#f}.
10198@end deftypevr
10199
10200@deftypevr {@code{cups-configuration} parameter} non-negative-integer job-kill-delay
10201Specifies the number of seconds to wait before killing the filters and
10202backend associated with a canceled or held job.
10203
10204Defaults to @samp{30}.
10205@end deftypevr
10206
10207@deftypevr {@code{cups-configuration} parameter} non-negative-integer job-retry-interval
10208Specifies the interval between retries of jobs in seconds. This is
10209typically used for fax queues but can also be used with normal print
10210queues whose error policy is @code{retry-job} or
10211@code{retry-current-job}.
10212
10213Defaults to @samp{30}.
10214@end deftypevr
10215
10216@deftypevr {@code{cups-configuration} parameter} non-negative-integer job-retry-limit
10217Specifies the number of retries that are done for jobs. This is
10218typically used for fax queues but can also be used with normal print
10219queues whose error policy is @code{retry-job} or
10220@code{retry-current-job}.
10221
10222Defaults to @samp{5}.
10223@end deftypevr
10224
10225@deftypevr {@code{cups-configuration} parameter} boolean keep-alive?
10226Specifies whether to support HTTP keep-alive connections.
10227
10228Defaults to @samp{#t}.
10229@end deftypevr
10230
10231@deftypevr {@code{cups-configuration} parameter} non-negative-integer keep-alive-timeout
10232Specifies how long an idle client connection remains open, in seconds.
10233
10234Defaults to @samp{30}.
10235@end deftypevr
10236
10237@deftypevr {@code{cups-configuration} parameter} non-negative-integer limit-request-body
10238Specifies the maximum size of print files, IPP requests, and HTML form
10239data. A limit of 0 disables the limit check.
10240
10241Defaults to @samp{0}.
10242@end deftypevr
10243
10244@deftypevr {@code{cups-configuration} parameter} multiline-string-list listen
10245Listens on the specified interfaces for connections. Valid values are
10246of the form @var{address}:@var{port}, where @var{address} is either an
10247IPv6 address enclosed in brackets, an IPv4 address, or @code{*} to
10248indicate all addresses. Values can also be file names of local UNIX
10249domain sockets. The Listen directive is similar to the Port directive
10250but allows you to restrict access to specific interfaces or networks.
10251@end deftypevr
10252
10253@deftypevr {@code{cups-configuration} parameter} non-negative-integer listen-back-log
10254Specifies the number of pending connections that will be allowed. This
10255normally only affects very busy servers that have reached the MaxClients
10256limit, but can also be triggered by large numbers of simultaneous
10257connections. When the limit is reached, the operating system will
10258refuse additional connections until the scheduler can accept the pending
10259ones.
10260
10261Defaults to @samp{128}.
10262@end deftypevr
10263
10264@deftypevr {@code{cups-configuration} parameter} location-access-control-list location-access-controls
10265Specifies a set of additional access controls.
10266
10267Available @code{location-access-controls} fields are:
10268
10269@deftypevr {@code{location-access-controls} parameter} file-name path
10270Specifies the URI path to which the access control applies.
10271@end deftypevr
10272
10273@deftypevr {@code{location-access-controls} parameter} access-control-list access-controls
10274Access controls for all access to this path, in the same format as the
10275@code{access-controls} of @code{operation-access-control}.
10276
10277Defaults to @samp{()}.
10278@end deftypevr
10279
10280@deftypevr {@code{location-access-controls} parameter} method-access-control-list method-access-controls
10281Access controls for method-specific access to this path.
10282
10283Defaults to @samp{()}.
10284
10285Available @code{method-access-controls} fields are:
10286
10287@deftypevr {@code{method-access-controls} parameter} boolean reverse?
10288If @code{#t}, apply access controls to all methods except the listed
10289methods. Otherwise apply to only the listed methods.
10290
10291Defaults to @samp{#f}.
10292@end deftypevr
10293
10294@deftypevr {@code{method-access-controls} parameter} method-list methods
10295Methods to which this access control applies.
10296
10297Defaults to @samp{()}.
10298@end deftypevr
10299
10300@deftypevr {@code{method-access-controls} parameter} access-control-list access-controls
10301Access control directives, as a list of strings. Each string should be
10302one directive, such as "Order allow,deny".
10303
10304Defaults to @samp{()}.
10305@end deftypevr
10306@end deftypevr
10307@end deftypevr
10308
10309@deftypevr {@code{cups-configuration} parameter} non-negative-integer log-debug-history
10310Specifies the number of debugging messages that are retained for logging
10311if an error occurs in a print job. Debug messages are logged regardless
10312of the LogLevel setting.
10313
10314Defaults to @samp{100}.
10315@end deftypevr
10316
10317@deftypevr {@code{cups-configuration} parameter} log-level log-level
10318Specifies the level of logging for the ErrorLog file. The value
10319@code{none} stops all logging while @code{debug2} logs everything.
10320
10321Defaults to @samp{info}.
10322@end deftypevr
10323
10324@deftypevr {@code{cups-configuration} parameter} log-time-format log-time-format
10325Specifies the format of the date and time in the log files. The value
10326@code{standard} logs whole seconds while @code{usecs} logs microseconds.
10327
10328Defaults to @samp{standard}.
10329@end deftypevr
10330
10331@deftypevr {@code{cups-configuration} parameter} non-negative-integer max-clients
10332Specifies the maximum number of simultaneous clients that are allowed by
10333the scheduler.
10334
10335Defaults to @samp{100}.
10336@end deftypevr
10337
10338@deftypevr {@code{cups-configuration} parameter} non-negative-integer max-clients-per-host
10339Specifies the maximum number of simultaneous clients that are allowed
10340from a single address.
10341
10342Defaults to @samp{100}.
10343@end deftypevr
10344
10345@deftypevr {@code{cups-configuration} parameter} non-negative-integer max-copies
10346Specifies the maximum number of copies that a user can print of each
10347job.
10348
10349Defaults to @samp{9999}.
10350@end deftypevr
10351
10352@deftypevr {@code{cups-configuration} parameter} non-negative-integer max-hold-time
10353Specifies the maximum time a job may remain in the @code{indefinite}
10354hold state before it is canceled. A value of 0 disables cancellation of
10355held jobs.
10356
10357Defaults to @samp{0}.
10358@end deftypevr
10359
10360@deftypevr {@code{cups-configuration} parameter} non-negative-integer max-jobs
10361Specifies the maximum number of simultaneous jobs that are allowed. Set
10362to 0 to allow an unlimited number of jobs.
10363
10364Defaults to @samp{500}.
10365@end deftypevr
10366
10367@deftypevr {@code{cups-configuration} parameter} non-negative-integer max-jobs-per-printer
10368Specifies the maximum number of simultaneous jobs that are allowed per
10369printer. A value of 0 allows up to MaxJobs jobs per printer.
10370
10371Defaults to @samp{0}.
10372@end deftypevr
10373
10374@deftypevr {@code{cups-configuration} parameter} non-negative-integer max-jobs-per-user
10375Specifies the maximum number of simultaneous jobs that are allowed per
10376user. A value of 0 allows up to MaxJobs jobs per user.
10377
10378Defaults to @samp{0}.
10379@end deftypevr
10380
10381@deftypevr {@code{cups-configuration} parameter} non-negative-integer max-job-time
10382Specifies the maximum time a job may take to print before it is
10383canceled, in seconds. Set to 0 to disable cancellation of "stuck" jobs.
10384
10385Defaults to @samp{10800}.
10386@end deftypevr
10387
10388@deftypevr {@code{cups-configuration} parameter} non-negative-integer max-log-size
10389Specifies the maximum size of the log files before they are rotated, in
10390bytes. The value 0 disables log rotation.
10391
10392Defaults to @samp{1048576}.
10393@end deftypevr
10394
10395@deftypevr {@code{cups-configuration} parameter} non-negative-integer multiple-operation-timeout
10396Specifies the maximum amount of time to allow between files in a
10397multiple file print job, in seconds.
10398
10399Defaults to @samp{300}.
10400@end deftypevr
10401
10402@deftypevr {@code{cups-configuration} parameter} string page-log-format
10403Specifies the format of PageLog lines. Sequences beginning with percent
10404(@samp{%}) characters are replaced with the corresponding information,
10405while all other characters are copied literally. The following percent
10406sequences are recognized:
10407
10408@table @samp
10409@item %%
10410insert a single percent character
10411
10412@item %@{name@}
10413insert the value of the specified IPP attribute
10414
10415@item %C
10416insert the number of copies for the current page
10417
10418@item %P
10419insert the current page number
10420
10421@item %T
10422insert the current date and time in common log format
10423
10424@item %j
10425insert the job ID
10426
10427@item %p
10428insert the printer name
10429
10430@item %u
10431insert the username
10432@end table
10433
10434A value of the empty string disables page logging. The string @code{%p
10435%u %j %T %P %C %@{job-billing@} %@{job-originating-host-name@}
10436%@{job-name@} %@{media@} %@{sides@}} creates a page log with the
10437standard items.
10438
10439Defaults to @samp{""}.
10440@end deftypevr
10441
10442@deftypevr {@code{cups-configuration} parameter} environment-variables environment-variables
10443Passes the specified environment variable(s) to child processes; a list
10444of strings.
10445
10446Defaults to @samp{()}.
10447@end deftypevr
10448
10449@deftypevr {@code{cups-configuration} parameter} policy-configuration-list policies
10450Specifies named access control policies.
10451
10452Available @code{policy-configuration} fields are:
10453
10454@deftypevr {@code{policy-configuration} parameter} string name
10455Name of the policy.
10456@end deftypevr
10457
10458@deftypevr {@code{policy-configuration} parameter} string job-private-access
10459Specifies an access list for a job's private values. @code{@@ACL} maps
10460to the printer's requesting-user-name-allowed or
10461requesting-user-name-denied values. @code{@@OWNER} maps to the job's
10462owner. @code{@@SYSTEM} maps to the groups listed for the
10463@code{system-group} field of the @code{files-config} configuration,
10464which is reified into the @code{cups-files.conf(5)} file. Other
10465possible elements of the access list include specific user names, and
10466@code{@@@var{group}} to indicate members of a specific group. The
10467access list may also be simply @code{all} or @code{default}.
10468
10469Defaults to @samp{"@@OWNER @@SYSTEM"}.
10470@end deftypevr
10471
10472@deftypevr {@code{policy-configuration} parameter} string job-private-values
10473Specifies the list of job values to make private, or @code{all},
10474@code{default}, or @code{none}.
10475
10476Defaults to @samp{"job-name job-originating-host-name
10477job-originating-user-name phone"}.
10478@end deftypevr
10479
10480@deftypevr {@code{policy-configuration} parameter} string subscription-private-access
10481Specifies an access list for a subscription's private values.
10482@code{@@ACL} maps to the printer's requesting-user-name-allowed or
10483requesting-user-name-denied values. @code{@@OWNER} maps to the job's
10484owner. @code{@@SYSTEM} maps to the groups listed for the
10485@code{system-group} field of the @code{files-config} configuration,
10486which is reified into the @code{cups-files.conf(5)} file. Other
10487possible elements of the access list include specific user names, and
10488@code{@@@var{group}} to indicate members of a specific group. The
10489access list may also be simply @code{all} or @code{default}.
10490
10491Defaults to @samp{"@@OWNER @@SYSTEM"}.
10492@end deftypevr
10493
10494@deftypevr {@code{policy-configuration} parameter} string subscription-private-values
10495Specifies the list of job values to make private, or @code{all},
10496@code{default}, or @code{none}.
10497
10498Defaults to @samp{"notify-events notify-pull-method notify-recipient-uri
10499notify-subscriber-user-name notify-user-data"}.
10500@end deftypevr
10501
10502@deftypevr {@code{policy-configuration} parameter} operation-access-control-list access-controls
10503Access control by IPP operation.
10504
10505Defaults to @samp{()}.
10506@end deftypevr
10507@end deftypevr
10508
10509@deftypevr {@code{cups-configuration} parameter} boolean-or-non-negative-integer preserve-job-files
10510Specifies whether job files (documents) are preserved after a job is
10511printed. If a numeric value is specified, job files are preserved for
10512the indicated number of seconds after printing. Otherwise a boolean
10513value applies indefinitely.
10514
10515Defaults to @samp{86400}.
10516@end deftypevr
10517
10518@deftypevr {@code{cups-configuration} parameter} boolean-or-non-negative-integer preserve-job-history
10519Specifies whether the job history is preserved after a job is printed.
10520If a numeric value is specified, the job history is preserved for the
10521indicated number of seconds after printing. If @code{#t}, the job
10522history is preserved until the MaxJobs limit is reached.
10523
10524Defaults to @samp{#t}.
10525@end deftypevr
10526
10527@deftypevr {@code{cups-configuration} parameter} non-negative-integer reload-timeout
10528Specifies the amount of time to wait for job completion before
10529restarting the scheduler.
10530
10531Defaults to @samp{30}.
10532@end deftypevr
10533
10534@deftypevr {@code{cups-configuration} parameter} string rip-cache
10535Specifies the maximum amount of memory to use when converting documents
10536into bitmaps for a printer.
10537
10538Defaults to @samp{"128m"}.
10539@end deftypevr
10540
10541@deftypevr {@code{cups-configuration} parameter} string server-admin
10542Specifies the email address of the server administrator.
10543
10544Defaults to @samp{"root@@localhost.localdomain"}.
10545@end deftypevr
10546
10547@deftypevr {@code{cups-configuration} parameter} host-name-list-or-* server-alias
10548The ServerAlias directive is used for HTTP Host header validation when
10549clients connect to the scheduler from external interfaces. Using the
10550special name @code{*} can expose your system to known browser-based DNS
10551rebinding attacks, even when accessing sites through a firewall. If the
10552auto-discovery of alternate names does not work, we recommend listing
10553each alternate name with a ServerAlias directive instead of using
10554@code{*}.
10555
10556Defaults to @samp{*}.
10557@end deftypevr
10558
10559@deftypevr {@code{cups-configuration} parameter} string server-name
10560Specifies the fully-qualified host name of the server.
10561
10562Defaults to @samp{"localhost"}.
10563@end deftypevr
10564
10565@deftypevr {@code{cups-configuration} parameter} server-tokens server-tokens
10566Specifies what information is included in the Server header of HTTP
10567responses. @code{None} disables the Server header. @code{ProductOnly}
10568reports @code{CUPS}. @code{Major} reports @code{CUPS 2}. @code{Minor}
10569reports @code{CUPS 2.0}. @code{Minimal} reports @code{CUPS 2.0.0}.
10570@code{OS} reports @code{CUPS 2.0.0 (@var{uname})} where @var{uname} is
10571the output of the @code{uname} command. @code{Full} reports @code{CUPS
105722.0.0 (@var{uname}) IPP/2.0}.
10573
10574Defaults to @samp{Minimal}.
10575@end deftypevr
10576
10577@deftypevr {@code{cups-configuration} parameter} string set-env
10578Set the specified environment variable to be passed to child processes.
10579
10580Defaults to @samp{"variable value"}.
10581@end deftypevr
10582
10583@deftypevr {@code{cups-configuration} parameter} multiline-string-list ssl-listen
10584Listens on the specified interfaces for encrypted connections. Valid
10585values are of the form @var{address}:@var{port}, where @var{address} is
10586either an IPv6 address enclosed in brackets, an IPv4 address, or
10587@code{*} to indicate all addresses.
10588
10589Defaults to @samp{()}.
10590@end deftypevr
10591
10592@deftypevr {@code{cups-configuration} parameter} ssl-options ssl-options
10593Sets encryption options. By default, CUPS only supports encryption
10594using TLS v1.0 or higher using known secure cipher suites. The
10595@code{AllowRC4} option enables the 128-bit RC4 cipher suites, which are
10596required for some older clients that do not implement newer ones. The
10597@code{AllowSSL3} option enables SSL v3.0, which is required for some
10598older clients that do not support TLS v1.0.
10599
10600Defaults to @samp{()}.
10601@end deftypevr
10602
10603@deftypevr {@code{cups-configuration} parameter} boolean strict-conformance?
10604Specifies whether the scheduler requires clients to strictly adhere to
10605the IPP specifications.
10606
10607Defaults to @samp{#f}.
10608@end deftypevr
10609
10610@deftypevr {@code{cups-configuration} parameter} non-negative-integer timeout
10611Specifies the HTTP request timeout, in seconds.
10612
10613Defaults to @samp{300}.
10614
10615@end deftypevr
10616
10617@deftypevr {@code{cups-configuration} parameter} boolean web-interface?
10618Specifies whether the web interface is enabled.
10619
10620Defaults to @samp{#f}.
10621@end deftypevr
10622
10623At this point you're probably thinking ``oh dear, Guix manual, I like
10624you but you can stop already with the configuration options''. Indeed.
10625However, one more point: it could be that you have an existing
10626@code{cupsd.conf} that you want to use. In that case, you can pass an
10627@code{opaque-cups-configuration} as the configuration of a
10628@code{cups-service-type}.
10629
10630Available @code{opaque-cups-configuration} fields are:
10631
10632@deftypevr {@code{opaque-cups-configuration} parameter} package cups
10633The CUPS package.
10634@end deftypevr
10635
10636@deftypevr {@code{opaque-cups-configuration} parameter} string cupsd.conf
10637The contents of the @code{cupsd.conf}, as a string.
10638@end deftypevr
10639
10640@deftypevr {@code{opaque-cups-configuration} parameter} string cups-files.conf
10641The contents of the @code{cups-files.conf} file, as a string.
10642@end deftypevr
10643
10644For example, if your @code{cupsd.conf} and @code{cups-files.conf} are in
10645strings of the same name, you could instantiate a CUPS service like
10646this:
10647
10648@example
10649(service cups-service-type
10650 (opaque-cups-configuration
10651 (cupsd.conf cupsd.conf)
10652 (cups-files.conf cups-files.conf)))
10653@end example
10654
10655
fe1a39d3
LC
10656@node Desktop Services
10657@subsubsection Desktop Services
aa4ed923 10658
fe1a39d3
LC
10659The @code{(gnu services desktop)} module provides services that are
10660usually useful in the context of a ``desktop'' setup---that is, on a
10661machine running a graphical display server, possibly with graphical user
7a2413e4
AW
10662interfaces, etc. It also defines services that provide specific desktop
10663environments like GNOME and XFCE.
aa4ed923 10664
4467be21
LC
10665To simplify things, the module defines a variable containing the set of
10666services that users typically expect on a machine with a graphical
10667environment and networking:
10668
10669@defvr {Scheme Variable} %desktop-services
10670This is a list of services that builds upon @var{%base-services} and
1068f26b 10671adds or adjusts services for a typical ``desktop'' setup.
4467be21
LC
10672
10673In particular, it adds a graphical login manager (@pxref{X Window,
6726282b
LC
10674@code{slim-service}}), screen lockers,
10675a network management tool (@pxref{Networking
4467be21 10676Services, @code{wicd-service}}), energy and color management services,
4650a77e 10677the @code{elogind} login and seat manager, the Polkit privilege service,
cee32ee4
AW
10678the GeoClue location service, an NTP client (@pxref{Networking
10679Services}), the Avahi daemon, and has the name service switch service
10680configured to be able to use @code{nss-mdns} (@pxref{Name Service
10681Switch, mDNS}).
4467be21
LC
10682@end defvr
10683
10684The @var{%desktop-services} variable can be used as the @code{services}
10685field of an @code{operating-system} declaration (@pxref{operating-system
10686Reference, @code{services}}).
10687
7a2413e4
AW
10688Additionally, the @code{gnome-desktop-service} and
10689@code{xfce-desktop-service} procedures can add GNOME and/or XFCE to a
10690system. To ``add GNOME'' means that system-level services like the
10691backlight adjustment helpers and the power management utilities are
10692added to the system, extending @code{polkit} and @code{dbus}
10693appropriately, allowing GNOME to operate with elevated privileges on a
10694limited number of special-purpose system interfaces. Additionally,
10695adding a service made by @code{gnome-desktop-service} adds the GNOME
10696metapackage to the system profile. Likewise, adding the XFCE service
10697not only adds the @code{xfce} metapackage to the system profile, but it
10698also gives the Thunar file manager the ability to open a ``root-mode''
10699file management window, if the user authenticates using the
10700administrator's password via the standard polkit graphical interface.
10701
10702@deffn {Scheme Procedure} gnome-desktop-service
10703Return a service that adds the @code{gnome} package to the system
10704profile, and extends polkit with the actions from
10705@code{gnome-settings-daemon}.
10706@end deffn
10707
10708@deffn {Scheme Procedure} xfce-desktop-service
10709Return a service that adds the @code{xfce} package to the system profile,
5741e3e5 10710and extends polkit with the ability for @code{thunar} to manipulate the
7a2413e4
AW
10711file system as root from within a user session, after the user has
10712authenticated with the administrator's password.
10713@end deffn
10714
10715Because the GNOME and XFCE desktop services pull in so many packages,
10716the default @code{%desktop-services} variable doesn't include either of
10717them by default. To add GNOME or XFCE, just @code{cons} them onto
10718@code{%desktop-services} in the @code{services} field of your
10719@code{operating-system}:
10720
10721@example
10722(use-modules (gnu))
10723(use-service-modules desktop)
10724(operating-system
10725 ...
10726 ;; cons* adds items to the list given as its last argument.
10727 (services (cons* (gnome-desktop-service)
10728 (xfce-desktop-service)
10729 %desktop-services))
10730 ...)
10731@end example
10732
10733These desktop environments will then be available as options in the
10734graphical login window.
10735
10736The actual service definitions included in @code{%desktop-services} and
10737provided by @code{(gnu services dbus)} and @code{(gnu services desktop)}
10738are described below.
4467be21 10739
0adfe95a 10740@deffn {Scheme Procedure} dbus-service [#:dbus @var{dbus}] [#:services '()]
fe1a39d3
LC
10741Return a service that runs the ``system bus'', using @var{dbus}, with
10742support for @var{services}.
aa4ed923 10743
fe1a39d3
LC
10744@uref{http://dbus.freedesktop.org/, D-Bus} is an inter-process communication
10745facility. Its system bus is used to allow system services to communicate
1068f26b 10746and to be notified of system-wide events.
aa4ed923 10747
fe1a39d3
LC
10748@var{services} must be a list of packages that provide an
10749@file{etc/dbus-1/system.d} directory containing additional D-Bus configuration
10750and policy files. For example, to allow avahi-daemon to use the system bus,
10751@var{services} must be equal to @code{(list avahi)}.
aa4ed923
AK
10752@end deffn
10753
0adfe95a 10754@deffn {Scheme Procedure} elogind-service [#:config @var{config}]
4650a77e
AW
10755Return a service that runs the @code{elogind} login and
10756seat management daemon. @uref{https://github.com/andywingo/elogind,
10757Elogind} exposes a D-Bus interface that can be used to know which users
10758are logged in, know what kind of sessions they have open, suspend the
10759system, inhibit system suspend, reboot the system, and other tasks.
10760
10761Elogind handles most system-level power events for a computer, for
10762example suspending the system when a lid is closed, or shutting it down
10763when the power button is pressed.
10764
10765The @var{config} keyword argument specifies the configuration for
1068f26b 10766elogind, and should be the result of an @code{(elogind-configuration
4650a77e
AW
10767(@var{parameter} @var{value})...)} invocation. Available parameters and
10768their default values are:
10769
10770@table @code
10771@item kill-user-processes?
10772@code{#f}
10773@item kill-only-users
10774@code{()}
10775@item kill-exclude-users
10776@code{("root")}
10777@item inhibit-delay-max-seconds
10778@code{5}
10779@item handle-power-key
10780@code{poweroff}
10781@item handle-suspend-key
10782@code{suspend}
10783@item handle-hibernate-key
10784@code{hibernate}
10785@item handle-lid-switch
10786@code{suspend}
10787@item handle-lid-switch-docked
10788@code{ignore}
10789@item power-key-ignore-inhibited?
10790@code{#f}
10791@item suspend-key-ignore-inhibited?
10792@code{#f}
10793@item hibernate-key-ignore-inhibited?
10794@code{#f}
10795@item lid-switch-ignore-inhibited?
10796@code{#t}
10797@item holdoff-timeout-seconds
10798@code{30}
10799@item idle-action
10800@code{ignore}
10801@item idle-action-seconds
10802@code{(* 30 60)}
10803@item runtime-directory-size-percent
10804@code{10}
10805@item runtime-directory-size
10806@code{#f}
10807@item remove-ipc?
10808@code{#t}
10809@item suspend-state
10810@code{("mem" "standby" "freeze")}
10811@item suspend-mode
10812@code{()}
10813@item hibernate-state
10814@code{("disk")}
10815@item hibernate-mode
10816@code{("platform" "shutdown")}
10817@item hybrid-sleep-state
10818@code{("disk")}
10819@item hybrid-sleep-mode
10820@code{("suspend" "platform" "shutdown")}
10821@end table
10822@end deffn
10823
be1c2c54 10824@deffn {Scheme Procedure} polkit-service @
4650a77e 10825 [#:polkit @var{polkit}]
222e3319
LC
10826Return a service that runs the
10827@uref{http://www.freedesktop.org/wiki/Software/polkit/, Polkit privilege
10828management service}, which allows system administrators to grant access to
10829privileged operations in a structured way. By querying the Polkit service, a
10830privileged system component can know when it should grant additional
10831capabilities to ordinary users. For example, an ordinary user can be granted
10832the capability to suspend the system if the user is logged in locally.
4650a77e
AW
10833@end deffn
10834
be1c2c54 10835@deffn {Scheme Procedure} upower-service [#:upower @var{upower}] @
be234128
AW
10836 [#:watts-up-pro? #f] @
10837 [#:poll-batteries? #t] @
10838 [#:ignore-lid? #f] @
10839 [#:use-percentage-for-policy? #f] @
10840 [#:percentage-low 10] @
10841 [#:percentage-critical 3] @
10842 [#:percentage-action 2] @
10843 [#:time-low 1200] @
10844 [#:time-critical 300] @
10845 [#:time-action 120] @
10846 [#:critical-power-action 'hybrid-sleep]
10847Return a service that runs @uref{http://upower.freedesktop.org/,
10848@command{upowerd}}, a system-wide monitor for power consumption and battery
10849levels, with the given configuration settings. It implements the
10850@code{org.freedesktop.UPower} D-Bus interface, and is notably used by
10851GNOME.
10852@end deffn
10853
2b9e0a94
LC
10854@deffn {Scheme Procedure} udisks-service [#:udisks @var{udisks}]
10855Return a service for @uref{http://udisks.freedesktop.org/docs/latest/,
10856UDisks}, a @dfn{disk management} daemon that provides user interfaces with
10857notifications and ways to mount/unmount disks. Programs that talk to UDisks
10858include the @command{udisksctl} command, part of UDisks, and GNOME Disks.
10859@end deffn
10860
be1c2c54 10861@deffn {Scheme Procedure} colord-service [#:colord @var{colord}]
7ce597ff
AW
10862Return a service that runs @command{colord}, a system service with a D-Bus
10863interface to manage the color profiles of input and output devices such as
10864screens and scanners. It is notably used by the GNOME Color Manager graphical
10865tool. See @uref{http://www.freedesktop.org/software/colord/, the colord web
10866site} for more information.
10867@end deffn
10868
cee32ee4 10869@deffn {Scheme Procedure} geoclue-application name [#:allowed? #t] [#:system? #f] [#:users '()]
1068f26b 10870Return a configuration allowing an application to access GeoClue
cee32ee4
AW
10871location data. @var{name} is the Desktop ID of the application, without
10872the @code{.desktop} part. If @var{allowed?} is true, the application
10873will have access to location information by default. The boolean
1068f26b 10874@var{system?} value indicates whether an application is a system component
cee32ee4
AW
10875or not. Finally @var{users} is a list of UIDs of all users for which
10876this application is allowed location info access. An empty users list
10877means that all users are allowed.
10878@end deffn
10879
10880@defvr {Scheme Variable} %standard-geoclue-applications
10881The standard list of well-known GeoClue application configurations,
1068f26b
AE
10882granting authority to the GNOME date-and-time utility to ask for the
10883current location in order to set the time zone, and allowing the
10884IceCat and Epiphany web browsers to request location information.
10885IceCat and Epiphany both query the user before allowing a web page to
cee32ee4
AW
10886know the user's location.
10887@end defvr
10888
be1c2c54 10889@deffn {Scheme Procedure} geoclue-service [#:colord @var{colord}] @
cee32ee4
AW
10890 [#:whitelist '()] @
10891 [#:wifi-geolocation-url "https://location.services.mozilla.com/v1/geolocate?key=geoclue"] @
10892 [#:submit-data? #f]
10893 [#:wifi-submission-url "https://location.services.mozilla.com/v1/submit?key=geoclue"] @
10894 [#:submission-nick "geoclue"] @
10895 [#:applications %standard-geoclue-applications]
10896Return a service that runs the GeoClue location service. This service
10897provides a D-Bus interface to allow applications to request access to a
10898user's physical location, and optionally to add information to online
10899location databases. See
10900@uref{https://wiki.freedesktop.org/www/Software/GeoClue/, the GeoClue
10901web site} for more information.
10902@end deffn
10903
922e21f4
SB
10904@deffn {Scheme Procedure} bluetooth-service [#:bluez @var{bluez}]
10905Return a service that runs the @command{bluetoothd} daemon, which manages
10906all the Bluetooth devices and provides a number of D-Bus interfaces.
10907
10908Users need to be in the @code{lp} group to access the D-Bus service.
10909@end deffn
10910
105369a4
DT
10911@node Database Services
10912@subsubsection Database Services
10913
e32171ee
JD
10914@cindex database
10915@cindex SQL
6575183b 10916The @code{(gnu services databases)} module provides the following services.
105369a4 10917
be1c2c54 10918@deffn {Scheme Procedure} postgresql-service [#:postgresql postgresql] @
2d3d5cc5 10919 [#:config-file] [#:data-directory ``/var/lib/postgresql/data''] @
e05b780a 10920 [#:port 5432] [#:locale ``en_US.utf8'']
105369a4
DT
10921Return a service that runs @var{postgresql}, the PostgreSQL database
10922server.
10923
e05b780a
CB
10924The PostgreSQL daemon loads its runtime configuration from @var{config-file},
10925creates a database cluster with @var{locale} as the default
10926locale, stored in @var{data-directory}. It then listens on @var{port}.
105369a4 10927@end deffn
fe1a39d3 10928
6575183b
SB
10929@deffn {Scheme Procedure} mysql-service [#:config (mysql-configuration)]
10930Return a service that runs @command{mysqld}, the MySQL or MariaDB
10931database server.
10932
10933The optional @var{config} argument specifies the configuration for
c940b8e6 10934@command{mysqld}, which should be a @code{<mysql-configuration>} object.
6575183b
SB
10935@end deffn
10936
10937@deftp {Data Type} mysql-configuration
10938Data type representing the configuration of @var{mysql-service}.
10939
10940@table @asis
10941@item @code{mysql} (default: @var{mariadb})
10942Package object of the MySQL database server, can be either @var{mariadb}
10943or @var{mysql}.
10944
7414de0a 10945For MySQL, a temporary root password will be displayed at activation time.
6575183b 10946For MariaDB, the root password is empty.
4b41febf
CB
10947
10948@item @code{port} (default: @code{3306})
10949TCP port on which the database server listens for incoming connections.
6575183b
SB
10950@end table
10951@end deftp
10952
67cadaca
CB
10953@defvr {Scheme Variable} redis-service-type
10954This is the service type for the @uref{https://redis.io/, Redis}
10955key/value store, whose value is a @code{redis-configuration} object.
10956@end defvr
10957
10958@deftp {Data Type} redis-configuration
10959Data type representing the configuration of redis.
10960
10961@table @asis
10962@item @code{redis} (default: @code{redis})
10963The Redis package to use.
10964
10965@item @code{bind} (default: @code{"127.0.0.1"})
10966Network interface on which to listen.
10967
10968@item @code{port} (default: @code{6379})
10969Port on which to accept connections on, a value of 0 will disable
10970listining on a TCP socket.
10971
10972@item @code{working-directory} (default: @code{"/var/lib/redis"})
10973Directory in which to store the database and related files.
10974@end table
10975@end deftp
10976
d8c18af8
AW
10977@node Mail Services
10978@subsubsection Mail Services
10979
e32171ee
JD
10980@cindex mail
10981@cindex email
d8c18af8 10982The @code{(gnu services mail)} module provides Guix service definitions
f88371e8
SB
10983for email services: IMAP, POP3, and LMTP servers, as well as mail
10984transport agents (MTAs). Lots of acronyms! These services are detailed
10985in the subsections below.
d8c18af8 10986
f88371e8 10987@subsubheading Dovecot Service
d8c18af8
AW
10988
10989@deffn {Scheme Procedure} dovecot-service [#:config (dovecot-configuration)]
10990Return a service that runs the Dovecot IMAP/POP3/LMTP mail server.
10991@end deffn
10992
1068f26b 10993By default, Dovecot does not need much configuration; the default
d8c18af8
AW
10994configuration object created by @code{(dovecot-configuration)} will
10995suffice if your mail is delivered to @code{~/Maildir}. A self-signed
10996certificate will be generated for TLS-protected connections, though
10997Dovecot will also listen on cleartext ports by default. There are a
1068f26b 10998number of options, though, which mail administrators might need to change,
d8c18af8
AW
10999and as is the case with other services, Guix allows the system
11000administrator to specify these parameters via a uniform Scheme interface.
11001
11002For example, to specify that mail is located at @code{maildir~/.mail},
11003one would instantiate the Dovecot service like this:
11004
11005@example
11006(dovecot-service #:config
11007 (dovecot-configuration
11008 (mail-location "maildir:~/.mail")))
11009@end example
11010
11011The available configuration parameters follow. Each parameter
11012definition is preceded by its type; for example, @samp{string-list foo}
11013indicates that the @code{foo} parameter should be specified as a list of
11014strings. There is also a way to specify the configuration as a string,
11015if you have an old @code{dovecot.conf} file that you want to port over
11016from some other system; see the end for more details.
11017
11018@c The following documentation was initially generated by
11019@c (generate-documentation) in (gnu services mail). Manually maintained
11020@c documentation is better, so we shouldn't hesitate to edit below as
11021@c needed. However if the change you want to make to this documentation
11022@c can be done in an automated way, it's probably easier to change
11023@c (generate-documentation) than to make it below and have to deal with
11024@c the churn as dovecot updates.
11025
11026Available @code{dovecot-configuration} fields are:
11027
11028@deftypevr {@code{dovecot-configuration} parameter} package dovecot
11029The dovecot package.
11030@end deftypevr
11031
11032@deftypevr {@code{dovecot-configuration} parameter} comma-separated-string-list listen
1068f26b
AE
11033A list of IPs or hosts where to listen for connections. @samp{*}
11034listens on all IPv4 interfaces, @samp{::} listens on all IPv6
d8c18af8
AW
11035interfaces. If you want to specify non-default ports or anything more
11036complex, customize the address and port fields of the
11037@samp{inet-listener} of the specific services you are interested in.
11038@end deftypevr
11039
11040@deftypevr {@code{dovecot-configuration} parameter} protocol-configuration-list protocols
11041List of protocols we want to serve. Available protocols include
11042@samp{imap}, @samp{pop3}, and @samp{lmtp}.
11043
11044Available @code{protocol-configuration} fields are:
11045
11046@deftypevr {@code{protocol-configuration} parameter} string name
11047The name of the protocol.
11048@end deftypevr
11049
11050@deftypevr {@code{protocol-configuration} parameter} string auth-socket-path
1068f26b 11051UNIX socket path to the master authentication server to find users.
d8c18af8 11052This is used by imap (for shared users) and lda.
1068f26b 11053It defaults to @samp{"/var/run/dovecot/auth-userdb"}.
d8c18af8
AW
11054@end deftypevr
11055
11056@deftypevr {@code{protocol-configuration} parameter} space-separated-string-list mail-plugins
11057Space separated list of plugins to load.
11058@end deftypevr
11059
11060@deftypevr {@code{protocol-configuration} parameter} non-negative-integer mail-max-userip-connections
11061Maximum number of IMAP connections allowed for a user from each IP
11062address. NOTE: The username is compared case-sensitively.
11063Defaults to @samp{10}.
11064@end deftypevr
11065
11066@end deftypevr
11067
11068@deftypevr {@code{dovecot-configuration} parameter} service-configuration-list services
11069List of services to enable. Available services include @samp{imap},
11070@samp{imap-login}, @samp{pop3}, @samp{pop3-login}, @samp{auth}, and
11071@samp{lmtp}.
11072
11073Available @code{service-configuration} fields are:
11074
11075@deftypevr {@code{service-configuration} parameter} string kind
11076The service kind. Valid values include @code{director},
11077@code{imap-login}, @code{pop3-login}, @code{lmtp}, @code{imap},
11078@code{pop3}, @code{auth}, @code{auth-worker}, @code{dict},
11079@code{tcpwrap}, @code{quota-warning}, or anything else.
11080@end deftypevr
11081
11082@deftypevr {@code{service-configuration} parameter} listener-configuration-list listeners
1068f26b 11083Listeners for the service. A listener is either a
d8c18af8
AW
11084@code{unix-listener-configuration}, a @code{fifo-listener-configuration}, or
11085an @code{inet-listener-configuration}.
11086Defaults to @samp{()}.
11087
11088Available @code{unix-listener-configuration} fields are:
11089
eba56076
CL
11090@deftypevr {@code{unix-listener-configuration} parameter} string path
11091Path to the file, relative to @code{base-dir} field. This is also used as
11092the section name.
d8c18af8
AW
11093@end deftypevr
11094
11095@deftypevr {@code{unix-listener-configuration} parameter} string mode
11096The access mode for the socket.
11097Defaults to @samp{"0600"}.
11098@end deftypevr
11099
11100@deftypevr {@code{unix-listener-configuration} parameter} string user
f9b9a033 11101The user to own the socket.
d8c18af8
AW
11102Defaults to @samp{""}.
11103@end deftypevr
11104
11105@deftypevr {@code{unix-listener-configuration} parameter} string group
11106The group to own the socket.
11107Defaults to @samp{""}.
11108@end deftypevr
11109
11110
11111Available @code{fifo-listener-configuration} fields are:
11112
eba56076
CL
11113@deftypevr {@code{fifo-listener-configuration} parameter} string path
11114Path to the file, relative to @code{base-dir} field. This is also used as
11115the section name.
d8c18af8
AW
11116@end deftypevr
11117
11118@deftypevr {@code{fifo-listener-configuration} parameter} string mode
11119The access mode for the socket.
11120Defaults to @samp{"0600"}.
11121@end deftypevr
11122
11123@deftypevr {@code{fifo-listener-configuration} parameter} string user
f9b9a033 11124The user to own the socket.
d8c18af8
AW
11125Defaults to @samp{""}.
11126@end deftypevr
11127
11128@deftypevr {@code{fifo-listener-configuration} parameter} string group
11129The group to own the socket.
11130Defaults to @samp{""}.
11131@end deftypevr
11132
11133
11134Available @code{inet-listener-configuration} fields are:
11135
11136@deftypevr {@code{inet-listener-configuration} parameter} string protocol
11137The protocol to listen for.
11138@end deftypevr
11139
11140@deftypevr {@code{inet-listener-configuration} parameter} string address
11141The address on which to listen, or empty for all addresses.
11142Defaults to @samp{""}.
11143@end deftypevr
11144
11145@deftypevr {@code{inet-listener-configuration} parameter} non-negative-integer port
11146The port on which to listen.
11147@end deftypevr
11148
11149@deftypevr {@code{inet-listener-configuration} parameter} boolean ssl?
11150Whether to use SSL for this service; @samp{yes}, @samp{no}, or
11151@samp{required}.
11152Defaults to @samp{#t}.
11153@end deftypevr
11154
11155@end deftypevr
11156
11157@deftypevr {@code{service-configuration} parameter} non-negative-integer service-count
11158Number of connections to handle before starting a new process.
11159Typically the only useful values are 0 (unlimited) or 1. 1 is more
11160secure, but 0 is faster. <doc/wiki/LoginProcess.txt>.
11161Defaults to @samp{1}.
11162@end deftypevr
11163
11164@deftypevr {@code{service-configuration} parameter} non-negative-integer process-min-avail
11165Number of processes to always keep waiting for more connections.
11166Defaults to @samp{0}.
11167@end deftypevr
11168
11169@deftypevr {@code{service-configuration} parameter} non-negative-integer vsz-limit
11170If you set @samp{service-count 0}, you probably need to grow
11171this.
11172Defaults to @samp{256000000}.
11173@end deftypevr
11174
11175@end deftypevr
11176
11177@deftypevr {@code{dovecot-configuration} parameter} dict-configuration dict
11178Dict configuration, as created by the @code{dict-configuration}
11179constructor.
11180
11181Available @code{dict-configuration} fields are:
11182
11183@deftypevr {@code{dict-configuration} parameter} free-form-fields entries
11184A list of key-value pairs that this dict should hold.
11185Defaults to @samp{()}.
11186@end deftypevr
11187
11188@end deftypevr
11189
11190@deftypevr {@code{dovecot-configuration} parameter} passdb-configuration-list passdbs
1068f26b 11191A list of passdb configurations, each one created by the
d8c18af8
AW
11192@code{passdb-configuration} constructor.
11193
11194Available @code{passdb-configuration} fields are:
11195
11196@deftypevr {@code{passdb-configuration} parameter} string driver
11197The driver that the passdb should use. Valid values include
11198@samp{pam}, @samp{passwd}, @samp{shadow}, @samp{bsdauth}, and
11199@samp{static}.
11200Defaults to @samp{"pam"}.
11201@end deftypevr
11202
11203@deftypevr {@code{passdb-configuration} parameter} free-form-args args
11204A list of key-value args to the passdb driver.
11205Defaults to @samp{()}.
11206@end deftypevr
11207
11208@end deftypevr
11209
11210@deftypevr {@code{dovecot-configuration} parameter} userdb-configuration-list userdbs
11211List of userdb configurations, each one created by the
11212@code{userdb-configuration} constructor.
11213
11214Available @code{userdb-configuration} fields are:
11215
11216@deftypevr {@code{userdb-configuration} parameter} string driver
11217The driver that the userdb should use. Valid values include
11218@samp{passwd} and @samp{static}.
11219Defaults to @samp{"passwd"}.
11220@end deftypevr
11221
11222@deftypevr {@code{userdb-configuration} parameter} free-form-args args
11223A list of key-value args to the userdb driver.
11224Defaults to @samp{()}.
11225@end deftypevr
11226
11227@deftypevr {@code{userdb-configuration} parameter} free-form-args override-fields
11228Override fields from passwd.
11229Defaults to @samp{()}.
11230@end deftypevr
11231
11232@end deftypevr
11233
11234@deftypevr {@code{dovecot-configuration} parameter} plugin-configuration plugin-configuration
11235Plug-in configuration, created by the @code{plugin-configuration}
11236constructor.
11237@end deftypevr
11238
11239@deftypevr {@code{dovecot-configuration} parameter} list-of-namespace-configuration namespaces
11240List of namespaces. Each item in the list is created by the
11241@code{namespace-configuration} constructor.
11242
11243Available @code{namespace-configuration} fields are:
11244
11245@deftypevr {@code{namespace-configuration} parameter} string name
11246Name for this namespace.
11247@end deftypevr
11248
11249@deftypevr {@code{namespace-configuration} parameter} string type
11250Namespace type: @samp{private}, @samp{shared} or @samp{public}.
11251Defaults to @samp{"private"}.
11252@end deftypevr
11253
11254@deftypevr {@code{namespace-configuration} parameter} string separator
11255Hierarchy separator to use. You should use the same separator for
11256all namespaces or some clients get confused. @samp{/} is usually a good
11257one. The default however depends on the underlying mail storage
11258format.
11259Defaults to @samp{""}.
11260@end deftypevr
11261
11262@deftypevr {@code{namespace-configuration} parameter} string prefix
11263Prefix required to access this namespace. This needs to be
11264different for all namespaces. For example @samp{Public/}.
11265Defaults to @samp{""}.
11266@end deftypevr
11267
11268@deftypevr {@code{namespace-configuration} parameter} string location
1068f26b 11269Physical location of the mailbox. This is in the same format as
d8c18af8
AW
11270mail_location, which is also the default for it.
11271Defaults to @samp{""}.
11272@end deftypevr
11273
11274@deftypevr {@code{namespace-configuration} parameter} boolean inbox?
11275There can be only one INBOX, and this setting defines which
11276namespace has it.
11277Defaults to @samp{#f}.
11278@end deftypevr
11279
11280@deftypevr {@code{namespace-configuration} parameter} boolean hidden?
11281If namespace is hidden, it's not advertised to clients via NAMESPACE
11282extension. You'll most likely also want to set @samp{list? #f}. This is mostly
11283useful when converting from another server with different namespaces
11284which you want to deprecate but still keep working. For example you can
11285create hidden namespaces with prefixes @samp{~/mail/}, @samp{~%u/mail/}
11286and @samp{mail/}.
11287Defaults to @samp{#f}.
11288@end deftypevr
11289
11290@deftypevr {@code{namespace-configuration} parameter} boolean list?
1068f26b
AE
11291Show the mailboxes under this namespace with the LIST command. This
11292makes the namespace visible for clients that do not support the NAMESPACE
d8c18af8
AW
11293extension. The special @code{children} value lists child mailboxes, but
11294hides the namespace prefix.
11295Defaults to @samp{#t}.
11296@end deftypevr
11297
11298@deftypevr {@code{namespace-configuration} parameter} boolean subscriptions?
11299Namespace handles its own subscriptions. If set to @code{#f}, the
11300parent namespace handles them. The empty prefix should always have this
1068f26b 11301as @code{#t}).
d8c18af8
AW
11302Defaults to @samp{#t}.
11303@end deftypevr
11304
11305@deftypevr {@code{namespace-configuration} parameter} mailbox-configuration-list mailboxes
11306List of predefined mailboxes in this namespace.
11307Defaults to @samp{()}.
11308
11309Available @code{mailbox-configuration} fields are:
11310
11311@deftypevr {@code{mailbox-configuration} parameter} string name
11312Name for this mailbox.
11313@end deftypevr
11314
11315@deftypevr {@code{mailbox-configuration} parameter} string auto
11316@samp{create} will automatically create this mailbox.
11317@samp{subscribe} will both create and subscribe to the mailbox.
11318Defaults to @samp{"no"}.
11319@end deftypevr
11320
11321@deftypevr {@code{mailbox-configuration} parameter} space-separated-string-list special-use
11322List of IMAP @code{SPECIAL-USE} attributes as specified by RFC 6154.
11323Valid values are @code{\All}, @code{\Archive}, @code{\Drafts},
11324@code{\Flagged}, @code{\Junk}, @code{\Sent}, and @code{\Trash}.
11325Defaults to @samp{()}.
11326@end deftypevr
11327
11328@end deftypevr
11329
11330@end deftypevr
11331
11332@deftypevr {@code{dovecot-configuration} parameter} file-name base-dir
11333Base directory where to store runtime data.
11334Defaults to @samp{"/var/run/dovecot/"}.
11335@end deftypevr
11336
11337@deftypevr {@code{dovecot-configuration} parameter} string login-greeting
11338Greeting message for clients.
11339Defaults to @samp{"Dovecot ready."}.
11340@end deftypevr
11341
11342@deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list login-trusted-networks
11343List of trusted network ranges. Connections from these IPs are
11344allowed to override their IP addresses and ports (for logging and for
11345authentication checks). @samp{disable-plaintext-auth} is also ignored
1068f26b 11346for these networks. Typically you would specify your IMAP proxy servers
d8c18af8
AW
11347here.
11348Defaults to @samp{()}.
11349@end deftypevr
11350
11351@deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list login-access-sockets
11352List of login access check sockets (e.g. tcpwrap).
11353Defaults to @samp{()}.
11354@end deftypevr
11355
11356@deftypevr {@code{dovecot-configuration} parameter} boolean verbose-proctitle?
11357Show more verbose process titles (in ps). Currently shows user name
1068f26b
AE
11358and IP address. Useful for seeing who is actually using the IMAP
11359processes (e.g. shared mailboxes or if the same uid is used for multiple
d8c18af8
AW
11360accounts).
11361Defaults to @samp{#f}.
11362@end deftypevr
11363
11364@deftypevr {@code{dovecot-configuration} parameter} boolean shutdown-clients?
11365Should all processes be killed when Dovecot master process shuts down.
11366Setting this to @code{#f} means that Dovecot can be upgraded without
11367forcing existing client connections to close (although that could also
1068f26b 11368be a problem if the upgrade is e.g. due to a security fix).
d8c18af8
AW
11369Defaults to @samp{#t}.
11370@end deftypevr
11371
11372@deftypevr {@code{dovecot-configuration} parameter} non-negative-integer doveadm-worker-count
11373If non-zero, run mail commands via this many connections to doveadm
11374server, instead of running them directly in the same process.
11375Defaults to @samp{0}.
11376@end deftypevr
11377
11378@deftypevr {@code{dovecot-configuration} parameter} string doveadm-socket-path
11379UNIX socket or host:port used for connecting to doveadm server.
11380Defaults to @samp{"doveadm-server"}.
11381@end deftypevr
11382
11383@deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list import-environment
11384List of environment variables that are preserved on Dovecot startup
11385and passed down to all of its child processes. You can also give
11386key=value pairs to always set specific settings.
11387@end deftypevr
11388
11389@deftypevr {@code{dovecot-configuration} parameter} boolean disable-plaintext-auth?
11390Disable LOGIN command and all other plaintext authentications unless
11391SSL/TLS is used (LOGINDISABLED capability). Note that if the remote IP
11392matches the local IP (i.e. you're connecting from the same computer),
11393the connection is considered secure and plaintext authentication is
11394allowed. See also ssl=required setting.
11395Defaults to @samp{#t}.
11396@end deftypevr
11397
11398@deftypevr {@code{dovecot-configuration} parameter} non-negative-integer auth-cache-size
11399Authentication cache size (e.g. @samp{#e10e6}). 0 means it's disabled.
11400Note that bsdauth, PAM and vpopmail require @samp{cache-key} to be set
11401for caching to be used.
11402Defaults to @samp{0}.
11403@end deftypevr
11404
11405@deftypevr {@code{dovecot-configuration} parameter} string auth-cache-ttl
11406Time to live for cached data. After TTL expires the cached record
11407is no longer used, *except* if the main database lookup returns internal
11408failure. We also try to handle password changes automatically: If
11409user's previous authentication was successful, but this one wasn't, the
11410cache isn't used. For now this works only with plaintext
11411authentication.
11412Defaults to @samp{"1 hour"}.
11413@end deftypevr
11414
11415@deftypevr {@code{dovecot-configuration} parameter} string auth-cache-negative-ttl
11416TTL for negative hits (user not found, password mismatch).
114170 disables caching them completely.
11418Defaults to @samp{"1 hour"}.
11419@end deftypevr
11420
11421@deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list auth-realms
11422List of realms for SASL authentication mechanisms that need them.
11423You can leave it empty if you don't want to support multiple realms.
11424Many clients simply use the first one listed here, so keep the default
11425realm first.
11426Defaults to @samp{()}.
11427@end deftypevr
11428
11429@deftypevr {@code{dovecot-configuration} parameter} string auth-default-realm
11430Default realm/domain to use if none was specified. This is used for
11431both SASL realms and appending @@domain to username in plaintext
11432logins.
11433Defaults to @samp{""}.
11434@end deftypevr
11435
11436@deftypevr {@code{dovecot-configuration} parameter} string auth-username-chars
11437List of allowed characters in username. If the user-given username
11438contains a character not listed in here, the login automatically fails.
11439This is just an extra check to make sure user can't exploit any
11440potential quote escaping vulnerabilities with SQL/LDAP databases. If
11441you want to allow all characters, set this value to empty.
11442Defaults to @samp{"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890.-_@@"}.
11443@end deftypevr
11444
11445@deftypevr {@code{dovecot-configuration} parameter} string auth-username-translation
11446Username character translations before it's looked up from
11447databases. The value contains series of from -> to characters. For
11448example @samp{#@@/@@} means that @samp{#} and @samp{/} characters are
11449translated to @samp{@@}.
11450Defaults to @samp{""}.
11451@end deftypevr
11452
11453@deftypevr {@code{dovecot-configuration} parameter} string auth-username-format
11454Username formatting before it's looked up from databases. You can
11455use the standard variables here, e.g. %Lu would lowercase the username,
11456%n would drop away the domain if it was given, or @samp{%n-AT-%d} would
11457change the @samp{@@} into @samp{-AT-}. This translation is done after
11458@samp{auth-username-translation} changes.
11459Defaults to @samp{"%Lu"}.
11460@end deftypevr
11461
11462@deftypevr {@code{dovecot-configuration} parameter} string auth-master-user-separator
11463If you want to allow master users to log in by specifying the master
11464username within the normal username string (i.e. not using SASL
11465mechanism's support for it), you can specify the separator character
11466here. The format is then <username><separator><master username>.
11467UW-IMAP uses @samp{*} as the separator, so that could be a good
11468choice.
11469Defaults to @samp{""}.
11470@end deftypevr
11471
11472@deftypevr {@code{dovecot-configuration} parameter} string auth-anonymous-username
11473Username to use for users logging in with ANONYMOUS SASL
11474mechanism.
11475Defaults to @samp{"anonymous"}.
11476@end deftypevr
11477
11478@deftypevr {@code{dovecot-configuration} parameter} non-negative-integer auth-worker-max-count
11479Maximum number of dovecot-auth worker processes. They're used to
11480execute blocking passdb and userdb queries (e.g. MySQL and PAM).
11481They're automatically created and destroyed as needed.
11482Defaults to @samp{30}.
11483@end deftypevr
11484
11485@deftypevr {@code{dovecot-configuration} parameter} string auth-gssapi-hostname
11486Host name to use in GSSAPI principal names. The default is to use
11487the name returned by gethostname(). Use @samp{$ALL} (with quotes) to
11488allow all keytab entries.
11489Defaults to @samp{""}.
11490@end deftypevr
11491
11492@deftypevr {@code{dovecot-configuration} parameter} string auth-krb5-keytab
11493Kerberos keytab to use for the GSSAPI mechanism. Will use the
8b499030 11494system default (usually @file{/etc/krb5.keytab}) if not specified. You may
d8c18af8
AW
11495need to change the auth service to run as root to be able to read this
11496file.
11497Defaults to @samp{""}.
11498@end deftypevr
11499
11500@deftypevr {@code{dovecot-configuration} parameter} boolean auth-use-winbind?
11501Do NTLM and GSS-SPNEGO authentication using Samba's winbind daemon
11502and @samp{ntlm-auth} helper.
11503<doc/wiki/Authentication/Mechanisms/Winbind.txt>.
11504Defaults to @samp{#f}.
11505@end deftypevr
11506
11507@deftypevr {@code{dovecot-configuration} parameter} file-name auth-winbind-helper-path
11508Path for Samba's @samp{ntlm-auth} helper binary.
11509Defaults to @samp{"/usr/bin/ntlm_auth"}.
11510@end deftypevr
11511
11512@deftypevr {@code{dovecot-configuration} parameter} string auth-failure-delay
11513Time to delay before replying to failed authentications.
11514Defaults to @samp{"2 secs"}.
11515@end deftypevr
11516
11517@deftypevr {@code{dovecot-configuration} parameter} boolean auth-ssl-require-client-cert?
11518Require a valid SSL client certificate or the authentication
11519fails.
11520Defaults to @samp{#f}.
11521@end deftypevr
11522
11523@deftypevr {@code{dovecot-configuration} parameter} boolean auth-ssl-username-from-cert?
11524Take the username from client's SSL certificate, using
11525@code{X509_NAME_get_text_by_NID()} which returns the subject's DN's
11526CommonName.
11527Defaults to @samp{#f}.
11528@end deftypevr
11529
11530@deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list auth-mechanisms
11531List of wanted authentication mechanisms. Supported mechanisms are:
11532@samp{plain}, @samp{login}, @samp{digest-md5}, @samp{cram-md5},
11533@samp{ntlm}, @samp{rpa}, @samp{apop}, @samp{anonymous}, @samp{gssapi},
11534@samp{otp}, @samp{skey}, and @samp{gss-spnego}. NOTE: See also
11535@samp{disable-plaintext-auth} setting.
11536@end deftypevr
11537
11538@deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list director-servers
11539List of IPs or hostnames to all director servers, including ourself.
11540Ports can be specified as ip:port. The default port is the same as what
11541director service's @samp{inet-listener} is using.
11542Defaults to @samp{()}.
11543@end deftypevr
11544
11545@deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list director-mail-servers
11546List of IPs or hostnames to all backend mail servers. Ranges are
11547allowed too, like 10.0.0.10-10.0.0.30.
11548Defaults to @samp{()}.
11549@end deftypevr
11550
11551@deftypevr {@code{dovecot-configuration} parameter} string director-user-expire
11552How long to redirect users to a specific server after it no longer
11553has any connections.
11554Defaults to @samp{"15 min"}.
11555@end deftypevr
11556
11557@deftypevr {@code{dovecot-configuration} parameter} non-negative-integer director-doveadm-port
11558TCP/IP port that accepts doveadm connections (instead of director
11559connections) If you enable this, you'll also need to add
11560@samp{inet-listener} for the port.
11561Defaults to @samp{0}.
11562@end deftypevr
11563
11564@deftypevr {@code{dovecot-configuration} parameter} string director-username-hash
11565How the username is translated before being hashed. Useful values
11566include %Ln if user can log in with or without @@domain, %Ld if mailboxes
11567are shared within domain.
11568Defaults to @samp{"%Lu"}.
11569@end deftypevr
11570
11571@deftypevr {@code{dovecot-configuration} parameter} string log-path
11572Log file to use for error messages. @samp{syslog} logs to syslog,
11573@samp{/dev/stderr} logs to stderr.
11574Defaults to @samp{"syslog"}.
11575@end deftypevr
11576
11577@deftypevr {@code{dovecot-configuration} parameter} string info-log-path
11578Log file to use for informational messages. Defaults to
11579@samp{log-path}.
11580Defaults to @samp{""}.
11581@end deftypevr
11582
11583@deftypevr {@code{dovecot-configuration} parameter} string debug-log-path
11584Log file to use for debug messages. Defaults to
11585@samp{info-log-path}.
11586Defaults to @samp{""}.
11587@end deftypevr
11588
11589@deftypevr {@code{dovecot-configuration} parameter} string syslog-facility
11590Syslog facility to use if you're logging to syslog. Usually if you
11591don't want to use @samp{mail}, you'll use local0..local7. Also other
11592standard facilities are supported.
11593Defaults to @samp{"mail"}.
11594@end deftypevr
11595
11596@deftypevr {@code{dovecot-configuration} parameter} boolean auth-verbose?
11597Log unsuccessful authentication attempts and the reasons why they
11598failed.
11599Defaults to @samp{#f}.
11600@end deftypevr
11601
11602@deftypevr {@code{dovecot-configuration} parameter} boolean auth-verbose-passwords?
11603In case of password mismatches, log the attempted password. Valid
11604values are no, plain and sha1. sha1 can be useful for detecting brute
11605force password attempts vs. user simply trying the same password over
11606and over again. You can also truncate the value to n chars by appending
11607":n" (e.g. sha1:6).
11608Defaults to @samp{#f}.
11609@end deftypevr
11610
11611@deftypevr {@code{dovecot-configuration} parameter} boolean auth-debug?
11612Even more verbose logging for debugging purposes. Shows for example
11613SQL queries.
11614Defaults to @samp{#f}.
11615@end deftypevr
11616
11617@deftypevr {@code{dovecot-configuration} parameter} boolean auth-debug-passwords?
11618In case of password mismatches, log the passwords and used scheme so
11619the problem can be debugged. Enabling this also enables
11620@samp{auth-debug}.
11621Defaults to @samp{#f}.
11622@end deftypevr
11623
11624@deftypevr {@code{dovecot-configuration} parameter} boolean mail-debug?
11625Enable mail process debugging. This can help you figure out why
11626Dovecot isn't finding your mails.
11627Defaults to @samp{#f}.
11628@end deftypevr
11629
11630@deftypevr {@code{dovecot-configuration} parameter} boolean verbose-ssl?
11631Show protocol level SSL errors.
11632Defaults to @samp{#f}.
11633@end deftypevr
11634
11635@deftypevr {@code{dovecot-configuration} parameter} string log-timestamp
11636Prefix for each line written to log file. % codes are in
11637strftime(3) format.
11638Defaults to @samp{"\"%b %d %H:%M:%S \""}.
11639@end deftypevr
11640
11641@deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list login-log-format-elements
11642List of elements we want to log. The elements which have a
11643non-empty variable value are joined together to form a comma-separated
11644string.
11645@end deftypevr
11646
11647@deftypevr {@code{dovecot-configuration} parameter} string login-log-format
11648Login log format. %s contains @samp{login-log-format-elements}
11649string, %$ contains the data we want to log.
11650Defaults to @samp{"%$: %s"}.
11651@end deftypevr
11652
11653@deftypevr {@code{dovecot-configuration} parameter} string mail-log-prefix
11654Log prefix for mail processes. See doc/wiki/Variables.txt for list
11655of possible variables you can use.
11656Defaults to @samp{"\"%s(%u): \""}.
11657@end deftypevr
11658
11659@deftypevr {@code{dovecot-configuration} parameter} string deliver-log-format
11660Format to use for logging mail deliveries. You can use variables:
11661@table @code
11662@item %$
11663Delivery status message (e.g. @samp{saved to INBOX})
11664@item %m
11665Message-ID
11666@item %s
11667Subject
11668@item %f
11669From address
11670@item %p
11671Physical size
11672@item %w
11673Virtual size.
11674@end table
11675Defaults to @samp{"msgid=%m: %$"}.
11676@end deftypevr
11677
11678@deftypevr {@code{dovecot-configuration} parameter} string mail-location
11679Location for users' mailboxes. The default is empty, which means
11680that Dovecot tries to find the mailboxes automatically. This won't work
11681if the user doesn't yet have any mail, so you should explicitly tell
11682Dovecot the full location.
11683
11684If you're using mbox, giving a path to the INBOX
11685file (e.g. /var/mail/%u) isn't enough. You'll also need to tell Dovecot
11686where the other mailboxes are kept. This is called the "root mail
11687directory", and it must be the first path given in the
11688@samp{mail-location} setting.
11689
11690There are a few special variables you can use, eg.:
11691
11692@table @samp
11693@item %u
11694username
11695@item %n
11696user part in user@@domain, same as %u if there's no domain
11697@item %d
11698domain part in user@@domain, empty if there's no domain
11699@item %h
11700home director
11701@end table
11702
11703See doc/wiki/Variables.txt for full list. Some examples:
11704@table @samp
11705@item maildir:~/Maildir
11706@item mbox:~/mail:INBOX=/var/mail/%u
11707@item mbox:/var/mail/%d/%1n/%n:INDEX=/var/indexes/%d/%1n/%
11708@end table
11709Defaults to @samp{""}.
11710@end deftypevr
11711
11712@deftypevr {@code{dovecot-configuration} parameter} string mail-uid
11713System user and group used to access mails. If you use multiple,
11714userdb can override these by returning uid or gid fields. You can use
11715either numbers or names. <doc/wiki/UserIds.txt>.
11716Defaults to @samp{""}.
11717@end deftypevr
11718
11719@deftypevr {@code{dovecot-configuration} parameter} string mail-gid
11720
11721Defaults to @samp{""}.
11722@end deftypevr
11723
11724@deftypevr {@code{dovecot-configuration} parameter} string mail-privileged-group
11725Group to enable temporarily for privileged operations. Currently
11726this is used only with INBOX when either its initial creation or
11727dotlocking fails. Typically this is set to "mail" to give access to
11728/var/mail.
11729Defaults to @samp{""}.
11730@end deftypevr
11731
11732@deftypevr {@code{dovecot-configuration} parameter} string mail-access-groups
11733Grant access to these supplementary groups for mail processes.
11734Typically these are used to set up access to shared mailboxes. Note
11735that it may be dangerous to set these if users can create
11736symlinks (e.g. if "mail" group is set here, ln -s /var/mail ~/mail/var
11737could allow a user to delete others' mailboxes, or ln -s
11738/secret/shared/box ~/mail/mybox would allow reading it).
11739Defaults to @samp{""}.
11740@end deftypevr
11741
11742@deftypevr {@code{dovecot-configuration} parameter} boolean mail-full-filesystem-access?
8f65585b 11743Allow full file system access to clients. There's no access checks
d8c18af8
AW
11744other than what the operating system does for the active UID/GID. It
11745works with both maildir and mboxes, allowing you to prefix mailboxes
11746names with e.g. /path/ or ~user/.
11747Defaults to @samp{#f}.
11748@end deftypevr
11749
11750@deftypevr {@code{dovecot-configuration} parameter} boolean mmap-disable?
11751Don't use mmap() at all. This is required if you store indexes to
8f65585b 11752shared file systems (NFS or clustered file system).
d8c18af8
AW
11753Defaults to @samp{#f}.
11754@end deftypevr
11755
11756@deftypevr {@code{dovecot-configuration} parameter} boolean dotlock-use-excl?
11757Rely on @samp{O_EXCL} to work when creating dotlock files. NFS
11758supports @samp{O_EXCL} since version 3, so this should be safe to use
11759nowadays by default.
11760Defaults to @samp{#t}.
11761@end deftypevr
11762
11763@deftypevr {@code{dovecot-configuration} parameter} string mail-fsync
11764When to use fsync() or fdatasync() calls:
11765@table @code
11766@item optimized
11767Whenever necessary to avoid losing important data
11768@item always
11769Useful with e.g. NFS when write()s are delayed
11770@item never
11771Never use it (best performance, but crashes can lose data).
11772@end table
11773Defaults to @samp{"optimized"}.
11774@end deftypevr
11775
11776@deftypevr {@code{dovecot-configuration} parameter} boolean mail-nfs-storage?
11777Mail storage exists in NFS. Set this to yes to make Dovecot flush
11778NFS caches whenever needed. If you're using only a single mail server
11779this isn't needed.
11780Defaults to @samp{#f}.
11781@end deftypevr
11782
11783@deftypevr {@code{dovecot-configuration} parameter} boolean mail-nfs-index?
11784Mail index files also exist in NFS. Setting this to yes requires
11785@samp{mmap-disable? #t} and @samp{fsync-disable? #f}.
11786Defaults to @samp{#f}.
11787@end deftypevr
11788
11789@deftypevr {@code{dovecot-configuration} parameter} string lock-method
11790Locking method for index files. Alternatives are fcntl, flock and
11791dotlock. Dotlocking uses some tricks which may create more disk I/O
11792than other locking methods. NFS users: flock doesn't work, remember to
11793change @samp{mmap-disable}.
11794Defaults to @samp{"fcntl"}.
11795@end deftypevr
11796
11797@deftypevr {@code{dovecot-configuration} parameter} file-name mail-temp-dir
11798Directory in which LDA/LMTP temporarily stores incoming mails >128
11799kB.
11800Defaults to @samp{"/tmp"}.
11801@end deftypevr
11802
11803@deftypevr {@code{dovecot-configuration} parameter} non-negative-integer first-valid-uid
11804Valid UID range for users. This is mostly to make sure that users can't
11805log in as daemons or other system users. Note that denying root logins is
11806hardcoded to dovecot binary and can't be done even if @samp{first-valid-uid}
11807is set to 0.
11808Defaults to @samp{500}.
11809@end deftypevr
11810
11811@deftypevr {@code{dovecot-configuration} parameter} non-negative-integer last-valid-uid
11812
11813Defaults to @samp{0}.
11814@end deftypevr
11815
11816@deftypevr {@code{dovecot-configuration} parameter} non-negative-integer first-valid-gid
11817Valid GID range for users. Users having non-valid GID as primary group ID
11818aren't allowed to log in. If user belongs to supplementary groups with
11819non-valid GIDs, those groups are not set.
11820Defaults to @samp{1}.
11821@end deftypevr
11822
11823@deftypevr {@code{dovecot-configuration} parameter} non-negative-integer last-valid-gid
11824
11825Defaults to @samp{0}.
11826@end deftypevr
11827
11828@deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mail-max-keyword-length
11829Maximum allowed length for mail keyword name. It's only forced when
11830trying to create new keywords.
11831Defaults to @samp{50}.
11832@end deftypevr
11833
11834@deftypevr {@code{dovecot-configuration} parameter} colon-separated-file-name-list valid-chroot-dirs
11835List of directories under which chrooting is allowed for mail
11836processes (i.e. /var/mail will allow chrooting to /var/mail/foo/bar
11837too). This setting doesn't affect @samp{login-chroot}
11838@samp{mail-chroot} or auth chroot settings. If this setting is empty,
11839"/./" in home dirs are ignored. WARNING: Never add directories here
11840which local users can modify, that may lead to root exploit. Usually
11841this should be done only if you don't allow shell access for users.
11842<doc/wiki/Chrooting.txt>.
11843Defaults to @samp{()}.
11844@end deftypevr
11845
11846@deftypevr {@code{dovecot-configuration} parameter} string mail-chroot
11847Default chroot directory for mail processes. This can be overridden
11848for specific users in user database by giving /./ in user's home
11849directory (e.g. /home/./user chroots into /home). Note that usually
11850there is no real need to do chrooting, Dovecot doesn't allow users to
11851access files outside their mail directory anyway. If your home
11852directories are prefixed with the chroot directory, append "/." to
11853@samp{mail-chroot}. <doc/wiki/Chrooting.txt>.
11854Defaults to @samp{""}.
11855@end deftypevr
11856
11857@deftypevr {@code{dovecot-configuration} parameter} file-name auth-socket-path
11858UNIX socket path to master authentication server to find users.
11859This is used by imap (for shared users) and lda.
11860Defaults to @samp{"/var/run/dovecot/auth-userdb"}.
11861@end deftypevr
11862
11863@deftypevr {@code{dovecot-configuration} parameter} file-name mail-plugin-dir
11864Directory where to look up mail plugins.
11865Defaults to @samp{"/usr/lib/dovecot"}.
11866@end deftypevr
11867
11868@deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list mail-plugins
11869List of plugins to load for all services. Plugins specific to IMAP,
11870LDA, etc. are added to this list in their own .conf files.
11871Defaults to @samp{()}.
11872@end deftypevr
11873
11874@deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mail-cache-min-mail-count
11875The minimum number of mails in a mailbox before updates are done to
11876cache file. This allows optimizing Dovecot's behavior to do less disk
11877writes at the cost of more disk reads.
11878Defaults to @samp{0}.
11879@end deftypevr
11880
11881@deftypevr {@code{dovecot-configuration} parameter} string mailbox-idle-check-interval
11882When IDLE command is running, mailbox is checked once in a while to
11883see if there are any new mails or other changes. This setting defines
11884the minimum time to wait between those checks. Dovecot can also use
11885dnotify, inotify and kqueue to find out immediately when changes
11886occur.
11887Defaults to @samp{"30 secs"}.
11888@end deftypevr
11889
11890@deftypevr {@code{dovecot-configuration} parameter} boolean mail-save-crlf?
11891Save mails with CR+LF instead of plain LF. This makes sending those
11892mails take less CPU, especially with sendfile() syscall with Linux and
11893FreeBSD. But it also creates a bit more disk I/O which may just make it
11894slower. Also note that if other software reads the mboxes/maildirs,
11895they may handle the extra CRs wrong and cause problems.
11896Defaults to @samp{#f}.
11897@end deftypevr
11898
11899@deftypevr {@code{dovecot-configuration} parameter} boolean maildir-stat-dirs?
11900By default LIST command returns all entries in maildir beginning
11901with a dot. Enabling this option makes Dovecot return only entries
11902which are directories. This is done by stat()ing each entry, so it
11903causes more disk I/O.
11904 (For systems setting struct @samp{dirent->d_type} this check is free
11905and it's done always regardless of this setting).
11906Defaults to @samp{#f}.
11907@end deftypevr
11908
11909@deftypevr {@code{dovecot-configuration} parameter} boolean maildir-copy-with-hardlinks?
11910When copying a message, do it with hard links whenever possible.
11911This makes the performance much better, and it's unlikely to have any
11912side effects.
11913Defaults to @samp{#t}.
11914@end deftypevr
11915
11916@deftypevr {@code{dovecot-configuration} parameter} boolean maildir-very-dirty-syncs?
11917Assume Dovecot is the only MUA accessing Maildir: Scan cur/
11918directory only when its mtime changes unexpectedly or when we can't find
11919the mail otherwise.
11920Defaults to @samp{#f}.
11921@end deftypevr
11922
11923@deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list mbox-read-locks
11924Which locking methods to use for locking mbox. There are four
11925available:
11926
11927@table @code
11928@item dotlock
11929Create <mailbox>.lock file. This is the oldest and most NFS-safe
11930solution. If you want to use /var/mail/ like directory, the users will
11931need write access to that directory.
11932@item dotlock-try
11933Same as dotlock, but if it fails because of permissions or because there
11934isn't enough disk space, just skip it.
11935@item fcntl
11936Use this if possible. Works with NFS too if lockd is used.
11937@item flock
a01ad638 11938May not exist in all systems. Doesn't work with NFS.
d8c18af8
AW
11939@item lockf
11940May not exist in all systems. Doesn't work with NFS.
11941@end table
11942
11943You can use multiple locking methods; if you do the order they're declared
11944in is important to avoid deadlocks if other MTAs/MUAs are using multiple
11945locking methods as well. Some operating systems don't allow using some of
11946them simultaneously.
11947@end deftypevr
11948
11949@deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list mbox-write-locks
11950
11951@end deftypevr
11952
11953@deftypevr {@code{dovecot-configuration} parameter} string mbox-lock-timeout
11954Maximum time to wait for lock (all of them) before aborting.
11955Defaults to @samp{"5 mins"}.
11956@end deftypevr
11957
11958@deftypevr {@code{dovecot-configuration} parameter} string mbox-dotlock-change-timeout
11959If dotlock exists but the mailbox isn't modified in any way,
11960override the lock file after this much time.
11961Defaults to @samp{"2 mins"}.
11962@end deftypevr
11963
11964@deftypevr {@code{dovecot-configuration} parameter} boolean mbox-dirty-syncs?
11965When mbox changes unexpectedly we have to fully read it to find out
11966what changed. If the mbox is large this can take a long time. Since
11967the change is usually just a newly appended mail, it'd be faster to
11968simply read the new mails. If this setting is enabled, Dovecot does
11969this but still safely fallbacks to re-reading the whole mbox file
11970whenever something in mbox isn't how it's expected to be. The only real
11971downside to this setting is that if some other MUA changes message
11972flags, Dovecot doesn't notice it immediately. Note that a full sync is
11973done with SELECT, EXAMINE, EXPUNGE and CHECK commands.
11974Defaults to @samp{#t}.
11975@end deftypevr
11976
11977@deftypevr {@code{dovecot-configuration} parameter} boolean mbox-very-dirty-syncs?
11978Like @samp{mbox-dirty-syncs}, but don't do full syncs even with SELECT,
11979EXAMINE, EXPUNGE or CHECK commands. If this is set,
11980@samp{mbox-dirty-syncs} is ignored.
11981Defaults to @samp{#f}.
11982@end deftypevr
11983
11984@deftypevr {@code{dovecot-configuration} parameter} boolean mbox-lazy-writes?
11985Delay writing mbox headers until doing a full write sync (EXPUNGE
11986and CHECK commands and when closing the mailbox). This is especially
11987useful for POP3 where clients often delete all mails. The downside is
11988that our changes aren't immediately visible to other MUAs.
11989Defaults to @samp{#t}.
11990@end deftypevr
11991
11992@deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mbox-min-index-size
11993If mbox size is smaller than this (e.g. 100k), don't write index
11994files. If an index file already exists it's still read, just not
11995updated.
11996Defaults to @samp{0}.
11997@end deftypevr
11998
11999@deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mdbox-rotate-size
12000Maximum dbox file size until it's rotated.
12001Defaults to @samp{2000000}.
12002@end deftypevr
12003
12004@deftypevr {@code{dovecot-configuration} parameter} string mdbox-rotate-interval
12005Maximum dbox file age until it's rotated. Typically in days. Day
12006begins from midnight, so 1d = today, 2d = yesterday, etc. 0 = check
12007disabled.
12008Defaults to @samp{"1d"}.
12009@end deftypevr
12010
12011@deftypevr {@code{dovecot-configuration} parameter} boolean mdbox-preallocate-space?
12012When creating new mdbox files, immediately preallocate their size to
12013@samp{mdbox-rotate-size}. This setting currently works only in Linux
8f65585b 12014with some file systems (ext4, xfs).
d8c18af8
AW
12015Defaults to @samp{#f}.
12016@end deftypevr
12017
12018@deftypevr {@code{dovecot-configuration} parameter} string mail-attachment-dir
12019sdbox and mdbox support saving mail attachments to external files,
12020which also allows single instance storage for them. Other backends
12021don't support this for now.
12022
12023WARNING: This feature hasn't been tested much yet. Use at your own risk.
12024
12025Directory root where to store mail attachments. Disabled, if empty.
12026Defaults to @samp{""}.
12027@end deftypevr
12028
12029@deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mail-attachment-min-size
12030Attachments smaller than this aren't saved externally. It's also
12031possible to write a plugin to disable saving specific attachments
12032externally.
12033Defaults to @samp{128000}.
12034@end deftypevr
12035
12036@deftypevr {@code{dovecot-configuration} parameter} string mail-attachment-fs
8f65585b 12037File system backend to use for saving attachments:
d8c18af8
AW
12038@table @code
12039@item posix
12040No SiS done by Dovecot (but this might help FS's own deduplication)
12041@item sis posix
12042SiS with immediate byte-by-byte comparison during saving
12043@item sis-queue posix
12044SiS with delayed comparison and deduplication.
12045@end table
12046Defaults to @samp{"sis posix"}.
12047@end deftypevr
12048
12049@deftypevr {@code{dovecot-configuration} parameter} string mail-attachment-hash
12050Hash format to use in attachment filenames. You can add any text and
12051variables: @code{%@{md4@}}, @code{%@{md5@}}, @code{%@{sha1@}},
12052@code{%@{sha256@}}, @code{%@{sha512@}}, @code{%@{size@}}. Variables can be
12053truncated, e.g. @code{%@{sha256:80@}} returns only first 80 bits.
12054Defaults to @samp{"%@{sha1@}"}.
12055@end deftypevr
12056
12057@deftypevr {@code{dovecot-configuration} parameter} non-negative-integer default-process-limit
12058
12059Defaults to @samp{100}.
12060@end deftypevr
12061
12062@deftypevr {@code{dovecot-configuration} parameter} non-negative-integer default-client-limit
12063
12064Defaults to @samp{1000}.
12065@end deftypevr
12066
12067@deftypevr {@code{dovecot-configuration} parameter} non-negative-integer default-vsz-limit
12068Default VSZ (virtual memory size) limit for service processes.
12069This is mainly intended to catch and kill processes that leak memory
12070before they eat up everything.
12071Defaults to @samp{256000000}.
12072@end deftypevr
12073
12074@deftypevr {@code{dovecot-configuration} parameter} string default-login-user
12075Login user is internally used by login processes. This is the most
12076untrusted user in Dovecot system. It shouldn't have access to anything
12077at all.
12078Defaults to @samp{"dovenull"}.
12079@end deftypevr
12080
12081@deftypevr {@code{dovecot-configuration} parameter} string default-internal-user
12082Internal user is used by unprivileged processes. It should be
12083separate from login user, so that login processes can't disturb other
12084processes.
12085Defaults to @samp{"dovecot"}.
12086@end deftypevr
12087
12088@deftypevr {@code{dovecot-configuration} parameter} string ssl?
12089SSL/TLS support: yes, no, required. <doc/wiki/SSL.txt>.
12090Defaults to @samp{"required"}.
12091@end deftypevr
12092
12093@deftypevr {@code{dovecot-configuration} parameter} string ssl-cert
12094PEM encoded X.509 SSL/TLS certificate (public key).
12095Defaults to @samp{"</etc/dovecot/default.pem"}.
12096@end deftypevr
12097
12098@deftypevr {@code{dovecot-configuration} parameter} string ssl-key
12099PEM encoded SSL/TLS private key. The key is opened before
12100dropping root privileges, so keep the key file unreadable by anyone but
12101root.
12102Defaults to @samp{"</etc/dovecot/private/default.pem"}.
12103@end deftypevr
12104
12105@deftypevr {@code{dovecot-configuration} parameter} string ssl-key-password
12106If key file is password protected, give the password here.
12107Alternatively give it when starting dovecot with -p parameter. Since
12108this file is often world-readable, you may want to place this setting
12109instead to a different.
12110Defaults to @samp{""}.
12111@end deftypevr
12112
12113@deftypevr {@code{dovecot-configuration} parameter} string ssl-ca
12114PEM encoded trusted certificate authority. Set this only if you
12115intend to use @samp{ssl-verify-client-cert? #t}. The file should
12116contain the CA certificate(s) followed by the matching
12117CRL(s). (e.g. @samp{ssl-ca </etc/ssl/certs/ca.pem}).
12118Defaults to @samp{""}.
12119@end deftypevr
12120
12121@deftypevr {@code{dovecot-configuration} parameter} boolean ssl-require-crl?
12122Require that CRL check succeeds for client certificates.
12123Defaults to @samp{#t}.
12124@end deftypevr
12125
12126@deftypevr {@code{dovecot-configuration} parameter} boolean ssl-verify-client-cert?
12127Request client to send a certificate. If you also want to require
12128it, set @samp{auth-ssl-require-client-cert? #t} in auth section.
12129Defaults to @samp{#f}.
12130@end deftypevr
12131
12132@deftypevr {@code{dovecot-configuration} parameter} string ssl-cert-username-field
12133Which field from certificate to use for username. commonName and
12134x500UniqueIdentifier are the usual choices. You'll also need to set
12135@samp{auth-ssl-username-from-cert? #t}.
12136Defaults to @samp{"commonName"}.
12137@end deftypevr
12138
12139@deftypevr {@code{dovecot-configuration} parameter} hours ssl-parameters-regenerate
12140How often to regenerate the SSL parameters file. Generation is
12141quite CPU intensive operation. The value is in hours, 0 disables
12142regeneration entirely.
12143Defaults to @samp{168}.
12144@end deftypevr
12145
12146@deftypevr {@code{dovecot-configuration} parameter} string ssl-protocols
12147SSL protocols to use.
12148Defaults to @samp{"!SSLv2"}.
12149@end deftypevr
12150
12151@deftypevr {@code{dovecot-configuration} parameter} string ssl-cipher-list
12152SSL ciphers to use.
12153Defaults to @samp{"ALL:!LOW:!SSLv2:!EXP:!aNULL"}.
12154@end deftypevr
12155
12156@deftypevr {@code{dovecot-configuration} parameter} string ssl-crypto-device
12157SSL crypto device to use, for valid values run "openssl engine".
12158Defaults to @samp{""}.
12159@end deftypevr
12160
12161@deftypevr {@code{dovecot-configuration} parameter} string postmaster-address
12162Address to use when sending rejection mails.
66329c23
AW
12163%d expands to recipient domain.
12164Defaults to @samp{"postmaster@@%d"}.
d8c18af8
AW
12165@end deftypevr
12166
12167@deftypevr {@code{dovecot-configuration} parameter} string hostname
12168Hostname to use in various parts of sent mails (e.g. in Message-Id)
12169and in LMTP replies. Default is the system's real hostname@@domain.
12170Defaults to @samp{""}.
12171@end deftypevr
12172
12173@deftypevr {@code{dovecot-configuration} parameter} boolean quota-full-tempfail?
12174If user is over quota, return with temporary failure instead of
12175bouncing the mail.
12176Defaults to @samp{#f}.
12177@end deftypevr
12178
12179@deftypevr {@code{dovecot-configuration} parameter} file-name sendmail-path
12180Binary to use for sending mails.
12181Defaults to @samp{"/usr/sbin/sendmail"}.
12182@end deftypevr
12183
12184@deftypevr {@code{dovecot-configuration} parameter} string submission-host
12185If non-empty, send mails via this SMTP host[:port] instead of
12186sendmail.
12187Defaults to @samp{""}.
12188@end deftypevr
12189
12190@deftypevr {@code{dovecot-configuration} parameter} string rejection-subject
12191Subject: header to use for rejection mails. You can use the same
12192variables as for @samp{rejection-reason} below.
12193Defaults to @samp{"Rejected: %s"}.
12194@end deftypevr
12195
12196@deftypevr {@code{dovecot-configuration} parameter} string rejection-reason
12197Human readable error message for rejection mails. You can use
12198variables:
12199
12200@table @code
12201@item %n
12202CRLF
12203@item %r
12204reason
12205@item %s
12206original subject
12207@item %t
12208recipient
12209@end table
12210Defaults to @samp{"Your message to <%t> was automatically rejected:%n%r"}.
12211@end deftypevr
12212
12213@deftypevr {@code{dovecot-configuration} parameter} string recipient-delimiter
12214Delimiter character between local-part and detail in email
12215address.
12216Defaults to @samp{"+"}.
12217@end deftypevr
12218
12219@deftypevr {@code{dovecot-configuration} parameter} string lda-original-recipient-header
12220Header where the original recipient address (SMTP's RCPT TO:
12221address) is taken from if not available elsewhere. With dovecot-lda -a
12222parameter overrides this. A commonly used header for this is
12223X-Original-To.
12224Defaults to @samp{""}.
12225@end deftypevr
12226
12227@deftypevr {@code{dovecot-configuration} parameter} boolean lda-mailbox-autocreate?
12228Should saving a mail to a nonexistent mailbox automatically create
12229it?.
12230Defaults to @samp{#f}.
12231@end deftypevr
12232
12233@deftypevr {@code{dovecot-configuration} parameter} boolean lda-mailbox-autosubscribe?
12234Should automatically created mailboxes be also automatically
12235subscribed?.
12236Defaults to @samp{#f}.
12237@end deftypevr
12238
12239@deftypevr {@code{dovecot-configuration} parameter} non-negative-integer imap-max-line-length
12240Maximum IMAP command line length. Some clients generate very long
12241command lines with huge mailboxes, so you may need to raise this if you
12242get "Too long argument" or "IMAP command line too large" errors
12243often.
12244Defaults to @samp{64000}.
12245@end deftypevr
12246
12247@deftypevr {@code{dovecot-configuration} parameter} string imap-logout-format
12248IMAP logout format string:
12249@table @code
12250@item %i
12251total number of bytes read from client
12252@item %o
12253total number of bytes sent to client.
12254@end table
12255Defaults to @samp{"in=%i out=%o"}.
12256@end deftypevr
12257
12258@deftypevr {@code{dovecot-configuration} parameter} string imap-capability
12259Override the IMAP CAPABILITY response. If the value begins with '+',
12260add the given capabilities on top of the defaults (e.g. +XFOO XBAR).
12261Defaults to @samp{""}.
12262@end deftypevr
12263
12264@deftypevr {@code{dovecot-configuration} parameter} string imap-idle-notify-interval
12265How long to wait between "OK Still here" notifications when client
12266is IDLEing.
12267Defaults to @samp{"2 mins"}.
12268@end deftypevr
12269
12270@deftypevr {@code{dovecot-configuration} parameter} string imap-id-send
12271ID field names and values to send to clients. Using * as the value
12272makes Dovecot use the default value. The following fields have default
12273values currently: name, version, os, os-version, support-url,
12274support-email.
12275Defaults to @samp{""}.
12276@end deftypevr
12277
12278@deftypevr {@code{dovecot-configuration} parameter} string imap-id-log
12279ID fields sent by client to log. * means everything.
12280Defaults to @samp{""}.
12281@end deftypevr
12282
12283@deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list imap-client-workarounds
12284Workarounds for various client bugs:
12285
12286@table @code
12287@item delay-newmail
12288Send EXISTS/RECENT new mail notifications only when replying to NOOP and
12289CHECK commands. Some clients ignore them otherwise, for example OSX
12290Mail (<v2.1). Outlook Express breaks more badly though, without this it
12291may show user "Message no longer in server" errors. Note that OE6
12292still breaks even with this workaround if synchronization is set to
12293"Headers Only".
12294
12295@item tb-extra-mailbox-sep
12296Thunderbird gets somehow confused with LAYOUT=fs (mbox and dbox) and
12297adds extra @samp{/} suffixes to mailbox names. This option causes Dovecot to
12298ignore the extra @samp{/} instead of treating it as invalid mailbox name.
12299
12300@item tb-lsub-flags
12301Show \Noselect flags for LSUB replies with LAYOUT=fs (e.g. mbox).
12302This makes Thunderbird realize they aren't selectable and show them
12303greyed out, instead of only later giving "not selectable" popup error.
12304@end table
12305Defaults to @samp{()}.
12306@end deftypevr
12307
12308@deftypevr {@code{dovecot-configuration} parameter} string imap-urlauth-host
12309Host allowed in URLAUTH URLs sent by client. "*" allows all.
12310Defaults to @samp{""}.
12311@end deftypevr
12312
12313
12314Whew! Lots of configuration options. The nice thing about it though is
12315that GuixSD has a complete interface to Dovecot's configuration
12316language. This allows not only a nice way to declare configurations,
12317but also offers reflective capabilities as well: users can write code to
12318inspect and transform configurations from within Scheme.
12319
12320However, it could be that you just want to get a @code{dovecot.conf} up
12321and running. In that case, you can pass an
7414de0a 12322@code{opaque-dovecot-configuration} as the @code{#:config} parameter to
d8c18af8
AW
12323@code{dovecot-service}. As its name indicates, an opaque configuration
12324does not have easy reflective capabilities.
12325
12326Available @code{opaque-dovecot-configuration} fields are:
12327
12328@deftypevr {@code{opaque-dovecot-configuration} parameter} package dovecot
12329The dovecot package.
12330@end deftypevr
12331
12332@deftypevr {@code{opaque-dovecot-configuration} parameter} string string
12333The contents of the @code{dovecot.conf}, as a string.
12334@end deftypevr
12335
12336For example, if your @code{dovecot.conf} is just the empty string, you
12337could instantiate a dovecot service like this:
12338
12339@example
12340(dovecot-service #:config
12341 (opaque-dovecot-configuration
12342 (string "")))
12343@end example
12344
f88371e8
SB
12345@subsubheading OpenSMTPD Service
12346
12347@deffn {Scheme Variable} opensmtpd-service-type
12348This is the type of the @uref{https://www.opensmtpd.org, OpenSMTPD}
12349service, whose value should be an @code{opensmtpd-configuration} object
12350as in this example:
12351
12352@example
12353(service opensmtpd-service-type
12354 (opensmtpd-configuration
12355 (config-file (local-file "./my-smtpd.conf"))))
12356@end example
12357@end deffn
12358
12359@deftp {Data Type} opensmtpd-configuration
12360Data type regresenting the configuration of opensmtpd.
12361
12362@table @asis
12363@item @code{package} (default: @var{opensmtpd})
12364Package object of the OpenSMTPD SMTP server.
12365
12366@item @code{config-file} (default: @var{%default-opensmtpd-file})
12367File-like object of the OpenSMTPD configuration file to use. By default
12368it listens on the loopback network interface, and allows for mail from
12369users and daemons on the local machine, as well as permitting email to
12370remote servers. Run @command{man smtpd.conf} for more information.
12371
12372@end table
12373@end deftp
859e367d 12374
82ccc499
CZ
12375@subsubheading Exim Service
12376
12377@deffn {Scheme Variable} exim-service-type
12378This is the type of the @uref{https://exim.org, Exim} service, whose value
12379should be an @code{exim-configuration} object as in this example:
12380
12381@example
12382(service exim-service-type
12383 (exim-configuration
12384 (config-file (local-file "./my-exim.conf"))
12385 (aliases '(("postmaster" "bob")
12386 ("bob" "bob@@example.com" "bob@@example2.com")))))
12387@end example
12388@end deffn
12389
12390@deftp {Data Type} exim-configuration
12391Data type representing the configuration of exim.
12392
12393@table @asis
12394@item @code{package} (default: @var{exim})
12395Package object of the Exim server.
12396
12397@item @code{config-file} (default: @code{#f})
12398File-like object of the Exim configuration file to use. If its value is
12399@code{#f} then use the default configuration file from the package
12400provided in @code{package}. The resulting configuration file is loaded
12401after setting the @code{exim_user} and @code{exim_group} configuration
12402variables.
12403
12404@item @code{aliases} (default: @code{'()})
12405List of aliases to use when delivering mail on this system. The
12406@code{car} of each list is used to match incoming mail, with the
12407@code{cdr} of each list designating how to deliver it. There may be many
12408delivery methods provided, in which case the mail is delivered to them
12409all.
12410
12411@end table
12412@end deftp
12413
78cef99b
CL
12414@node Messaging Services
12415@subsubsection Messaging Services
12416
12417@cindex messaging
12418@cindex jabber
12419@cindex XMPP
12420The @code{(gnu services messaging)} module provides Guix service
12421definitions for messaging services: currently only Prosody is supported.
12422
12423@subsubheading Prosody Service
12424
12425@deffn {Scheme Variable} prosody-service-type
12426This is the type for the @uref{http://prosody.im, Prosody XMPP
12427communication server}. Its value must be a @code{prosody-configuration}
12428record as in this example:
12429
12430@example
12431(service prosody-service-type
12432 (prosody-configuration
12433 (modules-enabled (cons "groups" %default-modules-enabled))
12434 (int-components
12435 (list
12436 (int-component-configuration
12437 (hostname "conference.example.net")
12438 (plugin "muc")
12439 (mod-muc (mod-muc-configuration)))))
12440 (virtualhosts
12441 (list
12442 (virtualhost-configuration
12443 (domain "example.net"))))))
12444@end example
12445
12446See below for details about @code{prosody-configuration}.
12447
12448@end deffn
12449
12450By default, Prosody does not need much configuration. Only one
12451@code{virtualhosts} field is needed: it specifies the domain you wish
12452Prosody to serve.
12453
12454Prosodyctl will help you generate X.509 certificates and keys:
12455
12456@example
12457prosodyctl cert request example.net
12458@end example
12459
12460The available configuration parameters follow. Each parameter
12461definition is preceded by its type; for example, @samp{string-list foo}
12462indicates that the @code{foo} parameter should be specified as a list of
12463strings. Types starting with @code{maybe-} denote parameters that won't
12464show up in @code{prosody.cfg.lua} when their value is @code{'disabled}.
12465
12466There is also a way to specify the configuration as a string, if you
12467have an old @code{prosody.cfg.lua} file that you want to port over from
12468some other system; see the end for more details.
12469
12470@c The following documentation was initially generated by
12471@c (generate-documentation) in (gnu services messaging). Manually maintained
12472@c documentation is better, so we shouldn't hesitate to edit below as
12473@c needed. However if the change you want to make to this documentation
12474@c can be done in an automated way, it's probably easier to change
12475@c (generate-documentation) than to make it below and have to deal with
12476@c the churn as Prosody updates.
12477
12478Available @code{prosody-configuration} fields are:
12479
12480@deftypevr {@code{prosody-configuration} parameter} package prosody
12481The Prosody package.
12482@end deftypevr
12483
12484@deftypevr {@code{prosody-configuration} parameter} file-name data-path
12485Location of the Prosody data storage directory. See
12486@url{http://prosody.im/doc/configure}.
12487Defaults to @samp{"/var/lib/prosody"}.
12488@end deftypevr
12489
12490@deftypevr {@code{prosody-configuration} parameter} file-name-list plugin-paths
12491Additional plugin directories. They are searched in all the specified
12492paths in order. See @url{http://prosody.im/doc/plugins_directory}.
12493Defaults to @samp{()}.
12494@end deftypevr
12495
12496@deftypevr {@code{prosody-configuration} parameter} string-list admins
12497This is a list of accounts that are admins for the server. Note that you
12498must create the accounts separately. See @url{http://prosody.im/doc/admins} and
12499@url{http://prosody.im/doc/creating_accounts}.
12500Example: @code{(admins '("user1@@example.com" "user2@@example.net"))}
12501Defaults to @samp{()}.
12502@end deftypevr
12503
12504@deftypevr {@code{prosody-configuration} parameter} boolean use-libevent?
12505Enable use of libevent for better performance under high load. See
12506@url{http://prosody.im/doc/libevent}.
12507Defaults to @samp{#f}.
12508@end deftypevr
12509
12510@deftypevr {@code{prosody-configuration} parameter} module-list modules-enabled
12511This is the list of modules Prosody will load on startup. It looks for
12512@code{mod_modulename.lua} in the plugins folder, so make sure that exists too.
12513Documentation on modules can be found at: @url{http://prosody.im/doc/modules}.
12514Defaults to @samp{%default-modules-enabled}.
12515@end deftypevr
12516
12517@deftypevr {@code{prosody-configuration} parameter} string-list modules-disabled
12518@samp{"offline"}, @samp{"c2s"} and @samp{"s2s"} are auto-loaded, but
12519should you want to disable them then add them to this list.
12520Defaults to @samp{()}.
12521@end deftypevr
12522
12523@deftypevr {@code{prosody-configuration} parameter} file-name groups-file
12524Path to a text file where the shared groups are defined. If this path is
12525empty then @samp{mod_groups} does nothing. See
12526@url{http://prosody.im/doc/modules/mod_groups}.
12527Defaults to @samp{"/var/lib/prosody/sharedgroups.txt"}.
12528@end deftypevr
12529
12530@deftypevr {@code{prosody-configuration} parameter} boolean allow-registration?
12531Disable account creation by default, for security. See
12532@url{http://prosody.im/doc/creating_accounts}.
12533Defaults to @samp{#f}.
12534@end deftypevr
12535
12536@deftypevr {@code{prosody-configuration} parameter} maybe-ssl-configuration ssl
12537These are the SSL/TLS-related settings. Most of them are disabled so to
12538use Prosody's defaults. If you do not completely understand these options, do
12539not add them to your config, it is easy to lower the security of your server
12540using them. See @url{http://prosody.im/doc/advanced_ssl_config}.
12541
12542Available @code{ssl-configuration} fields are:
12543
12544@deftypevr {@code{ssl-configuration} parameter} maybe-string protocol
12545This determines what handshake to use.
12546@end deftypevr
12547
12548@deftypevr {@code{ssl-configuration} parameter} file-name key
12549Path to your private key file, relative to @code{/etc/prosody}.
12550Defaults to @samp{"/etc/prosody/certs/key.pem"}.
12551@end deftypevr
12552
12553@deftypevr {@code{ssl-configuration} parameter} file-name certificate
12554Path to your certificate file, relative to @code{/etc/prosody}.
12555Defaults to @samp{"/etc/prosody/certs/cert.pem"}.
12556@end deftypevr
12557
12558@deftypevr {@code{ssl-configuration} parameter} file-name capath
12559Path to directory containing root certificates that you wish Prosody to
12560trust when verifying the certificates of remote servers.
12561Defaults to @samp{"/etc/ssl/certs"}.
12562@end deftypevr
12563
12564@deftypevr {@code{ssl-configuration} parameter} maybe-file-name cafile
12565Path to a file containing root certificates that you wish Prosody to trust.
12566Similar to @code{capath} but with all certificates concatenated together.
12567@end deftypevr
12568
12569@deftypevr {@code{ssl-configuration} parameter} maybe-string-list verify
12570A list of verification options (these mostly map to OpenSSL's
12571@code{set_verify()} flags).
12572@end deftypevr
12573
12574@deftypevr {@code{ssl-configuration} parameter} maybe-string-list options
12575A list of general options relating to SSL/TLS. These map to OpenSSL's
12576@code{set_options()}. For a full list of options available in LuaSec, see the
12577LuaSec source.
12578@end deftypevr
12579
12580@deftypevr {@code{ssl-configuration} parameter} maybe-non-negative-integer depth
12581How long a chain of certificate authorities to check when looking for a
12582trusted root certificate.
12583@end deftypevr
12584
12585@deftypevr {@code{ssl-configuration} parameter} maybe-string ciphers
12586An OpenSSL cipher string. This selects what ciphers Prosody will offer to
12587clients, and in what order.
12588@end deftypevr
12589
12590@deftypevr {@code{ssl-configuration} parameter} maybe-file-name dhparam
12591A path to a file containing parameters for Diffie-Hellman key exchange. You
12592can create such a file with:
12593@code{openssl dhparam -out /etc/prosody/certs/dh-2048.pem 2048}
12594@end deftypevr
12595
12596@deftypevr {@code{ssl-configuration} parameter} maybe-string curve
12597Curve for Elliptic curve Diffie-Hellman. Prosody's default is
12598@samp{"secp384r1"}.
12599@end deftypevr
12600
12601@deftypevr {@code{ssl-configuration} parameter} maybe-string-list verifyext
12602A list of "extra" verification options.
12603@end deftypevr
12604
12605@deftypevr {@code{ssl-configuration} parameter} maybe-string password
12606Password for encrypted private keys.
12607@end deftypevr
12608
12609@end deftypevr
12610
12611@deftypevr {@code{prosody-configuration} parameter} boolean c2s-require-encryption?
12612Whether to force all client-to-server connections to be encrypted or not.
12613See @url{http://prosody.im/doc/modules/mod_tls}.
12614Defaults to @samp{#f}.
12615@end deftypevr
12616
12617@deftypevr {@code{prosody-configuration} parameter} boolean s2s-require-encryption?
12618Whether to force all server-to-server connections to be encrypted or not.
12619See @url{http://prosody.im/doc/modules/mod_tls}.
12620Defaults to @samp{#f}.
12621@end deftypevr
12622
12623@deftypevr {@code{prosody-configuration} parameter} boolean s2s-secure-auth?
12624Whether to require encryption and certificate authentication. This
12625provides ideal security, but requires servers you communicate with to support
12626encryption AND present valid, trusted certificates. See
12627@url{http://prosody.im/doc/s2s#security}.
12628Defaults to @samp{#f}.
12629@end deftypevr
12630
12631@deftypevr {@code{prosody-configuration} parameter} string-list s2s-insecure-domains
12632Many servers don't support encryption or have invalid or self-signed
12633certificates. You can list domains here that will not be required to
12634authenticate using certificates. They will be authenticated using DNS. See
12635@url{http://prosody.im/doc/s2s#security}.
12636Defaults to @samp{()}.
12637@end deftypevr
12638
12639@deftypevr {@code{prosody-configuration} parameter} string-list s2s-secure-domains
12640Even if you leave @code{s2s-secure-auth?} disabled, you can still require
12641valid certificates for some domains by specifying a list here. See
12642@url{http://prosody.im/doc/s2s#security}.
12643Defaults to @samp{()}.
12644@end deftypevr
12645
12646@deftypevr {@code{prosody-configuration} parameter} string authentication
12647Select the authentication backend to use. The default provider stores
12648passwords in plaintext and uses Prosody's configured data storage to store the
12649authentication data. If you do not trust your server please see
12650@url{http://prosody.im/doc/modules/mod_auth_internal_hashed} for information
12651about using the hashed backend. See also
12652@url{http://prosody.im/doc/authentication}
12653Defaults to @samp{"internal_plain"}.
12654@end deftypevr
12655
12656@deftypevr {@code{prosody-configuration} parameter} maybe-string log
12657Set logging options. Advanced logging configuration is not yet supported
12658by the GuixSD Prosody Service. See @url{http://prosody.im/doc/logging}.
12659Defaults to @samp{"*syslog"}.
12660@end deftypevr
12661
12662@deftypevr {@code{prosody-configuration} parameter} file-name pidfile
12663File to write pid in. See @url{http://prosody.im/doc/modules/mod_posix}.
12664Defaults to @samp{"/var/run/prosody/prosody.pid"}.
12665@end deftypevr
12666
12667@deftypevr {@code{prosody-configuration} parameter} virtualhost-configuration-list virtualhosts
12668A host in Prosody is a domain on which user accounts can be created. For
12669example if you want your users to have addresses like
12670@samp{"john.smith@@example.com"} then you need to add a host
12671@samp{"example.com"}. All options in this list will apply only to this host.
12672
12673Note: the name "virtual" host is used in configuration to avoid confusion with
12674the actual physical host that Prosody is installed on. A single Prosody
12675instance can serve many domains, each one defined as a VirtualHost entry in
12676Prosody's configuration. Conversely a server that hosts a single domain would
12677have just one VirtualHost entry.
12678
12679See @url{http://prosody.im/doc/configure#virtual_host_settings}.
12680
12681Available @code{virtualhost-configuration} fields are:
12682
12683all 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{s2s-require-encryption?}, @code{s2s-secure-auth?}, @code{s2s-insecure-domains}, @code{s2s-secure-domains}, @code{authentication}, @code{log}, plus:
12684@deftypevr {@code{virtualhost-configuration} parameter} string domain
12685Domain you wish Prosody to serve.
12686@end deftypevr
12687
12688@end deftypevr
12689
12690@deftypevr {@code{prosody-configuration} parameter} int-component-configuration-list int-components
12691Components are extra services on a server which are available to clients,
12692usually on a subdomain of the main server (such as
12693@samp{"mycomponent.example.com"}). Example components might be chatroom
12694servers, user directories, or gateways to other protocols.
12695
12696Internal components are implemented with Prosody-specific plugins. To add an
12697internal component, you simply fill the hostname field, and the plugin you wish
12698to use for the component.
12699
12700See @url{http://prosody.im/doc/components}.
12701Defaults to @samp{()}.
12702
12703Available @code{int-component-configuration} fields are:
12704
12705all 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{s2s-require-encryption?}, @code{s2s-secure-auth?}, @code{s2s-insecure-domains}, @code{s2s-secure-domains}, @code{authentication}, @code{log}, plus:
12706@deftypevr {@code{int-component-configuration} parameter} string hostname
12707Hostname of the component.
12708@end deftypevr
12709
12710@deftypevr {@code{int-component-configuration} parameter} string plugin
12711Plugin you wish to use for the component.
12712@end deftypevr
12713
12714@deftypevr {@code{int-component-configuration} parameter} maybe-mod-muc-configuration mod-muc
12715Multi-user chat (MUC) is Prosody's module for allowing you to create
12716hosted chatrooms/conferences for XMPP users.
12717
12718General information on setting up and using multi-user chatrooms can be found
12719in the "Chatrooms" documentation (@url{http://prosody.im/doc/chatrooms}),
12720which you should read if you are new to XMPP chatrooms.
12721
12722See also @url{http://prosody.im/doc/modules/mod_muc}.
12723
12724Available @code{mod-muc-configuration} fields are:
12725
12726@deftypevr {@code{mod-muc-configuration} parameter} string name
12727The name to return in service discovery responses.
12728Defaults to @samp{"Prosody Chatrooms"}.
12729@end deftypevr
12730
12731@deftypevr {@code{mod-muc-configuration} parameter} string-or-boolean restrict-room-creation
12732If @samp{#t}, this will only allow admins to create new chatrooms.
12733Otherwise anyone can create a room. The value @samp{"local"} restricts room
12734creation to users on the service's parent domain. E.g. @samp{user@@example.com}
12735can create rooms on @samp{rooms.example.com}. The value @samp{"admin"}
12736restricts to service administrators only.
12737Defaults to @samp{#f}.
12738@end deftypevr
12739
12740@deftypevr {@code{mod-muc-configuration} parameter} non-negative-integer max-history-messages
12741Maximum number of history messages that will be sent to the member that has
12742just joined the room.
12743Defaults to @samp{20}.
12744@end deftypevr
12745
12746@end deftypevr
12747
12748@end deftypevr
12749
12750@deftypevr {@code{prosody-configuration} parameter} ext-component-configuration-list ext-components
12751External components use XEP-0114, which most standalone components
12752support. To add an external component, you simply fill the hostname field. See
12753@url{http://prosody.im/doc/components}.
12754Defaults to @samp{()}.
12755
12756Available @code{ext-component-configuration} fields are:
12757
12758all 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{s2s-require-encryption?}, @code{s2s-secure-auth?}, @code{s2s-insecure-domains}, @code{s2s-secure-domains}, @code{authentication}, @code{log}, plus:
12759@deftypevr {@code{ext-component-configuration} parameter} string component-secret
12760Password which the component will use to log in.
12761@end deftypevr
12762
12763@deftypevr {@code{ext-component-configuration} parameter} string hostname
12764Hostname of the component.
12765@end deftypevr
12766
12767@end deftypevr
12768
12769@deftypevr {@code{prosody-configuration} parameter} non-negative-integer-list component-ports
12770Port(s) Prosody listens on for component connections.
12771@end deftypevr
12772
12773@deftypevr {@code{prosody-configuration} parameter} string component-interface
12774Interface Prosody listens on for component connections.
12775Defaults to @samp{"127.0.0.1"}.
12776@end deftypevr
12777
12778It could be that you just want to get a @code{prosody.cfg.lua}
12779up and running. In that case, you can pass an
12780@code{opaque-prosody-configuration} record as the value of
12781@code{prosody-service-type}. As its name indicates, an opaque configuration
12782does not have easy reflective capabilities.
12783Available @code{opaque-prosody-configuration} fields are:
12784
12785@deftypevr {@code{opaque-prosody-configuration} parameter} package prosody
12786The prosody package.
12787@end deftypevr
12788
12789@deftypevr {@code{opaque-prosody-configuration} parameter} string prosody.cfg.lua
12790The contents of the @code{prosody.cfg.lua} to use.
12791@end deftypevr
12792
12793For example, if your @code{prosody.cfg.lua} is just the empty
12794string, you could instantiate a prosody service like this:
12795
12796@example
12797(service prosody-service-type
12798 (opaque-prosody-configuration
12799 (prosody.cfg.lua "")))
12800@end example
12801
859e367d
JD
12802@node Kerberos Services
12803@subsubsection Kerberos Services
12804@cindex Kerberos
12805
df31e36a 12806The @code{(gnu services kerberos)} module provides services relating to
859e367d
JD
12807the authentication protocol @dfn{Kerberos}.
12808
8e3f813f
JD
12809@subsubheading Krb5 Service
12810
12811Programs using a Kerberos client library normally
12812expect a configuration file in @file{/etc/krb5.conf}.
12813This service generates such a file from a definition provided in the
12814operating system declaration.
12815It does not cause any daemon to be started.
12816
12817No ``keytab'' files are provided by this service---you must explicitly create them.
12818This service is known to work with the MIT client library, @code{mit-krb5}.
12819Other implementations have not been tested.
12820
12821@defvr {Scheme Variable} krb5-service-type
12822A service type for Kerberos 5 clients.
12823@end defvr
12824
12825@noindent
12826Here is an example of its use:
12827@lisp
12828(service krb5-service-type
12829 (krb5-configuration
12830 (default-realm "EXAMPLE.COM")
12831 (allow-weak-crypto? #t)
12832 (realms (list
12833 (krb5-realm
12834 (name "EXAMPLE.COM")
12835 (admin-server "groucho.example.com")
12836 (kdc "karl.example.com"))
12837 (krb5-realm
12838 (name "ARGRX.EDU")
12839 (admin-server "kerb-admin.argrx.edu")
12840 (kdc "keys.argrx.edu"))))))
12841@end lisp
12842
12843@noindent
12844This example provides a Kerberos@tie{}5 client configuration which:
12845@itemize
12846@item Recognizes two realms, @i{viz:} ``EXAMPLE.COM'' and ``ARGRX.EDU'', both
12847of which have distinct administration servers and key distribution centers;
12848@item Will default to the realm ``EXAMPLE.COM'' if the realm is not explicitly
12849specified by clients;
12850@item Accepts services which only support encryption types known to be weak.
12851@end itemize
12852
12853The @code{krb5-realm} and @code{krb5-configuration} types have many fields.
12854Only the most commonly used ones are described here.
12855For a full list, and more detailed explanation of each, see the MIT
12856@uref{http://web.mit.edu/kerberos/krb5-devel/doc/admin/conf_files/krb5_conf.html,,krb5.conf}
12857documentation.
12858
12859
12860@deftp {Data Type} krb5-realm
12861@cindex realm, kerberos
12862@table @asis
12863@item @code{name}
12864This field is a string identifying the name of the realm.
12865A common convention is to use the fully qualified DNS name of your organization,
12866converted to upper case.
12867
12868@item @code{admin-server}
12869This field is a string identifying the host where the administration server is
12870running.
12871
12872@item @code{kdc}
12873This field is a string identifying the key distribution center
12874for the realm.
12875@end table
12876@end deftp
12877
12878@deftp {Data Type} krb5-configuration
12879
12880@table @asis
12881@item @code{allow-weak-crypto?} (default: @code{#f})
12882If this flag is @code{#t} then services which only offer encryption algorithms
12883known to be weak will be accepted.
12884
12885@item @code{default-realm} (default: @code{#f})
12886This field should be a string identifying the default Kerberos
12887realm for the client.
12888You should set this field to the name of your Kerberos realm.
12889If this value is @code{#f}
12890then a realm must be specified with every Kerberos principal when invoking programs
12891such as @command{kinit}.
12892
12893@item @code{realms}
12894This should be a non-empty list of @code{krb5-realm} objects, which clients may
12895access.
12896Normally, one of them will have a @code{name} field matching the @code{default-realm}
12897field.
12898@end table
12899@end deftp
12900
12901
859e367d
JD
12902@subsubheading PAM krb5 Service
12903@cindex pam-krb5
12904
df31e36a 12905The @code{pam-krb5} service allows for login authentication and password
859e367d
JD
12906management via Kerberos.
12907You will need this service if you want PAM enabled applications to authenticate
12908users using Kerberos.
12909
12910@defvr {Scheme Variable} pam-krb5-service-type
12911A service type for the Kerberos 5 PAM module.
12912@end defvr
12913
12914@deftp {Data Type} pam-krb5-configuration
12915Data type representing the configuration of the Kerberos 5 PAM module
12916This type has the following parameters:
12917@table @asis
12918@item @code{pam-krb5} (default: @code{pam-krb5})
12919The pam-krb5 package to use.
12920
12921@item @code{minimum-uid} (default: @code{1000})
12922The smallest user ID for which Kerberos authentications should be attempted.
12923Local accounts with lower values will silently fail to authenticate.
12924@end table
12925@end deftp
12926
12927
58724c48
DT
12928@node Web Services
12929@subsubsection Web Services
12930
e32171ee
JD
12931@cindex web
12932@cindex www
12933@cindex HTTP
58724c48
DT
12934The @code{(gnu services web)} module provides the following service:
12935
be1c2c54 12936@deffn {Scheme Procedure} nginx-service [#:nginx nginx] @
58724c48
DT
12937 [#:log-directory ``/var/log/nginx''] @
12938 [#:run-directory ``/var/run/nginx''] @
d338237d 12939 [#:server-list '()] @
cb341293 12940 [#:upstream-list '()] @
d338237d 12941 [#:config-file @code{#f}]
58724c48
DT
12942
12943Return a service that runs @var{nginx}, the nginx web server.
12944
12945The nginx daemon loads its runtime configuration from @var{config-file}.
12946Log files are written to @var{log-directory} and temporary runtime data
12947files are written to @var{run-directory}. For proper operation, these
12948arguments should match what is in @var{config-file} to ensure that the
12949directories are created when the service is activated.
12950
3b9b12ef 12951As an alternative to using a @var{config-file}, @var{server-list} can be
cb341293
CB
12952used to specify the list of @dfn{server blocks} required on the host and
12953@var{upstream-list} can be used to specify a list of @dfn{upstream
12954blocks} to configure. For this to work, use the default value for
12955@var{config-file}.
8c00b838 12956
58724c48
DT
12957@end deffn
12958
d338237d
JL
12959@deffn {Scheme Variable} nginx-service-type
12960This is type for the nginx web server.
12961
12962This service can be extended to add server blocks in addition to the
12963default one, as in this example:
12964
12965@example
12966(simple-service 'my-extra-server nginx-service-type
12967 (list (nginx-server-configuration
12968 (https-port #f)
12969 (root "/srv/http/extra-website"))))
12970@end example
12971@end deffn
12972
3b9b12ef
JL
12973@deftp {Data Type} nginx-server-configuration
12974Data type representing the configuration of an nginx server block.
8c00b838
JL
12975This type has the following parameters:
12976
12977@table @asis
12978@item @code{http-port} (default: @code{80})
12979Nginx will listen for HTTP connection on this port. Set it at @code{#f} if
12980nginx should not listen for HTTP (non secure) connection for this
3b9b12ef 12981@dfn{server block}.
8c00b838
JL
12982
12983@item @code{https-port} (default: @code{443})
12984Nginx will listen for HTTPS connection on this port. Set it at @code{#f} if
3b9b12ef 12985nginx should not listen for HTTPS (secure) connection for this @dfn{server block}.
8c00b838
JL
12986
12987Note that nginx can listen for HTTP and HTTPS connections in the same
3b9b12ef 12988@dfn{server block}.
8c00b838
JL
12989
12990@item @code{server-name} (default: @code{(list 'default)})
3b9b12ef
JL
12991A list of server names this server represents. @code{'default} represents the
12992default server for connections matching no other server.
8c00b838
JL
12993
12994@item @code{root} (default: @code{"/srv/http"})
12995Root of the website nginx will serve.
12996
9c557a69
CB
12997@item @code{locations} (default: @code{'()})
12998A list of @dfn{nginx-location-configuration} or
12999@dfn{nginx-named-location-configuration} records to use within this
13000server block.
13001
8c00b838
JL
13002@item @code{index} (default: @code{(list "index.html")})
13003Index files to look for when clients ask for a directory. If it cannot be found,
13004Nginx will send the list of files in the directory.
13005
13006@item @code{ssl-certificate} (default: @code{"/etc/nginx/cert.pem"})
13007Where to find the certificate for secure connections. Set it to @code{#f} if
13008you don't have a certificate or you don't want to use HTTPS.
13009
13010@item @code{ssl-certificate-key} (default: @code{"/etc/nginx/key.pem"})
13011Where to find the private key for secure connections. Set it to @code{#f} if
13012you don't have a key or you don't want to use HTTPS.
13013
13014@item @code{server-tokens?} (default: @code{#f})
13015Whether the server should add its configuration to response.
13016
13017@end table
13018@end deftp
13019
2be1b471
JL
13020@node VPN Services
13021@subsubsection VPN Services
13022@cindex VPN (virtual private network)
13023@cindex virtual private network (VPN)
13024
13025The @code{(gnu services vpn)} module provides services related to
13026@dfn{virtual private networks} (VPNs). It provides a @emph{client} service for
13027your machine to connect to a VPN, and a @emph{servire} service for your machine
13028to host a VPN. Both services use @uref{https://openvpn.net/, OpenVPN}.
13029
13030@deffn {Scheme Procedure} openvpn-client-service @
13031 [#:config (openvpn-client-configuration)]
13032
13033Return a service that runs @command{openvpn}, a VPN daemon, as a client.
13034@end deffn
13035
13036@deffn {Scheme Procedure} openvpn-server-service @
13037 [#:config (openvpn-server-configuration)]
13038
13039Return a service that runs @command{openvpn}, a VPN daemon, as a server.
13040
13041Both can be run simultaneously.
13042@end deffn
13043
13044@c %automatically generated documentation
13045
13046Available @code{openvpn-client-configuration} fields are:
13047
13048@deftypevr @code{openvpn-client-configuration} parameter package openvpn
13049The OpenVPN package.
13050
13051@end deftypevr
13052
13053@deftypevr @code{openvpn-client-configuration} parameter string pid-file
13054The OpenVPN pid file.
13055
13056Defaults to @samp{"/var/run/openvpn/openvpn.pid"}.
13057
13058@end deftypevr
13059
13060@deftypevr @code{openvpn-client-configuration} parameter proto proto
13061The protocol (UDP or TCP) used to open a channel between clients and
13062servers.
13063
13064Defaults to @samp{udp}.
13065
13066@end deftypevr
13067
13068@deftypevr @code{openvpn-client-configuration} parameter dev dev
13069The device type used to represent the VPN connection.
13070
13071Defaults to @samp{tun}.
13072
13073@end deftypevr
13074
13075@deftypevr @code{openvpn-client-configuration} parameter string ca
13076The certificate authority to check connections against.
13077
13078Defaults to @samp{"/etc/openvpn/ca.crt"}.
13079
13080@end deftypevr
13081
13082@deftypevr @code{openvpn-client-configuration} parameter string cert
13083The certificate of the machine the daemon is running on. It should be
13084signed by the authority given in @code{ca}.
13085
13086Defaults to @samp{"/etc/openvpn/client.crt"}.
13087
13088@end deftypevr
13089
13090@deftypevr @code{openvpn-client-configuration} parameter string key
13091The key of the machine the daemon is running on. It must be the key whose
13092certificate is @code{cert}.
13093
13094Defaults to @samp{"/etc/openvpn/client.key"}.
13095
13096@end deftypevr
13097
13098@deftypevr @code{openvpn-client-configuration} parameter boolean comp-lzo?
13099Whether to use the lzo compression algorithm.
13100
13101Defaults to @samp{#t}.
13102
13103@end deftypevr
13104
13105@deftypevr @code{openvpn-client-configuration} parameter boolean persist-key?
13106Don't re-read key files across SIGUSR1 or --ping-restart.
13107
13108Defaults to @samp{#t}.
13109
13110@end deftypevr
13111
13112@deftypevr @code{openvpn-client-configuration} parameter boolean persist-tun?
13113Don't close and reopen TUN/TAP device or run up/down scripts across
13114SIGUSR1 or --ping-restart restarts.
13115
13116Defaults to @samp{#t}.
13117
13118@end deftypevr
13119
13120@deftypevr @code{openvpn-client-configuration} parameter number verbosity
13121Verbosity level.
13122
13123Defaults to @samp{3}.
13124
13125@end deftypevr
13126
13127@deftypevr @code{openvpn-client-configuration} parameter tls-auth-client tls-auth
13128Add an additional layer of HMAC authentication on top of the TLS control
13129channel to protect against DoS attacks.
13130
13131Defaults to @samp{#f}.
13132
13133@end deftypevr
13134
13135@deftypevr @code{openvpn-client-configuration} parameter key-usage verify-key-usage?
13136Whether to check the server certificate has server usage extension.
13137
13138Defaults to @samp{#t}.
13139
13140@end deftypevr
13141
13142@deftypevr @code{openvpn-client-configuration} parameter bind bind?
13143Bind to a specific local port number.
13144
13145Defaults to @samp{#f}.
13146
13147@end deftypevr
13148
13149@deftypevr @code{openvpn-client-configuration} parameter resolv-retry resolv-retry?
13150Retry resolving server address.
13151
13152Defaults to @samp{#t}.
13153
13154@end deftypevr
13155
13156@deftypevr @code{openvpn-client-configuration} parameter openvpn-remote-list remote
13157A list of remote servers to connect to.
13158
13159Defaults to @samp{()}.
13160
13161Available @code{openvpn-remote-configuration} fields are:
13162
13163@deftypevr @code{openvpn-remote-configuration} parameter string name
13164Server name.
13165
13166Defaults to @samp{"my-server"}.
13167
13168@end deftypevr
13169
13170@deftypevr @code{openvpn-remote-configuration} parameter number port
13171Port number the server listens to.
13172
13173Defaults to @samp{1194}.
13174
13175@end deftypevr
13176
13177@end deftypevr
13178@c %end of automatic openvpn-client documentation
13179
13180@c %automatically generated documentation
13181
13182Available @code{openvpn-server-configuration} fields are:
13183
13184@deftypevr @code{openvpn-server-configuration} parameter package openvpn
13185The OpenVPN package.
13186
13187@end deftypevr
13188
13189@deftypevr @code{openvpn-server-configuration} parameter string pid-file
13190The OpenVPN pid file.
13191
13192Defaults to @samp{"/var/run/openvpn/openvpn.pid"}.
13193
13194@end deftypevr
13195
13196@deftypevr @code{openvpn-server-configuration} parameter proto proto
13197The protocol (UDP or TCP) used to open a channel between clients and
13198servers.
13199
13200Defaults to @samp{udp}.
13201
13202@end deftypevr
13203
13204@deftypevr @code{openvpn-server-configuration} parameter dev dev
13205The device type used to represent the VPN connection.
13206
13207Defaults to @samp{tun}.
13208
13209@end deftypevr
13210
13211@deftypevr @code{openvpn-server-configuration} parameter string ca
13212The certificate authority to check connections against.
13213
13214Defaults to @samp{"/etc/openvpn/ca.crt"}.
13215
13216@end deftypevr
13217
13218@deftypevr @code{openvpn-server-configuration} parameter string cert
13219The certificate of the machine the daemon is running on. It should be
13220signed by the authority given in @code{ca}.
13221
13222Defaults to @samp{"/etc/openvpn/client.crt"}.
13223
13224@end deftypevr
13225
13226@deftypevr @code{openvpn-server-configuration} parameter string key
13227The key of the machine the daemon is running on. It must be the key whose
13228certificate is @code{cert}.
13229
13230Defaults to @samp{"/etc/openvpn/client.key"}.
13231
13232@end deftypevr
13233
13234@deftypevr @code{openvpn-server-configuration} parameter boolean comp-lzo?
13235Whether to use the lzo compression algorithm.
13236
13237Defaults to @samp{#t}.
13238
13239@end deftypevr
13240
13241@deftypevr @code{openvpn-server-configuration} parameter boolean persist-key?
13242Don't re-read key files across SIGUSR1 or --ping-restart.
13243
13244Defaults to @samp{#t}.
13245
13246@end deftypevr
13247
13248@deftypevr @code{openvpn-server-configuration} parameter boolean persist-tun?
13249Don't close and reopen TUN/TAP device or run up/down scripts across
13250SIGUSR1 or --ping-restart restarts.
13251
13252Defaults to @samp{#t}.
13253
13254@end deftypevr
13255
13256@deftypevr @code{openvpn-server-configuration} parameter number verbosity
13257Verbosity level.
13258
13259Defaults to @samp{3}.
13260
13261@end deftypevr
13262
13263@deftypevr @code{openvpn-server-configuration} parameter tls-auth-server tls-auth
13264Add an additional layer of HMAC authentication on top of the TLS control
13265channel to protect against DoS attacks.
13266
13267Defaults to @samp{#f}.
13268
13269@end deftypevr
13270
13271@deftypevr @code{openvpn-server-configuration} parameter number port
13272Specifies the port number on which the server listens.
13273
13274Defaults to @samp{1194}.
13275
13276@end deftypevr
13277
13278@deftypevr @code{openvpn-server-configuration} parameter ip-mask server
13279An ip and mask specifying the subnet inside the virtual network.
13280
13281Defaults to @samp{"10.8.0.0 255.255.255.0"}.
13282
13283@end deftypevr
13284
13285@deftypevr @code{openvpn-server-configuration} parameter cidr6 server-ipv6
13286A CIDR notation specifying the IPv6 subnet inside the virtual network.
13287
13288Defaults to @samp{#f}.
13289
13290@end deftypevr
13291
13292@deftypevr @code{openvpn-server-configuration} parameter string dh
13293The Diffie-Hellman parameters file.
13294
13295Defaults to @samp{"/etc/openvpn/dh2048.pem"}.
13296
13297@end deftypevr
13298
13299@deftypevr @code{openvpn-server-configuration} parameter string ifconfig-pool-persist
13300The file that records client IPs.
13301
13302Defaults to @samp{"/etc/openvpn/ipp.txt"}.
13303
13304@end deftypevr
13305
13306@deftypevr @code{openvpn-server-configuration} parameter gateway redirect-gateway?
13307When true, the server will act as a gateway for its clients.
13308
13309Defaults to @samp{#f}.
13310
13311@end deftypevr
13312
13313@deftypevr @code{openvpn-server-configuration} parameter boolean client-to-client?
13314When true, clients are alowed to talk to each other inside the VPN.
13315
13316Defaults to @samp{#f}.
13317
13318@end deftypevr
13319
13320@deftypevr @code{openvpn-server-configuration} parameter keepalive keepalive
13321Causes ping-like messages to be sent back and forth over the link so
13322that each side knows when the other side has gone down. @code{keepalive}
13323requires a pair. The first element is the period of the ping sending,
13324and the second element is the timeout before considering the other side
13325down.
13326
13327@end deftypevr
13328
13329@deftypevr @code{openvpn-server-configuration} parameter number max-clients
13330The maximum number of clients.
13331
13332Defaults to @samp{100}.
13333
13334@end deftypevr
13335
13336@deftypevr @code{openvpn-server-configuration} parameter string status
13337The status file. This file shows a small report on current connection.
13338It is trunkated and rewritten every minute.
13339
13340Defaults to @samp{"/var/run/openvpn/status"}.
13341
13342@end deftypevr
13343
13344@deftypevr @code{openvpn-server-configuration} parameter openvpn-ccd-list client-config-dir
13345The list of configuration for some clients.
13346
13347Defaults to @samp{()}.
13348
13349Available @code{openvpn-ccd-configuration} fields are:
13350
13351@deftypevr @code{openvpn-ccd-configuration} parameter string name
13352Client name.
13353
13354Defaults to @samp{"client"}.
13355
13356@end deftypevr
13357
13358@deftypevr @code{openvpn-ccd-configuration} parameter ip-mask iroute
13359Client own network
13360
13361Defaults to @samp{#f}.
13362
13363@end deftypevr
13364
13365@deftypevr @code{openvpn-ccd-configuration} parameter ip-mask ifconfig-push
13366Client VPN IP.
13367
13368Defaults to @samp{#f}.
13369
13370@end deftypevr
13371
13372@end deftypevr
13373
13374
13375@c %end of automatic openvpn-server documentation
13376
13377
cb341293
CB
13378@deftp {Data Type} nginx-upstream-configuration
13379Data type representing the configuration of an nginx @code{upstream}
13380block. This type has the following parameters:
13381
13382@table @asis
13383@item @code{name}
13384Name for this group of servers.
13385
13386@item @code{servers}
13387Specify the addresses of the servers in the group. The address can be
13388specified as a IP address (e.g. @samp{127.0.0.1}), domain name
13389(e.g. @samp{backend1.example.com}) or a path to a UNIX socket using the
13390prefix @samp{unix:}. For addresses using an IP address or domain name,
13391the default port is 80, and a different port can be specified
13392explicitly.
13393
13394@end table
13395@end deftp
13396
9c557a69
CB
13397@deftp {Data Type} nginx-location-configuration
13398Data type representing the configuration of an nginx @code{location}
13399block. This type has the following parameters:
13400
13401@table @asis
13402@item @code{uri}
13403URI which this location block matches.
13404
13405@anchor{nginx-location-configuration body}
13406@item @code{body}
13407Body of the location block, specified as a string. This can contain many
13408configuration directives. For example, to pass requests to a upstream
13409server group defined using an @code{nginx-upstream-configuration} block,
13410the following directive would be specified in the body @samp{proxy_pass
13411http://upstream-name;}.
13412
13413@end table
13414@end deftp
13415
13416@deftp {Data Type} nginx-named-location-configuration
13417Data type representing the configuration of an nginx named location
13418block. Named location blocks are used for request redirection, and not
13419used for regular request processing. This type has the following
13420parameters:
13421
13422@table @asis
13423@item @code{name}
13424Name to identify this location block.
13425
13426@item @code{body}
13427@xref{nginx-location-configuration body}, as the body for named location
13428blocks can be used in a similar way to the
13429@code{nginx-location-configuration body}. One restriction is that the
13430body of a named location block cannot contain location blocks.
13431
13432@end table
13433@end deftp
13434
eb419bc9
JD
13435@node Network File System
13436@subsubsection Network File System
13437@cindex NFS
fe1a39d3 13438
eb419bc9
JD
13439The @code{(gnu services nfs)} module provides the following services,
13440which are most commonly used in relation to mounting or exporting
13441directory trees as @dfn{network file systems} (NFS).
d6a07ee6
JD
13442
13443@subsubheading RPC Bind Service
13444@cindex rpcbind
13445
eb419bc9
JD
13446The RPC Bind service provides a facility to map program numbers into
13447universal addresses.
13448Many NFS related services use this facility. Hence it is automatically
13449started when a dependent service starts.
d6a07ee6
JD
13450
13451@defvr {Scheme Variable} rpcbind-service-type
13452A service type for the RPC portmapper daemon.
13453@end defvr
13454
13455
13456@deftp {Data Type} rpcbind-configuration
13457Data type representing the configuration of the RPC Bind Service.
13458This type has the following parameters:
13459@table @asis
13460@item @code{rpcbind} (default: @code{rpcbind})
13461The rpcbind package to use.
13462
13463@item @code{warm-start?} (default: @code{#t})
13464If this parameter is @code{#t}, then the daemon will read a
13465state file on startup thus reloading state information saved by a previous
13466instance.
13467@end table
13468@end deftp
13469
eb419bc9
JD
13470
13471@subsubheading Pipefs Pseudo File System
13472@cindex pipefs
13473@cindex rpc_pipefs
13474
13475The pipefs file system is used to transfer NFS related data
13476between the kernel and user space programs.
13477
13478@defvr {Scheme Variable} pipefs-service-type
13479A service type for the pipefs pseudo file system.
13480@end defvr
13481
13482@deftp {Data Type} pipefs-configuration
13483Data type representing the configuration of the pipefs pseudo file system service.
13484This type has the following parameters:
13485@table @asis
13486@item @code{mount-point} (default: @code{"/var/lib/nfs/rpc_pipefs"})
13487The directory to which the file system is to be attached.
13488@end table
13489@end deftp
13490
13491
13492@subsubheading GSS Daemon Service
13493@cindex GSSD
13494@cindex GSS
13495@cindex global security system
13496
13497The @dfn{global security system} (GSS) daemon provides strong security for RPC
13498based protocols.
13499Before exchanging RPC requests an RPC client must establish a security
13500context. Typically this is done using the Kerberos command @command{kinit}
859e367d 13501or automatically at login time using PAM services (@pxref{Kerberos Services}).
eb419bc9
JD
13502
13503@defvr {Scheme Variable} gss-service-type
13504A service type for the Global Security System (GSS) daemon.
13505@end defvr
13506
13507@deftp {Data Type} gss-configuration
13508Data type representing the configuration of the GSS daemon service.
13509This type has the following parameters:
13510@table @asis
13511@item @code{nfs-utils} (default: @code{nfs-utils})
13512The package in which the @command{rpc.gssd} command is to be found.
13513
13514@item @code{pipefs-directory} (default: @code{"/var/lib/nfs/rpc_pipefs"})
13515The directory where the pipefs file system is mounted.
13516
13517@end table
13518@end deftp
13519
13520
13521@subsubheading IDMAP Daemon Service
13522@cindex idmapd
13523@cindex name mapper
13524
13525The idmap daemon service provides mapping between user IDs and user names.
13526Typically it is required in order to access file systems mounted via NFSv4.
13527
13528@defvr {Scheme Variable} idmap-service-type
13529A service type for the Identity Mapper (IDMAP) daemon.
13530@end defvr
13531
13532@deftp {Data Type} idmap-configuration
13533Data type representing the configuration of the IDMAP daemon service.
13534This type has the following parameters:
13535@table @asis
13536@item @code{nfs-utils} (default: @code{nfs-utils})
13537The package in which the @command{rpc.idmapd} command is to be found.
13538
13539@item @code{pipefs-directory} (default: @code{"/var/lib/nfs/rpc_pipefs"})
13540The directory where the pipefs file system is mounted.
13541
13542@item @code{domain} (default: @code{#f})
13543The local NFSv4 domain name.
13544This must be a string or @code{#f}.
13545If it is @code{#f} then the daemon will use the host's fully qualified domain name.
13546
13547@end table
13548@end deftp
13549
a7cf4eb6
ML
13550@node Continuous Integration
13551@subsubsection Continuous Integration
13552
13553@cindex continuous integration
13554@uref{https://notabug.org/mthl/cuirass, Cuirass} is a continuous
13555integration tool for Guix. It can be used both for development and for
13556providing substitutes to others (@pxref{Substitutes}).
13557
13558The @code{(gnu services cuirass)} module provides the following service.
13559
231eddc8
LC
13560@defvr {Scheme Procedure} cuirass-service-type
13561The type of the Cuirass service. Its value must be a
13562@code{cuirass-configuration} object, as described below.
13563@end defvr
a7cf4eb6 13564
231eddc8
LC
13565To add build jobs, you have to set the @code{specifications} field of
13566the configuration. Here is an example of a service defining a build job
13567based on a specification that can be found in Cuirass source tree. This
13568service polls the Guix repository and builds a subset of the Guix
13569packages, as prescribed in the @file{gnu-system.scm} example spec:
a7cf4eb6
ML
13570
13571@example
8de938d5
LC
13572(let ((spec #~((#:name . "guix")
13573 (#:url . "git://git.savannah.gnu.org/guix.git")
13574 (#:load-path . ".")
13575
13576 ;; Here we must provide an absolute file name.
13577 ;; We take jobs from one of the examples provided
13578 ;; by Cuirass.
13579 (#:file . #$(file-append
13580 cuirass
13581 "/tests/gnu-system.scm"))
13582
13583 (#:proc . hydra-jobs)
13584 (#:arguments (subset . "hello"))
13585 (#:branch . "master"))))
231eddc8
LC
13586 (service cuirass-service-type
13587 (cuirass-configuration
13588 (specifications #~(list #$spec)))))
a7cf4eb6
ML
13589@end example
13590
231eddc8 13591While information related to build jobs is located directly in the
a7cf4eb6
ML
13592specifications, global settings for the @command{cuirass} process are
13593accessible in other @code{cuirass-configuration} fields.
13594
13595@deftp {Data Type} cuirass-configuration
13596Data type representing the configuration of Cuirass.
13597
13598@table @asis
b17e326f
LC
13599@item @code{log-file} (default: @code{"/var/log/cuirass.log"})
13600Location of the log file.
13601
463995da 13602@item @code{cache-directory} (default: @code{"/var/cache/cuirass"})
a7cf4eb6
ML
13603Location of the repository cache.
13604
13605@item @code{user} (default: @code{"cuirass"})
13606Owner of the @code{cuirass} process.
13607
13608@item @code{group} (default: @code{"cuirass"})
13609Owner's group of the @code{cuirass} process.
13610
13611@item @code{interval} (default: @code{60})
13612Number of seconds between the poll of the repositories followed by the
13613Cuirass jobs.
13614
13615@item @code{database} (default: @code{"/var/run/cuirass/cuirass.db"})
13616Location of sqlite database which contains the build results and previously
13617added specifications.
13618
11b7717d
MO
13619@item @code{port} (default: @code{8080})
13620Port number used by the HTTP server.
13621
8de938d5
LC
13622@item @code{specifications} (default: @code{#~'()})
13623A gexp (@pxref{G-Expressions}) that evaluates to a list of specifications,
13624where a specification is an association list
a7cf4eb6
ML
13625(@pxref{Associations Lists,,, guile, GNU Guile Reference Manual}) whose
13626keys are keywords (@code{#:keyword-example}) as shown in the example
13627above.
13628
13629@item @code{use-substitutes?} (default: @code{#f})
13630This allows using substitutes to avoid building every dependencies of a job
13631from source.
13632
13633@item @code{one-shot?} (default: @code{#f})
13634Only evaluate specifications and build derivations once.
379b6ba5 13635
eb122280
MO
13636@item @code{load-path} (default: @code{'()})
13637This allows users to define their own packages and make them visible to
13638cuirass as in @command{guix build} command.
13639
379b6ba5
LC
13640@item @code{cuirass} (default: @code{cuirass})
13641The Cuirass package to use.
a7cf4eb6
ML
13642@end table
13643@end deftp
eb419bc9
JD
13644
13645@node Miscellaneous Services
13646@subsubsection Miscellaneous Services
13647
13648
8ff4dcbe
DC
13649@cindex lirc
13650@subsubheading Lirc Service
13651
fe1a39d3
LC
13652The @code{(gnu services lirc)} module provides the following service.
13653
be1c2c54 13654@deffn {Scheme Procedure} lirc-service [#:lirc lirc] @
fe1a39d3
LC
13655 [#:device #f] [#:driver #f] [#:config-file #f] @
13656 [#:extra-options '()]
13657Return a service that runs @url{http://www.lirc.org,LIRC}, a daemon that
13658decodes infrared signals from remote controls.
13659
13660Optionally, @var{device}, @var{driver} and @var{config-file}
13661(configuration file name) may be specified. See @command{lircd} manual
13662for details.
13663
13664Finally, @var{extra-options} is a list of additional command-line options
13665passed to @command{lircd}.
13666@end deffn
13667
00f46905
DC
13668@cindex spice
13669@subsubheading Spice Service
13670
13671The @code{(gnu services spice)} module provides the following service.
13672
13673@deffn {Scheme Procedure} spice-vdagent-service [#:spice-vdagent]
13674Returns a service that runs @url{http://www.spice-space.org,VDAGENT}, a daemon
13675that enables sharing the clipboard with a vm and setting the guest display
13676resolution when the graphical console window resizes.
13677@end deffn
13678
c3d38b2b 13679@subsubsection Dictionary Services
e32171ee 13680@cindex dictionary
c3d38b2b
SB
13681The @code{(gnu services dict)} module provides the following service:
13682
13683@deffn {Scheme Procedure} dicod-service [#:config (dicod-configuration)]
13684Return a service that runs the @command{dicod} daemon, an implementation
13685of DICT server (@pxref{Dicod,,, dico, GNU Dico Manual}).
13686
13687The optional @var{config} argument specifies the configuration for
13688@command{dicod}, which should be a @code{<dicod-configuration>} object, by
13689default it serves the GNU Collaborative International Dictonary of English.
13690
13691You can add @command{open localhost} to your @file{~/.dico} file to make
13692@code{localhost} the default server for @command{dico} client
13693(@pxref{Initialization File,,, dico, GNU Dico Manual}).
13694@end deffn
13695
13696@deftp {Data Type} dicod-configuration
13697Data type representing the configuration of dicod.
13698
13699@table @asis
13700@item @code{dico} (default: @var{dico})
13701Package object of the GNU Dico dictionary server.
13702
a1b48465
LC
13703@item @code{interfaces} (default: @var{'("localhost")})
13704This is the list of IP addresses and ports and possibly socket file
13705names to listen to (@pxref{Server Settings, @code{listen} directive,,
13706dico, GNU Dico Manual}).
13707
c3d38b2b
SB
13708@item @code{databases} (default: @var{(list %dicod-database:gcide)})
13709List of @code{<dicod-database>} objects denoting dictionaries to be served.
13710@end table
13711@end deftp
13712
13713@deftp {Data Type} dicod-database
13714Data type representing a dictionary database.
13715
13716@table @asis
13717@item @code{name}
13718Name of the database, will be used in DICT commands.
13719
13720@item @code{module}
13721Name of the dicod module used by this database
13722(@pxref{Modules,,, dico, GNU Dico Manual}).
13723
13724@item @code{options}
13725List of strings or gexps representing the arguments for the module handler
13726(@pxref{Handlers,,, dico, GNU Dico Manual}).
13727@end table
13728@end deftp
13729
13730@defvr {Scheme Variable} %dicod-database:gcide
13731A @code{<dicod-database>} object serving the GNU Collaborative International
13732Dictonary of English using the @code{gcide} package.
13733@end defvr
fe1a39d3 13734
e01e2c6c 13735@subsubsection Version Control
13736
13737The @code{(gnu services version-control)} module provides the following services:
13738
13739@subsubheading Git daemon service
13740
13741@deffn {Scheme Procedure} git-daemon-service [#:config (git-daemon-configuration)]
13742
13743Return a service that runs @command{git daemon}, a simple TCP server to
13744expose repositiories over the Git protocol for annoymous access.
13745
13746The optional @var{config} argument should be a
13747@code{<git-daemon-configuration>} object, by default it allows read-only
13748access to exported@footnote{By creating the magic file
13749"git-daemon-export-ok" in the repository directory.} repositories under
13750@file{/srv/git}.
13751
13752@end deffn
13753
13754@deftp {Data Type} git-daemon-configuration
13755Data type representing the configuration for @code{git-daemon-service}.
13756
13757@table @asis
13758@item @code{package} (default: @var{git})
13759Package object of the Git distributed version control system.
13760
13761@item @code{export-all?} (default: @var{#f})
13762Whether to allow access for all Git repositories, even if they do not
13763have the @file{git-daemon-export-ok} file.
13764
13765@item @code{base-path} (default: @file{/srv/git})
13766Whether to remap all the path requests as relative to the given path.
13767If you run git daemon with @var{(base-path "/srv/git")} on example.com,
13768then if you later try to pull @code{git://example.com/hello.git}, git
13769daemon will interpret the path as @code{/srv/git/hello.git}.
13770
13771@item @code{user-path} (default: @var{#f})
13772Whether to allow @code{~user} notation to be used in requests. When
13773specified with empty string, requests to @code{git://host/~alice/foo} is
13774taken as a request to access @code{foo} repository in the home directory
13775of user @code{alice}. If @var{(user-path "path")} is specified, the
13776same request is taken as a request to access @code{path/foo} repository
13777in the home directory of user @code{alice}.
13778
13779@item @code{listen} (default: @var{'()})
13780Whether to listen on specific IP addresses or hostnames, defaults to
13781all.
13782
13783@item @code{port} (default: @var{#f})
13784Whether to listen on an alternative port, which defaults to 9418.
13785
13786@item @code{whitelist} (default: @var{'()})
13787If not empty, only allow access to this list of directories.
13788
13789@item @code{extra-options} (default: @var{'()})
13790Extra options will be passed to @code{git daemon}, please run
13791@command{man git-daemon} for more information.
13792
13793@end table
13794@end deftp
13795
0ae8c15a
LC
13796@node Setuid Programs
13797@subsection Setuid Programs
13798
13799@cindex setuid programs
13800Some programs need to run with ``root'' privileges, even when they are
13801launched by unprivileged users. A notorious example is the
4d40227c
LC
13802@command{passwd} program, which users can run to change their
13803password, and which needs to access the @file{/etc/passwd} and
0ae8c15a
LC
13804@file{/etc/shadow} files---something normally restricted to root, for
13805obvious security reasons. To address that, these executables are
13806@dfn{setuid-root}, meaning that they always run with root privileges
13807(@pxref{How Change Persona,,, libc, The GNU C Library Reference Manual},
f7e4ae7f 13808for more info about the setuid mechanism.)
0ae8c15a
LC
13809
13810The store itself @emph{cannot} contain setuid programs: that would be a
13811security issue since any user on the system can write derivations that
13812populate the store (@pxref{The Store}). Thus, a different mechanism is
13813used: instead of changing the setuid bit directly on files that are in
13814the store, we let the system administrator @emph{declare} which programs
13815should be setuid root.
13816
13817The @code{setuid-programs} field of an @code{operating-system}
13818declaration contains a list of G-expressions denoting the names of
13819programs to be setuid-root (@pxref{Using the Configuration System}).
13820For instance, the @command{passwd} program, which is part of the Shadow
13821package, can be designated by this G-expression (@pxref{G-Expressions}):
13822
13823@example
13824#~(string-append #$shadow "/bin/passwd")
13825@end example
13826
13827A default set of setuid programs is defined by the
13828@code{%setuid-programs} variable of the @code{(gnu system)} module.
13829
13830@defvr {Scheme Variable} %setuid-programs
13831A list of G-expressions denoting common programs that are setuid-root.
13832
13833The list includes commands such as @command{passwd}, @command{ping},
13834@command{su}, and @command{sudo}.
13835@end defvr
13836
13837Under the hood, the actual setuid programs are created in the
13838@file{/run/setuid-programs} directory at system activation time. The
13839files in this directory refer to the ``real'' binaries, which are in the
13840store.
13841
efb5e833
LC
13842@node X.509 Certificates
13843@subsection X.509 Certificates
13844
13845@cindex HTTPS, certificates
13846@cindex X.509 certificates
13847@cindex TLS
13848Web servers available over HTTPS (that is, HTTP over the transport-layer
13849security mechanism, TLS) send client programs an @dfn{X.509 certificate}
13850that the client can then use to @emph{authenticate} the server. To do
13851that, clients verify that the server's certificate is signed by a
13852so-called @dfn{certificate authority} (CA). But to verify the CA's
13853signature, clients must have first acquired the CA's certificate.
13854
13855Web browsers such as GNU@tie{}IceCat include their own set of CA
13856certificates, such that they are able to verify CA signatures
13857out-of-the-box.
13858
13859However, most other programs that can talk HTTPS---@command{wget},
13860@command{git}, @command{w3m}, etc.---need to be told where CA
13861certificates can be found.
13862
13863@cindex @code{nss-certs}
13864In GuixSD, this is done by adding a package that provides certificates
13865to the @code{packages} field of the @code{operating-system} declaration
13866(@pxref{operating-system Reference}). GuixSD includes one such package,
13867@code{nss-certs}, which is a set of CA certificates provided as part of
13868Mozilla's Network Security Services.
13869
13870Note that it is @emph{not} part of @var{%base-packages}, so you need to
13871explicitly add it. The @file{/etc/ssl/certs} directory, which is where
13872most applications and libraries look for certificates by default, points
13873to the certificates installed globally.
13874
b3129f2b
LC
13875Unprivileged users, including users of Guix on a foreign distro,
13876can also install their own certificate package in
efb5e833
LC
13877their profile. A number of environment variables need to be defined so
13878that applications and libraries know where to find them. Namely, the
13879OpenSSL library honors the @code{SSL_CERT_DIR} and @code{SSL_CERT_FILE}
13880variables. Some applications add their own environment variables; for
13881instance, the Git version control system honors the certificate bundle
b3129f2b
LC
13882pointed to by the @code{GIT_SSL_CAINFO} environment variable. Thus, you
13883would typically run something like:
efb5e833 13884
b3129f2b
LC
13885@example
13886$ guix package -i nss-certs
13887$ export SSL_CERT_DIR="$HOME/.guix-profile/etc/ssl/certs"
13888$ export SSL_CERT_FILE="$HOME/.guix-profile/etc/ssl/certs/ca-certificates.crt"
13889$ export GIT_SSL_CAINFO="$SSL_CERT_FILE"
13890@end example
efb5e833 13891
996ed739
LC
13892@node Name Service Switch
13893@subsection Name Service Switch
13894
13895@cindex name service switch
13896@cindex NSS
13897The @code{(gnu system nss)} module provides bindings to the
1068f26b 13898configuration file of the libc @dfn{name service switch} or @dfn{NSS}
996ed739
LC
13899(@pxref{NSS Configuration File,,, libc, The GNU C Library Reference
13900Manual}). In a nutshell, the NSS is a mechanism that allows libc to be
13901extended with new ``name'' lookup methods for system databases, which
13902includes host names, service names, user accounts, and more (@pxref{Name
13903Service Switch, System Databases and Name Service Switch,, libc, The GNU
13904C Library Reference Manual}).
13905
13906The NSS configuration specifies, for each system database, which lookup
13907method is to be used, and how the various methods are chained
13908together---for instance, under which circumstances NSS should try the
13909next method in the list. The NSS configuration is given in the
13910@code{name-service-switch} field of @code{operating-system} declarations
13911(@pxref{operating-system Reference, @code{name-service-switch}}).
13912
4c9050c6
LC
13913@cindex nss-mdns
13914@cindex .local, host name lookup
996ed739 13915As an example, the declaration below configures the NSS to use the
4c9050c6
LC
13916@uref{http://0pointer.de/lennart/projects/nss-mdns/, @code{nss-mdns}
13917back-end}, which supports host name lookups over multicast DNS (mDNS)
13918for host names ending in @code{.local}:
996ed739
LC
13919
13920@example
13921(name-service-switch
13922 (hosts (list %files ;first, check /etc/hosts
13923
13924 ;; If the above did not succeed, try
13925 ;; with 'mdns_minimal'.
13926 (name-service
13927 (name "mdns_minimal")
13928
13929 ;; 'mdns_minimal' is authoritative for
13930 ;; '.local'. When it returns "not found",
13931 ;; no need to try the next methods.
13932 (reaction (lookup-specification
13933 (not-found => return))))
13934
13935 ;; Then fall back to DNS.
13936 (name-service
13937 (name "dns"))
13938
13939 ;; Finally, try with the "full" 'mdns'.
13940 (name-service
13941 (name "mdns")))))
13942@end example
13943
1068f26b
AE
13944Do not worry: the @code{%mdns-host-lookup-nss} variable (see below)
13945contains this configuration, so you will not have to type it if all you
15137a29
LC
13946want is to have @code{.local} host lookup working.
13947
4c9050c6
LC
13948Note that, in this case, in addition to setting the
13949@code{name-service-switch} of the @code{operating-system} declaration,
cc9c1f39
LC
13950you also need to use @code{avahi-service} (@pxref{Networking Services,
13951@code{avahi-service}}), or @var{%desktop-services}, which includes it
13952(@pxref{Desktop Services}). Doing this makes @code{nss-mdns} accessible
13953to the name service cache daemon (@pxref{Base Services,
13954@code{nscd-service}}).
15137a29
LC
13955
13956For convenience, the following variables provide typical NSS
13957configurations.
13958
13959@defvr {Scheme Variable} %default-nss
13960This is the default name service switch configuration, a
13961@code{name-service-switch} object.
13962@end defvr
13963
13964@defvr {Scheme Variable} %mdns-host-lookup-nss
13965This is the name service switch configuration with support for host name
13966lookup over multicast DNS (mDNS) for host names ending in @code{.local}.
13967@end defvr
4c9050c6 13968
996ed739 13969The reference for name service switch configuration is given below. It
1068f26b 13970is a direct mapping of the configuration file format of the C library , so
996ed739
LC
13971please refer to the C library manual for more information (@pxref{NSS
13972Configuration File,,, libc, The GNU C Library Reference Manual}).
1068f26b 13973Compared to the configuration file format of libc NSS, it has the advantage
996ed739 13974not only of adding this warm parenthetic feel that we like, but also
1068f26b 13975static checks: you will know about syntax errors and typos as soon as you
996ed739
LC
13976run @command{guix system}.
13977
996ed739
LC
13978@deftp {Data Type} name-service-switch
13979
13980This is the data type representation the configuration of libc's name
13981service switch (NSS). Each field below represents one of the supported
13982system databases.
13983
13984@table @code
13985@item aliases
13986@itemx ethers
13987@itemx group
13988@itemx gshadow
13989@itemx hosts
13990@itemx initgroups
13991@itemx netgroup
13992@itemx networks
13993@itemx password
13994@itemx public-key
13995@itemx rpc
13996@itemx services
13997@itemx shadow
13998The system databases handled by the NSS. Each of these fields must be a
1068f26b 13999list of @code{<name-service>} objects (see below).
996ed739
LC
14000@end table
14001@end deftp
14002
14003@deftp {Data Type} name-service
14004
14005This is the data type representing an actual name service and the
14006associated lookup action.
14007
14008@table @code
14009@item name
14010A string denoting the name service (@pxref{Services in the NSS
14011configuration,,, libc, The GNU C Library Reference Manual}).
14012
4aee6e60
LC
14013Note that name services listed here must be visible to nscd. This is
14014achieved by passing the @code{#:name-services} argument to
14015@code{nscd-service} the list of packages providing the needed name
14016services (@pxref{Base Services, @code{nscd-service}}).
14017
996ed739
LC
14018@item reaction
14019An action specified using the @code{lookup-specification} macro
14020(@pxref{Actions in the NSS configuration,,, libc, The GNU C Library
14021Reference Manual}). For example:
14022
14023@example
14024(lookup-specification (unavailable => continue)
14025 (success => return))
14026@end example
14027@end table
14028@end deftp
0ae8c15a 14029
fd1b1fa2
LC
14030@node Initial RAM Disk
14031@subsection Initial RAM Disk
14032
e32171ee
JD
14033@cindex initrd
14034@cindex initial RAM disk
fd1b1fa2
LC
14035For bootstrapping purposes, the Linux-Libre kernel is passed an
14036@dfn{initial RAM disk}, or @dfn{initrd}. An initrd contains a temporary
1068f26b 14037root file system as well as an initialization script. The latter is
fd1b1fa2
LC
14038responsible for mounting the real root file system, and for loading any
14039kernel modules that may be needed to achieve that.
14040
14041The @code{initrd} field of an @code{operating-system} declaration allows
14042you to specify which initrd you would like to use. The @code{(gnu
47bdc5a1
MO
14043system linux-initrd)} module provides three ways to build an initrd: the
14044high-level @code{base-initrd} procedure and the low-level
14045@code{raw-initrd} and @code{expression->initrd} procedures.
fd1b1fa2
LC
14046
14047The @code{base-initrd} procedure is intended to cover most common uses.
14048For example, if you want to add a bunch of kernel modules to be loaded
14049at boot time, you can define the @code{initrd} field of the operating
14050system declaration like this:
14051
14052@example
52ac153e 14053(initrd (lambda (file-systems . rest)
027981d6
LC
14054 ;; Create a standard initrd that has modules "foo.ko"
14055 ;; and "bar.ko", as well as their dependencies, in
14056 ;; addition to the modules available by default.
52ac153e 14057 (apply base-initrd file-systems
027981d6 14058 #:extra-modules '("foo" "bar")
52ac153e 14059 rest)))
fd1b1fa2
LC
14060@end example
14061
52ac153e 14062The @code{base-initrd} procedure also handles common use cases that
1068f26b
AE
14063involves using the system as a QEMU guest, or as a ``live'' system with
14064volatile root file system.
fd1b1fa2 14065
47bdc5a1
MO
14066The @code{base-initrd} procedure is built from @code{raw-initrd} procedure.
14067Unlike @code{base-initrd}, @code{raw-initrd} doesn't do anything high-level,
14068such as trying to guess which kernel modules and packages should be included
14069to the initrd. An example use of @code{raw-initrd} is when a user has
14070a custom Linux kernel configuration and default kernel modules included by
14071@code{base-initrd} are not available.
14072
14073The initial RAM disk produced by @code{base-initrd} or @code{raw-initrd}
14074honors several options passed on the Linux kernel command line
14075(that is, arguments passed @i{via} the @code{linux} command of GRUB, or the
4af2fafd 14076@code{-append} option of QEMU), notably:
e90cf6c1
LC
14077
14078@table @code
14079@item --load=@var{boot}
14080Tell the initial RAM disk to load @var{boot}, a file containing a Scheme
14081program, once it has mounted the root file system.
14082
14083GuixSD uses this option to yield control to a boot program that runs the
dd17bc38 14084service activation programs and then spawns the GNU@tie{}Shepherd, the
e90cf6c1
LC
14085initialization system.
14086
14087@item --root=@var{root}
1068f26b 14088Mount @var{root} as the root file system. @var{root} can be a
e90cf6c1
LC
14089device name like @code{/dev/sda1}, a partition label, or a partition
14090UUID.
14091
14092@item --system=@var{system}
14093Have @file{/run/booted-system} and @file{/run/current-system} point to
14094@var{system}.
14095
14096@item modprobe.blacklist=@var{modules}@dots{}
14097@cindex module, black-listing
14098@cindex black list, of kernel modules
14099Instruct the initial RAM disk as well as the @command{modprobe} command
14100(from the kmod package) to refuse to load @var{modules}. @var{modules}
14101must be a comma-separated list of module names---e.g.,
14102@code{usbkbd,9pnet}.
14103
14104@item --repl
14105Start a read-eval-print loop (REPL) from the initial RAM disk before it
14106tries to load kernel modules and to mount the root file system. Our
14107marketing team calls it @dfn{boot-to-Guile}. The Schemer in you will
14108love it. @xref{Using Guile Interactively,,, guile, GNU Guile Reference
14109Manual}, for more information on Guile's REPL.
14110
14111@end table
14112
14113Now that you know all the features that initial RAM disks produced by
47bdc5a1
MO
14114@code{base-initrd} and @code{raw-initrd} provide,
14115here is how to use it and customize it further.
e90cf6c1 14116
e32171ee
JD
14117@cindex initrd
14118@cindex initial RAM disk
47bdc5a1
MO
14119@deffn {Monadic Procedure} raw-initrd @var{file-systems} @
14120 [#:linux-modules '()] [#:mapped-devices '()] @
14121 [#:helper-packages '()] [#:qemu-networking? #f] [#:volatile-root? #f]
14122Return a monadic derivation that builds a raw initrd. @var{file-systems} is
1068f26b 14123a list of file systems to be mounted by the initrd, possibly in addition to
fd1b1fa2 14124the root file system specified on the kernel command line via @code{--root}.
47bdc5a1 14125@var{linux-modules} is a list of kernel modules to be loaded at boot time.
52ac153e
LC
14126@var{mapped-devices} is a list of device mappings to realize before
14127@var{file-systems} are mounted (@pxref{Mapped Devices}).
47bdc5a1
MO
14128@var{helper-packages} is a list of packages to be copied in the initrd. It may
14129include @code{e2fsck/static} or other packages needed by the initrd to check
14130root partition.
fd1b1fa2
LC
14131
14132When @var{qemu-networking?} is true, set up networking with the standard QEMU
1068f26b
AE
14133parameters. When @var{virtio?} is true, load additional modules so that the
14134initrd can be used as a QEMU guest with para-virtualized I/O drivers.
fd1b1fa2
LC
14135
14136When @var{volatile-root?} is true, the root file system is writable but any changes
14137to it are lost.
47bdc5a1
MO
14138@end deffn
14139
14140@deffn {Monadic Procedure} base-initrd @var{file-systems} @
14141 [#:mapped-devices '()] [#:qemu-networking? #f] [#:volatile-root? #f]@
14142 [#:virtio? #t] [#:extra-modules '()]
14143Return a monadic derivation that builds a generic initrd. @var{file-systems} is
14144a list of file systems to be mounted by the initrd like for @code{raw-initrd}.
14145@var{mapped-devices}, @var{qemu-networking?} and @var{volatile-root?}
14146also behaves as in @code{raw-initrd}.
14147
14148When @var{virtio?} is true, load additional modules so that the
14149initrd can be used as a QEMU guest with para-virtualized I/O drivers.
fd1b1fa2
LC
14150
14151The initrd is automatically populated with all the kernel modules necessary
14152for @var{file-systems} and for the given options. However, additional kernel
14153modules can be listed in @var{extra-modules}. They will be added to the initrd, and
14154loaded at boot time in the order in which they appear.
14155@end deffn
14156
14157Needless to say, the initrds we produce and use embed a
14158statically-linked Guile, and the initialization program is a Guile
14159program. That gives a lot of flexibility. The
14160@code{expression->initrd} procedure builds such an initrd, given the
14161program to run in that initrd.
14162
14163@deffn {Monadic Procedure} expression->initrd @var{exp} @
4ee96a79 14164 [#:guile %guile-static-stripped] [#:name "guile-initrd"]
fd1b1fa2
LC
14165Return a derivation that builds a Linux initrd (a gzipped cpio archive)
14166containing @var{guile} and that evaluates @var{exp}, a G-expression,
df650fa8
LC
14167upon booting. All the derivations referenced by @var{exp} are
14168automatically copied to the initrd.
fd1b1fa2
LC
14169@end deffn
14170
88faf933
LC
14171@node GRUB Configuration
14172@subsection GRUB Configuration
14173
14174@cindex GRUB
14175@cindex boot loader
14176
14177The operating system uses GNU@tie{}GRUB as its boot loader
14178(@pxref{Overview, overview of GRUB,, grub, GNU GRUB Manual}). It is
1068f26b
AE
14179configured using a @code{grub-configuration} declaration. This data type
14180is exported by the @code{(gnu system grub)} module and described below.
88faf933
LC
14181
14182@deftp {Data Type} grub-configuration
14183The type of a GRUB configuration declaration.
14184
14185@table @asis
14186
14187@item @code{device}
14188This is a string denoting the boot device. It must be a device name
14189understood by the @command{grub-install} command, such as
14190@code{/dev/sda} or @code{(hd0)} (@pxref{Invoking grub-install,,, grub,
14191GNU GRUB Manual}).
14192
14193@item @code{menu-entries} (default: @code{()})
14194A possibly empty list of @code{menu-entry} objects (see below), denoting
14195entries to appear in the GRUB boot menu, in addition to the current
14196system entry and the entry pointing to previous system generations.
14197
14198@item @code{default-entry} (default: @code{0})
1068f26b
AE
14199The index of the default boot menu entry. Index 0 is for the entry of the
14200current system.
88faf933
LC
14201
14202@item @code{timeout} (default: @code{5})
14203The number of seconds to wait for keyboard input before booting. Set to
142040 to boot immediately, and to -1 to wait indefinitely.
14205
14206@item @code{theme} (default: @var{%default-theme})
14207The @code{grub-theme} object describing the theme to use.
9b06f503
LC
14208
14209@item @code{grub} (default: @code{grub})
14210The GRUB package to use.
88faf933
LC
14211@end table
14212
14213@end deftp
14214
44d5f54e
LC
14215@cindex dual boot
14216@cindex boot menu
88faf933
LC
14217Should you want to list additional boot menu entries @i{via} the
14218@code{menu-entries} field above, you will need to create them with the
44d5f54e
LC
14219@code{menu-entry} form. For example, imagine you want to be able to
14220boot another distro (hard to imagine!), you can define a menu entry
14221along these lines:
14222
14223@example
14224(menu-entry
14225 (label "The Other Distro")
14226 (linux "/boot/old/vmlinux-2.6.32")
14227 (linux-arguments '("root=/dev/sda2"))
14228 (initrd "/boot/old/initrd"))
14229@end example
14230
14231Details below.
88faf933
LC
14232
14233@deftp {Data Type} menu-entry
14234The type of an entry in the GRUB boot menu.
14235
14236@table @asis
14237
14238@item @code{label}
35ed9306 14239The label to show in the menu---e.g., @code{"GNU"}.
88faf933
LC
14240
14241@item @code{linux}
44d5f54e
LC
14242The Linux kernel image to boot, for example:
14243
14244@example
14245(file-append linux-libre "/bzImage")
14246@end example
88faf933 14247
1ef8b72a
CM
14248It is also possible to specify a device explicitly in the file path
14249using GRUB's device naming convention (@pxref{Naming convention,,, grub,
14250GNU GRUB manual}), for example:
14251
14252@example
14253"(hd0,msdos1)/boot/vmlinuz"
14254@end example
14255
14256If the device is specified explicitly as above, then the @code{device}
14257field is ignored entirely.
14258
88faf933
LC
14259@item @code{linux-arguments} (default: @code{()})
14260The list of extra Linux kernel command-line arguments---e.g.,
14261@code{("console=ttyS0")}.
14262
14263@item @code{initrd}
14264A G-Expression or string denoting the file name of the initial RAM disk
14265to use (@pxref{G-Expressions}).
14266
1ef8b72a
CM
14267@item @code{device} (default: @code{#f})
14268The device where the kernel and initrd are to be found---i.e., the GRUB
14269@dfn{root} for this menu entry (@pxref{root,,, grub, GNU GRUB manual}).
14270
14271This may be a file system label (a string), a file system UUID (a
14272bytevector, @pxref{File Systems}), or @code{#f}, in which case GRUB will
14273search the device containing the file specified by the @code{linux}
14274field (@pxref{search,,, grub, GNU GRUB manual}). It must @emph{not} be
14275an OS device name such as @file{/dev/sda1}.
14276
14277@item @code{device-mount-point} (default: @code{"/"})
14278The mount point of the above device on the system. You probably do not
14279need to change the default value. GuixSD uses it to strip the prefix of
14280store file names for systems where @file{/gnu} or @file{/gnu/store} is
14281on a separate partition.
14282
88faf933
LC
14283@end table
14284@end deftp
14285
14286@c FIXME: Write documentation once it's stable.
14287Themes are created using the @code{grub-theme} form, which is not
14288documented yet.
14289
14290@defvr {Scheme Variable} %default-theme
14291This is the default GRUB theme used by the operating system, with a
14292fancy background image displaying the GNU and Guix logos.
14293@end defvr
14294
14295
cf4a9129
LC
14296@node Invoking guix system
14297@subsection Invoking @code{guix system}
0918e64a 14298
1068f26b 14299Once you have written an operating system declaration as seen in the
cf4a9129
LC
14300previous section, it can be @dfn{instantiated} using the @command{guix
14301system} command. The synopsis is:
4af2447e 14302
cf4a9129
LC
14303@example
14304guix system @var{options}@dots{} @var{action} @var{file}
14305@end example
4af2447e 14306
cf4a9129
LC
14307@var{file} must be the name of a file containing an
14308@code{operating-system} declaration. @var{action} specifies how the
a40424bd 14309operating system is instantiated. Currently the following values are
cf4a9129 14310supported:
4af2447e 14311
cf4a9129
LC
14312@table @code
14313@item reconfigure
14314Build the operating system described in @var{file}, activate it, and
8074b330
CM
14315switch to it@footnote{This action (and the related actions
14316@code{switch-generation} and @code{roll-back}) are usable only on
14317systems already running GuixSD.}.
4af2447e 14318
cf4a9129
LC
14319This effects all the configuration specified in @var{file}: user
14320accounts, system services, global package list, setuid programs, etc.
240b57f0
LC
14321The command starts system services specified in @var{file} that are not
14322currently running; if a service is currently running, it does not
1068f26b 14323attempt to upgrade it since this would not be possible without stopping it
240b57f0 14324first.
4af2447e 14325
067a2e2d
CM
14326This command creates a new generation whose number is one greater than
14327the current generation (as reported by @command{guix system
14328list-generations}). If that generation already exists, it will be
14329overwritten. This behavior mirrors that of @command{guix package}
14330(@pxref{Invoking guix package}).
14331
cf4a9129
LC
14332It also adds a GRUB menu entry for the new OS configuration, and moves
14333entries for older configurations to a submenu---unless
14334@option{--no-grub} is passed.
4af2447e 14335
240b57f0 14336@quotation Note
bf2479c7
LC
14337@c The paragraph below refers to the problem discussed at
14338@c <http://lists.gnu.org/archive/html/guix-devel/2014-08/msg00057.html>.
14339It is highly recommended to run @command{guix pull} once before you run
14340@command{guix system reconfigure} for the first time (@pxref{Invoking
14341guix pull}). Failing to do that you would see an older version of Guix
14342once @command{reconfigure} has completed.
240b57f0 14343@end quotation
bf2479c7 14344
8074b330 14345@item switch-generation
e32171ee 14346@cindex generations
8074b330
CM
14347Switch to an existing system generation. This action atomically
14348switches the system profile to the specified system generation. It also
14349rearranges the system's existing GRUB menu entries. It makes the menu
14350entry for the specified system generation the default, and it moves the
14351entries for the other generations to a submenu. The next time the
14352system boots, it will use the specified system generation.
14353
14354The target generation can be specified explicitly by its generation
14355number. For example, the following invocation would switch to system
14356generation 7:
14357
14358@example
14359guix system switch-generation 7
14360@end example
14361
14362The target generation can also be specified relative to the current
14363generation with the form @code{+N} or @code{-N}, where @code{+3} means
14364``3 generations ahead of the current generation,'' and @code{-1} means
14365``1 generation prior to the current generation.'' When specifying a
14366negative value such as @code{-1}, you must precede it with @code{--} to
14367prevent it from being parsed as an option. For example:
14368
14369@example
14370guix system switch-generation -- -1
14371@end example
14372
14373Currently, the effect of invoking this action is @emph{only} to switch
14374the system profile to an existing generation and rearrange the GRUB menu
14375entries. To actually start using the target system generation, you must
14376reboot after running this action. In the future, it will be updated to
14377do the same things as @command{reconfigure}, like activating and
14378deactivating services.
14379
14380This action will fail if the specified generation does not exist.
14381
14382@item roll-back
e32171ee 14383@cindex rolling back
8074b330
CM
14384Switch to the preceding system generation. The next time the system
14385boots, it will use the preceding system generation. This is the inverse
14386of @command{reconfigure}, and it is exactly the same as invoking
14387@command{switch-generation} with an argument of @code{-1}.
14388
14389Currently, as with @command{switch-generation}, you must reboot after
14390running this action to actually start using the preceding system
14391generation.
14392
cf4a9129 14393@item build
1068f26b 14394Build the derivation of the operating system, which includes all the
cf4a9129
LC
14395configuration files and programs needed to boot and run the system.
14396This action does not actually install anything.
113daf62 14397
cf4a9129
LC
14398@item init
14399Populate the given directory with all the files necessary to run the
14400operating system specified in @var{file}. This is useful for first-time
4705641f 14401installations of GuixSD. For instance:
113daf62
LC
14402
14403@example
cf4a9129 14404guix system init my-os-config.scm /mnt
113daf62
LC
14405@end example
14406
cf4a9129
LC
14407copies to @file{/mnt} all the store items required by the configuration
14408specified in @file{my-os-config.scm}. This includes configuration
14409files, packages, and so on. It also creates other essential files
14410needed for the system to operate correctly---e.g., the @file{/etc},
14411@file{/var}, and @file{/run} directories, and the @file{/bin/sh} file.
113daf62 14412
cf4a9129
LC
14413This command also installs GRUB on the device specified in
14414@file{my-os-config}, unless the @option{--no-grub} option was passed.
113daf62 14415
cf4a9129
LC
14416@item vm
14417@cindex virtual machine
0276f697 14418@cindex VM
f535dcbe 14419@anchor{guix system vm}
1068f26b 14420Build a virtual machine that contains the operating system declared in
cf4a9129 14421@var{file}, and return a script to run that virtual machine (VM).
1068f26b 14422Arguments given to the script are passed to QEMU.
113daf62 14423
cf4a9129 14424The VM shares its store with the host system.
113daf62 14425
0276f697
LC
14426Additional file systems can be shared between the host and the VM using
14427the @code{--share} and @code{--expose} command-line options: the former
14428specifies a directory to be shared with write access, while the latter
14429provides read-only access to the shared directory.
14430
14431The example below creates a VM in which the user's home directory is
14432accessible read-only, and where the @file{/exchange} directory is a
1068f26b 14433read-write mapping of @file{$HOME/tmp} on the host:
0276f697
LC
14434
14435@example
14436guix system vm my-config.scm \
14437 --expose=$HOME --share=$HOME/tmp=/exchange
14438@end example
14439
6aa260af
LC
14440On GNU/Linux, the default is to boot directly to the kernel; this has
14441the advantage of requiring only a very tiny root disk image since the
1068f26b 14442store of the host can then be mounted.
6aa260af
LC
14443
14444The @code{--full-boot} option forces a complete boot sequence, starting
14445with the bootloader. This requires more disk space since a root image
14446containing at least the kernel, initrd, and bootloader data files must
14447be created. The @code{--image-size} option can be used to specify the
1068f26b 14448size of the image.
ab11f0be 14449
cf4a9129
LC
14450@item vm-image
14451@itemx disk-image
14452Return a virtual machine or disk image of the operating system declared
14453in @var{file} that stands alone. Use the @option{--image-size} option
14454to specify the size of the image.
113daf62 14455
cf4a9129 14456When using @code{vm-image}, the returned image is in qcow2 format, which
97d76250
LF
14457the QEMU emulator can efficiently use. @xref{Running GuixSD in a VM},
14458for more information on how to run the image in a virtual machine.
113daf62 14459
cf4a9129
LC
14460When using @code{disk-image}, a raw disk image is produced; it can be
14461copied as is to a USB stick, for instance. Assuming @code{/dev/sdc} is
1068f26b 14462the device corresponding to a USB stick, one can copy the image to it
cf4a9129 14463using the following command:
113daf62 14464
cf4a9129
LC
14465@example
14466# dd if=$(guix system disk-image my-os.scm) of=/dev/sdc
14467@end example
113daf62 14468
1c8a81b1
DT
14469@item container
14470Return a script to run the operating system declared in @var{file}
14471within a container. Containers are a set of lightweight isolation
14472mechanisms provided by the kernel Linux-libre. Containers are
14473substantially less resource-demanding than full virtual machines since
14474the kernel, shared objects, and other resources can be shared with the
14475host system; this also means they provide thinner isolation.
14476
14477Currently, the script must be run as root in order to support more than
14478a single user and group. The container shares its store with the host
14479system.
14480
14481As with the @code{vm} action (@pxref{guix system vm}), additional file
14482systems to be shared between the host and container can be specified
14483using the @option{--share} and @option{--expose} options:
14484
14485@example
14486guix system container my-config.scm \
14487 --expose=$HOME --share=$HOME/tmp=/exchange
14488@end example
14489
0f252e26 14490@quotation Note
cfd35b4e 14491This option requires Linux-libre 3.19 or newer.
0f252e26
DT
14492@end quotation
14493
cf4a9129 14494@end table
113daf62 14495
ccd7158d
LC
14496@var{options} can contain any of the common build options (@pxref{Common
14497Build Options}). In addition, @var{options} can contain one of the
14498following:
113daf62 14499
cf4a9129
LC
14500@table @option
14501@item --system=@var{system}
14502@itemx -s @var{system}
1068f26b 14503Attempt to build for @var{system} instead of the host system type.
cf4a9129 14504This works as per @command{guix build} (@pxref{Invoking guix build}).
113daf62 14505
f3f427c2
LC
14506@item --derivation
14507@itemx -d
14508Return the derivation file name of the given operating system without
14509building anything.
14510
cf4a9129
LC
14511@item --image-size=@var{size}
14512For the @code{vm-image} and @code{disk-image} actions, create an image
14513of the given @var{size}. @var{size} may be a number of bytes, or it may
4a44d7bb
LC
14514include a unit as a suffix (@pxref{Block size, size specifications,,
14515coreutils, GNU Coreutils}).
db030303
LC
14516
14517@item --on-error=@var{strategy}
14518Apply @var{strategy} when an error occurs when reading @var{file}.
14519@var{strategy} may be one of the following:
14520
14521@table @code
14522@item nothing-special
14523Report the error concisely and exit. This is the default strategy.
14524
14525@item backtrace
14526Likewise, but also display a backtrace.
14527
14528@item debug
14529Report the error and enter Guile's debugger. From there, you can run
14530commands such as @code{,bt} to get a backtrace, @code{,locals} to
1068f26b
AE
14531display local variable values, and more generally inspect the state of the
14532program. @xref{Debug Commands,,, guile, GNU Guile Reference Manual}, for
db030303
LC
14533a list of available debugging commands.
14534@end table
113daf62 14535@end table
113daf62 14536
eca69fc0
LC
14537@quotation Note
14538All the actions above, except @code{build} and @code{init},
14539can use KVM support in the Linux-libre kernel. Specifically, if the
14540machine has hardware virtualization support, the corresponding
cf4a9129 14541KVM kernel module should be loaded, and the @file{/dev/kvm} device node
1068f26b 14542must exist and be readable and writable by the user and by the
eca69fc0
LC
14543build users of the daemon (@pxref{Build Environment Setup}).
14544@end quotation
8451a568 14545
65797bff
LC
14546Once you have built, configured, re-configured, and re-re-configured
14547your GuixSD installation, you may find it useful to list the operating
14548system generations available on disk---and that you can choose from the
14549GRUB boot menu:
14550
14551@table @code
14552
14553@item list-generations
14554List a summary of each generation of the operating system available on
14555disk, in a human-readable way. This is similar to the
14556@option{--list-generations} option of @command{guix package}
14557(@pxref{Invoking guix package}).
14558
14559Optionally, one can specify a pattern, with the same syntax that is used
14560in @command{guix package --list-generations}, to restrict the list of
14561generations displayed. For instance, the following command displays
1068f26b 14562generations that are up to 10 days old:
65797bff
LC
14563
14564@example
14565$ guix system list-generations 10d
14566@end example
14567
14568@end table
14569
d6c3267a
LC
14570The @command{guix system} command has even more to offer! The following
14571sub-commands allow you to visualize how your system services relate to
14572each other:
14573
14574@anchor{system-extension-graph}
14575@table @code
14576
14577@item extension-graph
14578Emit in Dot/Graphviz format to standard output the @dfn{service
14579extension graph} of the operating system defined in @var{file}
14580(@pxref{Service Composition}, for more information on service
14581extensions.)
14582
14583The command:
14584
14585@example
14586$ guix system extension-graph @var{file} | dot -Tpdf > services.pdf
14587@end example
14588
14589produces a PDF file showing the extension relations among services.
14590
710fa231
AK
14591@anchor{system-shepherd-graph}
14592@item shepherd-graph
6f305ea5 14593Emit in Dot/Graphviz format to standard output the @dfn{dependency
dd17bc38
AK
14594graph} of shepherd services of the operating system defined in
14595@var{file}. @xref{Shepherd Services}, for more information and for an
14596example graph.
6f305ea5 14597
d6c3267a
LC
14598@end table
14599
97d76250 14600@node Running GuixSD in a VM
70ac09a5 14601@subsection Running GuixSD in a Virtual Machine
97d76250 14602
e32171ee 14603@cindex virtual machine
97d76250
LF
14604One way to run GuixSD in a virtual machine (VM) is to build a GuixSD
14605virtual machine image using @command{guix system vm-image}
14606(@pxref{Invoking guix system}). The returned image is in qcow2 format,
14607which the @uref{http://qemu.org/, QEMU emulator} can efficiently use.
14608
e32171ee 14609@cindex QEMU
97d76250
LF
14610To run the image in QEMU, copy it out of the store (@pxref{The Store})
14611and give yourself permission to write to the copy. When invoking QEMU,
14612you must choose a system emulator that is suitable for your hardware
14613platform. Here is a minimal QEMU invocation that will boot the result
14614of @command{guix system vm-image} on x86_64 hardware:
14615
14616@example
14617$ qemu-system-x86_64 \
14618 -net user -net nic,model=virtio \
14619 -enable-kvm -m 256 /tmp/qemu-image
14620@end example
14621
14622Here is what each of these options means:
14623
14624@table @code
14625@item qemu-system-x86_64
14626This specifies the hardware platform to emulate. This should match the
14627host.
14628
14629@item -net user
14630Enable the unprivileged user-mode network stack. The guest OS can
14631access the host but not vice versa. This is the simplest way to get the
58806e6f 14632guest OS online.
97d76250
LF
14633
14634@item -net nic,model=virtio
1068f26b 14635You must create a network interface of a given model. If you do not
97d76250
LF
14636create a NIC, the boot will fail. Assuming your hardware platform is
14637x86_64, you can get a list of available NIC models by running
14638@command{qemu-system-x86_64 -net nic,model=help}.
14639
14640@item -enable-kvm
14641If your system has hardware virtualization extensions, enabling the
1068f26b 14642virtual machine support (KVM) of the Linux kernel will make things run
97d76250
LF
14643faster.
14644
14645@item -m 256
14646RAM available to the guest OS, in mebibytes. Defaults to 128@tie{}MiB,
7414de0a 14647which may be insufficient for some operations.
97d76250
LF
14648
14649@item /tmp/qemu-image
14650The file name of the qcow2 image.
14651@end table
d6c3267a 14652
3ddc50db
DC
14653The default @command{run-vm.sh} script that is returned by an invokation of
14654@command{guix system vm} does not add a @command{-net user} flag by default.
14655To get network access from within the vm add the @code{(dhcp-client-service)}
14656to your system definition and start the VM using
14657@command{`guix system vm config.scm` -net user}. An important caveat of using
14658@command{-net user} for networking is that @command{ping} will not work, because
14659it uses the ICMP protocol. You'll have to use a different command to check for
14660network connectivity, like for example @command{curl}.
14661
14662@subsubsection Connecting Through SSH
14663
e32171ee
JD
14664@cindex SSH
14665@cindex SSH server
3ddc50db
DC
14666To enable SSH inside a VM you need to add a SSH server like @code{(dropbear-service)}
14667or @code{(lsh-service)} to your VM. The @code{(lsh-service}) doesn't currently
14668boot unsupervised. It requires you to type some characters to initialize the
14669randomness generator. In addition you need to forward the SSH port, 22 by
14670default, to the host. You can do this with
14671
14672@example
14673`guix system vm config.scm` -net user,hostfwd=tcp::10022-:22
14674@end example
14675
14676To connect to the VM you can run
14677
14678@example
14679ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 10022
14680@end example
14681
14682The @command{-p} tells @command{ssh} the port you want to connect to.
14683@command{-o UserKnownHostsFile=/dev/null} prevents @command{ssh} from complaining
14684every time you modify your @command{config.scm} file and the
14685@command{-o StrictHostKeyChecking=no} prevents you from having to allow a
14686connection to an unknown host every time you connect.
14687
14688@subsubsection Using @command{virt-viewer} with Spice
14689
14690As an alternative to the default @command{qemu} graphical client you can
14691use the @command{remote-viewer} from the @command{virt-viewer} package. To
14692connect pass the @command{-spice port=5930,disable-ticketing} flag to
14693@command{qemu}. See previous section for further information on how to do this.
14694
14695Spice also allows you to do some nice stuff like share your clipboard with your
14696VM. To enable that you'll also have to pass the following flags to @command{qemu}:
14697
14698@example
14699-device virtio-serial-pci,id=virtio-serial0,max_ports=16,bus=pci.0,addr=0x5
14700-chardev spicevmc,name=vdagent,id=vdagent
14701-device virtserialport,nr=1,bus=virtio-serial0.0,chardev=vdagent,
14702name=com.redhat.spice.0
14703@end example
14704
14705You'll also need to add the @pxref{Miscellaneous Services, Spice service}.
14706
cf4a9129
LC
14707@node Defining Services
14708@subsection Defining Services
8451a568 14709
eb524192 14710The previous sections show the available services and how one can combine
0adfe95a
LC
14711them in an @code{operating-system} declaration. But how do we define
14712them in the first place? And what is a service anyway?
8451a568 14713
0adfe95a
LC
14714@menu
14715* Service Composition:: The model for composing services.
14716* Service Types and Services:: Types and services.
14717* Service Reference:: API reference.
dd17bc38 14718* Shepherd Services:: A particular type of service.
0adfe95a
LC
14719@end menu
14720
14721@node Service Composition
14722@subsubsection Service Composition
14723
14724@cindex services
14725@cindex daemons
14726Here we define a @dfn{service} as, broadly, something that extends the
1068f26b 14727functionality of the operating system. Often a service is a process---a
0adfe95a
LC
14728@dfn{daemon}---started when the system boots: a secure shell server, a
14729Web server, the Guix build daemon, etc. Sometimes a service is a daemon
14730whose execution can be triggered by another daemon---e.g., an FTP server
14731started by @command{inetd} or a D-Bus service activated by
14732@command{dbus-daemon}. Occasionally, a service does not map to a
14733daemon. For instance, the ``account'' service collects user accounts
14734and makes sure they exist when the system runs; the ``udev'' service
14735collects device management rules and makes them available to the eudev
1068f26b
AE
14736daemon; the @file{/etc} service populates the @file{/etc} directory
14737of the system.
0adfe95a 14738
d6c3267a 14739@cindex service extensions
0adfe95a 14740GuixSD services are connected by @dfn{extensions}. For instance, the
1068f26b 14741secure shell service @emph{extends} the Shepherd---the GuixSD
dd17bc38
AK
14742initialization system, running as PID@tie{}1---by giving it the command
14743lines to start and stop the secure shell daemon (@pxref{Networking
14744Services, @code{lsh-service}}); the UPower service extends the D-Bus
14745service by passing it its @file{.service} specification, and extends the
14746udev service by passing it device management rules (@pxref{Desktop
14747Services, @code{upower-service}}); the Guix daemon service extends the
14748Shepherd by passing it the command lines to start and stop the daemon,
14749and extends the account service by passing it a list of required build
14750user accounts (@pxref{Base Services}).
0adfe95a
LC
14751
14752All in all, services and their ``extends'' relations form a directed
14753acyclic graph (DAG). If we represent services as boxes and extensions
14754as arrows, a typical system might provide something like this:
14755
14756@image{images/service-graph,,5in,Typical service extension graph.}
14757
d62e201c
LC
14758@cindex system service
14759At the bottom, we see the @dfn{system service}, which produces the
14760directory containing everything to run and boot the system, as returned
14761by the @command{guix system build} command. @xref{Service Reference},
14762to learn about the other service types shown here.
d6c3267a
LC
14763@xref{system-extension-graph, the @command{guix system extension-graph}
14764command}, for information on how to generate this representation for a
14765particular operating system definition.
0adfe95a
LC
14766
14767@cindex service types
14768Technically, developers can define @dfn{service types} to express these
14769relations. There can be any number of services of a given type on the
14770system---for instance, a system running two instances of the GNU secure
14771shell server (lsh) has two instances of @var{lsh-service-type}, with
14772different parameters.
14773
14774The following section describes the programming interface for service
14775types and services.
14776
14777@node Service Types and Services
14778@subsubsection Service Types and Services
14779
14780A @dfn{service type} is a node in the DAG described above. Let us start
14781with a simple example, the service type for the Guix build daemon
14782(@pxref{Invoking guix-daemon}):
14783
14784@example
14785(define guix-service-type
14786 (service-type
14787 (name 'guix)
14788 (extensions
d4053c71 14789 (list (service-extension shepherd-root-service-type guix-shepherd-service)
0adfe95a
LC
14790 (service-extension account-service-type guix-accounts)
14791 (service-extension activation-service-type guix-activation)))))
14792@end example
8451a568 14793
cf4a9129 14794@noindent
1068f26b 14795It defines two things:
0adfe95a
LC
14796
14797@enumerate
14798@item
14799A name, whose sole purpose is to make inspection and debugging easier.
14800
14801@item
14802A list of @dfn{service extensions}, where each extension designates the
1068f26b
AE
14803target service type and a procedure that, given the parameters of the
14804service, returns a list of objects to extend the service of that type.
0adfe95a
LC
14805
14806Every service type has at least one service extension. The only
14807exception is the @dfn{boot service type}, which is the ultimate service.
14808@end enumerate
14809
14810In this example, @var{guix-service-type} extends three services:
14811
14812@table @var
d4053c71
AK
14813@item shepherd-root-service-type
14814The @var{guix-shepherd-service} procedure defines how the Shepherd
14815service is extended. Namely, it returns a @code{<shepherd-service>}
14816object that defines how @command{guix-daemon} is started and stopped
14817(@pxref{Shepherd Services}).
0adfe95a
LC
14818
14819@item account-service-type
14820This extension for this service is computed by @var{guix-accounts},
14821which returns a list of @code{user-group} and @code{user-account}
14822objects representing the build user accounts (@pxref{Invoking
14823guix-daemon}).
14824
14825@item activation-service-type
14826Here @var{guix-activation} is a procedure that returns a gexp, which is
14827a code snippet to run at ``activation time''---e.g., when the service is
14828booted.
14829@end table
14830
14831A service of this type is instantiated like this:
14832
14833@example
14834(service guix-service-type
14835 (guix-configuration
14836 (build-accounts 5)
14837 (use-substitutes? #f)))
14838@end example
14839
14840The second argument to the @code{service} form is a value representing
14841the parameters of this specific service instance.
14842@xref{guix-configuration-type, @code{guix-configuration}}, for
14843information about the @code{guix-configuration} data type.
14844
14845@var{guix-service-type} is quite simple because it extends other
14846services but is not extensible itself.
14847
14848@c @subsubsubsection Extensible Service Types
14849
14850The service type for an @emph{extensible} service looks like this:
14851
14852@example
14853(define udev-service-type
14854 (service-type (name 'udev)
14855 (extensions
d4053c71
AK
14856 (list (service-extension shepherd-root-service-type
14857 udev-shepherd-service)))
0adfe95a
LC
14858
14859 (compose concatenate) ;concatenate the list of rules
14860 (extend (lambda (config rules)
14861 (match config
14862 (($ <udev-configuration> udev initial-rules)
14863 (udev-configuration
14864 (udev udev) ;the udev package to use
14865 (rules (append initial-rules rules)))))))))
14866@end example
14867
14868This is the service type for the
14869@uref{https://wiki.gentoo.org/wiki/Project:Eudev, eudev device
14870management daemon}. Compared to the previous example, in addition to an
d4053c71 14871extension of @var{shepherd-root-service-type}, we see two new fields:
0adfe95a
LC
14872
14873@table @code
14874@item compose
14875This is the procedure to @dfn{compose} the list of extensions to
14876services of this type.
14877
14878Services can extend the udev service by passing it lists of rules; we
14879compose those extensions simply by concatenating them.
14880
14881@item extend
1068f26b 14882This procedure defines how the value of the service is @dfn{extended} with
0adfe95a
LC
14883the composition of the extensions.
14884
14885Udev extensions are composed into a list of rules, but the udev service
14886value is itself a @code{<udev-configuration>} record. So here, we
a40424bd 14887extend that record by appending the list of rules it contains to the
0adfe95a
LC
14888list of contributed rules.
14889@end table
14890
14891There can be only one instance of an extensible service type such as
14892@var{udev-service-type}. If there were more, the
14893@code{service-extension} specifications would be ambiguous.
14894
14895Still here? The next section provides a reference of the programming
14896interface for services.
14897
14898@node Service Reference
14899@subsubsection Service Reference
14900
14901We have seen an overview of service types (@pxref{Service Types and
14902Services}). This section provides a reference on how to manipulate
14903services and service types. This interface is provided by the
14904@code{(gnu services)} module.
14905
14906@deffn {Scheme Procedure} service @var{type} @var{value}
14907Return a new service of @var{type}, a @code{<service-type>} object (see
14908below.) @var{value} can be any object; it represents the parameters of
14909this particular service instance.
14910@end deffn
14911
14912@deffn {Scheme Procedure} service? @var{obj}
14913Return true if @var{obj} is a service.
14914@end deffn
8451a568 14915
0adfe95a
LC
14916@deffn {Scheme Procedure} service-kind @var{service}
14917Return the type of @var{service}---i.e., a @code{<service-type>} object.
14918@end deffn
14919
14920@deffn {Scheme Procedure} service-parameters @var{service}
14921Return the value associated with @var{service}. It represents its
14922parameters.
14923@end deffn
14924
14925Here is an example of how a service is created and manipulated:
14926
14927@example
14928(define s
14929 (service nginx-service-type
14930 (nginx-configuration
14931 (nginx nginx)
14932 (log-directory log-directory)
14933 (run-directory run-directory)
14934 (file config-file))))
14935
14936(service? s)
14937@result{} #t
14938
14939(eq? (service-kind s) nginx-service-type)
14940@result{} #t
14941@end example
14942
cd6f6c22
LC
14943The @code{modify-services} form provides a handy way to change the
14944parameters of some of the services of a list such as
4d343a14 14945@var{%base-services} (@pxref{Base Services, @code{%base-services}}). It
7414de0a 14946evaluates to a list of services. Of course, you could always use
4d343a14
CM
14947standard list combinators such as @code{map} and @code{fold} to do that
14948(@pxref{SRFI-1, List Library,, guile, GNU Guile Reference Manual});
14949@code{modify-services} simply provides a more concise form for this
14950common pattern.
cd6f6c22
LC
14951
14952@deffn {Scheme Syntax} modify-services @var{services} @
14953 (@var{type} @var{variable} => @var{body}) @dots{}
14954
14955Modify the services listed in @var{services} according to the given
14956clauses. Each clause has the form:
14957
14958@example
14959(@var{type} @var{variable} => @var{body})
14960@end example
14961
4d343a14
CM
14962where @var{type} is a service type---e.g.,
14963@code{guix-service-type}---and @var{variable} is an identifier that is
14964bound within the @var{body} to the service parameters---e.g., a
14965@code{guix-configuration} instance---of the original service of that
14966@var{type}.
cd6f6c22 14967
4d343a14
CM
14968The @var{body} should evaluate to the new service parameters, which will
14969be used to configure the new service. This new service will replace the
14970original in the resulting list. Because a service's service parameters
7414de0a 14971are created using @code{define-record-type*}, you can write a succinct
4d343a14
CM
14972@var{body} that evaluates to the new service parameters by using the
14973@code{inherit} feature that @code{define-record-type*} provides.
14974
b53daad0 14975@xref{Using the Configuration System}, for example usage.
cd6f6c22 14976
cd6f6c22
LC
14977@end deffn
14978
14979Next comes the programming interface for service types. This is
14980something you want to know when writing new service definitions, but not
14981necessarily when simply looking for ways to customize your
14982@code{operating-system} declaration.
14983
0adfe95a
LC
14984@deftp {Data Type} service-type
14985@cindex service type
14986This is the representation of a @dfn{service type} (@pxref{Service Types
14987and Services}).
14988
14989@table @asis
14990@item @code{name}
14991This is a symbol, used only to simplify inspection and debugging.
14992
14993@item @code{extensions}
1068f26b 14994A non-empty list of @code{<service-extension>} objects (see below).
0adfe95a
LC
14995
14996@item @code{compose} (default: @code{#f})
14997If this is @code{#f}, then the service type denotes services that cannot
14998be extended---i.e., services that do not receive ``values'' from other
14999services.
15000
15001Otherwise, it must be a one-argument procedure. The procedure is called
15002by @code{fold-services} and is passed a list of values collected from
15003extensions. It must return a value that is a valid parameter value for
15004the service instance.
15005
15006@item @code{extend} (default: @code{#f})
15007If this is @code{#f}, services of this type cannot be extended.
15008
15009Otherwise, it must be a two-argument procedure: @code{fold-services}
1068f26b 15010calls it, passing it the initial value of the service as the first argument
0adfe95a
LC
15011and the result of applying @code{compose} to the extension values as the
15012second argument.
15013@end table
15014
15015@xref{Service Types and Services}, for examples.
15016@end deftp
15017
15018@deffn {Scheme Procedure} service-extension @var{target-type} @
15019 @var{compute}
15020Return a new extension for services of type @var{target-type}.
15021@var{compute} must be a one-argument procedure: @code{fold-services}
15022calls it, passing it the value associated with the service that provides
15023the extension; it must return a valid value for the target service.
15024@end deffn
15025
15026@deffn {Scheme Procedure} service-extension? @var{obj}
15027Return true if @var{obj} is a service extension.
15028@end deffn
15029
71654dfd
LC
15030Occasionally, you might want to simply extend an existing service. This
15031involves creating a new service type and specifying the extension of
15032interest, which can be verbose; the @code{simple-service} procedure
15033provides a shorthand for this.
15034
15035@deffn {Scheme Procedure} simple-service @var{name} @var{target} @var{value}
15036Return a service that extends @var{target} with @var{value}. This works
15037by creating a singleton service type @var{name}, of which the returned
15038service is an instance.
15039
15040For example, this extends mcron (@pxref{Scheduled Job Execution}) with
15041an additional job:
15042
15043@example
15044(simple-service 'my-mcron-job mcron-service-type
15045 #~(job '(next-hour (3)) "guix gc -F 2G"))
15046@end example
15047@end deffn
15048
0adfe95a
LC
15049At the core of the service abstraction lies the @code{fold-services}
15050procedure, which is responsible for ``compiling'' a list of services
d62e201c
LC
15051down to a single directory that contains everything needed to boot and
15052run the system---the directory shown by the @command{guix system build}
15053command (@pxref{Invoking guix system}). In essence, it propagates
15054service extensions down the service graph, updating each node parameters
15055on the way, until it reaches the root node.
0adfe95a
LC
15056
15057@deffn {Scheme Procedure} fold-services @var{services} @
d62e201c 15058 [#:target-type @var{system-service-type}]
0adfe95a
LC
15059Fold @var{services} by propagating their extensions down to the root of
15060type @var{target-type}; return the root service adjusted accordingly.
15061@end deffn
15062
15063Lastly, the @code{(gnu services)} module also defines several essential
15064service types, some of which are listed below.
15065
d62e201c
LC
15066@defvr {Scheme Variable} system-service-type
15067This is the root of the service graph. It produces the system directory
15068as returned by the @command{guix system build} command.
15069@end defvr
15070
0adfe95a 15071@defvr {Scheme Variable} boot-service-type
d62e201c
LC
15072The type of the ``boot service'', which produces the @dfn{boot script}.
15073The boot script is what the initial RAM disk runs when booting.
0adfe95a
LC
15074@end defvr
15075
15076@defvr {Scheme Variable} etc-service-type
15077The type of the @file{/etc} service. This service can be extended by
15078passing it name/file tuples such as:
15079
15080@example
15081(list `("issue" ,(plain-file "issue" "Welcome!\n")))
15082@end example
15083
15084In this example, the effect would be to add an @file{/etc/issue} file
15085pointing to the given file.
15086@end defvr
15087
15088@defvr {Scheme Variable} setuid-program-service-type
15089Type for the ``setuid-program service''. This service collects lists of
15090executable file names, passed as gexps, and adds them to the set of
15091setuid-root programs on the system (@pxref{Setuid Programs}).
15092@end defvr
15093
af4c3fd5
LC
15094@defvr {Scheme Variable} profile-service-type
15095Type of the service that populates the @dfn{system profile}---i.e., the
15096programs under @file{/run/current-system/profile}. Other services can
15097extend it by passing it lists of packages to add to the system profile.
15098@end defvr
15099
0adfe95a 15100
dd17bc38
AK
15101@node Shepherd Services
15102@subsubsection Shepherd Services
0adfe95a 15103
e32171ee 15104@cindex shepherd services
0adfe95a
LC
15105@cindex PID 1
15106@cindex init system
a40424bd
CM
15107The @code{(gnu services shepherd)} module provides a way to define
15108services managed by the GNU@tie{}Shepherd, which is the GuixSD
15109initialization system---the first process that is started when the
1068f26b
AE
15110system boots, also known as PID@tie{}1
15111(@pxref{Introduction,,, shepherd, The GNU Shepherd Manual}).
6f305ea5 15112
dd17bc38
AK
15113Services in the Shepherd can depend on each other. For instance, the
15114SSH daemon may need to be started after the syslog daemon has been
15115started, which in turn can only happen once all the file systems have
15116been mounted. The simple operating system defined earlier (@pxref{Using
15117the Configuration System}) results in a service graph like this:
6f305ea5 15118
710fa231 15119@image{images/shepherd-graph,,5in,Typical shepherd service graph.}
6f305ea5
LC
15120
15121You can actually generate such a graph for any operating system
710fa231
AK
15122definition using the @command{guix system shepherd-graph} command
15123(@pxref{system-shepherd-graph, @command{guix system shepherd-graph}}).
6f305ea5 15124
d4053c71
AK
15125The @var{%shepherd-root-service} is a service object representing
15126PID@tie{}1, of type @var{shepherd-root-service-type}; it can be extended
15127by passing it lists of @code{<shepherd-service>} objects.
0adfe95a 15128
d4053c71 15129@deftp {Data Type} shepherd-service
dd17bc38 15130The data type representing a service managed by the Shepherd.
0adfe95a
LC
15131
15132@table @asis
15133@item @code{provision}
15134This is a list of symbols denoting what the service provides.
15135
dd17bc38
AK
15136These are the names that may be passed to @command{herd start},
15137@command{herd status}, and similar commands (@pxref{Invoking herd,,,
15138shepherd, The GNU Shepherd Manual}). @xref{Slots of services, the
15139@code{provides} slot,, shepherd, The GNU Shepherd Manual}, for details.
0adfe95a
LC
15140
15141@item @code{requirements} (default: @code{'()})
dd17bc38 15142List of symbols denoting the Shepherd services this one depends on.
0adfe95a
LC
15143
15144@item @code{respawn?} (default: @code{#t})
15145Whether to restart the service when it stops, for instance when the
15146underlying process dies.
15147
15148@item @code{start}
15149@itemx @code{stop} (default: @code{#~(const #f)})
dd17bc38
AK
15150The @code{start} and @code{stop} fields refer to the Shepherd's
15151facilities to start and stop processes (@pxref{Service De- and
15152Constructors,,, shepherd, The GNU Shepherd Manual}). They are given as
15153G-expressions that get expanded in the Shepherd configuration file
15154(@pxref{G-Expressions}).
0adfe95a
LC
15155
15156@item @code{documentation}
15157A documentation string, as shown when running:
15158
15159@example
dd17bc38 15160herd doc @var{service-name}
0adfe95a
LC
15161@end example
15162
15163where @var{service-name} is one of the symbols in @var{provision}
dd17bc38 15164(@pxref{Invoking herd,,, shepherd, The GNU Shepherd Manual}).
fae685b9
LC
15165
15166@item @code{modules} (default: @var{%default-modules})
15167This is the list of modules that must be in scope when @code{start} and
15168@code{stop} are evaluated.
15169
0adfe95a
LC
15170@end table
15171@end deftp
15172
d4053c71 15173@defvr {Scheme Variable} shepherd-root-service-type
dd17bc38 15174The service type for the Shepherd ``root service''---i.e., PID@tie{}1.
0adfe95a
LC
15175
15176This is the service type that extensions target when they want to create
dd17bc38 15177shepherd services (@pxref{Service Types and Services}, for an example).
d4053c71 15178Each extension must pass a list of @code{<shepherd-service>}.
0adfe95a
LC
15179@end defvr
15180
d4053c71 15181@defvr {Scheme Variable} %shepherd-root-service
0adfe95a
LC
15182This service represents PID@tie{}1.
15183@end defvr
8451a568 15184
8451a568 15185
cf4a9129
LC
15186@node Installing Debugging Files
15187@section Installing Debugging Files
8451a568 15188
cf4a9129
LC
15189@cindex debugging files
15190Program binaries, as produced by the GCC compilers for instance, are
15191typically written in the ELF format, with a section containing
15192@dfn{debugging information}. Debugging information is what allows the
15193debugger, GDB, to map binary code to source code; it is required to
15194debug a compiled program in good conditions.
8451a568 15195
cf4a9129
LC
15196The problem with debugging information is that is takes up a fair amount
15197of disk space. For example, debugging information for the GNU C Library
15198weighs in at more than 60 MiB. Thus, as a user, keeping all the
15199debugging info of all the installed programs is usually not an option.
15200Yet, space savings should not come at the cost of an impediment to
15201debugging---especially in the GNU system, which should make it easier
15202for users to exert their computing freedom (@pxref{GNU Distribution}).
8451a568 15203
cf4a9129
LC
15204Thankfully, the GNU Binary Utilities (Binutils) and GDB provide a
15205mechanism that allows users to get the best of both worlds: debugging
15206information can be stripped from the binaries and stored in separate
15207files. GDB is then able to load debugging information from those files,
15208when they are available (@pxref{Separate Debug Files,,, gdb, Debugging
15209with GDB}).
8451a568 15210
cf4a9129
LC
15211The GNU distribution takes advantage of this by storing debugging
15212information in the @code{lib/debug} sub-directory of a separate package
15213output unimaginatively called @code{debug} (@pxref{Packages with
15214Multiple Outputs}). Users can choose to install the @code{debug} output
15215of a package when they need it. For instance, the following command
15216installs the debugging information for the GNU C Library and for GNU
15217Guile:
8451a568
LC
15218
15219@example
cf4a9129 15220guix package -i glibc:debug guile:debug
8451a568
LC
15221@end example
15222
cf4a9129
LC
15223GDB must then be told to look for debug files in the user's profile, by
15224setting the @code{debug-file-directory} variable (consider setting it
15225from the @file{~/.gdbinit} file, @pxref{Startup,,, gdb, Debugging with
15226GDB}):
8451a568 15227
cf4a9129
LC
15228@example
15229(gdb) set debug-file-directory ~/.guix-profile/lib/debug
15230@end example
8451a568 15231
cf4a9129
LC
15232From there on, GDB will pick up debugging information from the
15233@code{.debug} files under @file{~/.guix-profile/lib/debug}.
8451a568 15234
cf4a9129
LC
15235In addition, you will most likely want GDB to be able to show the source
15236code being debugged. To do that, you will have to unpack the source
15237code of the package of interest (obtained with @code{guix build
15238--source}, @pxref{Invoking guix build}), and to point GDB to that source
15239directory using the @code{directory} command (@pxref{Source Path,
15240@code{directory},, gdb, Debugging with GDB}).
8451a568 15241
cf4a9129
LC
15242@c XXX: keep me up-to-date
15243The @code{debug} output mechanism in Guix is implemented by the
15244@code{gnu-build-system} (@pxref{Build Systems}). Currently, it is
1068f26b
AE
15245opt-in---debugging information is available only for the packages
15246with definitions explicitly declaring a @code{debug} output. This may be
15247changed to opt-out in the future if our build farm servers can handle
cf4a9129
LC
15248the load. To check whether a package has a @code{debug} output, use
15249@command{guix package --list-available} (@pxref{Invoking guix package}).
8451a568 15250
8451a568 15251
05962f29
LC
15252@node Security Updates
15253@section Security Updates
15254
09866b39
LC
15255@cindex security updates
15256@cindex security vulnerabilities
15257Occasionally, important security vulnerabilities are discovered in software
15258packages and must be patched. Guix developers try hard to keep track of
15259known vulnerabilities and to apply fixes as soon as possible in the
15260@code{master} branch of Guix (we do not yet provide a ``stable'' branch
15261containing only security updates.) The @command{guix lint} tool helps
15262developers find out about vulnerable versions of software packages in the
15263distribution:
15264
15265@smallexample
15266$ guix lint -c cve
15267gnu/packages/base.scm:652:2: glibc-2.21: probably vulnerable to CVE-2015-1781, CVE-2015-7547
15268gnu/packages/gcc.scm:334:2: gcc-4.9.3: probably vulnerable to CVE-2015-5276
15269gnu/packages/image.scm:312:2: openjpeg-2.1.0: probably vulnerable to CVE-2016-1923, CVE-2016-1924
15270@dots{}
15271@end smallexample
15272
15273@xref{Invoking guix lint}, for more information.
15274
843858b8 15275@quotation Note
09866b39
LC
15276As of version @value{VERSION}, the feature described below is considered
15277``beta''.
843858b8 15278@end quotation
05962f29 15279
09866b39 15280Guix follows a functional
05962f29
LC
15281package management discipline (@pxref{Introduction}), which implies
15282that, when a package is changed, @emph{every package that depends on it}
15283must be rebuilt. This can significantly slow down the deployment of
15284fixes in core packages such as libc or Bash, since basically the whole
15285distribution would need to be rebuilt. Using pre-built binaries helps
15286(@pxref{Substitutes}), but deployment may still take more time than
15287desired.
15288
15289@cindex grafts
1068f26b 15290To address this, Guix implements @dfn{grafts}, a mechanism that allows
05962f29
LC
15291for fast deployment of critical updates without the costs associated
15292with a whole-distribution rebuild. The idea is to rebuild only the
15293package that needs to be patched, and then to ``graft'' it onto packages
15294explicitly installed by the user and that were previously referring to
15295the original package. The cost of grafting is typically very low, and
15296order of magnitudes lower than a full rebuild of the dependency chain.
15297
15298@cindex replacements of packages, for grafts
15299For instance, suppose a security update needs to be applied to Bash.
15300Guix developers will provide a package definition for the ``fixed''
15301Bash, say @var{bash-fixed}, in the usual way (@pxref{Defining
15302Packages}). Then, the original package definition is augmented with a
15303@code{replacement} field pointing to the package containing the bug fix:
15304
15305@example
15306(define bash
15307 (package
15308 (name "bash")
15309 ;; @dots{}
15310 (replacement bash-fixed)))
15311@end example
15312
c22a1324
LC
15313From there on, any package depending directly or indirectly on Bash---as
15314reported by @command{guix gc --requisites} (@pxref{Invoking guix
15315gc})---that is installed is automatically ``rewritten'' to refer to
05962f29 15316@var{bash-fixed} instead of @var{bash}. This grafting process takes
1068f26b 15317time proportional to the size of the package, usually less than a
c22a1324
LC
15318minute for an ``average'' package on a recent machine. Grafting is
15319recursive: when an indirect dependency requires grafting, then grafting
15320``propagates'' up to the package that the user is installing.
05962f29 15321
57bdd79e
LC
15322Currently, the length of the name and version of the graft and that of
15323the package it replaces (@var{bash-fixed} and @var{bash} in the example
15324above) must be equal. This restriction mostly comes from the fact that
15325grafting works by patching files, including binary files, directly.
05962f29
LC
15326Other restrictions may apply: for instance, when adding a graft to a
15327package providing a shared library, the original shared library and its
15328replacement must have the same @code{SONAME} and be binary-compatible.
15329
59a4dd50
LC
15330The @option{--no-grafts} command-line option allows you to forcefully
15331avoid grafting (@pxref{Common Build Options, @option{--no-grafts}}).
15332Thus, the command:
15333
15334@example
15335guix build bash --no-grafts
15336@end example
15337
15338@noindent
15339returns the store file name of the original Bash, whereas:
15340
15341@example
15342guix build bash
15343@end example
15344
15345@noindent
15346returns the store file name of the ``fixed'', replacement Bash. This
15347allows you to distinguish between the two variants of Bash.
15348
15349To verify which Bash your whole profile refers to, you can run
15350(@pxref{Invoking guix gc}):
15351
15352@example
15353guix gc -R `readlink -f ~/.guix-profile` | grep bash
15354@end example
15355
15356@noindent
15357@dots{} and compare the store file names that you get with those above.
15358Likewise for a complete GuixSD system generation:
15359
15360@example
15361guix gc -R `guix system build my-config.scm` | grep bash
15362@end example
15363
15364Lastly, to check which Bash running processes are using, you can use the
15365@command{lsof} command:
15366
15367@example
15368lsof | grep /gnu/store/.*bash
15369@end example
15370
05962f29 15371
cf4a9129
LC
15372@node Package Modules
15373@section Package Modules
8451a568 15374
cf4a9129
LC
15375From a programming viewpoint, the package definitions of the
15376GNU distribution are provided by Guile modules in the @code{(gnu packages
15377@dots{})} name space@footnote{Note that packages under the @code{(gnu
15378packages @dots{})} module name space are not necessarily ``GNU
15379packages''. This module naming scheme follows the usual Guile module
15380naming convention: @code{gnu} means that these modules are distributed
15381as part of the GNU system, and @code{packages} identifies modules that
15382define packages.} (@pxref{Modules, Guile modules,, guile, GNU Guile
15383Reference Manual}). For instance, the @code{(gnu packages emacs)}
15384module exports a variable named @code{emacs}, which is bound to a
15385@code{<package>} object (@pxref{Defining Packages}).
113daf62 15386
300868ba 15387The @code{(gnu packages @dots{})} module name space is
cf4a9129
LC
15388automatically scanned for packages by the command-line tools. For
15389instance, when running @code{guix package -i emacs}, all the @code{(gnu
15390packages @dots{})} modules are scanned until one that exports a package
15391object whose name is @code{emacs} is found. This package search
15392facility is implemented in the @code{(gnu packages)} module.
113daf62 15393
300868ba 15394@cindex customization, of packages
8689901f 15395@cindex package module search path
cf4a9129 15396Users can store package definitions in modules with different
60142854 15397names---e.g., @code{(my-packages emacs)}@footnote{Note that the file
c95ded7e
LC
15398name and module name must match. For instance, the @code{(my-packages
15399emacs)} module must be stored in a @file{my-packages/emacs.scm} file
15400relative to the load path specified with @option{--load-path} or
15401@code{GUIX_PACKAGE_PATH}. @xref{Modules and the File System,,,
15402guile, GNU Guile Reference Manual}, for details.}. These package definitions
1068f26b
AE
15403will not be visible by default. Users can invoke commands such as
15404@command{guix package} and @command{guix build} with the
c95ded7e
LC
15405@code{-e} option so that they know where to find the package. Better
15406yet, they can use the
300868ba 15407@code{-L} option of these commands to make those modules visible
8689901f
LC
15408(@pxref{Invoking guix build, @code{--load-path}}), or define the
15409@code{GUIX_PACKAGE_PATH} environment variable. This environment
15410variable makes it easy to extend or customize the distribution and is
15411honored by all the user interfaces.
15412
15413@defvr {Environment Variable} GUIX_PACKAGE_PATH
1068f26b
AE
15414This is a colon-separated list of directories to search for additional
15415package modules. Directories listed in this variable take precedence
15416over the own modules of the distribution.
8689901f 15417@end defvr
ef5dd60a 15418
cf4a9129
LC
15419The distribution is fully @dfn{bootstrapped} and @dfn{self-contained}:
15420each package is built based solely on other packages in the
15421distribution. The root of this dependency graph is a small set of
15422@dfn{bootstrap binaries}, provided by the @code{(gnu packages
15423bootstrap)} module. For more information on bootstrapping,
081145cf 15424@pxref{Bootstrapping}.
ef5dd60a 15425
cf4a9129
LC
15426@node Packaging Guidelines
15427@section Packaging Guidelines
ef5dd60a 15428
e32171ee 15429@cindex packages, creating
cf4a9129
LC
15430The GNU distribution is nascent and may well lack some of your favorite
15431packages. This section describes how you can help make the distribution
15432grow. @xref{Contributing}, for additional information on how you can
15433help.
ef5dd60a 15434
cf4a9129
LC
15435Free software packages are usually distributed in the form of
15436@dfn{source code tarballs}---typically @file{tar.gz} files that contain
15437all the source files. Adding a package to the distribution means
15438essentially two things: adding a @dfn{recipe} that describes how to
15439build the package, including a list of other packages required to build
f97c9175 15440it, and adding @dfn{package metadata} along with that recipe, such as a
cf4a9129 15441description and licensing information.
ef5dd60a 15442
cf4a9129
LC
15443In Guix all this information is embodied in @dfn{package definitions}.
15444Package definitions provide a high-level view of the package. They are
15445written using the syntax of the Scheme programming language; in fact,
15446for each package we define a variable bound to the package definition,
15447and export that variable from a module (@pxref{Package Modules}).
15448However, in-depth Scheme knowledge is @emph{not} a prerequisite for
15449creating packages. For more information on package definitions,
081145cf 15450@pxref{Defining Packages}.
ef5dd60a 15451
cf4a9129
LC
15452Once a package definition is in place, stored in a file in the Guix
15453source tree, it can be tested using the @command{guix build} command
15454(@pxref{Invoking guix build}). For example, assuming the new package is
c71979f4
LC
15455called @code{gnew}, you may run this command from the Guix build tree
15456(@pxref{Running Guix Before It Is Installed}):
ef5dd60a
LC
15457
15458@example
cf4a9129 15459./pre-inst-env guix build gnew --keep-failed
ef5dd60a 15460@end example
ef5dd60a 15461
cf4a9129
LC
15462Using @code{--keep-failed} makes it easier to debug build failures since
15463it provides access to the failed build tree. Another useful
15464command-line option when debugging is @code{--log-file}, to access the
15465build log.
ef5dd60a 15466
cf4a9129
LC
15467If the package is unknown to the @command{guix} command, it may be that
15468the source file contains a syntax error, or lacks a @code{define-public}
15469clause to export the package variable. To figure it out, you may load
15470the module from Guile to get more information about the actual error:
ef5dd60a 15471
cf4a9129
LC
15472@example
15473./pre-inst-env guile -c '(use-modules (gnu packages gnew))'
15474@end example
ef5dd60a 15475
cf4a9129
LC
15476Once your package builds correctly, please send us a patch
15477(@pxref{Contributing}). Well, if you need help, we will be happy to
15478help you too. Once the patch is committed in the Guix repository, the
15479new package automatically gets built on the supported platforms by
2b1cee21 15480@url{http://hydra.gnu.org/jobset/gnu/master, our continuous integration
cf4a9129 15481system}.
ef5dd60a 15482
cf4a9129
LC
15483@cindex substituter
15484Users can obtain the new package definition simply by running
15485@command{guix pull} (@pxref{Invoking guix pull}). When
15486@code{hydra.gnu.org} is done building the package, installing the
15487package automatically downloads binaries from there
15488(@pxref{Substitutes}). The only place where human intervention is
15489needed is to review and apply the patch.
ef5dd60a 15490
ef5dd60a 15491
cf4a9129 15492@menu
ec0339cd
LC
15493* Software Freedom:: What may go into the distribution.
15494* Package Naming:: What's in a name?
15495* Version Numbers:: When the name is not enough.
cbd02397 15496* Synopses and Descriptions:: Helping users find the right package.
ec0339cd
LC
15497* Python Modules:: Taming the snake.
15498* Perl Modules:: Little pearls.
e1c963bf 15499* Java Packages:: Coffee break.
ec0339cd 15500* Fonts:: Fond of fonts.
cf4a9129 15501@end menu
ef5dd60a 15502
cf4a9129
LC
15503@node Software Freedom
15504@subsection Software Freedom
ef5dd60a 15505
cf4a9129 15506@c Adapted from http://www.gnu.org/philosophy/philosophy.html.
e32171ee 15507@cindex free software
cf4a9129
LC
15508The GNU operating system has been developed so that users can have
15509freedom in their computing. GNU is @dfn{free software}, meaning that
15510users have the @url{http://www.gnu.org/philosophy/free-sw.html,four
15511essential freedoms}: to run the program, to study and change the program
15512in source code form, to redistribute exact copies, and to distribute
15513modified versions. Packages found in the GNU distribution provide only
15514software that conveys these four freedoms.
c11a6eb1 15515
cf4a9129
LC
15516In addition, the GNU distribution follow the
15517@url{http://www.gnu.org/distros/free-system-distribution-guidelines.html,free
15518software distribution guidelines}. Among other things, these guidelines
15519reject non-free firmware, recommendations of non-free software, and
15520discuss ways to deal with trademarks and patents.
ef5dd60a 15521
1068f26b
AE
15522Some otherwise free upstream package sources contain a small and optional
15523subset that violates the above guidelines, for instance because this subset
15524is itself non-free code. When that happens, the offending items are removed
15525with appropriate patches or code snippets in the @code{origin} form of the
15526package (@pxref{Defining Packages}). This way, @code{guix
cf4a9129
LC
15527build --source} returns the ``freed'' source rather than the unmodified
15528upstream source.
ef5dd60a 15529
ef5dd60a 15530
cf4a9129
LC
15531@node Package Naming
15532@subsection Package Naming
ef5dd60a 15533
e32171ee 15534@cindex package name
cf4a9129
LC
15535A package has actually two names associated with it:
15536First, there is the name of the @emph{Scheme variable}, the one following
15537@code{define-public}. By this name, the package can be made known in the
15538Scheme code, for instance as input to another package. Second, there is
15539the string in the @code{name} field of a package definition. This name
15540is used by package management commands such as
15541@command{guix package} and @command{guix build}.
ef5dd60a 15542
cf4a9129
LC
15543Both are usually the same and correspond to the lowercase conversion of
15544the project name chosen upstream, with underscores replaced with
15545hyphens. For instance, GNUnet is available as @code{gnunet}, and
15546SDL_net as @code{sdl-net}.
927097ef 15547
cf4a9129 15548We do not add @code{lib} prefixes for library packages, unless these are
081145cf 15549already part of the official project name. But @pxref{Python
cf4a9129
LC
15550Modules} and @ref{Perl Modules} for special rules concerning modules for
15551the Python and Perl languages.
927097ef 15552
1b366ee4 15553Font package names are handled differently, @pxref{Fonts}.
7fec52b7 15554
ef5dd60a 15555
cf4a9129
LC
15556@node Version Numbers
15557@subsection Version Numbers
ef5dd60a 15558
e32171ee 15559@cindex package version
cf4a9129
LC
15560We usually package only the latest version of a given free software
15561project. But sometimes, for instance for incompatible library versions,
15562two (or more) versions of the same package are needed. These require
15563different Scheme variable names. We use the name as defined
15564in @ref{Package Naming}
15565for the most recent version; previous versions use the same name, suffixed
15566by @code{-} and the smallest prefix of the version number that may
15567distinguish the two versions.
ef5dd60a 15568
cf4a9129
LC
15569The name inside the package definition is the same for all versions of a
15570package and does not contain any version number.
ef5dd60a 15571
cf4a9129 15572For instance, the versions 2.24.20 and 3.9.12 of GTK+ may be packaged as follows:
ef5dd60a 15573
cf4a9129
LC
15574@example
15575(define-public gtk+
15576 (package
17d8e33f
ML
15577 (name "gtk+")
15578 (version "3.9.12")
15579 ...))
cf4a9129
LC
15580(define-public gtk+-2
15581 (package
17d8e33f
ML
15582 (name "gtk+")
15583 (version "2.24.20")
15584 ...))
cf4a9129
LC
15585@end example
15586If we also wanted GTK+ 3.8.2, this would be packaged as
15587@example
15588(define-public gtk+-3.8
15589 (package
17d8e33f
ML
15590 (name "gtk+")
15591 (version "3.8.2")
15592 ...))
cf4a9129 15593@end example
ef5dd60a 15594
880d647d
LC
15595@c See <https://lists.gnu.org/archive/html/guix-devel/2016-01/msg00425.html>,
15596@c for a discussion of what follows.
15597@cindex version number, for VCS snapshots
15598Occasionally, we package snapshots of upstream's version control system
15599(VCS) instead of formal releases. This should remain exceptional,
15600because it is up to upstream developers to clarify what the stable
15601release is. Yet, it is sometimes necessary. So, what should we put in
15602the @code{version} field?
15603
15604Clearly, we need to make the commit identifier of the VCS snapshot
15605visible in the version string, but we also need to make sure that the
15606version string is monotonically increasing so that @command{guix package
15607--upgrade} can determine which version is newer. Since commit
15608identifiers, notably with Git, are not monotonically increasing, we add
15609a revision number that we increase each time we upgrade to a newer
15610snapshot. The resulting version string looks like this:
15611
15612@example
156132.0.11-3.cabba9e
15614 ^ ^ ^
15615 | | `-- upstream commit ID
15616 | |
15617 | `--- Guix package revision
15618 |
15619latest upstream version
15620@end example
15621
15622It is a good idea to strip commit identifiers in the @code{version}
15623field to, say, 7 digits. It avoids an aesthetic annoyance (assuming
15624aesthetics have a role to play here) as well as problems related to OS
15625limits such as the maximum shebang length (127 bytes for the Linux
15626kernel.) It is best to use the full commit identifiers in
561360a5
LC
15627@code{origin}s, though, to avoid ambiguities. A typical package
15628definition may look like this:
15629
15630@example
15631(define my-package
6e42660b 15632 (let ((commit "c3f29bc928d5900971f65965feaae59e1272a3f7")
15633 (revision "1")) ;Guix package revision
561360a5 15634 (package
6e42660b 15635 (version (string-append "0.9-" revision "."
561360a5
LC
15636 (string-take commit 7)))
15637 (source (origin
15638 (method git-fetch)
15639 (uri (git-reference
15640 (url "git://example.org/my-package.git")
15641 (commit commit)))
15642 (sha256 (base32 "1mbikn@dots{}"))
15643 (file-name (string-append "my-package-" version
15644 "-checkout"))))
15645 ;; @dots{}
15646 )))
15647@end example
880d647d 15648
cbd02397
LC
15649@node Synopses and Descriptions
15650@subsection Synopses and Descriptions
15651
e32171ee
JD
15652@cindex package description
15653@cindex package synopsis
cbd02397
LC
15654As we have seen before, each package in GNU@tie{}Guix includes a
15655synopsis and a description (@pxref{Defining Packages}). Synopses and
15656descriptions are important: They are what @command{guix package
15657--search} searches, and a crucial piece of information to help users
15658determine whether a given package suits their needs. Consequently,
15659packagers should pay attention to what goes into them.
15660
15661Synopses must start with a capital letter and must not end with a
15662period. They must not start with ``a'' or ``the'', which usually does
15663not bring anything; for instance, prefer ``File-frobbing tool'' over ``A
15664tool that frobs files''. The synopsis should say what the package
15665is---e.g., ``Core GNU utilities (file, text, shell)''---or what it is
15666used for---e.g., the synopsis for GNU@tie{}grep is ``Print lines
15667matching a pattern''.
15668
15669Keep in mind that the synopsis must be meaningful for a very wide
15670audience. For example, ``Manipulate alignments in the SAM format''
15671might make sense for a seasoned bioinformatics researcher, but might be
15672fairly unhelpful or even misleading to a non-specialized audience. It
15673is a good idea to come up with a synopsis that gives an idea of the
15674application domain of the package. In this example, this might give
15675something like ``Manipulate nucleotide sequence alignments'', which
15676hopefully gives the user a better idea of whether this is what they are
15677looking for.
15678
cbd02397
LC
15679Descriptions should take between five and ten lines. Use full
15680sentences, and avoid using acronyms without first introducing them.
762e54b7
LC
15681Please avoid marketing phrases such as ``world-leading'',
15682``industrial-strength'', and ``next-generation'', and avoid superlatives
15683like ``the most advanced''---they are not helpful to users looking for a
15684package and may even sound suspicious. Instead, try to be factual,
15685mentioning use cases and features.
15686
15687@cindex Texinfo markup, in package descriptions
cbd02397
LC
15688Descriptions can include Texinfo markup, which is useful to introduce
15689ornaments such as @code{@@code} or @code{@@dfn}, bullet lists, or
ba7d6c76
ML
15690hyperlinks (@pxref{Overview,,, texinfo, GNU Texinfo}). However you
15691should be careful when using some characters for example @samp{@@} and
15692curly braces which are the basic special characters in Texinfo
15693(@pxref{Special Characters,,, texinfo, GNU Texinfo}). User interfaces
15694such as @command{guix package --show} take care of rendering it
15695appropriately.
cbd02397
LC
15696
15697Synopses and descriptions are translated by volunteers
15698@uref{http://translationproject.org/domain/guix-packages.html, at the
15699Translation Project} so that as many users as possible can read them in
15700their native language. User interfaces search them and display them in
15701the language specified by the current locale.
15702
15703Translation is a lot of work so, as a packager, please pay even more
15704attention to your synopses and descriptions as every change may entail
ba7d6c76 15705additional work for translators. In order to help them, it is possible
36743e71 15706to make recommendations or instructions visible to them by inserting
ba7d6c76
ML
15707special comments like this (@pxref{xgettext Invocation,,, gettext, GNU
15708Gettext}):
15709
15710@example
15711;; TRANSLATORS: "X11 resize-and-rotate" should not be translated.
15712(description "ARandR is designed to provide a simple visual front end
15713for the X11 resize-and-rotate (RandR) extension. @dots{}")
15714@end example
cbd02397 15715
ef5dd60a 15716
cf4a9129
LC
15717@node Python Modules
15718@subsection Python Modules
ef5dd60a 15719
e32171ee 15720@cindex python
cf4a9129
LC
15721We currently package Python 2 and Python 3, under the Scheme variable names
15722@code{python-2} and @code{python} as explained in @ref{Version Numbers}.
15723To avoid confusion and naming clashes with other programming languages, it
15724seems desirable that the name of a package for a Python module contains
15725the word @code{python}.
ef5dd60a 15726
cf4a9129
LC
15727Some modules are compatible with only one version of Python, others with both.
15728If the package Foo compiles only with Python 3, we name it
15729@code{python-foo}; if it compiles only with Python 2, we name it
15730@code{python2-foo}. If it is compatible with both versions, we create two
15731packages with the corresponding names.
ef5dd60a 15732
cf4a9129
LC
15733If a project already contains the word @code{python}, we drop this;
15734for instance, the module python-dateutil is packaged under the names
99c866a0
HG
15735@code{python-dateutil} and @code{python2-dateutil}. If the project name
15736starts with @code{py} (e.g. @code{pytz}), we keep it and prefix it as
15737described above.
113daf62 15738
e940a271
HG
15739@subsubsection Specifying Dependencies
15740@cindex inputs, for Python packages
15741
15742Dependency information for Python packages is usually available in the
15743package source tree, with varying degrees of accuracy: in the
15744@file{setup.py} file, in @file{requirements.txt}, or in @file{tox.ini}.
15745
15746Your mission, when writing a recipe for a Python package, is to map
15747these dependencies to the appropriate type of ``input'' (@pxref{package
15748Reference, inputs}). Although the @code{pypi} importer normally does a
15749good job (@pxref{Invoking guix import}), you may want to check the
15750following check list to determine which dependency goes where.
15751
15752@itemize
15753
aaf75c89
HG
15754@item
15755We currently package Python 2 with @code{setuptools} and @code{pip}
15756installed like Python 3.4 has per default. Thus you don't need to
891a843d
HG
15757specify either of these as an input. @command{guix lint} will warn you
15758if you do.
aaf75c89 15759
e940a271
HG
15760@item
15761Python dependencies required at run time go into
15762@code{propagated-inputs}. They are typically defined with the
15763@code{install_requires} keyword in @file{setup.py}, or in the
15764@file{requirements.txt} file.
15765
15766@item
15767Python packages required only at build time---e.g., those listed with
15768the @code{setup_requires} keyword in @file{setup.py}---or only for
15769testing---e.g., those in @code{tests_require}---go into
15770@code{native-inputs}. The rationale is that (1) they do not need to be
15771propagated because they are not needed at run time, and (2) in a
15772cross-compilation context, it's the ``native'' input that we'd want.
15773
aaf75c89 15774Examples are the @code{pytest}, @code{mock}, and @code{nose} test
e940a271
HG
15775frameworks. Of course if any of these packages is also required at
15776run-time, it needs to go to @code{propagated-inputs}.
15777
15778@item
15779Anything that does not fall in the previous categories goes to
15780@code{inputs}, for example programs or C libraries required for building
15781Python packages containing C extensions.
15782
15783@item
15784If a Python package has optional dependencies (@code{extras_require}),
15785it is up to you to decide whether to add them or not, based on their
15786usefulness/overhead ratio (@pxref{Submitting Patches, @command{guix
15787size}}).
15788
15789@end itemize
15790
15791
cf4a9129
LC
15792@node Perl Modules
15793@subsection Perl Modules
523e4896 15794
e32171ee 15795@cindex perl
cf4a9129
LC
15796Perl programs standing for themselves are named as any other package,
15797using the lowercase upstream name.
15798For Perl packages containing a single class, we use the lowercase class name,
15799replace all occurrences of @code{::} by dashes and prepend the prefix
15800@code{perl-}.
15801So the class @code{XML::Parser} becomes @code{perl-xml-parser}.
15802Modules containing several classes keep their lowercase upstream name and
15803are also prepended by @code{perl-}. Such modules tend to have the word
15804@code{perl} somewhere in their name, which gets dropped in favor of the
15805prefix. For instance, @code{libwww-perl} becomes @code{perl-libwww}.
523e4896 15806
523e4896 15807
e1c963bf
HG
15808@node Java Packages
15809@subsection Java Packages
15810
e32171ee 15811@cindex java
e1c963bf
HG
15812Java programs standing for themselves are named as any other package,
15813using the lowercase upstream name.
15814
15815To avoid confusion and naming clashes with other programming languages,
15816it is desirable that the name of a package for a Java package is
15817prefixed with @code{java-}. If a project already contains the word
15818@code{java}, we drop this; for instance, the package @code{ngsjava} is
15819packaged under the name @code{java-ngs}.
15820
15821For Java packages containing a single class or a small class hierarchy,
15822we use the lowercase class name, replace all occurrences of @code{.} by
15823dashes and prepend the prefix @code{java-}. So the class
15824@code{apache.commons.cli} becomes package
15825@code{java-apache-commons-cli}.
15826
15827
7fec52b7
AE
15828@node Fonts
15829@subsection Fonts
15830
e32171ee 15831@cindex fonts
7fec52b7
AE
15832For fonts that are in general not installed by a user for typesetting
15833purposes, or that are distributed as part of a larger software package,
15834we rely on the general packaging rules for software; for instance, this
15835applies to the fonts delivered as part of the X.Org system or fonts that
15836are part of TeX Live.
15837
15838To make it easier for a user to search for fonts, names for other packages
15839containing only fonts are constructed as follows, independently of the
15840upstream package name.
15841
15842The name of a package containing only one font family starts with
15843@code{font-}; it is followed by the foundry name and a dash @code{-}
15844if the foundry is known, and the font family name, in which spaces are
15845replaced by dashes (and as usual, all upper case letters are transformed
15846to lower case).
15847For example, the Gentium font family by SIL is packaged under the name
15848@code{font-sil-gentium}.
15849
15850For a package containing several font families, the name of the collection
15851is used in the place of the font family name.
15852For instance, the Liberation fonts consist of three families,
15853Liberation Sans, Liberation Serif and Liberation Mono.
15854These could be packaged separately under the names
15855@code{font-liberation-sans} and so on; but as they are distributed together
15856under a common name, we prefer to package them together as
15857@code{font-liberation}.
15858
15859In the case where several formats of the same font family or font collection
15860are packaged separately, a short form of the format, prepended by a dash,
15861is added to the package name. We use @code{-ttf} for TrueType fonts,
1b366ee4 15862@code{-otf} for OpenType fonts and @code{-type1} for PostScript Type 1
7fec52b7
AE
15863fonts.
15864
15865
b25937e3 15866
cf4a9129
LC
15867@node Bootstrapping
15868@section Bootstrapping
b25937e3 15869
cf4a9129 15870@c Adapted from the ELS 2013 paper.
b25937e3 15871
cf4a9129 15872@cindex bootstrapping
7889394e 15873
cf4a9129
LC
15874Bootstrapping in our context refers to how the distribution gets built
15875``from nothing''. Remember that the build environment of a derivation
15876contains nothing but its declared inputs (@pxref{Introduction}). So
15877there's an obvious chicken-and-egg problem: how does the first package
15878get built? How does the first compiler get compiled? Note that this is
15879a question of interest only to the curious hacker, not to the regular
15880user, so you can shamelessly skip this section if you consider yourself
15881a ``regular user''.
72b9d60d 15882
cf4a9129
LC
15883@cindex bootstrap binaries
15884The GNU system is primarily made of C code, with libc at its core. The
15885GNU build system itself assumes the availability of a Bourne shell and
15886command-line tools provided by GNU Coreutils, Awk, Findutils, `sed', and
15887`grep'. Furthermore, build programs---programs that run
15888@code{./configure}, @code{make}, etc.---are written in Guile Scheme
15889(@pxref{Derivations}). Consequently, to be able to build anything at
15890all, from scratch, Guix relies on pre-built binaries of Guile, GCC,
15891Binutils, libc, and the other packages mentioned above---the
15892@dfn{bootstrap binaries}.
72b9d60d 15893
cf4a9129
LC
15894These bootstrap binaries are ``taken for granted'', though we can also
15895re-create them if needed (more on that later).
72b9d60d 15896
cf4a9129 15897@unnumberedsubsec Preparing to Use the Bootstrap Binaries
c79d54fe 15898
cf4a9129
LC
15899@c As of Emacs 24.3, Info-mode displays the image, but since it's a
15900@c large image, it's hard to scroll. Oh well.
15901@image{images/bootstrap-graph,6in,,Dependency graph of the early bootstrap derivations}
523e4896 15902
cf4a9129
LC
15903The figure above shows the very beginning of the dependency graph of the
15904distribution, corresponding to the package definitions of the @code{(gnu
d33fa0c7
LC
15905packages bootstrap)} module. A similar figure can be generated with
15906@command{guix graph} (@pxref{Invoking guix graph}), along the lines of:
15907
15908@example
15909guix graph -t derivation \
15910 -e '(@@@@ (gnu packages bootstrap) %bootstrap-gcc)' \
15911 | dot -Tps > t.ps
15912@end example
15913
15914At this level of detail, things are
cf4a9129
LC
15915slightly complex. First, Guile itself consists of an ELF executable,
15916along with many source and compiled Scheme files that are dynamically
15917loaded when it runs. This gets stored in the @file{guile-2.0.7.tar.xz}
15918tarball shown in this graph. This tarball is part of Guix's ``source''
15919distribution, and gets inserted into the store with @code{add-to-store}
15920(@pxref{The Store}).
2e7b5cea 15921
cf4a9129
LC
15922But how do we write a derivation that unpacks this tarball and adds it
15923to the store? To solve this problem, the @code{guile-bootstrap-2.0.drv}
15924derivation---the first one that gets built---uses @code{bash} as its
15925builder, which runs @code{build-bootstrap-guile.sh}, which in turn calls
15926@code{tar} to unpack the tarball. Thus, @file{bash}, @file{tar},
15927@file{xz}, and @file{mkdir} are statically-linked binaries, also part of
15928the Guix source distribution, whose sole purpose is to allow the Guile
15929tarball to be unpacked.
fb729425 15930
cf4a9129
LC
15931Once @code{guile-bootstrap-2.0.drv} is built, we have a functioning
15932Guile that can be used to run subsequent build programs. Its first task
15933is to download tarballs containing the other pre-built binaries---this
15934is what the @code{.tar.xz.drv} derivations do. Guix modules such as
15935@code{ftp-client.scm} are used for this purpose. The
15936@code{module-import.drv} derivations import those modules in a directory
15937in the store, using the original layout. The
15938@code{module-import-compiled.drv} derivations compile those modules, and
15939write them in an output directory with the right layout. This
15940corresponds to the @code{#:modules} argument of
15941@code{build-expression->derivation} (@pxref{Derivations}).
fb729425 15942
cf4a9129
LC
15943Finally, the various tarballs are unpacked by the
15944derivations @code{gcc-bootstrap-0.drv}, @code{glibc-bootstrap-0.drv},
15945etc., at which point we have a working C tool chain.
fb729425 15946
fb729425 15947
cf4a9129 15948@unnumberedsubsec Building the Build Tools
523e4896 15949
cf4a9129
LC
15950Bootstrapping is complete when we have a full tool chain that does not
15951depend on the pre-built bootstrap tools discussed above. This
15952no-dependency requirement is verified by checking whether the files of
15953the final tool chain contain references to the @file{/gnu/store}
15954directories of the bootstrap inputs. The process that leads to this
15955``final'' tool chain is described by the package definitions found in
1f6f57df 15956the @code{(gnu packages commencement)} module.
df2ce343 15957
d33fa0c7
LC
15958The @command{guix graph} command allows us to ``zoom out'' compared to
15959the graph above, by looking at the level of package objects instead of
15960individual derivations---remember that a package may translate to
15961several derivations, typically one derivation to download its source,
15962one to build the Guile modules it needs, and one to actually build the
15963package from source. The command:
15964
15965@example
15966guix graph -t bag \
15967 -e '(@@@@ (gnu packages commencement)
15968 glibc-final-with-bootstrap-bash)' | dot -Tps > t.ps
15969@end example
15970
15971@noindent
15972produces the dependency graph leading to the ``final'' C
15973library@footnote{You may notice the @code{glibc-intermediate} label,
15974suggesting that it is not @emph{quite} final, but as a good
15975approximation, we will consider it final.}, depicted below.
15976
15977@image{images/bootstrap-packages,6in,,Dependency graph of the early packages}
15978
cf4a9129
LC
15979@c See <http://lists.gnu.org/archive/html/gnu-system-discuss/2012-10/msg00000.html>.
15980The first tool that gets built with the bootstrap binaries is
d33fa0c7
LC
15981GNU@tie{}Make---noted @code{make-boot0} above---which is a prerequisite
15982for all the following packages. From there Findutils and Diffutils get
15983built.
523e4896 15984
cf4a9129
LC
15985Then come the first-stage Binutils and GCC, built as pseudo cross
15986tools---i.e., with @code{--target} equal to @code{--host}. They are
15987used to build libc. Thanks to this cross-build trick, this libc is
15988guaranteed not to hold any reference to the initial tool chain.
4af2447e 15989
d33fa0c7
LC
15990From there the final Binutils and GCC (not shown above) are built.
15991GCC uses @code{ld}
cf4a9129
LC
15992from the final Binutils, and links programs against the just-built libc.
15993This tool chain is used to build the other packages used by Guix and by
15994the GNU Build System: Guile, Bash, Coreutils, etc.
4af2447e 15995
cf4a9129
LC
15996And voilà! At this point we have the complete set of build tools that
15997the GNU Build System expects. These are in the @code{%final-inputs}
dd164244
MW
15998variable of the @code{(gnu packages commencement)} module, and are
15999implicitly used by any package that uses @code{gnu-build-system}
1f6f57df 16000(@pxref{Build Systems, @code{gnu-build-system}}).
4af2447e 16001
4af2447e 16002
cf4a9129 16003@unnumberedsubsec Building the Bootstrap Binaries
4af2447e 16004
e32171ee 16005@cindex bootstrap binaries
cf4a9129
LC
16006Because the final tool chain does not depend on the bootstrap binaries,
16007those rarely need to be updated. Nevertheless, it is useful to have an
16008automated way to produce them, should an update occur, and this is what
16009the @code{(gnu packages make-bootstrap)} module provides.
4af2447e 16010
cf4a9129
LC
16011The following command builds the tarballs containing the bootstrap
16012binaries (Guile, Binutils, GCC, libc, and a tarball containing a mixture
16013of Coreutils and other basic command-line tools):
4b2615e1 16014
cf4a9129
LC
16015@example
16016guix build bootstrap-tarballs
16017@end example
16018
16019The generated tarballs are those that should be referred to in the
16020@code{(gnu packages bootstrap)} module mentioned at the beginning of
16021this section.
16022
16023Still here? Then perhaps by now you've started to wonder: when do we
16024reach a fixed point? That is an interesting question! The answer is
16025unknown, but if you would like to investigate further (and have
16026significant computational and storage resources to do so), then let us
16027know.
16028
16029@node Porting
16030@section Porting to a New Platform
16031
16032As discussed above, the GNU distribution is self-contained, and
16033self-containment is achieved by relying on pre-built ``bootstrap
16034binaries'' (@pxref{Bootstrapping}). These binaries are specific to an
16035operating system kernel, CPU architecture, and application binary
16036interface (ABI). Thus, to port the distribution to a platform that is
16037not yet supported, one must build those bootstrap binaries, and update
16038the @code{(gnu packages bootstrap)} module to use them on that platform.
16039
16040Fortunately, Guix can @emph{cross compile} those bootstrap binaries.
16041When everything goes well, and assuming the GNU tool chain supports the
16042target platform, this can be as simple as running a command like this
16043one:
16044
16045@example
16046guix build --target=armv5tel-linux-gnueabi bootstrap-tarballs
16047@end example
16048
1c0c417d
LC
16049For this to work, the @code{glibc-dynamic-linker} procedure in
16050@code{(gnu packages bootstrap)} must be augmented to return the right
16051file name for libc's dynamic linker on that platform; likewise,
16052@code{system->linux-architecture} in @code{(gnu packages linux)} must be
16053taught about the new platform.
16054
cf4a9129 16055Once these are built, the @code{(gnu packages bootstrap)} module needs
1c0c417d
LC
16056to be updated to refer to these binaries on the target platform. That
16057is, the hashes and URLs of the bootstrap tarballs for the new platform
16058must be added alongside those of the currently supported platforms. The
16059bootstrap Guile tarball is treated specially: it is expected to be
03d0e2d2 16060available locally, and @file{gnu/local.mk} has rules do download it for
1c0c417d
LC
16061the supported architectures; a rule for the new platform must be added
16062as well.
cf4a9129
LC
16063
16064In practice, there may be some complications. First, it may be that the
16065extended GNU triplet that specifies an ABI (like the @code{eabi} suffix
16066above) is not recognized by all the GNU tools. Typically, glibc
16067recognizes some of these, whereas GCC uses an extra @code{--with-abi}
16068configure flag (see @code{gcc.scm} for examples of how to handle this).
16069Second, some of the required packages could fail to build for that
16070platform. Lastly, the generated binaries could be broken for some
16071reason.
4af2447e 16072
9bf3c1a7 16073@c *********************************************************************
8c01b9d0 16074@include contributing.texi
c78bd12b 16075
568717fd
LC
16076@c *********************************************************************
16077@node Acknowledgments
16078@chapter Acknowledgments
16079
136787cb
LC
16080Guix is based on the @uref{http://nixos.org/nix/, Nix package manager},
16081which was designed and
4c7ac9aa
LC
16082implemented by Eelco Dolstra, with contributions from other people (see
16083the @file{nix/AUTHORS} file in Guix.) Nix pioneered functional package
568717fd
LC
16084management, and promoted unprecedented features, such as transactional
16085package upgrades and rollbacks, per-user profiles, and referentially
16086transparent build processes. Without this work, Guix would not exist.
16087
16088The Nix-based software distributions, Nixpkgs and NixOS, have also been
16089an inspiration for Guix.
16090
4c7ac9aa
LC
16091GNU@tie{}Guix itself is a collective work with contributions from a
16092number of people. See the @file{AUTHORS} file in Guix for more
16093information on these fine people. The @file{THANKS} file lists people
16094who have helped by reporting bugs, taking care of the infrastructure,
16095providing artwork and themes, making suggestions, and more---thank you!
16096
16097
568717fd
LC
16098@c *********************************************************************
16099@node GNU Free Documentation License
16100@appendix GNU Free Documentation License
e32171ee 16101@cindex license, GNU Free Documentation License
568717fd
LC
16102@include fdl-1.3.texi
16103
16104@c *********************************************************************
16105@node Concept Index
16106@unnumbered Concept Index
16107@printindex cp
16108
a85b83d2
LC
16109@node Programming Index
16110@unnumbered Programming Index
16111@syncodeindex tp fn
16112@syncodeindex vr fn
568717fd
LC
16113@printindex fn
16114
16115@bye
16116
16117@c Local Variables:
16118@c ispell-local-dictionary: "american";
16119@c End: