emacs: Add "edit" command to a list of packages.
[jackhill/guix/guix.git] / doc / guix.texi
CommitLineData
568717fd
LC
1\input texinfo
2@c -*-texinfo-*-
3
4@c %**start of header
5@setfilename guix.info
6@documentencoding UTF-8
f8348b91 7@settitle GNU Guix Reference Manual
568717fd
LC
8@c %**end of header
9
10@include version.texi
7df7a74e
NK
11
12@copying
4379c35b 13Copyright @copyright{} 2012, 2013, 2014, 2015 Ludovic Courtès@*
af8a56b8 14Copyright @copyright{} 2013, 2014 Andreas Enge@*
87eafdbd 15Copyright @copyright{} 2013 Nikita Karetnikov@*
8c01b9d0
ML
16Copyright @copyright{} 2015 Mathieu Lirzin@*
17Copyright @copyright{} 2014 Pierre-Antoine Rault@*
87eafdbd 18Copyright @copyright{} 2015 Taylan Ulrich Bayırlı/Kammer
7df7a74e
NK
19
20Permission is granted to copy, distribute and/or modify this document
21under the terms of the GNU Free Documentation License, Version 1.3 or
22any later version published by the Free Software Foundation; with no
23Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A
24copy of the license is included in the section entitled ``GNU Free
25Documentation License''.
26@end copying
568717fd 27
eeaf4427 28@dircategory Package management
568717fd
LC
29@direntry
30* guix: (guix). Guix, the functional package manager.
e49951eb 31* guix package: (guix)Invoking guix package
eeaf4427 32 Managing packages with Guix.
e49951eb 33* guix build: (guix)Invoking guix build
568717fd 34 Building packages with Guix.
054e8576
LC
35* guix system: (guix)Invoking guix system
36 Managing the operating system configuration.
568717fd 37@end direntry
568717fd 38
372c4bbc
DT
39@dircategory Software development
40@direntry
41* guix environment: (guix)Invoking guix environment
42 Building development environments with Guix.
43@end direntry
44
568717fd 45@titlepage
7730d112
LC
46@title GNU Guix Reference Manual
47@subtitle Using the GNU Guix Functional Package Manager
568717fd 48@author Ludovic Courtès
da7cabd4 49@author Andreas Enge
acc08466 50@author Nikita Karetnikov
568717fd
LC
51
52@page
53@vskip 0pt plus 1filll
54Edition @value{EDITION} @*
55@value{UPDATED} @*
56
7df7a74e 57@insertcopying
568717fd
LC
58@end titlepage
59
568717fd
LC
60@contents
61
62@c *********************************************************************
63@node Top
f8348b91 64@top GNU Guix
568717fd 65
f8348b91
LC
66This document describes GNU Guix version @value{VERSION}, a functional
67package management tool written for the GNU system.
568717fd
LC
68
69@menu
70* Introduction:: What is Guix about?
bd5e766b 71* Installation:: Installing Guix.
eeaf4427 72* Package Management:: Package installation, upgrade, etc.
568717fd
LC
73* Programming Interface:: Using Guix in Scheme.
74* Utilities:: Package management commands.
a1ba8475 75* GNU Distribution:: Software for your friendly GNU system.
9bf3c1a7 76* Contributing:: Your help needed!
568717fd
LC
77
78* Acknowledgments:: Thanks!
79* GNU Free Documentation License:: The license of this manual.
80* Concept Index:: Concepts.
a85b83d2 81* Programming Index:: Data types, functions, and variables.
aaa3eaa9
LC
82
83@detailmenu
84 --- The Detailed Node Listing ---
85
86Installation
87
1b2b8177 88* Binary Installation:: Getting Guix running in no time!
aaa3eaa9 89* Requirements:: Software needed to build and run Guix.
ec0339cd 90* Running the Test Suite:: Testing Guix.
aaa3eaa9
LC
91* Setting Up the Daemon:: Preparing the build daemon's environment.
92* Invoking guix-daemon:: Running the build daemon.
93
94Setting Up the Daemon
95
96* Build Environment Setup:: Preparing the isolated build environment.
97* Daemon Offload Setup:: Offloading builds to remote machines.
98
99Package Management
100
101* Features:: How Guix will make your life brighter.
102* Invoking guix package:: Package installation, removal, etc.
103* Emacs Interface:: Package management from Emacs.
104* Substitutes:: Downloading pre-built binaries.
105* Packages with Multiple Outputs:: Single source package, multiple outputs.
106* Invoking guix gc:: Running the garbage collector.
107* Invoking guix pull:: Fetching the latest Guix and distribution.
108* Invoking guix archive:: Exporting and importing store files.
109
110Programming Interface
111
112* Defining Packages:: Defining new packages.
113* Build Systems:: Specifying how packages are built.
114* The Store:: Manipulating the package store.
115* Derivations:: Low-level interface to package derivations.
116* The Store Monad:: Purely functional interface to the store.
117* G-Expressions:: Manipulating build expressions.
118
92492b23
LC
119Defining Packages
120
121* package Reference:: The package data type.
122* origin Reference:: The origin data type.
123
aaa3eaa9
LC
124Utilities
125
126* Invoking guix build:: Building packages from the command line.
fcc58db6 127* Invoking guix edit:: Editing package definitions.
aaa3eaa9
LC
128* Invoking guix download:: Downloading a file and printing its hash.
129* Invoking guix hash:: Computing the cryptographic hash of a file.
130* Invoking guix import:: Importing package definitions.
131* Invoking guix refresh:: Updating package definitions.
132* Invoking guix lint:: Finding errors in package definitions.
fcc58db6 133* Invoking guix size:: Profiling disk usage.
aaa3eaa9 134* Invoking guix environment:: Setting up development environments.
aff8ce7c 135* Invoking guix publish:: Sharing substitutes.
aaa3eaa9
LC
136
137GNU Distribution
138
139* System Installation:: Installing the whole operating system.
35ed9306 140* System Configuration:: Configuring the operating system.
aaa3eaa9
LC
141* Installing Debugging Files:: Feeding the debugger.
142* Security Updates:: Deploying security fixes quickly.
143* Package Modules:: Packages from the programmer's viewpoint.
144* Packaging Guidelines:: Growing the distribution.
145* Bootstrapping:: GNU/Linux built from scratch.
146* Porting:: Targeting another platform or kernel.
147
148System Configuration
149
150* Using the Configuration System:: Customizing your GNU system.
151* operating-system Reference:: Detail of operating-system declarations.
152* File Systems:: Configuring file system mounts.
153* Mapped Devices:: Block device extra processing.
154* User Accounts:: Specifying user accounts.
598e19dc 155* Locales:: Language and cultural convention settings.
aaa3eaa9
LC
156* Services:: Specifying system services.
157* Setuid Programs:: Programs running with root privileges.
1b2b8177 158* X.509 Certificates:: Authenticating HTTPS servers.
996ed739 159* Name Service Switch:: Configuring libc's name service switch.
aaa3eaa9
LC
160* Initial RAM Disk:: Linux-Libre bootstrapping.
161* GRUB Configuration:: Configuring the boot loader.
162* Invoking guix system:: Instantiating a system configuration.
163* Defining Services:: Adding new service definitions.
164
165Services
166
167* Base Services:: Essential system services.
168* Networking Services:: Network setup, SSH daemon, etc.
169* X Window:: Graphical display.
1b2b8177
LC
170* Desktop Services:: D-Bus and desktop services.
171* Database Services:: SQL databases.
aa4ed923 172* Various Services:: Other services.
aaa3eaa9
LC
173
174Packaging Guidelines
175
ec0339cd
LC
176* Software Freedom:: What may go into the distribution.
177* Package Naming:: What's in a name?
178* Version Numbers:: When the name is not enough.
179* Python Modules:: Taming the snake.
180* Perl Modules:: Little pearls.
181* Fonts:: Fond of fonts.
aaa3eaa9 182
8c01b9d0
ML
183Contributing
184
185* Building from Git:: The latest and greatest.
186* Running Guix Before It Is Installed:: Hacker tricks.
187* The Perfect Setup:: The right tools.
188* Coding Style:: Hygiene of the contributor.
189* Submitting Patches:: Share your work.
190
191Coding Style
192
193* Programming Paradigm:: How to compose your elements.
194* Modules:: Where to store your code?
195* Data Types and Pattern Matching:: Implementing data structures.
196* Formatting Code:: Writing conventions.
197
aaa3eaa9 198@end detailmenu
568717fd
LC
199@end menu
200
201@c *********************************************************************
202@node Introduction
203@chapter Introduction
204
c80e7e55
LC
205GNU Guix@footnote{``Guix'' is pronounced like ``geeks'', or ``ɡiːks''
206using the international phonetic alphabet (IPA).} is a functional
207package management tool for the GNU system. Package management consists
4bfc4ea3
NK
208of all activities that relate to building packages from sources,
209honoring their build-time and run-time dependencies,
c80e7e55
LC
210installing packages in user environments, upgrading installed packages
211to new versions or rolling back to a previous set, removing unused
212software packages, etc.
568717fd
LC
213
214@cindex functional package management
215The term @dfn{functional} refers to a specific package management
216discipline. In Guix, the package build and installation process is seen
4bfc4ea3
NK
217as a function, in the mathematical sense. That function takes inputs,
218such as build scripts, a compiler, and libraries, and
219returns an installed package. As a pure function, its result depends
568717fd
LC
220solely on its inputs---for instance, it cannot refer to software or
221scripts that were not explicitly passed as inputs. A build function
4bfc4ea3
NK
222always produces the same result when passed a given set of inputs. It
223cannot alter the system's environment in
568717fd
LC
224any way; for instance, it cannot create, modify, or delete files outside
225of its build and installation directories. This is achieved by running
e900c503 226build processes in isolated environments (or @dfn{containers}), where only their
4bfc4ea3 227explicit inputs are visible.
568717fd 228
e531ac2a 229@cindex store
568717fd 230The result of package build functions is @dfn{cached} in the file
e531ac2a
LC
231system, in a special directory called @dfn{the store} (@pxref{The
232Store}). Each package is installed in a directory of its own, in the
834129e0 233store---by default under @file{/gnu/store}. The directory name contains
568717fd
LC
234a hash of all the inputs used to build that package; thus, changing an
235input yields a different directory name.
236
237This approach is the foundation of Guix's salient features: support for
4bfc4ea3 238transactional package upgrade and rollback, per-user installation, and
eeaf4427 239garbage collection of packages (@pxref{Features}).
568717fd 240
4bfc4ea3 241Guix has a command-line interface, which allows users to build, install,
568717fd 242upgrade, and remove packages, as well as a Scheme programming interface.
568717fd 243
3ca2731c 244@cindex Guix System Distribution
4705641f 245@cindex GuixSD
a1ba8475 246Last but not least, Guix is used to build a distribution of the GNU
3ca2731c 247system, with many GNU and non-GNU free software packages. The Guix
4705641f
LC
248System Distribution, or GNU@tie{}GuixSD, takes advantage of the core
249properties of Guix at the system level. With GuixSD, users
3ca2731c
LC
250@emph{declare} all aspects of the operating system configuration, and
251Guix takes care of instantiating that configuration in a reproducible,
252stateless fashion. @xref{GNU Distribution}.
a1ba8475 253
bd5e766b
LC
254@c *********************************************************************
255@node Installation
256@chapter Installation
257
48febeb8
LC
258GNU Guix is available for download from its website at
259@url{http://www.gnu.org/software/guix/}. This section describes the
260software requirements of Guix, as well as how to install it and get
261ready to use it.
bd5e766b 262
5af6de3e
LC
263Note that this section is concerned with the installation of the package
264manager, which can be done on top of a running GNU/Linux system. If,
265instead, you want to install the complete GNU operating system,
6621cdb6 266@pxref{System Installation}.
5af6de3e 267
bd5e766b 268@menu
09722b11 269* Binary Installation:: Getting Guix running in no time!
bd5e766b 270* Requirements:: Software needed to build and run Guix.
ec0339cd 271* Running the Test Suite:: Testing Guix.
bd5e766b
LC
272* Setting Up the Daemon:: Preparing the build daemon's environment.
273* Invoking guix-daemon:: Running the build daemon.
274@end menu
275
09722b11
LC
276@node Binary Installation
277@section Binary Installation
278
279This section describes how to install Guix on an arbitrary system from a
280self-contained tarball providing binaries for Guix and for all its
281dependencies. This is often quicker than installing from source, which
282is described in the next sections. The only requirement is to have
283GNU@tie{}tar and Xz.
284
285Installing goes along these lines:
286
287@enumerate
288@item
289Download the binary tarball from
ae806096 290@indicateurl{ftp://alpha.gnu.org/gnu/guix/guix-binary-@value{VERSION}.@var{system}.tar.xz}@footnote{As
09722b11
LC
291usual, make sure to download the associated @file{.sig} file and to
292verify the authenticity of the tarball against it!}, where @var{system}
293is @code{x86_64-linux} for an @code{x86_64} machine already running the
294kernel Linux, and so on.
295
296@item
297As @code{root}, run:
298
299@example
5dc42964 300# cd /tmp
b91d7f0f 301# tar xf guix-binary-@value{VERSION}.@var{system}.tar.xz
5dc42964 302# mv var/guix /var/ && mv gnu /
09722b11
LC
303@end example
304
7acd3439
LC
305This creates @file{/gnu/store} (@pxref{The Store}) and @file{/var/guix}.
306The latter contains a ready-to-use profile for @code{root} (see next
307step.)
09722b11 308
5dc3ce5f
LC
309Do @emph{not} unpack the tarball on a working Guix system since that
310would overwrite its own essential files.
311
7acd3439
LC
312@item
313Make @code{root}'s profile available under @file{~/.guix-profile}:
314
315@example
316# ln -sf /var/guix/profiles/per-user/root/guix-profile \
317 ~root/.guix-profile
318@end example
319
09722b11 320@item
175ced41 321Run the daemon:
09722b11
LC
322
323@example
7acd3439 324# ~root/.guix-profile/bin/guix-daemon --build-users-group=guixbuild
09722b11
LC
325@end example
326
327@item
328Make the @command{guix} command available to other users on the machine,
329for instance with:
330
331@example
332# mkdir -p /usr/local/bin
333# cd /usr/local/bin
d72d05f9 334# ln -s /var/guix/profiles/per-user/root/guix-profile/bin/guix
09722b11 335@end example
39f8ed14
LC
336
337@item
338To use substitutes from @code{hydra.gnu.org} (@pxref{Substitutes}),
339authorize them:
340
341@example
7acd3439 342# guix archive --authorize < ~root/.guix-profile/share/guix/hydra.gnu.org.pub
39f8ed14 343@end example
09722b11
LC
344@end enumerate
345
346And that's it!
347
5dc3ce5f 348The @code{guix} package must remain available in @code{root}'s
09722b11
LC
349profile, or it would become subject to garbage collection---in which
350case you would find yourself badly handicapped by the lack of the
351@command{guix} command.
352
39f8ed14
LC
353The tarball in question can be (re)produced and verified simply by
354running the following command in the Guix source tree:
09722b11
LC
355
356@example
357make guix-binary.@var{system}.tar.xz
358@end example
359
360
bd5e766b
LC
361@node Requirements
362@section Requirements
363
09722b11
LC
364This section lists requirements when building Guix from source. The
365build procedure for Guix is the same as for other GNU software, and is
366not covered here. Please see the files @file{README} and @file{INSTALL}
367in the Guix source tree for additional details.
368
bd5e766b
LC
369GNU Guix depends on the following packages:
370
371@itemize
47c66da0 372@item @url{http://gnu.org/software/guile/, GNU Guile}, version 2.0.7 or later;
288dca55 373@item @url{http://gnupg.org/, GNU libgcrypt};
f0b98b84 374@item @url{http://www.gnu.org/software/make/, GNU Make}.
8a96bd4b
ID
375@end itemize
376
377The following dependencies are optional:
378
379@itemize
288dca55 380@item
8a96bd4b 381Installing
288dca55 382@url{http://savannah.nongnu.org/projects/guile-json/, Guile-JSON} will
2f7d2d91
LC
383allow you to use the @command{guix import pypi} command (@pxref{Invoking
384guix import}). It is of
288dca55 385interest primarily for developers and not for casual users.
8a96bd4b
ID
386@item
387Installing @uref{http://gnutls.org/, GnuTLS-Guile} will
388allow you to access @code{https} URLs with the @command{guix download}
d45dc6da
EB
389command (@pxref{Invoking guix download}), the @command{guix import pypi}
390command, and the @command{guix import cpan} command. This is primarily
391of interest to developers. @xref{Guile Preparations, how to install the
392GnuTLS bindings for Guile,, gnutls-guile, GnuTLS-Guile}.
bd5e766b
LC
393@end itemize
394
395Unless @code{--disable-daemon} was passed to @command{configure}, the
396following packages are also needed:
397
398@itemize
368d08f7
LC
399@item @url{http://sqlite.org, SQLite 3};
400@item @url{http://www.bzip.org, libbz2};
401@item @url{http://gcc.gnu.org, GCC's g++}, with support for the
402C++11 standard.
bd5e766b
LC
403@end itemize
404
4bfc4ea3
NK
405When a working installation of @url{http://nixos.org/nix/, the Nix package
406manager} is available, you
bd5e766b 407can instead configure Guix with @code{--disable-daemon}. In that case,
4bfc4ea3 408Nix replaces the three dependencies above.
bd5e766b 409
b22a12fd
LC
410Guix is compatible with Nix, so it is possible to share the same store
411between both. To do so, you must pass @command{configure} not only the
412same @code{--with-store-dir} value, but also the same
4bfc4ea3
NK
413@code{--localstatedir} value. The latter is essential because it
414specifies where the database that stores metadata about the store is
834129e0 415located, among other things. The default values for Nix are
b22a12fd 416@code{--with-store-dir=/nix/store} and @code{--localstatedir=/nix/var}.
4bfc4ea3
NK
417Note that @code{--disable-daemon} is not required if
418your goal is to share the store with Nix.
b22a12fd 419
ec0339cd
LC
420@node Running the Test Suite
421@section Running the Test Suite
422
423After a successful @command{configure} and @code{make} run, it is a good
424idea to run the test suite. It can help catch issues with the setup or
425environment, or bugs in Guix itself---and really, reporting test
426failures is a good way to help improve the software. To run the test
427suite, type:
428
429@example
430make check
431@end example
432
433Test cases can run in parallel: you can use the @code{-j} option of
434GNU@tie{}make to speed things up. The first run may take a few minutes
435on a recent machine; subsequent runs will be faster because the store
436that is created for test purposes will already have various things in
437cache.
438
439Upon failure, please email @email{bug-guix@@gnu.org} and attach the
440@file{test-suite.log} file. When @file{tests/@var{something}.scm}
441fails, please also attach the @file{@var{something}.log} file available
442in the top-level build directory. Please specify the Guix version being
443used as well as version numbers of the dependencies
444(@pxref{Requirements}) in your message.
445
bd5e766b
LC
446@node Setting Up the Daemon
447@section Setting Up the Daemon
448
449@cindex daemon
450Operations such as building a package or running the garbage collector
49e6291a 451are all performed by a specialized process, the @dfn{build daemon}, on
bd5e766b
LC
452behalf of clients. Only the daemon may access the store and its
453associated database. Thus, any operation that manipulates the store
454goes through the daemon. For instance, command-line tools such as
e49951eb 455@command{guix package} and @command{guix build} communicate with the
bd5e766b
LC
456daemon (@i{via} remote procedure calls) to instruct it what to do.
457
49e6291a 458The following sections explain how to prepare the build daemon's
225dafde
LC
459environment. Also @ref{Substitutes}, for information on how to allow
460the daemon to download pre-built binaries.
49e6291a
LC
461
462@menu
463* Build Environment Setup:: Preparing the isolated build environment.
464* Daemon Offload Setup:: Offloading builds to remote machines.
465@end menu
466
467@node Build Environment Setup
468@subsection Build Environment Setup
469
bd5e766b
LC
470In a standard multi-user setup, Guix and its daemon---the
471@command{guix-daemon} program---are installed by the system
834129e0 472administrator; @file{/gnu/store} is owned by @code{root} and
bd5e766b
LC
473@command{guix-daemon} runs as @code{root}. Unprivileged users may use
474Guix tools to build packages or otherwise access the store, and the
475daemon will do it on their behalf, ensuring that the store is kept in a
476consistent state, and allowing built packages to be shared among users.
477
478@cindex build users
479When @command{guix-daemon} runs as @code{root}, you may not want package
480build processes themselves to run as @code{root} too, for obvious
481security reasons. To avoid that, a special pool of @dfn{build users}
482should be created for use by build processes started by the daemon.
483These build users need not have a shell and a home directory: they will
484just be used when the daemon drops @code{root} privileges in build
485processes. Having several such users allows the daemon to launch
486distinct build processes under separate UIDs, which guarantees that they
487do not interfere with each other---an essential feature since builds are
488regarded as pure functions (@pxref{Introduction}).
489
490On a GNU/Linux system, a build user pool may be created like this (using
491Bash syntax and the @code{shadow} commands):
492
091196b3
LC
493@c See http://lists.gnu.org/archive/html/bug-guix/2013-01/msg00239.html
494@c for why `-G' is needed.
bd5e766b 495@example
cfc149dc
LC
496# groupadd --system guixbuild
497# for i in `seq -w 1 10`;
bd5e766b 498 do
cfc149dc
LC
499 useradd -g guixbuild -G guixbuild \
500 -d /var/empty -s `which nologin` \
501 -c "Guix build user $i" --system \
502 guixbuilder$i;
bd5e766b
LC
503 done
504@end example
505
506@noindent
54eb03ab
LC
507The number of build users determines how many build jobs may run in
508parallel, as specified by the @option{--max-jobs} option
509(@pxref{Invoking guix-daemon, @option{--max-jobs}}).
bd5e766b
LC
510The @code{guix-daemon} program may then be run as @code{root} with:
511
512@example
cfc149dc 513# guix-daemon --build-users-group=guixbuild
bd5e766b
LC
514@end example
515
e900c503 516@cindex chroot
b095792f
LC
517@noindent
518This way, the daemon starts build processes in a chroot, under one of
cfc149dc 519the @code{guixbuilder} users. On GNU/Linux, by default, the chroot
6dc99317
LC
520environment contains nothing but:
521
522@c Keep this list in sync with libstore/build.cc! -----------------------
523@itemize
524@item
4743a4da
LC
525a minimal @code{/dev} directory, created mostly independently from the
526host @code{/dev}@footnote{``Mostly'', because while the set of files
527that appear in the chroot's @code{/dev} is fixed, most of these files
528can only be created if the host has them.};
529
530@item
531the @code{/proc} directory; it only shows the container's processes
532since a separate PID name space is used;
6dc99317
LC
533
534@item
535@file{/etc/passwd} with an entry for the current user and an entry for
536user @file{nobody};
537
538@item
539@file{/etc/group} with an entry for the user's group;
540
541@item
542@file{/etc/hosts} with an entry that maps @code{localhost} to
543@code{127.0.0.1};
544
545@item
546a writable @file{/tmp} directory.
547@end itemize
b095792f 548
1e2644bb
LC
549If you are installing Guix as an unprivileged user, it is still possible
550to run @command{guix-daemon} provided you pass @code{--disable-chroot}.
551However, build processes will not be isolated from one another, and not
552from the rest of the system. Thus, build processes may interfere with
553each other, and may access programs, libraries, and other files
554available on the system---making it much harder to view them as
555@emph{pure} functions.
bd5e766b 556
49e6291a
LC
557
558@node Daemon Offload Setup
559@subsection Using the Offload Facility
560
561@cindex offloading
4ec2e92d
LC
562@cindex build hook
563When desired, the build daemon can @dfn{offload}
564derivation builds to other machines
49e6291a
LC
565running Guix, using the @code{offload} @dfn{build hook}. When that
566feature is enabled, a list of user-specified build machines is read from
567@file{/etc/guix/machines.scm}; anytime a build is requested, for
568instance via @code{guix build}, the daemon attempts to offload it to one
569of the machines that satisfies the derivation's constraints, in
570particular its system type---e.g., @file{x86_64-linux}. Missing
571prerequisites for the build are copied over SSH to the target machine,
572which then proceeds with the build; upon success the output(s) of the
573build are copied back to the initial machine.
574
4ec2e92d 575The @file{/etc/guix/machines.scm} file typically looks like this:
49e6291a
LC
576
577@example
578(list (build-machine
579 (name "eightysix.example.org")
580 (system "x86_64-linux")
581 (user "bob")
582 (speed 2.)) ; incredibly fast!
583
584 (build-machine
585 (name "meeps.example.org")
586 (system "mips64el-linux")
587 (user "alice")
588 (private-key
589 (string-append (getenv "HOME")
590 "/.ssh/id-rsa-for-guix"))))
591@end example
592
593@noindent
594In the example above we specify a list of two build machines, one for
595the @code{x86_64} architecture and one for the @code{mips64el}
4ec2e92d
LC
596architecture.
597
598In fact, this file is---not surprisingly!---a Scheme file that is
599evaluated when the @code{offload} hook is started. Its return value
600must be a list of @code{build-machine} objects. While this example
601shows a fixed list of build machines, one could imagine, say, using
602DNS-SD to return a list of potential build machines discovered in the
603local network (@pxref{Introduction, Guile-Avahi,, guile-avahi, Using
c678a4ee
LC
604Avahi in Guile Scheme Programs}). The @code{build-machine} data type is
605detailed below.
4ec2e92d 606
c678a4ee
LC
607@deftp {Data Type} build-machine
608This data type represents build machines the daemon may offload builds
609to. The important fields are:
49e6291a
LC
610
611@table @code
612
613@item name
614The remote machine's host name.
615
616@item system
c678a4ee 617The remote machine's system type---e.g., @code{"x86_64-linux"}.
49e6291a
LC
618
619@item user
620The user account to use when connecting to the remote machine over SSH.
621Note that the SSH key pair must @emph{not} be passphrase-protected, to
622allow non-interactive logins.
623
624@end table
625
4ec2e92d 626A number of optional fields may be specified:
49e6291a
LC
627
628@table @code
629
cecd72d5
LC
630@item port
631Port number of the machine's SSH server (default: 22).
632
49e6291a
LC
633@item private-key
634The SSH private key file to use when connecting to the machine.
635
636@item parallel-builds
637The number of builds that may run in parallel on the machine (1 by
638default.)
639
640@item speed
641A ``relative speed factor''. The offload scheduler will tend to prefer
642machines with a higher speed factor.
643
644@item features
645A list of strings denoting specific features supported by the machine.
646An example is @code{"kvm"} for machines that have the KVM Linux modules
647and corresponding hardware support. Derivations can request features by
648name, and they will be scheduled on matching build machines.
649
650@end table
c678a4ee 651@end deftp
49e6291a
LC
652
653The @code{guix} command must be in the search path on the build
654machines, since offloading works by invoking the @code{guix archive} and
655@code{guix build} commands.
656
657There's one last thing to do once @file{machines.scm} is in place. As
658explained above, when offloading, files are transferred back and forth
659between the machine stores. For this to work, you need to generate a
660key pair to allow the daemon to export signed archives of files from the
661store (@pxref{Invoking guix archive}):
662
663@example
664# guix archive --generate-key
665@end example
666
667@noindent
668Thus, when receiving files, a machine's build daemon can make sure they
669are genuine, have not been tampered with, and that they are signed by an
670authorized key.
671
672
bd5e766b
LC
673@node Invoking guix-daemon
674@section Invoking @command{guix-daemon}
675
676The @command{guix-daemon} program implements all the functionality to
677access the store. This includes launching build processes, running the
678garbage collector, querying the availability of a build result, etc. It
679is normally run as @code{root} like this:
680
681@example
cfc149dc 682# guix-daemon --build-users-group=guixbuild
bd5e766b
LC
683@end example
684
685@noindent
081145cf 686For details on how to set it up, @pxref{Setting Up the Daemon}.
bd5e766b 687
e900c503
LC
688@cindex chroot
689@cindex container, build environment
690@cindex build environment
691@cindex reproducible builds
bd5e766b
LC
692By default, @command{guix-daemon} launches build processes under
693different UIDs, taken from the build group specified with
694@code{--build-users-group}. In addition, each build process is run in a
695chroot environment that only contains the subset of the store that the
696build process depends on, as specified by its derivation
697(@pxref{Programming Interface, derivation}), plus a set of specific
698system directories. By default, the latter contains @file{/dev} and
e900c503
LC
699@file{/dev/pts}. Furthermore, on GNU/Linux, the build environment is a
700@dfn{container}: in addition to having its own file system tree, it has
701a separate mount name space, its own PID name space, network name space,
702etc. This helps achieve reproducible builds (@pxref{Features}).
bd5e766b 703
cbc538fe
LC
704When the daemon performs a build on behalf of the user, it creates a
705build directory under @file{/tmp} or under the directory specified by
706its @code{TMPDIR} environment variable; this directory is shared with
707the container for the duration of the build. Be aware that using a
708directory other than @file{/tmp} can affect build results---for example,
709with a longer directory name, a build process that uses Unix-domain
710sockets might hit the name length limitation for @code{sun_path}, which
711it would otherwise not hit.
712
713The build directory is automatically deleted upon completion, unless the
714build failed and the client specified @option{--keep-failed}
715(@pxref{Invoking guix build, @option{--keep-failed}}).
716
bd5e766b
LC
717The following command-line options are supported:
718
719@table @code
720@item --build-users-group=@var{group}
721Take users from @var{group} to run build processes (@pxref{Setting Up
722the Daemon, build users}).
723
6858f9d1 724@item --no-substitutes
b5385b52 725@cindex substitutes
6858f9d1 726Do not use substitutes for build products. That is, always build things
c4202d60
LC
727locally instead of allowing downloads of pre-built binaries
728(@pxref{Substitutes}).
6858f9d1 729
b5385b52
LC
730By default substitutes are used, unless the client---such as the
731@command{guix package} command---is explicitly invoked with
732@code{--no-substitutes}.
733
734When the daemon runs with @code{--no-substitutes}, clients can still
735explicitly enable substitution @i{via} the @code{set-build-options}
736remote procedure call (@pxref{The Store}).
737
9176607e
LC
738@item --substitute-urls=@var{urls}
739Consider @var{urls} the default whitespace-separated list of substitute
ae806096 740source URLs. When this option is omitted, @indicateurl{http://hydra.gnu.org}
9176607e
LC
741is used.
742
743This means that substitutes may be downloaded from @var{urls}, as long
744as they are signed by a trusted signature (@pxref{Substitutes}).
745
4ec2e92d
LC
746@cindex build hook
747@item --no-build-hook
748Do not use the @dfn{build hook}.
749
750The build hook is a helper program that the daemon can start and to
751which it submits build requests. This mechanism is used to offload
752builds to other machines (@pxref{Daemon Offload Setup}).
753
bd5e766b
LC
754@item --cache-failures
755Cache build failures. By default, only successful builds are cached.
756
757@item --cores=@var{n}
758@itemx -c @var{n}
759Use @var{n} CPU cores to build each derivation; @code{0} means as many
760as available.
761
6efc160e 762The default value is @code{0}, but it may be overridden by clients, such
e49951eb
MW
763as the @code{--cores} option of @command{guix build} (@pxref{Invoking
764guix build}).
bd5e766b
LC
765
766The effect is to define the @code{NIX_BUILD_CORES} environment variable
767in the build process, which can then use it to exploit internal
768parallelism---for instance, by running @code{make -j$NIX_BUILD_CORES}.
769
770@item --max-jobs=@var{n}
771@itemx -M @var{n}
772Allow at most @var{n} build jobs in parallel. The default value is
f6526eb3
LC
773@code{1}. Setting it to @code{0} means that no builds will be performed
774locally; instead, the daemon will offload builds (@pxref{Daemon Offload
775Setup}), or simply fail.
bd5e766b
LC
776
777@item --debug
778Produce debugging output.
779
780This is useful to debug daemon start-up issues, but then it may be
781overridden by clients, for example the @code{--verbosity} option of
e49951eb 782@command{guix build} (@pxref{Invoking guix build}).
bd5e766b
LC
783
784@item --chroot-directory=@var{dir}
785Add @var{dir} to the build chroot.
786
787Doing this may change the result of build processes---for instance if
788they use optional dependencies found in @var{dir} when it is available,
789and not otherwise. For that reason, it is not recommended to do so.
790Instead, make sure that each derivation declares all the inputs that it
791needs.
792
793@item --disable-chroot
794Disable chroot builds.
795
796Using this option is not recommended since, again, it would allow build
1e2644bb
LC
797processes to gain access to undeclared dependencies. It is necessary,
798though, when @command{guix-daemon} is running under an unprivileged user
799account.
bd5e766b
LC
800
801@item --disable-log-compression
802Disable compression of the build logs.
803
1da983b9
LC
804Unless @code{--lose-logs} is used, all the build logs are kept in the
805@var{localstatedir}. To save space, the daemon automatically compresses
806them with bzip2 by default. This option disables that.
807
ab3893d7
LC
808@item --disable-deduplication
809@cindex deduplication
bd5e766b
LC
810Disable automatic file ``deduplication'' in the store.
811
1da983b9 812By default, files added to the store are automatically ``deduplicated'':
ab3893d7
LC
813if a newly added file is identical to another one found in the store,
814the daemon makes the new file a hard link to the other file. This can
815noticeably reduce disk usage, at the expense of slightly increasde
816input/output load at the end of a build process. This option disables
817this optimization.
1da983b9 818
6e37066e
LC
819@item --gc-keep-outputs[=yes|no]
820Tell whether the garbage collector (GC) must keep outputs of live
821derivations.
822
823When set to ``yes'', the GC will keep the outputs of any live derivation
824available in the store---the @code{.drv} files. The default is ``no'',
825meaning that derivation outputs are kept only if they are GC roots.
826
827@item --gc-keep-derivations[=yes|no]
828Tell whether the garbage collector (GC) must keep derivations
829corresponding to live outputs.
830
831When set to ``yes'', as is the case by default, the GC keeps
832derivations---i.e., @code{.drv} files---as long as at least one of their
833outputs is live. This allows users to keep track of the origins of
834items in their store. Setting it to ``no'' saves a bit of disk space.
835
836Note that when both @code{--gc-keep-derivations} and
837@code{--gc-keep-outputs} are used, the effect is to keep all the build
838prerequisites (the sources, compiler, libraries, and other build-time
839tools) of live objects in the store, regardless of whether these
840prerequisites are live. This is convenient for developers since it
841saves rebuilds or downloads.
842
bd5e766b
LC
843@item --impersonate-linux-2.6
844On Linux-based systems, impersonate Linux 2.6. This means that the
845kernel's @code{uname} system call will report 2.6 as the release number.
846
847This might be helpful to build programs that (usually wrongfully) depend
848on the kernel version number.
849
850@item --lose-logs
851Do not keep build logs. By default they are kept under
ce33631f 852@code{@var{localstatedir}/guix/log}.
bd5e766b
LC
853
854@item --system=@var{system}
855Assume @var{system} as the current system type. By default it is the
856architecture/kernel pair found at configure time, such as
857@code{x86_64-linux}.
b8d2aa26
LC
858
859@item --listen=@var{socket}
860Listen for connections on @var{socket}, the file name of a Unix-domain
861socket. The default socket is
862@file{@var{localstatedir}/daemon-socket/socket}. This option is only
863useful in exceptional circumstances, such as if you need to run several
864daemons on the same machine.
bd5e766b
LC
865@end table
866
867
eeaf4427
LC
868@c *********************************************************************
869@node Package Management
870@chapter Package Management
871
f8348b91 872The purpose of GNU Guix is to allow users to easily install, upgrade, and
eeaf4427
LC
873remove software packages, without having to know about their build
874procedure or dependencies. Guix also goes beyond this obvious set of
875features.
876
877This chapter describes the main features of Guix, as well as the package
c1941588
LC
878management tools it provides. Two user interfaces are provided for
879routine package management tasks: a command-line interface
880(@pxref{Invoking guix package, @code{guix package}}), and a visual user
881interface in Emacs (@pxref{Emacs Interface}).
eeaf4427
LC
882
883@menu
884* Features:: How Guix will make your life brighter.
e49951eb 885* Invoking guix package:: Package installation, removal, etc.
457f60fa 886* Emacs Interface:: Package management from Emacs.
c4202d60 887* Substitutes:: Downloading pre-built binaries.
760c60d6 888* Packages with Multiple Outputs:: Single source package, multiple outputs.
e49951eb 889* Invoking guix gc:: Running the garbage collector.
f651b477 890* Invoking guix pull:: Fetching the latest Guix and distribution.
760c60d6 891* Invoking guix archive:: Exporting and importing store files.
eeaf4427
LC
892@end menu
893
894@node Features
895@section Features
896
897When using Guix, each package ends up in the @dfn{package store}, in its
898own directory---something that resembles
9a130e19
AK
899@file{/gnu/store/xxx-package-1.2}, where @code{xxx} is a base32 string
900(note that Guix comes with an Emacs extension to shorten those file
081145cf 901names, @pxref{Emacs Prettify}.)
eeaf4427
LC
902
903Instead of referring to these directories, users have their own
904@dfn{profile}, which points to the packages that they actually want to
821b0015
LC
905use. These profiles are stored within each user's home directory, at
906@code{$HOME/.guix-profile}.
eeaf4427 907
821b0015 908For example, @code{alice} installs GCC 4.7.2. As a result,
eeaf4427 909@file{/home/alice/.guix-profile/bin/gcc} points to
834129e0 910@file{/gnu/store/@dots{}-gcc-4.7.2/bin/gcc}. Now, on the same machine,
821b0015
LC
911@code{bob} had already installed GCC 4.8.0. The profile of @code{bob}
912simply continues to point to
834129e0 913@file{/gnu/store/@dots{}-gcc-4.8.0/bin/gcc}---i.e., both versions of GCC
821b0015 914coexist on the same system without any interference.
eeaf4427 915
e49951eb
MW
916The @command{guix package} command is the central tool to manage
917packages (@pxref{Invoking guix package}). It operates on those per-user
821b0015 918profiles, and can be used @emph{with normal user privileges}.
eeaf4427
LC
919
920The command provides the obvious install, remove, and upgrade
921operations. Each invocation is actually a @emph{transaction}: either
ba55b1cb 922the specified operation succeeds, or nothing happens. Thus, if the
e49951eb 923@command{guix package} process is terminated during the transaction,
eeaf4427
LC
924or if a power outage occurs during the transaction, then the user's
925profile remains in its previous state, and remains usable.
926
927In addition, any package transaction may be @emph{rolled back}. So, if,
928for example, an upgrade installs a new version of a package that turns
929out to have a serious bug, users may roll back to the previous instance
4af2447e
LC
930of their profile, which was known to work well. Similarly, the global
931system configuration is subject to transactional upgrades and roll-back
932(@pxref{Using the Configuration System}).
eeaf4427
LC
933
934All those packages in the package store may be @emph{garbage-collected}.
935Guix can determine which packages are still referenced by the user
fe8ff028 936profiles, and remove those that are provably no longer referenced
e49951eb 937(@pxref{Invoking guix gc}). Users may also explicitly remove old
fe8ff028
LC
938generations of their profile so that the packages they refer to can be
939collected.
eeaf4427 940
e900c503
LC
941@cindex reproducibility
942@cindex reproducible builds
eeaf4427
LC
943Finally, Guix takes a @dfn{purely functional} approach to package
944management, as described in the introduction (@pxref{Introduction}).
834129e0 945Each @file{/gnu/store} package directory name contains a hash of all the
eeaf4427
LC
946inputs that were used to build that package---compiler, libraries, build
947scripts, etc. This direct correspondence allows users to make sure a
948given package installation matches the current state of their
e900c503
LC
949distribution. It also helps maximize @dfn{build reproducibility}:
950thanks to the isolated build environments that are used, a given build
951is likely to yield bit-identical files when performed on different
952machines (@pxref{Invoking guix-daemon, container}).
eeaf4427 953
c4202d60 954@cindex substitutes
eeaf4427 955This foundation allows Guix to support @dfn{transparent binary/source
c4202d60 956deployment}. When a pre-built binary for a @file{/gnu/store} item is
18f2887b 957available from an external source---a @dfn{substitute}, Guix just
c4202d60
LC
958downloads it and unpacks it;
959otherwise, it builds the package from source, locally
960(@pxref{Substitutes}).
eeaf4427 961
f5fd4fd2
LC
962Control over the build environment is a feature that is also useful for
963developers. The @command{guix environment} command allows developers of
964a package to quickly set up the right development environment for their
965package, without having to manually install the package's dependencies
966in their profile (@pxref{Invoking guix environment}).
967
e49951eb
MW
968@node Invoking guix package
969@section Invoking @command{guix package}
eeaf4427 970
e49951eb 971The @command{guix package} command is the tool that allows users to
eeaf4427
LC
972install, upgrade, and remove packages, as well as rolling back to
973previous configurations. It operates only on the user's own profile,
974and works with normal user privileges (@pxref{Features}). Its syntax
975is:
976
977@example
e49951eb 978guix package @var{options}
eeaf4427
LC
979@end example
980
ba55b1cb 981Primarily, @var{options} specifies the operations to be performed during
eeaf4427 982the transaction. Upon completion, a new profile is created, but
99bd74d5 983previous @dfn{generations} of the profile remain available, should the user
eeaf4427
LC
984want to roll back.
985
6447738c
MW
986For example, to remove @code{lua} and install @code{guile} and
987@code{guile-cairo} in a single transaction:
988
989@example
990guix package -r lua -i guile guile-cairo
991@end example
992
99bd74d5
LC
993@command{guix package} also supports a @dfn{declarative approach}
994whereby the user specifies the exact set of packages to be available and
995passes it @i{via} the @option{--manifest} option
996(@pxref{profile-manifest, @option{--manifest}}).
997
b9e5c0a9 998For each user, a symlink to the user's default profile is automatically
0ec1af59 999created in @file{$HOME/.guix-profile}. This symlink always points to the
b9e5c0a9
LC
1000current generation of the user's default profile. Thus, users can add
1001@file{$HOME/.guix-profile/bin} to their @code{PATH} environment
1002variable, and so on.
d664f1b4
LC
1003@cindex search paths
1004If you are not using the Guix System Distribution, consider adding the
1005following lines to your @file{~/.bash_profile} (@pxref{Bash Startup
1006Files,,, bash, The GNU Bash Reference Manual}) so that newly-spawned
1007shells get all the right environment variable definitions:
1008
1009@example
1010GUIX_PROFILE="$HOME/.guix-profile" \
1011source "$HOME/.guix-profile/etc/profile"
1012@end example
b9e5c0a9 1013
4379c35b
LC
1014In a multi-user setup, user profiles are stored in a place registered as
1015a @dfn{garbage-collector root}, which @file{$HOME/.guix-profile} points
1016to (@pxref{Invoking guix gc}). That directory is normally
0ec1af59
LC
1017@code{@var{localstatedir}/profiles/per-user/@var{user}}, where
1018@var{localstatedir} is the value passed to @code{configure} as
4379c35b
LC
1019@code{--localstatedir}, and @var{user} is the user name. The
1020@file{per-user} directory is created when @command{guix-daemon} is
1021started, and the @var{user} sub-directory is created by @command{guix
1022package}.
0ec1af59
LC
1023
1024The @var{options} can be among the following:
1025
eeaf4427
LC
1026@table @code
1027
6447738c
MW
1028@item --install=@var{package} @dots{}
1029@itemx -i @var{package} @dots{}
1030Install the specified @var{package}s.
eeaf4427 1031
6447738c 1032Each @var{package} may specify either a simple package name, such as
eeaf4427 1033@code{guile}, or a package name followed by a hyphen and version number,
724311a2
LC
1034such as @code{guile-1.8.8} or simply @code{guile-1.8} (in the latter
1035case, the newest version prefixed by @code{1.8} is selected.)
1036
1037If no version number is specified, the
dc5669cd
MW
1038newest available version will be selected. In addition, @var{package}
1039may contain a colon, followed by the name of one of the outputs of the
6e721c4d 1040package, as in @code{gcc:doc} or @code{binutils-2.22:lib}
e7f34eb0
LC
1041(@pxref{Packages with Multiple Outputs}). Packages with a corresponding
1042name (and optionally version) are searched for among the GNU
1043distribution modules (@pxref{Package Modules}).
eeaf4427 1044
461572cc
LC
1045@cindex propagated inputs
1046Sometimes packages have @dfn{propagated inputs}: these are dependencies
21461f27
LC
1047that automatically get installed along with the required package
1048(@pxref{package-propagated-inputs, @code{propagated-inputs} in
1049@code{package} objects}, for information about propagated inputs in
1050package definitions).
461572cc 1051
21461f27 1052@anchor{package-cmd-propagated-inputs}
461572cc
LC
1053An example is the GNU MPC library: its C header files refer to those of
1054the GNU MPFR library, which in turn refer to those of the GMP library.
1055Thus, when installing MPC, the MPFR and GMP libraries also get installed
1056in the profile; removing MPC also removes MPFR and GMP---unless they had
1057also been explicitly installed independently.
1058
ba7ea5ce 1059Besides, packages sometimes rely on the definition of environment
5924080d 1060variables for their search paths (see explanation of
ba7ea5ce 1061@code{--search-paths} below). Any missing or possibly incorrect
5924080d
LC
1062environment variable definitions are reported here.
1063
ef010c0f 1064@c XXX: keep me up-to-date
5924080d 1065Finally, when installing a GNU package, the tool reports the
ef010c0f
LC
1066availability of a newer upstream version. In the future, it may provide
1067the option of installing directly from the upstream version, even if
1068that version is not yet in the distribution.
1069
5d4b411f
LC
1070@item --install-from-expression=@var{exp}
1071@itemx -e @var{exp}
1072Install the package @var{exp} evaluates to.
1073
1074@var{exp} must be a Scheme expression that evaluates to a
1075@code{<package>} object. This option is notably useful to disambiguate
1076between same-named variants of a package, with expressions such as
1077@code{(@@ (gnu packages base) guile-final)}.
1078
1079Note that this option installs the first output of the specified
1080package, which may be insufficient when needing a specific output of a
1081multiple-output package.
1082
6447738c
MW
1083@item --remove=@var{package} @dots{}
1084@itemx -r @var{package} @dots{}
1085Remove the specified @var{package}s.
eeaf4427 1086
6447738c 1087As for @code{--install}, each @var{package} may specify a version number
13ed095c
LC
1088and/or output name in addition to the package name. For instance,
1089@code{-r glibc:debug} would remove the @code{debug} output of
1090@code{glibc}.
1091
6447738c
MW
1092@item --upgrade[=@var{regexp} @dots{}]
1093@itemx -u [@var{regexp} @dots{}]
1094Upgrade all the installed packages. If one or more @var{regexp}s are
1095specified, upgrade only installed packages whose name matches a
d5f01e48 1096@var{regexp}. Also see the @code{--do-not-upgrade} option below.
eeaf4427 1097
f651b477
LC
1098Note that this upgrades package to the latest version of packages found
1099in the distribution currently installed. To update your distribution,
1100you should regularly run @command{guix pull} (@pxref{Invoking guix
1101pull}).
1102
d5f01e48
MW
1103@item --do-not-upgrade[=@var{regexp} @dots{}]
1104When used together with the @code{--upgrade} option, do @emph{not}
1105upgrade any packages whose name matches a @var{regexp}. For example, to
1106upgrade all packages in the current profile except those containing the
1107substring ``emacs'':
1108
1109@example
1110$ guix package --upgrade . --do-not-upgrade emacs
1111@end example
1112
99bd74d5 1113@item @anchor{profile-manifest}--manifest=@var{file}
1b676447 1114@itemx -m @var{file}
99bd74d5
LC
1115@cindex profile declaration
1116@cindex profile manifest
1117Create a new generation of the profile from the manifest object
1b676447
DT
1118returned by the Scheme code in @var{file}.
1119
99bd74d5
LC
1120This allows you to @emph{declare} the profile's contents rather than
1121constructing it through a sequence of @code{--install} and similar
1122commands. The advantage is that @var{file} can be put under version
1123control, copied to different machines to reproduce the same profile, and
1124so on.
1125
1126@c FIXME: Add reference to (guix profile) documentation when available.
1127@var{file} must return a @dfn{manifest} object, which is roughly a list
1128of packages:
1b676447 1129
99bd74d5 1130@findex packages->manifest
1b676447 1131@example
99bd74d5 1132(use-package-modules guile emacs)
1b676447
DT
1133
1134(packages->manifest
99bd74d5
LC
1135 (list emacs
1136 guile-2.0
1b676447 1137 ;; Use a specific package output.
99bd74d5 1138 (list guile-2.0 "debug")))
1b676447
DT
1139@end example
1140
24e262f0
LC
1141@item --roll-back
1142Roll back to the previous @dfn{generation} of the profile---i.e., undo
1143the last transaction.
1144
1145When combined with options such as @code{--install}, roll back occurs
1146before any other actions.
1147
d9307267 1148When rolling back from the first generation that actually contains
4b2bc804
NK
1149installed packages, the profile is made to point to the @dfn{zeroth
1150generation}, which contains no files apart from its own meta-data.
d9307267 1151
82fe08ed
LC
1152Installing, removing, or upgrading packages from a generation that has
1153been rolled back to overwrites previous future generations. Thus, the
1154history of a profile's generations is always linear.
1155
b3bb82f1
AK
1156@item --switch-generation=@var{pattern}
1157@itemx -S @var{pattern}
1158Switch to a particular generation defined by @var{pattern}.
1159
1160@var{pattern} may be either a generation number or a number prefixed
1161with ``+'' or ``-''. The latter means: move forward/backward by a
1162specified number of generations. For example, if you want to return to
1163the latest generation after @code{--roll-back}, use
1164@code{--switch-generation=+1}.
1165
1166The difference between @code{--roll-back} and
1167@code{--switch-generation=-1} is that @code{--switch-generation} will
1168not make a zeroth generation, so if a specified generation does not
1169exist, the current generation will not be changed.
1170
dbc31ab2 1171@item --search-paths[=@var{kind}]
5924080d
LC
1172@cindex search paths
1173Report environment variable definitions, in Bash syntax, that may be
1174needed in order to use the set of installed packages. These environment
1175variables are used to specify @dfn{search paths} for files used by some
1176of the installed packages.
1177
1178For example, GCC needs the @code{CPATH} and @code{LIBRARY_PATH}
1179environment variables to be defined so it can look for headers and
1180libraries in the user's profile (@pxref{Environment Variables,,, gcc,
1181Using the GNU Compiler Collection (GCC)}). If GCC and, say, the C
1182library are installed in the profile, then @code{--search-paths} will
1183suggest setting these variables to @code{@var{profile}/include} and
1184@code{@var{profile}/lib}, respectively.
1185
dbc31ab2
LC
1186The typical use case is to define these environment variables in the
1187shell:
1188
1189@example
1190$ eval `guix package --search-paths`
1191@end example
1192
1193@var{kind} may be one of @code{exact}, @code{prefix}, or @code{suffix},
1194meaning that the returned environment variable definitions will either
1195be exact settings, or prefixes or suffixes of the current value of these
1196variables. When omitted, @var{kind} defaults to @code{exact}.
1197
eeaf4427
LC
1198@item --profile=@var{profile}
1199@itemx -p @var{profile}
1200Use @var{profile} instead of the user's default profile.
1201
70915c1a
LC
1202@item --verbose
1203Produce verbose output. In particular, emit the environment's build log
1204on the standard error port.
1205
eeaf4427
LC
1206@item --bootstrap
1207Use the bootstrap Guile to build the profile. This option is only
1208useful to distribution developers.
1209
1210@end table
1211
e49951eb 1212In addition to these actions @command{guix package} supports the
733b4130
LC
1213following options to query the current state of a profile, or the
1214availability of packages:
eeaf4427 1215
733b4130
LC
1216@table @option
1217
acc08466
NK
1218@item --search=@var{regexp}
1219@itemx -s @var{regexp}
5763ad92 1220List the available packages whose name, synopsis, or description matches
299112d3
LC
1221@var{regexp}. Print all the meta-data of matching packages in
1222@code{recutils} format (@pxref{Top, GNU recutils databases,, recutils,
1223GNU recutils manual}).
acc08466 1224
299112d3
LC
1225This allows specific fields to be extracted using the @command{recsel}
1226command, for instance:
1227
1228@example
e49951eb 1229$ guix package -s malloc | recsel -p name,version
299112d3
LC
1230name: glibc
1231version: 2.17
1232
1233name: libgc
1234version: 7.2alpha6
1235@end example
acc08466 1236
a12d92f5
LC
1237Similarly, to show the name of all the packages available under the
1238terms of the GNU@tie{}LGPL version 3:
1239
1240@example
1241$ guix package -s "" | recsel -p name -e 'license ~ "LGPL 3"'
1242name: elfutils
1243
1244name: gmp
1245@dots{}
1246@end example
1247
2aa6efb0
CR
1248@item --show=@var{package}
1249Show details about @var{package}, taken from the list of available packages, in
1250@code{recutils} format (@pxref{Top, GNU recutils databases,, recutils, GNU
1251recutils manual}).
1252
1253@example
1254$ guix package --show=python | recsel -p name,version
1255name: python
1256version: 2.7.6
1257
1258name: python
1259version: 3.3.5
1260@end example
1261
1262You may also specify the full name of a package to only get details about a
1263specific version of it:
1264@example
1265$ guix package --show=python-3.3.5 | recsel -p name,version
1266name: python
1267version: 3.3.5
1268@end example
1269
1270
1271
733b4130
LC
1272@item --list-installed[=@var{regexp}]
1273@itemx -I [@var{regexp}]
bd9bde1c
LC
1274List the currently installed packages in the specified profile, with the
1275most recently installed packages shown last. When @var{regexp} is
1276specified, list only installed packages whose name matches @var{regexp}.
733b4130
LC
1277
1278For each installed package, print the following items, separated by
1279tabs: the package name, its version string, the part of the package that
1280is installed (for instance, @code{out} for the default output,
1281@code{include} for its headers, etc.), and the path of this package in
1282the store.
1283
64fc89b6
LC
1284@item --list-available[=@var{regexp}]
1285@itemx -A [@var{regexp}]
5763ad92 1286List packages currently available in the distribution for this system
a1ba8475
LC
1287(@pxref{GNU Distribution}). When @var{regexp} is specified, list only
1288installed packages whose name matches @var{regexp}.
64fc89b6
LC
1289
1290For each package, print the following items separated by tabs: its name,
6e721c4d
LC
1291its version string, the parts of the package (@pxref{Packages with
1292Multiple Outputs}), and the source location of its definition.
64fc89b6 1293
f566d765
LC
1294@item --list-generations[=@var{pattern}]
1295@itemx -l [@var{pattern}]
1296Return a list of generations along with their creation dates; for each
1297generation, show the installed packages, with the most recently
4b2bc804
NK
1298installed packages shown last. Note that the zeroth generation is never
1299shown.
f566d765
LC
1300
1301For each installed package, print the following items, separated by
1302tabs: the name of a package, its version string, the part of the package
1303that is installed (@pxref{Packages with Multiple Outputs}), and the
1304location of this package in the store.
1305
1306When @var{pattern} is used, the command returns only matching
1307generations. Valid patterns include:
1308
1309@itemize
1310@item @emph{Integers and comma-separated integers}. Both patterns denote
1311generation numbers. For instance, @code{--list-generations=1} returns
1312the first one.
1313
1314And @code{--list-generations=1,8,2} outputs three generations in the
1315specified order. Neither spaces nor trailing commas are allowed.
1316
1317@item @emph{Ranges}. @code{--list-generations=2..9} prints the
1318specified generations and everything in between. Note that the start of
1319a range must be lesser than its end.
1320
1321It is also possible to omit the endpoint. For example,
1322@code{--list-generations=2..}, returns all generations starting from the
1323second one.
1324
1325@item @emph{Durations}. You can also get the last @emph{N}@tie{}days, weeks,
1326or months by passing an integer along with the first letter of the
d7ddb257
LC
1327duration. For example, @code{--list-generations=20d} lists generations
1328that are up to 20 days old.
f566d765
LC
1329@end itemize
1330
b7884ca3
NK
1331@item --delete-generations[=@var{pattern}]
1332@itemx -d [@var{pattern}]
d7ddb257
LC
1333When @var{pattern} is omitted, delete all generations except the current
1334one.
b7884ca3
NK
1335
1336This command accepts the same patterns as @option{--list-generations}.
d7ddb257
LC
1337When @var{pattern} is specified, delete the matching generations. When
1338@var{pattern} specifies a duration, generations @emph{older} than the
1339specified duration match. For instance, @code{--delete-generations=1m}
1340deletes generations that are more than one month old.
1341
391bdd8f
LC
1342If the current generation matches, it is @emph{not} deleted. Also, the
1343zeroth generation is never deleted.
b7884ca3 1344
1bb9900a
LC
1345Note that deleting generations prevents roll-back to them.
1346Consequently, this command must be used with care.
1347
733b4130 1348@end table
eeaf4427 1349
70ee5642
LC
1350Finally, since @command{guix package} may actually start build
1351processes, it supports all the common build options that @command{guix
1352build} supports (@pxref{Invoking guix build, common build options}).
1353
457f60fa
AK
1354@include emacs.texi
1355
c4202d60
LC
1356@node Substitutes
1357@section Substitutes
1358
1359@cindex substitutes
1360@cindex pre-built binaries
1361Guix supports transparent source/binary deployment, which means that it
1362can either build things locally, or download pre-built items from a
1363server. We call these pre-built items @dfn{substitutes}---they are
1364substitutes for local build results. In many cases, downloading a
1365substitute is much faster than building things locally.
1366
1367Substitutes can be anything resulting from a derivation build
1368(@pxref{Derivations}). Of course, in the common case, they are
1369pre-built package binaries, but source tarballs, for instance, which
1370also result from derivation builds, can be available as substitutes.
1371
1372The @code{hydra.gnu.org} server is a front-end to a build farm that
1373builds packages from the GNU distribution continuously for some
9176607e
LC
1374architectures, and makes them available as substitutes. This is the
1375default source of substitutes; it can be overridden by passing
1376@command{guix-daemon} the @code{--substitute-urls} option
1377(@pxref{Invoking guix-daemon}).
c4202d60
LC
1378
1379@cindex security
1380@cindex digital signatures
1381To allow Guix to download substitutes from @code{hydra.gnu.org}, you
1382must add its public key to the access control list (ACL) of archive
1383imports, using the @command{guix archive} command (@pxref{Invoking guix
1384archive}). Doing so implies that you trust @code{hydra.gnu.org} to not
1385be compromised and to serve genuine substitutes.
1386
1387This public key is installed along with Guix, in
1388@code{@var{prefix}/share/guix/hydra.gnu.org.pub}, where @var{prefix} is
1389the installation prefix of Guix. If you installed Guix from source,
1390make sure you checked the GPG signature of
1391@file{guix-@value{VERSION}.tar.gz}, which contains this public key file.
1392Then, you can run something like this:
1393
1394@example
1395# guix archive --authorize < hydra.gnu.org.pub
1396@end example
1397
1398Once this is in place, the output of a command like @code{guix build}
1399should change from something like:
1400
1401@example
1402$ guix build emacs --dry-run
1403The following derivations would be built:
1404 /gnu/store/yr7bnx8xwcayd6j95r2clmkdl1qh688w-emacs-24.3.drv
1405 /gnu/store/x8qsh1hlhgjx6cwsjyvybnfv2i37z23w-dbus-1.6.4.tar.gz.drv
1406 /gnu/store/1ixwp12fl950d15h2cj11c73733jay0z-alsa-lib-1.0.27.1.tar.bz2.drv
1407 /gnu/store/nlma1pw0p603fpfiqy7kn4zm105r5dmw-util-linux-2.21.drv
1408@dots{}
1409@end example
1410
1411@noindent
1412to something like:
1413
1414@example
1415$ guix build emacs --dry-run
1416The following files would be downloaded:
1417 /gnu/store/pk3n22lbq6ydamyymqkkz7i69wiwjiwi-emacs-24.3
1418 /gnu/store/2ygn4ncnhrpr61rssa6z0d9x22si0va3-libjpeg-8d
1419 /gnu/store/71yz6lgx4dazma9dwn2mcjxaah9w77jq-cairo-1.12.16
1420 /gnu/store/7zdhgp0n1518lvfn8mb96sxqfmvqrl7v-libxrender-0.9.7
1421@dots{}
1422@end example
1423
1424@noindent
1425This indicates that substitutes from @code{hydra.gnu.org} are usable and
1426will be downloaded, when possible, for future builds.
1427
1428Guix ignores substitutes that are not signed, or that are not signed by
ef27aa9c 1429one of the keys listed in the ACL. It also detects and raises an error
c4202d60
LC
1430when attempting to use a substitute that has been tampered with.
1431
1432The substitute mechanism can be disabled globally by running
1433@code{guix-daemon} with @code{--no-substitutes} (@pxref{Invoking
1434guix-daemon}). It can also be disabled temporarily by passing the
1435@code{--no-substitutes} option to @command{guix package}, @command{guix
1436build}, and other command-line tools.
1437
1438
1439Today, each individual's control over their own computing is at the
1440mercy of institutions, corporations, and groups with enough power and
1441determination to subvert the computing infrastructure and exploit its
1442weaknesses. While using @code{hydra.gnu.org} substitutes can be
1443convenient, we encourage users to also build on their own, or even run
1444their own build farm, such that @code{hydra.gnu.org} is less of an
8ce229fc
LC
1445interesting target. One way to help is by publishing the software you
1446build using @command{guix publish} so that others have one more choice
1447of server to download substitutes from (@pxref{Invoking guix publish}).
c4202d60
LC
1448
1449Guix has the foundations to maximize build reproducibility
1450(@pxref{Features}). In most cases, independent builds of a given
1451package or derivation should yield bit-identical results. Thus, through
1452a diverse set of independent package builds, we can strengthen the
1453integrity of our systems.
1454
1455In the future, we want Guix to have support to publish and retrieve
1456binaries to/from other users, in a peer-to-peer fashion. If you would
1457like to discuss this project, join us on @email{guix-devel@@gnu.org}.
1458
1459
6e721c4d
LC
1460@node Packages with Multiple Outputs
1461@section Packages with Multiple Outputs
1462
1463@cindex multiple-output packages
1464@cindex package outputs
1465
1466Often, packages defined in Guix have a single @dfn{output}---i.e., the
1467source package leads exactly one directory in the store. When running
1468@command{guix package -i glibc}, one installs the default output of the
1469GNU libc package; the default output is called @code{out}, but its name
1470can be omitted as shown in this command. In this particular case, the
1471default output of @code{glibc} contains all the C header files, shared
1472libraries, static libraries, Info documentation, and other supporting
1473files.
1474
1475Sometimes it is more appropriate to separate the various types of files
1476produced from a single source package into separate outputs. For
1477instance, the GLib C library (used by GTK+ and related packages)
1478installs more than 20 MiB of reference documentation as HTML pages.
1479To save space for users who do not need it, the documentation goes to a
1480separate output, called @code{doc}. To install the main GLib output,
1481which contains everything but the documentation, one would run:
1482
1483@example
1484guix package -i glib
1485@end example
1486
1487The command to install its documentation is:
1488
1489@example
1490guix package -i glib:doc
1491@end example
1492
1493Some packages install programs with different ``dependency footprints''.
1494For instance, the WordNet package install both command-line tools and
1495graphical user interfaces (GUIs). The former depend solely on the C
1496library, whereas the latter depend on Tcl/Tk and the underlying X
1497libraries. In this case, we leave the command-line tools in the default
1498output, whereas the GUIs are in a separate output. This allows users
fcc58db6
LC
1499who do not need the GUIs to save space. The @command{guix size} command
1500can help find out about such situations (@pxref{Invoking guix size}).
6e721c4d
LC
1501
1502There are several such multiple-output packages in the GNU distribution.
91ef73d4
LC
1503Other conventional output names include @code{lib} for libraries and
1504possibly header files, @code{bin} for stand-alone programs, and
1505@code{debug} for debugging information (@pxref{Installing Debugging
1506Files}). The outputs of a packages are listed in the third column of
1507the output of @command{guix package --list-available} (@pxref{Invoking
1508guix package}).
6e721c4d 1509
eeaf4427 1510
e49951eb
MW
1511@node Invoking guix gc
1512@section Invoking @command{guix gc}
fe8ff028
LC
1513
1514@cindex garbage collector
1515Packages that are installed but not used may be @dfn{garbage-collected}.
e49951eb 1516The @command{guix gc} command allows users to explicitly run the garbage
c22eb992
LC
1517collector to reclaim space from the @file{/gnu/store} directory. It is
1518the @emph{only} way to remove files from @file{/gnu/store}---removing
1519files or directories manually may break it beyond repair!
fe8ff028
LC
1520
1521The garbage collector has a set of known @dfn{roots}: any file under
834129e0 1522@file{/gnu/store} reachable from a root is considered @dfn{live} and
fe8ff028
LC
1523cannot be deleted; any other file is considered @dfn{dead} and may be
1524deleted. The set of garbage collector roots includes default user
e49951eb
MW
1525profiles, and may be augmented with @command{guix build --root}, for
1526example (@pxref{Invoking guix build}).
fe8ff028 1527
1bb9900a
LC
1528Prior to running @code{guix gc --collect-garbage} to make space, it is
1529often useful to remove old generations from user profiles; that way, old
1530package builds referenced by those generations can be reclaimed. This
1531is achieved by running @code{guix package --delete-generations}
1532(@pxref{Invoking guix package}).
1533
e49951eb 1534The @command{guix gc} command has three modes of operation: it can be
fe8ff028 1535used to garbage-collect any dead files (the default), to delete specific
7770aafc
LC
1536files (the @code{--delete} option), to print garbage-collector
1537information, or for more advanced queries. The garbage collection
1538options are as follows:
fe8ff028
LC
1539
1540@table @code
1541@item --collect-garbage[=@var{min}]
1542@itemx -C [@var{min}]
834129e0 1543Collect garbage---i.e., unreachable @file{/gnu/store} files and
fe8ff028
LC
1544sub-directories. This is the default operation when no option is
1545specified.
1546
1547When @var{min} is given, stop once @var{min} bytes have been collected.
1548@var{min} may be a number of bytes, or it may include a unit as a
4a44d7bb
LC
1549suffix, such as @code{MiB} for mebibytes and @code{GB} for gigabytes
1550(@pxref{Block size, size specifications,, coreutils, GNU Coreutils}).
fe8ff028
LC
1551
1552When @var{min} is omitted, collect all the garbage.
1553
1554@item --delete
1555@itemx -d
1556Attempt to delete all the store files and directories specified as
1557arguments. This fails if some of the files are not in the store, or if
1558they are still live.
1559
1560@item --list-dead
1561Show the list of dead files and directories still present in the
1562store---i.e., files and directories no longer reachable from any root.
1563
1564@item --list-live
1565Show the list of live store files and directories.
ba8b732d
LC
1566
1567@end table
1568
1569In addition, the references among existing store files can be queried:
1570
1571@table @code
1572
1573@item --references
1574@itemx --referrers
1575List the references (respectively, the referrers) of store files given
1576as arguments.
1577
8e59fdd5
LC
1578@item --requisites
1579@itemx -R
fcc58db6 1580@cindex closure
8e59fdd5
LC
1581List the requisites of the store files passed as arguments. Requisites
1582include the store files themselves, their references, and the references
1583of these, recursively. In other words, the returned list is the
1584@dfn{transitive closure} of the store files.
1585
fcc58db6
LC
1586@xref{Invoking guix size}, for a tool to profile the size of an
1587element's closure.
1588
fe8ff028
LC
1589@end table
1590
7770aafc
LC
1591Lastly, the following options allow you to check the integrity of the
1592store and to control disk usage.
1593
1594@table @option
1595
1596@item --verify[=@var{options}]
1597@cindex integrity, of the store
1598@cindex integrity checking
1599Verify the integrity of the store.
1600
1601By default, make sure that all the store items marked as valid in the
1602daemon's database actually exist in @file{/gnu/store}.
1603
1604When provided, @var{options} must a comma-separated list containing one
1605or more of @code{contents} and @code{repair}.
1606
1607When passing @option{--verify=contents}, the daemon will compute the
1608content hash of each store item and compare it against its hash in the
1609database. Hash mismatches are reported as data corruptions. Because it
1610traverses @emph{all the files in the store}, this command can take a
1611long time, especially on systems with a slow disk drive.
1612
1613@cindex repairing the store
1614Using @option{--verify=repair} or @option{--verify=contents,repair}
1615causes the daemon to try to repair corrupt store items by fetching
1616substitutes for them (@pxref{Substitutes}). Because repairing is not
1617atomic, and thus potentially dangerous, it is available only to the
1618system administrator.
1619
1620@item --optimize
1621@cindex deduplication
1622Optimize the store by hard-linking identical files---this is
1623@dfn{deduplication}.
1624
1625The daemon performs deduplication after each successful build or archive
1626import, unless it was started with @code{--disable-deduplication}
1627(@pxref{Invoking guix-daemon, @code{--disable-deduplication}}). Thus,
1628this option is primarily useful when the daemon was running with
1629@code{--disable-deduplication}.
1630
1631@end table
eeaf4427 1632
f651b477
LC
1633@node Invoking guix pull
1634@section Invoking @command{guix pull}
1635
1636Packages are installed or upgraded to the latest version available in
1637the distribution currently available on your local machine. To update
1638that distribution, along with the Guix tools, you must run @command{guix
1639pull}: the command downloads the latest Guix source code and package
1640descriptions, and deploys it.
1641
1642On completion, @command{guix package} will use packages and package
1643versions from this just-retrieved copy of Guix. Not only that, but all
1644the Guix commands and Scheme modules will also be taken from that latest
1645version. New @command{guix} sub-commands added by the update also
1646become available.
1647
1648The @command{guix pull} command is usually invoked with no arguments,
1649but it supports the following options:
1650
1651@table @code
1652@item --verbose
1653Produce verbose output, writing build logs to the standard error output.
1654
ab5d72ad
LC
1655@item --url=@var{url}
1656Download the source tarball of Guix from @var{url}.
1657
1658By default, the tarball is taken from its canonical address at
1659@code{gnu.org}, for the stable branch of Guix.
1660
f651b477
LC
1661@item --bootstrap
1662Use the bootstrap Guile to build the latest Guix. This option is only
1663useful to Guix developers.
1664@end table
1665
760c60d6
LC
1666
1667@node Invoking guix archive
1668@section Invoking @command{guix archive}
1669
1670The @command{guix archive} command allows users to @dfn{export} files
1671from the store into a single archive, and to later @dfn{import} them.
1672In particular, it allows store files to be transferred from one machine
1673to another machine's store. For example, to transfer the @code{emacs}
1674package to a machine connected over SSH, one would run:
1675
1676@example
56607088 1677guix archive --export -r emacs | ssh the-machine guix archive --import
760c60d6
LC
1678@end example
1679
87236aed 1680@noindent
56607088
LC
1681Similarly, a complete user profile may be transferred from one machine
1682to another like this:
1683
1684@example
1685guix archive --export -r $(readlink -f ~/.guix-profile) | \
1686 ssh the-machine guix-archive --import
1687@end example
1688
1689@noindent
1690However, note that, in both examples, all of @code{emacs} and the
1691profile as well as all of their dependencies are transferred (due to
1692@code{-r}), regardless of what is already available in the target
1693machine's store. The @code{--missing} option can help figure out which
1694items are missing from the target's store.
87236aed 1695
760c60d6 1696Archives are stored in the ``Nix archive'' or ``Nar'' format, which is
0dbd88db
LC
1697comparable in spirit to `tar', but with a few noteworthy differences
1698that make it more appropriate for our purposes. First, rather than
1699recording all Unix meta-data for each file, the Nar format only mentions
1700the file type (regular, directory, or symbolic link); Unix permissions
1701and owner/group are dismissed. Second, the order in which directory
1702entries are stored always follows the order of file names according to
1703the C locale collation order. This makes archive production fully
1704deterministic.
1705
1706When exporting, the daemon digitally signs the contents of the archive,
1707and that digital signature is appended. When importing, the daemon
1708verifies the signature and rejects the import in case of an invalid
1709signature or if the signing key is not authorized.
760c60d6
LC
1710@c FIXME: Add xref to daemon doc about signatures.
1711
1712The main options are:
1713
1714@table @code
1715@item --export
1716Export the specified store files or packages (see below.) Write the
1717resulting archive to the standard output.
1718
56607088
LC
1719Dependencies are @emph{not} included in the output, unless
1720@code{--recursive} is passed.
1721
1722@item -r
1723@itemx --recursive
1724When combined with @code{--export}, this instructs @command{guix
1725archive} to include dependencies of the given items in the archive.
1726Thus, the resulting archive is self-contained: it contains the closure
1727of the exported store items.
1728
760c60d6
LC
1729@item --import
1730Read an archive from the standard input, and import the files listed
1731therein into the store. Abort if the archive has an invalid digital
f82cc5fd
LC
1732signature, or if it is signed by a public key not among the authorized
1733keys (see @code{--authorize} below.)
554f26ec 1734
87236aed
LC
1735@item --missing
1736Read a list of store file names from the standard input, one per line,
1737and write on the standard output the subset of these files missing from
1738the store.
1739
554f26ec 1740@item --generate-key[=@var{parameters}]
f82cc5fd 1741@cindex signing, archives
554f26ec
LC
1742Generate a new key pair for the daemons. This is a prerequisite before
1743archives can be exported with @code{--export}. Note that this operation
1744usually takes time, because it needs to gather enough entropy to
1745generate the key pair.
1746
1747The generated key pair is typically stored under @file{/etc/guix}, in
1748@file{signing-key.pub} (public key) and @file{signing-key.sec} (private
867d8473
LC
1749key, which must be kept secret.) When @var{parameters} is omitted,
1750an ECDSA key using the Ed25519 curve is generated, or, for Libgcrypt
1751versions before 1.6.0, it is a 4096-bit RSA key.
1752Alternately, @var{parameters} can specify
554f26ec
LC
1753@code{genkey} parameters suitable for Libgcrypt (@pxref{General
1754public-key related Functions, @code{gcry_pk_genkey},, gcrypt, The
1755Libgcrypt Reference Manual}).
f82cc5fd
LC
1756
1757@item --authorize
1758@cindex authorizing, archives
1759Authorize imports signed by the public key passed on standard input.
1760The public key must be in ``s-expression advanced format''---i.e., the
1761same format as the @file{signing-key.pub} file.
1762
1763The list of authorized keys is kept in the human-editable file
1764@file{/etc/guix/acl}. The file contains
1765@url{http://people.csail.mit.edu/rivest/Sexp.txt, ``advanced-format
1766s-expressions''} and is structured as an access-control list in the
1767@url{http://theworld.com/~cme/spki.txt, Simple Public-Key Infrastructure
1768(SPKI)}.
760c60d6
LC
1769@end table
1770
1771To export store files as an archive to the standard output, run:
1772
1773@example
1774guix archive --export @var{options} @var{specifications}...
1775@end example
1776
1777@var{specifications} may be either store file names or package
1778specifications, as for @command{guix package} (@pxref{Invoking guix
1779package}). For instance, the following command creates an archive
1780containing the @code{gui} output of the @code{git} package and the main
1781output of @code{emacs}:
1782
1783@example
834129e0 1784guix archive --export git:gui /gnu/store/...-emacs-24.3 > great.nar
760c60d6
LC
1785@end example
1786
1787If the specified packages are not built yet, @command{guix archive}
1788automatically builds them. The build process may be controlled with the
1789same options that can be passed to the @command{guix build} command
70ee5642 1790(@pxref{Invoking guix build, common build options}).
760c60d6
LC
1791
1792
568717fd
LC
1793@c *********************************************************************
1794@node Programming Interface
1795@chapter Programming Interface
1796
3dc1970d
LC
1797GNU Guix provides several Scheme programming interfaces (APIs) to
1798define, build, and query packages. The first interface allows users to
1799write high-level package definitions. These definitions refer to
1800familiar packaging concepts, such as the name and version of a package,
1801its build system, and its dependencies. These definitions can then be
1802turned into concrete build actions.
1803
ba55b1cb 1804Build actions are performed by the Guix daemon, on behalf of users. In a
3dc1970d 1805standard setup, the daemon has write access to the store---the
834129e0 1806@file{/gnu/store} directory---whereas users do not. The recommended
3dc1970d
LC
1807setup also has the daemon perform builds in chroots, under a specific
1808build users, to minimize interference with the rest of the system.
1809
1810@cindex derivation
1811Lower-level APIs are available to interact with the daemon and the
1812store. To instruct the daemon to perform a build action, users actually
1813provide it with a @dfn{derivation}. A derivation is a low-level
1814representation of the build actions to be taken, and the environment in
1815which they should occur---derivations are to package definitions what
49ad317a
LC
1816assembly is to C programs. The term ``derivation'' comes from the fact
1817that build results @emph{derive} from them.
3dc1970d
LC
1818
1819This chapter describes all these APIs in turn, starting from high-level
1820package definitions.
1821
568717fd 1822@menu
b860f382 1823* Defining Packages:: Defining new packages.
7458bd0a 1824* Build Systems:: Specifying how packages are built.
b860f382
LC
1825* The Store:: Manipulating the package store.
1826* Derivations:: Low-level interface to package derivations.
1827* The Store Monad:: Purely functional interface to the store.
21b679f6 1828* G-Expressions:: Manipulating build expressions.
568717fd
LC
1829@end menu
1830
1831@node Defining Packages
1832@section Defining Packages
1833
3dc1970d
LC
1834The high-level interface to package definitions is implemented in the
1835@code{(guix packages)} and @code{(guix build-system)} modules. As an
1836example, the package definition, or @dfn{recipe}, for the GNU Hello
1837package looks like this:
1838
1839@example
e7f34eb0
LC
1840(define-module (gnu packages hello)
1841 #:use-module (guix packages)
1842 #:use-module (guix download)
1843 #:use-module (guix build-system gnu)
1844 #:use-module (guix licenses))
b22a12fd 1845
79f5dd59 1846(define-public hello
3dc1970d
LC
1847 (package
1848 (name "hello")
1849 (version "2.8")
1850 (source (origin
1851 (method url-fetch)
1852 (uri (string-append "mirror://gnu/hello/hello-" version
1853 ".tar.gz"))
1854 (sha256
1855 (base32 "0wqd8sjmxfskrflaxywc7gqw7sfawrfvdxd9skxawzfgyy0pzdz6"))))
1856 (build-system gnu-build-system)
7458bd0a 1857 (arguments `(#:configure-flags '("--enable-silent-rules")))
3dc1970d 1858 (inputs `(("gawk" ,gawk)))
7458bd0a
LC
1859 (synopsis "Hello, GNU world: An example GNU package")
1860 (description "Guess what GNU Hello prints!")
3dc1970d 1861 (home-page "http://www.gnu.org/software/hello/")
b22a12fd 1862 (license gpl3+)))
3dc1970d
LC
1863@end example
1864
1865@noindent
1866Without being a Scheme expert, the reader may have guessed the meaning
e7f34eb0 1867of the various fields here. This expression binds variable @code{hello}
3dc1970d
LC
1868to a @code{<package>} object, which is essentially a record
1869(@pxref{SRFI-9, Scheme records,, guile, GNU Guile Reference Manual}).
1870This package object can be inspected using procedures found in the
1871@code{(guix packages)} module; for instance, @code{(package-name hello)}
1872returns---surprise!---@code{"hello"}.
1873
2f7d2d91
LC
1874With luck, you may be able to import part or all of the definition of
1875the package you are interested in from another repository, using the
1876@code{guix import} command (@pxref{Invoking guix import}).
1877
e7f34eb0
LC
1878In the example above, @var{hello} is defined into a module of its own,
1879@code{(gnu packages hello)}. Technically, this is not strictly
1880necessary, but it is convenient to do so: all the packages defined in
1881modules under @code{(gnu packages @dots{})} are automatically known to
1882the command-line tools (@pxref{Package Modules}).
1883
3dc1970d
LC
1884There are a few points worth noting in the above package definition:
1885
1886@itemize
1887@item
a2bf4907
LC
1888The @code{source} field of the package is an @code{<origin>} object
1889(@pxref{origin Reference}, for the complete reference).
3dc1970d
LC
1890Here, the @code{url-fetch} method from @code{(guix download)} is used,
1891meaning that the source is a file to be downloaded over FTP or HTTP.
1892
1893The @code{mirror://gnu} prefix instructs @code{url-fetch} to use one of
1894the GNU mirrors defined in @code{(guix download)}.
1895
1896The @code{sha256} field specifies the expected SHA256 hash of the file
1897being downloaded. It is mandatory, and allows Guix to check the
1898integrity of the file. The @code{(base32 @dots{})} form introduces the
6c365eca 1899base32 representation of the hash. You can obtain this information with
210cc920
LC
1900@code{guix download} (@pxref{Invoking guix download}) and @code{guix
1901hash} (@pxref{Invoking guix hash}).
3dc1970d 1902
f9cc8971
LC
1903@cindex patches
1904When needed, the @code{origin} form can also have a @code{patches} field
1905listing patches to be applied, and a @code{snippet} field giving a
1906Scheme expression to modify the source code.
1907
3dc1970d
LC
1908@item
1909@cindex GNU Build System
7458bd0a
LC
1910The @code{build-system} field specifies the procedure to build the
1911package (@pxref{Build Systems}). Here, @var{gnu-build-system}
1912represents the familiar GNU Build System, where packages may be
1913configured, built, and installed with the usual @code{./configure &&
1914make && make check && make install} command sequence.
1915
1916@item
1917The @code{arguments} field specifies options for the build system
1918(@pxref{Build Systems}). Here it is interpreted by
1919@var{gnu-build-system} as a request run @file{configure} with the
1920@code{--enable-silent-rules} flag.
3dc1970d
LC
1921
1922@item
1923The @code{inputs} field specifies inputs to the build process---i.e.,
1924build-time or run-time dependencies of the package. Here, we define an
1925input called @code{"gawk"} whose value is that of the @var{gawk}
1926variable; @var{gawk} is itself bound to a @code{<package>} object.
1927
1928Note that GCC, Coreutils, Bash, and other essential tools do not need to
1929be specified as inputs here. Instead, @var{gnu-build-system} takes care
7458bd0a 1930of ensuring that they are present (@pxref{Build Systems}).
3dc1970d
LC
1931
1932However, any other dependencies need to be specified in the
1933@code{inputs} field. Any dependency not specified here will simply be
1934unavailable to the build process, possibly leading to a build failure.
1935@end itemize
1936
87eafdbd
TUBK
1937@xref{package Reference}, for a full description of possible fields.
1938
2f7d2d91 1939Once a package definition is in place, the
e49951eb 1940package may actually be built using the @code{guix build} command-line
39bee8a2
LC
1941tool (@pxref{Invoking guix build}). You can easily jump back to the
1942package definition using the @command{guix edit} command
1943(@pxref{Invoking guix edit}).
1944@xref{Packaging Guidelines}, for
b4f5e0e8
CR
1945more information on how to test package definitions, and
1946@ref{Invoking guix lint}, for information on how to check a definition
1947for style conformance.
1948
7458bd0a
LC
1949Eventually, updating the package definition to a new upstream version
1950can be partly automated by the @command{guix refresh} command
1951(@pxref{Invoking guix refresh}).
3dc1970d
LC
1952
1953Behind the scenes, a derivation corresponding to the @code{<package>}
1954object is first computed by the @code{package-derivation} procedure.
834129e0 1955That derivation is stored in a @code{.drv} file under @file{/gnu/store}.
ba55b1cb 1956The build actions it prescribes may then be realized by using the
3dc1970d
LC
1957@code{build-derivations} procedure (@pxref{The Store}).
1958
1959@deffn {Scheme Procedure} package-derivation @var{store} @var{package} [@var{system}]
59688fc4
LC
1960Return the @code{<derivation>} object of @var{package} for @var{system}
1961(@pxref{Derivations}).
3dc1970d
LC
1962
1963@var{package} must be a valid @code{<package>} object, and @var{system}
1964must be a string denoting the target system type---e.g.,
1965@code{"x86_64-linux"} for an x86_64 Linux-based GNU system. @var{store}
1966must be a connection to the daemon, which operates on the store
1967(@pxref{The Store}).
1968@end deffn
568717fd 1969
9c1edabd
LC
1970@noindent
1971@cindex cross-compilation
1972Similarly, it is possible to compute a derivation that cross-builds a
1973package for some other system:
1974
1975@deffn {Scheme Procedure} package-cross-derivation @var{store} @
1976 @var{package} @var{target} [@var{system}]
59688fc4
LC
1977Return the @code{<derivation>} object of @var{package} cross-built from
1978@var{system} to @var{target}.
9c1edabd
LC
1979
1980@var{target} must be a valid GNU triplet denoting the target hardware
1981and operating system, such as @code{"mips64el-linux-gnu"}
1982(@pxref{Configuration Names, GNU configuration triplets,, configure, GNU
1983Configure and Build System}).
1984@end deffn
1985
87eafdbd
TUBK
1986@menu
1987* package Reference :: The package data type.
1988* origin Reference:: The origin data type.
1989@end menu
1990
1991
1992@node package Reference
1993@subsection @code{package} Reference
1994
1995This section summarizes all the options available in @code{package}
1996declarations (@pxref{Defining Packages}).
1997
1998@deftp {Data Type} package
1999This is the data type representing a package recipe.
2000
2001@table @asis
2002@item @code{name}
2003The name of the package, as a string.
2004
2005@item @code{version}
2006The version of the package, as a string.
2007
2008@item @code{source}
2009An origin object telling how the source code for the package should be
2010acquired (@pxref{origin Reference}).
2011
2012@item @code{build-system}
2013The build system that should be used to build the package (@pxref{Build
2014Systems}).
2015
2016@item @code{arguments} (default: @code{'()})
2017The arguments that should be passed to the build system. This is a
2018list, typically containing sequential keyword-value pairs.
2019
2020@item @code{inputs} (default: @code{'()})
2021Package or derivation inputs to the build. This is a list of lists,
2022where each list has the name of the input (a string) as its first
2023element, a package or derivation object as its second element, and
2024optionally the name of the output of the package or derivation that
2025should be used, which defaults to @code{"out"}.
2026
21461f27
LC
2027@item @anchor{package-propagated-inputs}@code{propagated-inputs} (default: @code{'()})
2028@cindex propagated inputs
87eafdbd 2029This field is like @code{inputs}, but the specified packages will be
21461f27
LC
2030force-installed alongside the package they belong to
2031(@pxref{package-cmd-propagated-inputs, @command{guix package}}, for
2032information on how @command{guix package} deals with propagated inputs.)
2033
2034For example this is necessary when a library needs headers of another
2035library to compile, or needs another shared library to be linked
2036alongside itself when a program wants to link to it.
87eafdbd
TUBK
2037
2038@item @code{native-inputs} (default: @code{'()})
2039This field is like @code{inputs}, but in case of a cross-compilation it
2040will be ensured that packages for the architecture of the build machine
2041are present, such that executables from them can be used during the
21461f27
LC
2042build.
2043
2044This is typically where you would list tools needed at build time but
2045not at run time, such as Autoconf, Automake, pkg-config, Gettext, or
2046Bison. @command{guix lint} can report likely mistakes in this area
2047(@pxref{Invoking guix lint}).
87eafdbd
TUBK
2048
2049@item @code{self-native-input?} (default: @code{#f})
2050This is a Boolean field telling whether the package should use itself as
2051a native input when cross-compiling.
2052
2053@item @code{outputs} (default: @code{'("out")})
2054The list of output names of the package. @xref{Packages with Multiple
2055Outputs}, for typical uses of additional outputs.
2056
2057@item @code{native-search-paths} (default: @code{'()})
2058@itemx @code{search-paths} (default: @code{'()})
2059A list of @code{search-path-specification} objects describing
2060search-path environment variables honored by the package.
2061
2062@item @code{replacement} (default: @code{#f})
2063This must either @code{#f} or a package object that will be used as a
2064@dfn{replacement} for this package. @xref{Security Updates, grafts},
2065for details.
2066
2067@item @code{synopsis}
2068A one-line description of the package.
2069
2070@item @code{description}
2071A more elaborate description of the package.
2072
2073@item @code{license}
2074The license of the package; a value from @code{(guix licenses)}.
2075
2076@item @code{home-page}
2077The URL to the home-page of the package, as a string.
2078
2079@item @code{supported-systems} (default: @var{%supported-systems})
2080The list of systems supported by the package, as strings of the form
2081@code{architecture-kernel}, for example @code{"x86_64-linux"}.
2082
2083@item @code{maintainers} (default: @code{'()})
2084The list of maintainers of the package, as @code{maintainer} objects.
2085
2086@item @code{location} (default: source location of the @code{package} form)
2087The source location of the package. It's useful to override this when
2088inheriting from another package, in which case this field is not
2089automatically corrected.
2090@end table
2091@end deftp
2092
2093
2094@node origin Reference
2095@subsection @code{origin} Reference
2096
2097This section summarizes all the options available in @code{origin}
2098declarations (@pxref{Defining Packages}).
2099
2100@deftp {Data Type} origin
2101This is the data type representing a source code origin.
2102
2103@table @asis
2104@item @code{uri}
2105An object containing the URI of the source. The object type depends on
2106the @code{method} (see below). For example, when using the
2107@var{url-fetch} method of @code{(guix download)}, the valid @code{uri}
2108values are: a URL represented as a string, or a list thereof.
2109
2110@item @code{method}
2111A procedure that will handle the URI.
2112
2113Examples include:
2114
2115@table @asis
2116@item @var{url-fetch} from @code{(guix download)}
2117download a file the HTTP, HTTPS, or FTP URL specified in the
2118@code{uri} field;
2119
2120@item @var{git-fetch} from @code{(guix git-download)}
2121clone the Git version control repository, and check out the revision
2122specified in the @code{uri} field as a @code{git-reference} object; a
2123@code{git-reference} looks like this:
2124
2125@example
2126(git-reference
2127 (url "git://git.debian.org/git/pkg-shadow/shadow")
2128 (commit "v4.1.5.1"))
2129@end example
2130@end table
2131
2132@item @code{sha256}
2133A bytevector containing the SHA-256 hash of the source. Typically the
2134@code{base32} form is used here to generate the bytevector from a
2135base-32 string.
2136
2137@item @code{file-name} (default: @code{#f})
2138The file name under which the source code should be saved. When this is
2139@code{#f}, a sensible default value will be used in most cases. In case
2140the source is fetched from a URL, the file name from the URL will be
2141used. For version control checkouts, it's recommended to provide the
2142file name explicitly because the default is not very descriptive.
2143
2144@item @code{patches} (default: @code{'()})
2145A list of file names containing patches to be applied to the source.
2146
2147@item @code{snippet} (default: @code{#f})
2148A quoted piece of code that will be run in the source directory to make
2149any modifications, which is sometimes more convenient than a patch.
2150
2151@item @code{patch-flags} (default: @code{'("-p1")})
2152A list of command-line flags that should be passed to the @code{patch}
2153command.
2154
2155@item @code{patch-inputs} (default: @code{#f})
2156Input packages or derivations to the patching process. When this is
2157@code{#f}, the usual set of inputs necessary for patching are provided,
2158such as GNU@tie{}Patch.
2159
2160@item @code{modules} (default: @code{'()})
2161A list of Guile modules that should be loaded during the patching
2162process and while running the code in the @code{snippet} field.
2163
2164@item @code{imported-modules} (default: @code{'()})
2165The list of Guile modules to import in the patch derivation, for use by
2166the @code{snippet}.
2167
2168@item @code{patch-guile} (default: @code{#f})
2169The Guile package that should be used in the patching process. When
2170this is @code{#f}, a sensible default is used.
2171@end table
2172@end deftp
2173
9c1edabd 2174
7458bd0a
LC
2175@node Build Systems
2176@section Build Systems
2177
2178@cindex build system
2179Each package definition specifies a @dfn{build system} and arguments for
2180that build system (@pxref{Defining Packages}). This @code{build-system}
2181field represents the build procedure of the package, as well implicit
2182dependencies of that build procedure.
2183
2184Build systems are @code{<build-system>} objects. The interface to
2185create and manipulate them is provided by the @code{(guix build-system)}
2186module, and actual build systems are exported by specific modules.
2187
f5fd4fd2 2188@cindex bag (low-level package representation)
0d5a559f
LC
2189Under the hood, build systems first compile package objects to
2190@dfn{bags}. A @dfn{bag} is like a package, but with less
2191ornamentation---in other words, a bag is a lower-level representation of
2192a package, which includes all the inputs of that package, including some
2193that were implicitly added by the build system. This intermediate
2194representation is then compiled to a derivation (@pxref{Derivations}).
2195
7458bd0a
LC
2196Build systems accept an optional list of @dfn{arguments}. In package
2197definitions, these are passed @i{via} the @code{arguments} field
2198(@pxref{Defining Packages}). They are typically keyword arguments
2199(@pxref{Optional Arguments, keyword arguments in Guile,, guile, GNU
2200Guile Reference Manual}). The value of these arguments is usually
2201evaluated in the @dfn{build stratum}---i.e., by a Guile process launched
2202by the daemon (@pxref{Derivations}).
2203
2204The main build system is @var{gnu-build-system}, which implements the
2205standard build procedure for GNU packages and many other packages. It
2206is provided by the @code{(guix build-system gnu)} module.
2207
2208@defvr {Scheme Variable} gnu-build-system
2209@var{gnu-build-system} represents the GNU Build System, and variants
2210thereof (@pxref{Configuration, configuration and makefile conventions,,
2211standards, GNU Coding Standards}).
2212
2213@cindex build phases
2214In a nutshell, packages using it configured, built, and installed with
2215the usual @code{./configure && make && make check && make install}
2216command sequence. In practice, a few additional steps are often needed.
2217All these steps are split up in separate @dfn{phases},
2218notably@footnote{Please see the @code{(guix build gnu-build-system)}
2219modules for more details about the build phases.}:
2220
2221@table @code
2222@item unpack
2223Unpack the source tarball, and change the current directory to the
2224extracted source tree. If the source is actually a directory, copy it
2225to the build tree, and enter that directory.
2226
2227@item patch-source-shebangs
2228Patch shebangs encountered in source files so they refer to the right
2229store file names. For instance, this changes @code{#!/bin/sh} to
2230@code{#!/gnu/store/@dots{}-bash-4.3/bin/sh}.
2231
2232@item configure
2233Run the @file{configure} script with a number of default options, such
2234as @code{--prefix=/gnu/store/@dots{}}, as well as the options specified
2235by the @code{#:configure-flags} argument.
2236
2237@item build
2238Run @code{make} with the list of flags specified with
2239@code{#:make-flags}. If the @code{#:parallel-builds?} argument is true
2240(the default), build with @code{make -j}.
2241
2242@item check
2243Run @code{make check}, or some other target specified with
2244@code{#:test-target}, unless @code{#:tests? #f} is passed. If the
2245@code{#:parallel-tests?} argument is true (the default), run @code{make
2246check -j}.
2247
2248@item install
2249Run @code{make install} with the flags listed in @code{#:make-flags}.
2250
2251@item patch-shebangs
2252Patch shebangs on the installed executable files.
2253
2254@item strip
2255Strip debugging symbols from ELF files (unless @code{#:strip-binaries?}
2256is false), copying them to the @code{debug} output when available
2257(@pxref{Installing Debugging Files}).
2258@end table
2259
2260@vindex %standard-phases
2261The build-side module @code{(guix build gnu-build-system)} defines
2262@var{%standard-phases} as the default list of build phases.
2263@var{%standard-phases} is a list of symbol/procedure pairs, where the
2264procedure implements the actual phase.
2265
2266The list of phases used for a particular package can be changed with the
2267@code{#:phases} parameter. For instance, passing:
2268
2269@example
2270#:phases (alist-delete 'configure %standard-phases)
2271@end example
2272
9bf404e9 2273means that all the phases described above will be used, except the
7458bd0a
LC
2274@code{configure} phase.
2275
2276In addition, this build system ensures that the ``standard'' environment
2277for GNU packages is available. This includes tools such as GCC, libc,
2278Coreutils, Bash, Make, Diffutils, grep, and sed (see the @code{(guix
2279build-system gnu)} module for a complete list.) We call these the
2280@dfn{implicit inputs} of a package, because package definitions don't
2281have to mention them.
2282@end defvr
2283
2284Other @code{<build-system>} objects are defined to support other
2285conventions and tools used by free software packages. They inherit most
2286of @var{gnu-build-system}, and differ mainly in the set of inputs
2287implicitly added to the build process, and in the list of phases
2288executed. Some of these build systems are listed below.
2289
2290@defvr {Scheme Variable} cmake-build-system
2291This variable is exported by @code{(guix build-system cmake)}. It
2292implements the build procedure for packages using the
2293@url{http://www.cmake.org, CMake build tool}.
2294
2295It automatically adds the @code{cmake} package to the set of inputs.
2296Which package is used can be specified with the @code{#:cmake}
2297parameter.
9849cfc1
LC
2298
2299The @code{#:configure-flags} parameter is taken as a list of flags
2300passed to the @command{cmake} command. The @code{#:build-type}
2301parameter specifies in abstract terms the flags passed to the compiler;
2302it defaults to @code{"RelWithDebInfo"} (short for ``release mode with
2303debugging information''), which roughly means that code is compiled with
2304@code{-O2 -g}, as is the case for Autoconf-based packages by default.
7458bd0a
LC
2305@end defvr
2306
3afcf52b
FB
2307@defvr {Scheme Variable} glib-or-gtk-build-system
2308This variable is exported by @code{(guix build-system glib-or-gtk)}. It
2309is intended for use with packages making use of GLib or GTK+.
2310
2311This build system adds the following two phases to the ones defined by
2312@var{gnu-build-system}:
2313
2314@table @code
2315@item glib-or-gtk-wrap
2316The phase @code{glib-or-gtk-wrap} ensures that programs found under
2317@file{bin/} are able to find GLib's ``schemas'' and
2318@uref{https://developer.gnome.org/gtk3/stable/gtk-running.html, GTK+
2319modules}. This is achieved by wrapping the programs in launch scripts
2320that appropriately set the @code{XDG_DATA_DIRS} and @code{GTK_PATH}
2321environment variables.
2322
73aa8ddb
LC
2323It is possible to exclude specific package outputs from that wrapping
2324process by listing their names in the
2325@code{#:glib-or-gtk-wrap-excluded-outputs} parameter. This is useful
2326when an output is known not to contain any GLib or GTK+ binaries, and
2327where wrapping would gratuitously add a dependency of that output on
2328GLib and GTK+.
2329
3afcf52b
FB
2330@item glib-or-gtk-compile-schemas
2331The phase @code{glib-or-gtk-compile-schemas} makes sure that all GLib's
2332@uref{https://developer.gnome.org/gio/stable/glib-compile-schemas.html,
2333GSettings schemas} are compiled. Compilation is performed by the
2334@command{glib-compile-schemas} program. It is provided by the package
2335@code{glib:bin} which is automatically imported by the build system.
2336The @code{glib} package providing @command{glib-compile-schemas} can be
2337specified with the @code{#:glib} parameter.
2338@end table
2339
2340Both phases are executed after the @code{install} phase.
2341@end defvr
2342
7458bd0a
LC
2343@defvr {Scheme Variable} python-build-system
2344This variable is exported by @code{(guix build-system python)}. It
2345implements the more or less standard build procedure used by Python
2346packages, which consists in running @code{python setup.py build} and
2347then @code{python setup.py install --prefix=/gnu/store/@dots{}}.
2348
2349For packages that install stand-alone Python programs under @code{bin/},
2350it takes care of wrapping these programs so their @code{PYTHONPATH}
2351environment variable points to all the Python libraries they depend on.
2352
2353Which Python package is used can be specified with the @code{#:python}
2354parameter.
2355@end defvr
2356
2357@defvr {Scheme Variable} perl-build-system
2358This variable is exported by @code{(guix build-system perl)}. It
2d2a53fc
EB
2359implements the standard build procedure for Perl packages, which either
2360consists in running @code{perl Build.PL --prefix=/gnu/store/@dots{}},
2361followed by @code{Build} and @code{Build install}; or in running
2362@code{perl Makefile.PL PREFIX=/gnu/store/@dots{}}, followed by
2363@code{make} and @code{make install}; depending on which of
2364@code{Build.PL} or @code{Makefile.PL} is present in the package
2365distribution. Preference is given to the former if both @code{Build.PL}
2366and @code{Makefile.PL} exist in the package distribution. This
2367preference can be reversed by specifying @code{#t} for the
2368@code{#:make-maker?} parameter.
2369
2370The initial @code{perl Makefile.PL} or @code{perl Build.PL} invocation
2371passes flags specified by the @code{#:make-maker-flags} or
2372@code{#:module-build-flags} parameter, respectively.
7458bd0a
LC
2373
2374Which Perl package is used can be specified with @code{#:perl}.
2375@end defvr
2376
c08f9818
DT
2377@defvr {Scheme Variable} ruby-build-system
2378This variable is exported by @code{(guix build-system ruby)}. It
2379implements the RubyGems build procedure used by Ruby packages, which
2380involves running @code{gem build} followed by @code{gem install}.
2381
2382Which Ruby package is used can be specified with the @code{#:ruby}
2383parameter.
2384@end defvr
7458bd0a 2385
a677c726
RW
2386@defvr {Scheme Variable} waf-build-system
2387This variable is exported by @code{(guix build-system waf)}. It
2388implements a build procedure around the @code{waf} script. The common
2389phases---@code{configure}, @code{build}, and @code{install}---are
2390implemented by passing their names as arguments to the @code{waf}
2391script.
2392
2393The @code{waf} script is executed by the Python interpreter. Which
2394Python package is used to run the script can be specified with the
2395@code{#:python} parameter.
2396@end defvr
2397
14dfdf2e
FB
2398@defvr {Scheme Variable} haskell-build-system
2399This variable is exported by @code{(guix build-system haskell)}. It
2400implements the Cabal build procedure used by Haskell packages, which
2401involves running @code{runhaskell Setup.hs configure
2402--prefix=/gnu/store/@dots{}} and @code{runhaskell Setup.hs build}.
2403Instead of installing the package by running @code{runhaskell Setup.hs
2404install}, to avoid trying to register libraries in the read-only
2405compiler store directory, the build system uses @code{runhaskell
2406Setup.hs copy}, followed by @code{runhaskell Setup.hs register}. In
2407addition, the build system generates the package documentation by
2408running @code{runhaskell Setup.hs haddock}, unless @code{#:haddock? #f}
2409is passed. Optional Haddock parameters can be passed with the help of
2410the @code{#:haddock-flags} parameter. If the file @code{Setup.hs} is
2411not found, the build system looks for @code{Setup.lhs} instead.
2412
2413Which Haskell compiler is used can be specified with the @code{#:haskell}
a54bd6d7 2414parameter which defaults to @code{ghc}.
14dfdf2e
FB
2415@end defvr
2416
7458bd0a
LC
2417Lastly, for packages that do not need anything as sophisticated, a
2418``trivial'' build system is provided. It is trivial in the sense that
2419it provides basically no support: it does not pull any implicit inputs,
2420and does not have a notion of build phases.
2421
2422@defvr {Scheme Variable} trivial-build-system
2423This variable is exported by @code{(guix build-system trivial)}.
2424
2425This build system requires a @code{#:builder} argument. This argument
2426must be a Scheme expression that builds the package's output(s)---as
2427with @code{build-expression->derivation} (@pxref{Derivations,
2428@code{build-expression->derivation}}).
2429@end defvr
2430
568717fd
LC
2431@node The Store
2432@section The Store
2433
e531ac2a
LC
2434@cindex store
2435@cindex store paths
2436
2437Conceptually, the @dfn{store} is where derivations that have been
834129e0 2438successfully built are stored---by default, under @file{/gnu/store}.
e531ac2a
LC
2439Sub-directories in the store are referred to as @dfn{store paths}. The
2440store has an associated database that contains information such has the
2441store paths referred to by each store path, and the list of @emph{valid}
2442store paths---paths that result from a successful build.
2443
2444The store is always accessed by the daemon on behalf of its clients
2445(@pxref{Invoking guix-daemon}). To manipulate the store, clients
2446connect to the daemon over a Unix-domain socket, send it requests, and
2447read the result---these are remote procedure calls, or RPCs.
2448
2449The @code{(guix store)} module provides procedures to connect to the
2450daemon, and to perform RPCs. These are described below.
2451
2452@deffn {Scheme Procedure} open-connection [@var{file}] [#:reserve-space? #t]
2453Connect to the daemon over the Unix-domain socket at @var{file}. When
2454@var{reserve-space?} is true, instruct it to reserve a little bit of
2455extra space on the file system so that the garbage collector can still
2456operate, should the disk become full. Return a server object.
2457
2458@var{file} defaults to @var{%default-socket-path}, which is the normal
2459location given the options that were passed to @command{configure}.
2460@end deffn
2461
2462@deffn {Scheme Procedure} close-connection @var{server}
2463Close the connection to @var{server}.
2464@end deffn
2465
2466@defvr {Scheme Variable} current-build-output-port
2467This variable is bound to a SRFI-39 parameter, which refers to the port
2468where build and error logs sent by the daemon should be written.
2469@end defvr
2470
2471Procedures that make RPCs all take a server object as their first
2472argument.
2473
2474@deffn {Scheme Procedure} valid-path? @var{server} @var{path}
2475Return @code{#t} when @var{path} is a valid store path.
2476@end deffn
2477
cfbf9160 2478@deffn {Scheme Procedure} add-text-to-store @var{server} @var{name} @var{text} [@var{references}]
e531ac2a
LC
2479Add @var{text} under file @var{name} in the store, and return its store
2480path. @var{references} is the list of store paths referred to by the
2481resulting store path.
2482@end deffn
2483
874e6874 2484@deffn {Scheme Procedure} build-derivations @var{server} @var{derivations}
59688fc4
LC
2485Build @var{derivations} (a list of @code{<derivation>} objects or
2486derivation paths), and return when the worker is done building them.
2487Return @code{#t} on success.
874e6874
LC
2488@end deffn
2489
b860f382
LC
2490Note that the @code{(guix monads)} module provides a monad as well as
2491monadic versions of the above procedures, with the goal of making it
2492more convenient to work with code that accesses the store (@pxref{The
2493Store Monad}).
2494
e531ac2a
LC
2495@c FIXME
2496@i{This section is currently incomplete.}
568717fd
LC
2497
2498@node Derivations
2499@section Derivations
2500
874e6874
LC
2501@cindex derivations
2502Low-level build actions and the environment in which they are performed
2503are represented by @dfn{derivations}. A derivation contain the
2504following pieces of information:
2505
2506@itemize
2507@item
2508The outputs of the derivation---derivations produce at least one file or
2509directory in the store, but may produce more.
2510
2511@item
2512The inputs of the derivations, which may be other derivations or plain
2513files in the store (patches, build scripts, etc.)
2514
2515@item
2516The system type targeted by the derivation---e.g., @code{x86_64-linux}.
2517
2518@item
2519The file name of a build script in the store, along with the arguments
2520to be passed.
2521
2522@item
2523A list of environment variables to be defined.
2524
2525@end itemize
2526
2527@cindex derivation path
2528Derivations allow clients of the daemon to communicate build actions to
2529the store. They exist in two forms: as an in-memory representation,
2530both on the client- and daemon-side, and as files in the store whose
2531name end in @code{.drv}---these files are referred to as @dfn{derivation
2532paths}. Derivations paths can be passed to the @code{build-derivations}
2533procedure to perform the build actions they prescribe (@pxref{The
2534Store}).
2535
2536The @code{(guix derivations)} module provides a representation of
2537derivations as Scheme objects, along with procedures to create and
2538otherwise manipulate derivations. The lowest-level primitive to create
2539a derivation is the @code{derivation} procedure:
2540
1909431c
LC
2541@deffn {Scheme Procedure} derivation @var{store} @var{name} @var{builder} @
2542 @var{args} [#:outputs '("out")] [#:hash #f] [#:hash-algo #f] @
2096ef47 2543 [#:recursive? #f] [#:inputs '()] [#:env-vars '()] @
1909431c 2544 [#:system (%current-system)] [#:references-graphs #f] @
c0468155 2545 [#:allowed-references #f] [#:leaked-env-vars #f] [#:local-build? #f]
59688fc4
LC
2546Build a derivation with the given arguments, and return the resulting
2547@code{<derivation>} object.
874e6874 2548
2096ef47 2549When @var{hash} and @var{hash-algo} are given, a
874e6874 2550@dfn{fixed-output derivation} is created---i.e., one whose result is
36bbbbd1
LC
2551known in advance, such as a file download. If, in addition,
2552@var{recursive?} is true, then that fixed output may be an executable
2553file or a directory and @var{hash} must be the hash of an archive
2554containing this output.
5b0c9d16 2555
858e9282 2556When @var{references-graphs} is true, it must be a list of file
5b0c9d16
LC
2557name/store path pairs. In that case, the reference graph of each store
2558path is exported in the build environment in the corresponding file, in
2559a simple text format.
1909431c 2560
b53be755
LC
2561When @var{allowed-references} is true, it must be a list of store items
2562or outputs that the derivation's output may refer to.
2563
c0468155
LC
2564When @var{leaked-env-vars} is true, it must be a list of strings
2565denoting environment variables that are allowed to ``leak'' from the
2566daemon's environment to the build environment. This is only applicable
2567to fixed-output derivations---i.e., when @var{hash} is true. The main
2568use is to allow variables such as @code{http_proxy} to be passed to
2569derivations that download files.
2570
1909431c
LC
2571When @var{local-build?} is true, declare that the derivation is not a
2572good candidate for offloading and should rather be built locally
2573(@pxref{Daemon Offload Setup}). This is the case for small derivations
2574where the costs of data transfers would outweigh the benefits.
874e6874
LC
2575@end deffn
2576
2577@noindent
2578Here's an example with a shell script as its builder, assuming
2579@var{store} is an open connection to the daemon, and @var{bash} points
2580to a Bash executable in the store:
2581
2582@lisp
2583(use-modules (guix utils)
2584 (guix store)
2585 (guix derivations))
2586
59688fc4
LC
2587(let ((builder ; add the Bash script to the store
2588 (add-text-to-store store "my-builder.sh"
2589 "echo hello world > $out\n" '())))
2590 (derivation store "foo"
2591 bash `("-e" ,builder)
21b679f6 2592 #:inputs `((,bash) (,builder))
59688fc4 2593 #:env-vars '(("HOME" . "/homeless"))))
834129e0 2594@result{} #<derivation /gnu/store/@dots{}-foo.drv => /gnu/store/@dots{}-foo>
874e6874
LC
2595@end lisp
2596
21b679f6
LC
2597As can be guessed, this primitive is cumbersome to use directly. A
2598better approach is to write build scripts in Scheme, of course! The
2599best course of action for that is to write the build code as a
2600``G-expression'', and to pass it to @code{gexp->derivation}. For more
6621cdb6 2601information, @pxref{G-Expressions}.
21b679f6
LC
2602
2603Once upon a time, @code{gexp->derivation} did not exist and constructing
2604derivations with build code written in Scheme was achieved with
2605@code{build-expression->derivation}, documented below. This procedure
2606is now deprecated in favor of the much nicer @code{gexp->derivation}.
874e6874 2607
dd1a5a15
LC
2608@deffn {Scheme Procedure} build-expression->derivation @var{store} @
2609 @var{name} @var{exp} @
2610 [#:system (%current-system)] [#:inputs '()] @
2611 [#:outputs '("out")] [#:hash #f] [#:hash-algo #f] @
36bbbbd1 2612 [#:recursive? #f] [#:env-vars '()] [#:modules '()] @
63a42824
LC
2613 [#:references-graphs #f] [#:allowed-references #f] @
2614 [#:local-build? #f] [#:guile-for-build #f]
874e6874
LC
2615Return a derivation that executes Scheme expression @var{exp} as a
2616builder for derivation @var{name}. @var{inputs} must be a list of
2617@code{(name drv-path sub-drv)} tuples; when @var{sub-drv} is omitted,
2618@code{"out"} is assumed. @var{modules} is a list of names of Guile
2619modules from the current search path to be copied in the store,
2620compiled, and made available in the load path during the execution of
2621@var{exp}---e.g., @code{((guix build utils) (guix build
2622gnu-build-system))}.
2623
2624@var{exp} is evaluated in an environment where @code{%outputs} is bound
2625to a list of output/path pairs, and where @code{%build-inputs} is bound
2626to a list of string/output-path pairs made from @var{inputs}.
2627Optionally, @var{env-vars} is a list of string pairs specifying the name
2628and value of environment variables visible to the builder. The builder
2629terminates by passing the result of @var{exp} to @code{exit}; thus, when
2630@var{exp} returns @code{#f}, the build is considered to have failed.
2631
2632@var{exp} is built using @var{guile-for-build} (a derivation). When
2633@var{guile-for-build} is omitted or is @code{#f}, the value of the
2634@code{%guile-for-build} fluid is used instead.
9c629a27 2635
63a42824
LC
2636See the @code{derivation} procedure for the meaning of
2637@var{references-graphs}, @var{allowed-references}, and @var{local-build?}.
874e6874
LC
2638@end deffn
2639
2640@noindent
2641Here's an example of a single-output derivation that creates a directory
2642containing one file:
2643
2644@lisp
2645(let ((builder '(let ((out (assoc-ref %outputs "out")))
834129e0 2646 (mkdir out) ; create /gnu/store/@dots{}-goo
874e6874
LC
2647 (call-with-output-file (string-append out "/test")
2648 (lambda (p)
2649 (display '(hello guix) p))))))
dd1a5a15 2650 (build-expression->derivation store "goo" builder))
874e6874 2651
834129e0 2652@result{} #<derivation /gnu/store/@dots{}-goo.drv => @dots{}>
874e6874
LC
2653@end lisp
2654
568717fd 2655
b860f382
LC
2656@node The Store Monad
2657@section The Store Monad
2658
2659@cindex monad
2660
2661The procedures that operate on the store described in the previous
2662sections all take an open connection to the build daemon as their first
2663argument. Although the underlying model is functional, they either have
2664side effects or depend on the current state of the store.
2665
2666The former is inconvenient: the connection to the build daemon has to be
2667carried around in all those functions, making it impossible to compose
2668functions that do not take that parameter with functions that do. The
2669latter can be problematic: since store operations have side effects
2670and/or depend on external state, they have to be properly sequenced.
2671
2672@cindex monadic values
2673@cindex monadic functions
2674This is where the @code{(guix monads)} module comes in. This module
2675provides a framework for working with @dfn{monads}, and a particularly
2676useful monad for our uses, the @dfn{store monad}. Monads are a
2677construct that allows two things: associating ``context'' with values
2678(in our case, the context is the store), and building sequences of
561fb6c3 2679computations (here computations include accesses to the store.) Values
b860f382
LC
2680in a monad---values that carry this additional context---are called
2681@dfn{monadic values}; procedures that return such values are called
2682@dfn{monadic procedures}.
2683
2684Consider this ``normal'' procedure:
2685
2686@example
45adbd62
LC
2687(define (sh-symlink store)
2688 ;; Return a derivation that symlinks the 'bash' executable.
2689 (let* ((drv (package-derivation store bash))
2690 (out (derivation->output-path drv))
2691 (sh (string-append out "/bin/bash")))
2692 (build-expression->derivation store "sh"
2693 `(symlink ,sh %output))))
b860f382
LC
2694@end example
2695
c6f30b81
LC
2696Using @code{(guix monads)} and @code{(guix gexp)}, it may be rewritten
2697as a monadic function:
b860f382
LC
2698
2699@example
45adbd62 2700(define (sh-symlink)
b860f382 2701 ;; Same, but return a monadic value.
c6f30b81
LC
2702 (mlet %store-monad ((drv (package->derivation bash)))
2703 (gexp->derivation "sh"
2704 #~(symlink (string-append #$drv "/bin/bash")
2705 #$output))))
b860f382
LC
2706@end example
2707
c6f30b81
LC
2708There several things to note in the second version: the @code{store}
2709parameter is now implicit and is ``threaded'' in the calls to the
2710@code{package->derivation} and @code{gexp->derivation} monadic
2711procedures, and the monadic value returned by @code{package->derivation}
2712is @dfn{bound} using @code{mlet} instead of plain @code{let}.
2713
2714As it turns out, the call to @code{package->derivation} can even be
2715omitted since it will take place implicitly, as we will see later
2716(@pxref{G-Expressions}):
2717
2718@example
2719(define (sh-symlink)
2720 (gexp->derivation "sh"
2721 #~(symlink (string-append #$bash "/bin/bash")
2722 #$output)))
2723@end example
b860f382 2724
8e9aa37f 2725Calling the monadic @code{sh-symlink} has no effect. To get the desired
b860f382
LC
2726effect, one must use @code{run-with-store}:
2727
2728@example
8e9aa37f
CAW
2729(run-with-store (open-connection) (sh-symlink))
2730@result{} /gnu/store/...-sh-symlink
b860f382
LC
2731@end example
2732
b9b86078
LC
2733Note that the @code{(guix monad-repl)} module extends Guile's REPL with
2734new ``meta-commands'' to make it easier to deal with monadic procedures:
2735@code{run-in-store}, and @code{enter-store-monad}. The former, is used
2736to ``run'' a single monadic value through the store:
2737
2738@example
2739scheme@@(guile-user)> ,run-in-store (package->derivation hello)
2740$1 = #<derivation /gnu/store/@dots{}-hello-2.9.drv => @dots{}>
2741@end example
2742
2743The latter enters a recursive REPL, where all the return values are
2744automatically run through the store:
2745
2746@example
2747scheme@@(guile-user)> ,enter-store-monad
2748store-monad@@(guile-user) [1]> (package->derivation hello)
2749$2 = #<derivation /gnu/store/@dots{}-hello-2.9.drv => @dots{}>
2750store-monad@@(guile-user) [1]> (text-file "foo" "Hello!")
2751$3 = "/gnu/store/@dots{}-foo"
2752store-monad@@(guile-user) [1]> ,q
2753scheme@@(guile-user)>
2754@end example
2755
2756@noindent
2757Note that non-monadic values cannot be returned in the
2758@code{store-monad} REPL.
2759
e87f0591
LC
2760The main syntactic forms to deal with monads in general are provided by
2761the @code{(guix monads)} module and are described below.
b860f382
LC
2762
2763@deffn {Scheme Syntax} with-monad @var{monad} @var{body} ...
2764Evaluate any @code{>>=} or @code{return} forms in @var{body} as being
2765in @var{monad}.
2766@end deffn
2767
2768@deffn {Scheme Syntax} return @var{val}
2769Return a monadic value that encapsulates @var{val}.
2770@end deffn
2771
751630c9 2772@deffn {Scheme Syntax} >>= @var{mval} @var{mproc} ...
b860f382 2773@dfn{Bind} monadic value @var{mval}, passing its ``contents'' to monadic
751630c9
LC
2774procedures @var{mproc}@dots{}@footnote{This operation is commonly
2775referred to as ``bind'', but that name denotes an unrelated procedure in
2776Guile. Thus we use this somewhat cryptic symbol inherited from the
2777Haskell language.}. There can be one @var{mproc} or several of them, as
2778in this example:
2779
2780@example
2781(run-with-state
2782 (with-monad %state-monad
2783 (>>= (return 1)
2784 (lambda (x) (return (+ 1 x)))
2785 (lambda (x) (return (* 2 x)))))
2786 'some-state)
2787
2788@result{} 4
2789@result{} some-state
2790@end example
b860f382
LC
2791@end deffn
2792
2793@deffn {Scheme Syntax} mlet @var{monad} ((@var{var} @var{mval}) ...) @
2794 @var{body} ...
2795@deffnx {Scheme Syntax} mlet* @var{monad} ((@var{var} @var{mval}) ...) @
2796 @var{body} ...
2797Bind the variables @var{var} to the monadic values @var{mval} in
2798@var{body}. The form (@var{var} -> @var{val}) binds @var{var} to the
2799``normal'' value @var{val}, as per @code{let}.
2800
2801@code{mlet*} is to @code{mlet} what @code{let*} is to @code{let}
2802(@pxref{Local Bindings,,, guile, GNU Guile Reference Manual}).
2803@end deffn
2804
405a9d4e
LC
2805@deffn {Scheme System} mbegin @var{monad} @var{mexp} ...
2806Bind @var{mexp} and the following monadic expressions in sequence,
2807returning the result of the last expression.
2808
2809This is akin to @code{mlet}, except that the return values of the
2810monadic expressions are ignored. In that sense, it is analogous to
2811@code{begin}, but applied to monadic expressions.
2812@end deffn
2813
561fb6c3
LC
2814@cindex state monad
2815The @code{(guix monads)} module provides the @dfn{state monad}, which
2816allows an additional value---the state---to be @emph{threaded} through
2817monadic procedure calls.
2818
2819@defvr {Scheme Variable} %state-monad
2820The state monad. Procedures in the state monad can access and change
2821the state that is threaded.
2822
2823Consider the example below. The @code{square} procedure returns a value
2824in the state monad. It returns the square of its argument, but also
2825increments the current state value:
2826
2827@example
2828(define (square x)
2829 (mlet %state-monad ((count (current-state)))
2830 (mbegin %state-monad
2831 (set-current-state (+ 1 count))
2832 (return (* x x)))))
2833
2834(run-with-state (sequence %state-monad (map square (iota 3))) 0)
2835@result{} (0 1 4)
2836@result{} 3
2837@end example
2838
2839When ``run'' through @var{%state-monad}, we obtain that additional state
2840value, which is the number of @code{square} calls.
2841@end defvr
2842
2843@deffn {Monadic Procedure} current-state
2844Return the current state as a monadic value.
2845@end deffn
2846
2847@deffn {Monadic Procedure} set-current-state @var{value}
2848Set the current state to @var{value} and return the previous state as a
2849monadic value.
2850@end deffn
2851
2852@deffn {Monadic Procedure} state-push @var{value}
2853Push @var{value} to the current state, which is assumed to be a list,
2854and return the previous state as a monadic value.
2855@end deffn
2856
2857@deffn {Monadic Procedure} state-pop
2858Pop a value from the current state and return it as a monadic value.
2859The state is assumed to be a list.
2860@end deffn
2861
2862@deffn {Scheme Procedure} run-with-state @var{mval} [@var{state}]
2863Run monadic value @var{mval} starting with @var{state} as the initial
2864state. Return two values: the resulting value, and the resulting state.
2865@end deffn
2866
e87f0591
LC
2867The main interface to the store monad, provided by the @code{(guix
2868store)} module, is as follows.
b860f382
LC
2869
2870@defvr {Scheme Variable} %store-monad
561fb6c3
LC
2871The store monad---an alias for @var{%state-monad}.
2872
2873Values in the store monad encapsulate accesses to the store. When its
2874effect is needed, a value of the store monad must be ``evaluated'' by
2875passing it to the @code{run-with-store} procedure (see below.)
b860f382
LC
2876@end defvr
2877
2878@deffn {Scheme Procedure} run-with-store @var{store} @var{mval} [#:guile-for-build] [#:system (%current-system)]
2879Run @var{mval}, a monadic value in the store monad, in @var{store}, an
2880open store connection.
2881@end deffn
2882
ad372953 2883@deffn {Monadic Procedure} text-file @var{name} @var{text} [@var{references}]
b860f382 2884Return as a monadic value the absolute file name in the store of the file
ad372953
LC
2885containing @var{text}, a string. @var{references} is a list of store items that the
2886resulting text file refers to; it defaults to the empty list.
45adbd62
LC
2887@end deffn
2888
0a90af15
LC
2889@deffn {Monadic Procedure} interned-file @var{file} [@var{name}] @
2890 [#:recursive? #t]
2891Return the name of @var{file} once interned in the store. Use
2892@var{name} as its store name, or the basename of @var{file} if
2893@var{name} is omitted.
2894
2895When @var{recursive?} is true, the contents of @var{file} are added
2896recursively; if @var{file} designates a flat file and @var{recursive?}
2897is true, its contents are added, and its permission bits are kept.
2898
2899The example below adds a file to the store, under two different names:
2900
2901@example
2902(run-with-store (open-connection)
2903 (mlet %store-monad ((a (interned-file "README"))
2904 (b (interned-file "README" "LEGU-MIN")))
2905 (return (list a b))))
2906
2907@result{} ("/gnu/store/rwm@dots{}-README" "/gnu/store/44i@dots{}-LEGU-MIN")
2908@end example
2909
2910@end deffn
2911
e87f0591
LC
2912The @code{(guix packages)} module exports the following package-related
2913monadic procedures:
2914
b860f382 2915@deffn {Monadic Procedure} package-file @var{package} [@var{file}] @
4231f05b
LC
2916 [#:system (%current-system)] [#:target #f] @
2917 [#:output "out"] Return as a monadic
b860f382
LC
2918value in the absolute file name of @var{file} within the @var{output}
2919directory of @var{package}. When @var{file} is omitted, return the name
4231f05b
LC
2920of the @var{output} directory of @var{package}. When @var{target} is
2921true, use it as a cross-compilation target triplet.
b860f382
LC
2922@end deffn
2923
b860f382 2924@deffn {Monadic Procedure} package->derivation @var{package} [@var{system}]
4231f05b
LC
2925@deffnx {Monadic Procedure} package->cross-derivation @var{package} @
2926 @var{target} [@var{system}]
2927Monadic version of @code{package-derivation} and
2928@code{package-cross-derivation} (@pxref{Defining Packages}).
b860f382
LC
2929@end deffn
2930
2931
21b679f6
LC
2932@node G-Expressions
2933@section G-Expressions
2934
2935@cindex G-expression
2936@cindex build code quoting
2937So we have ``derivations'', which represent a sequence of build actions
2938to be performed to produce an item in the store (@pxref{Derivations}).
2939Those build actions are performed when asking the daemon to actually
2940build the derivations; they are run by the daemon in a container
2941(@pxref{Invoking guix-daemon}).
2942
2943@cindex strata of code
2944It should come as no surprise that we like to write those build actions
2945in Scheme. When we do that, we end up with two @dfn{strata} of Scheme
2946code@footnote{The term @dfn{stratum} in this context was coined by
ef4ab0a4
LC
2947Manuel Serrano et al.@: in the context of their work on Hop. Oleg
2948Kiselyov, who has written insightful
2949@url{http://okmij.org/ftp/meta-programming/#meta-scheme, essays and code
2950on this topic}, refers to this kind of code generation as
2951@dfn{staging}.}: the ``host code''---code that defines packages, talks
2952to the daemon, etc.---and the ``build code''---code that actually
2953performs build actions, such as making directories, invoking
2954@command{make}, etc.
21b679f6
LC
2955
2956To describe a derivation and its build actions, one typically needs to
2957embed build code inside host code. It boils down to manipulating build
2958code as data, and Scheme's homoiconicity---code has a direct
2959representation as data---comes in handy for that. But we need more than
2960Scheme's normal @code{quasiquote} mechanism to construct build
2961expressions.
2962
2963The @code{(guix gexp)} module implements @dfn{G-expressions}, a form of
2964S-expressions adapted to build expressions. G-expressions, or
2965@dfn{gexps}, consist essentially in three syntactic forms: @code{gexp},
2966@code{ungexp}, and @code{ungexp-splicing} (or simply: @code{#~},
2967@code{#$}, and @code{#$@@}), which are comparable respectively to
2968@code{quasiquote}, @code{unquote}, and @code{unquote-splicing}
2969(@pxref{Expression Syntax, @code{quasiquote},, guile, GNU Guile
2970Reference Manual}). However, there are major differences:
2971
2972@itemize
2973@item
2974Gexps are meant to be written to a file and run or manipulated by other
2975processes.
2976
2977@item
b39fc6f7
LC
2978When a high-level object such as a package or derivation is unquoted
2979inside a gexp, the result is as if its output file name had been
2980introduced.
ff40e9b7 2981
21b679f6
LC
2982@item
2983Gexps carry information about the packages or derivations they refer to,
2984and these dependencies are automatically added as inputs to the build
2985processes that use them.
2986@end itemize
2987
343eacbe
LC
2988This mechanism is not limited to package and derivation
2989objects: @dfn{compilers} able to ``lower'' other high-level objects to
b39fc6f7 2990derivations can be defined, such that these objects can also be inserted
343eacbe
LC
2991into gexps. For example, a useful type of high-level object that can be
2992inserted in a gexp is ``file-like objects'', which make it easy to
2993add files to the store and refer to them in
558e8b11
LC
2994derivations and such (see @code{local-file} and @code{plain-file}
2995below.)
b39fc6f7 2996
21b679f6
LC
2997To illustrate the idea, here is an example of a gexp:
2998
2999@example
3000(define build-exp
3001 #~(begin
3002 (mkdir #$output)
3003 (chdir #$output)
aff8ce7c 3004 (symlink (string-append #$coreutils "/bin/ls")
21b679f6
LC
3005 "list-files")))
3006@end example
3007
3008This gexp can be passed to @code{gexp->derivation}; we obtain a
3009derivation that builds a directory containing exactly one symlink to
3010@file{/gnu/store/@dots{}-coreutils-8.22/bin/ls}:
3011
3012@example
3013(gexp->derivation "the-thing" build-exp)
3014@end example
3015
e20fd1bf 3016As one would expect, the @code{"/gnu/store/@dots{}-coreutils-8.22"} string is
21b679f6
LC
3017substituted to the reference to the @var{coreutils} package in the
3018actual build code, and @var{coreutils} is automatically made an input to
3019the derivation. Likewise, @code{#$output} (equivalent to @code{(ungexp
3020output)}) is replaced by a string containing the derivation's output
667b2508
LC
3021directory name.
3022
3023@cindex cross compilation
3024In a cross-compilation context, it is useful to distinguish between
3025references to the @emph{native} build of a package---that can run on the
3026host---versus references to cross builds of a package. To that end, the
3027@code{#+} plays the same role as @code{#$}, but is a reference to a
3028native package build:
3029
3030@example
3031(gexp->derivation "vi"
3032 #~(begin
3033 (mkdir #$output)
3034 (system* (string-append #+coreutils "/bin/ln")
3035 "-s"
3036 (string-append #$emacs "/bin/emacs")
3037 (string-append #$output "/bin/vi")))
3038 #:target "mips64el-linux")
3039@end example
3040
3041@noindent
3042In the example above, the native build of @var{coreutils} is used, so
3043that @command{ln} can actually run on the host; but then the
3044cross-compiled build of @var{emacs} is referenced.
3045
3046The syntactic form to construct gexps is summarized below.
21b679f6
LC
3047
3048@deffn {Scheme Syntax} #~@var{exp}
3049@deffnx {Scheme Syntax} (gexp @var{exp})
3050Return a G-expression containing @var{exp}. @var{exp} may contain one
3051or more of the following forms:
3052
3053@table @code
3054@item #$@var{obj}
3055@itemx (ungexp @var{obj})
b39fc6f7
LC
3056Introduce a reference to @var{obj}. @var{obj} may have one of the
3057supported types, for example a package or a
21b679f6
LC
3058derivation, in which case the @code{ungexp} form is replaced by its
3059output file name---e.g., @code{"/gnu/store/@dots{}-coreutils-8.22}.
3060
b39fc6f7
LC
3061If @var{obj} is a list, it is traversed and references to supported
3062objects are substituted similarly.
21b679f6
LC
3063
3064If @var{obj} is another gexp, its contents are inserted and its
3065dependencies are added to those of the containing gexp.
3066
3067If @var{obj} is another kind of object, it is inserted as is.
3068
b39fc6f7
LC
3069@item #$@var{obj}:@var{output}
3070@itemx (ungexp @var{obj} @var{output})
21b679f6 3071This is like the form above, but referring explicitly to the
b39fc6f7
LC
3072@var{output} of @var{obj}---this is useful when @var{obj} produces
3073multiple outputs (@pxref{Packages with Multiple Outputs}).
21b679f6 3074
667b2508
LC
3075@item #+@var{obj}
3076@itemx #+@var{obj}:output
3077@itemx (ungexp-native @var{obj})
3078@itemx (ungexp-native @var{obj} @var{output})
3079Same as @code{ungexp}, but produces a reference to the @emph{native}
3080build of @var{obj} when used in a cross compilation context.
3081
21b679f6
LC
3082@item #$output[:@var{output}]
3083@itemx (ungexp output [@var{output}])
3084Insert a reference to derivation output @var{output}, or to the main
3085output when @var{output} is omitted.
3086
3087This only makes sense for gexps passed to @code{gexp->derivation}.
3088
3089@item #$@@@var{lst}
3090@itemx (ungexp-splicing @var{lst})
3091Like the above, but splices the contents of @var{lst} inside the
3092containing list.
3093
667b2508
LC
3094@item #+@@@var{lst}
3095@itemx (ungexp-native-splicing @var{lst})
3096Like the above, but refers to native builds of the objects listed in
3097@var{lst}.
3098
21b679f6
LC
3099@end table
3100
3101G-expressions created by @code{gexp} or @code{#~} are run-time objects
3102of the @code{gexp?} type (see below.)
3103@end deffn
3104
3105@deffn {Scheme Procedure} gexp? @var{obj}
3106Return @code{#t} if @var{obj} is a G-expression.
3107@end deffn
3108
3109G-expressions are meant to be written to disk, either as code building
3110some derivation, or as plain files in the store. The monadic procedures
3111below allow you to do that (@pxref{The Store Monad}, for more
3112information about monads.)
3113
3114@deffn {Monadic Procedure} gexp->derivation @var{name} @var{exp} @
ce45eb4c 3115 [#:system (%current-system)] [#:target #f] [#:graft? #t] @
21b679f6
LC
3116 [#:hash #f] [#:hash-algo #f] @
3117 [#:recursive? #f] [#:env-vars '()] [#:modules '()] @
4684f301 3118 [#:module-path @var{%load-path}] @
c8351d9a 3119 [#:references-graphs #f] [#:allowed-references #f] @
c0468155 3120 [#:leaked-env-vars #f] @
c8351d9a 3121 [#:local-build? #f] [#:guile-for-build #f]
21b679f6 3122Return a derivation @var{name} that runs @var{exp} (a gexp) with
68a61e9f
LC
3123@var{guile-for-build} (a derivation) on @var{system}. When @var{target}
3124is true, it is used as the cross-compilation target triplet for packages
3125referred to by @var{exp}.
21b679f6 3126
ce45eb4c
LC
3127Make @var{modules} available in the evaluation context of @var{exp};
3128@var{modules} is a list of names of Guile modules searched in
3129@var{module-path} to be copied in the store, compiled, and made available in
21b679f6
LC
3130the load path during the execution of @var{exp}---e.g., @code{((guix
3131build utils) (guix build gnu-build-system))}.
3132
ce45eb4c
LC
3133@var{graft?} determines whether packages referred to by @var{exp} should be grafted when
3134applicable.
3135
b53833b2
LC
3136When @var{references-graphs} is true, it must be a list of tuples of one of the
3137following forms:
3138
3139@example
3140(@var{file-name} @var{package})
3141(@var{file-name} @var{package} @var{output})
3142(@var{file-name} @var{derivation})
3143(@var{file-name} @var{derivation} @var{output})
3144(@var{file-name} @var{store-item})
3145@end example
3146
3147The right-hand-side of each element of @var{references-graphs} is automatically made
3148an input of the build process of @var{exp}. In the build environment, each
3149@var{file-name} contains the reference graph of the corresponding item, in a simple
3150text format.
3151
c8351d9a
LC
3152@var{allowed-references} must be either @code{#f} or a list of output names and packages.
3153In the latter case, the list denotes store items that the result is allowed to
3154refer to. Any reference to another store item will lead to a build error.
3155
e20fd1bf 3156The other arguments are as for @code{derivation} (@pxref{Derivations}).
21b679f6
LC
3157@end deffn
3158
343eacbe
LC
3159@cindex file-like objects
3160The @code{local-file} and @code{plain-file} procedures below return
3161@dfn{file-like objects}. That is, when unquoted in a G-expression,
3162these objects lead to a file in the store. Consider this G-expression:
3163
3164@example
3165#~(system* (string-append #$glibc "/sbin/nscd") "-f"
3166 #$(local-file "/tmp/my-nscd.conf"))
3167@end example
3168
3169The effect here is to ``intern'' @file{/tmp/my-nscd.conf} by copying it
3170to the store. Once expanded, for instance @i{via}
3171@code{gexp->derivation}, the G-expression refers to that copy under
3172@file{/gnu/store}; thus, modifying or removing the file in @file{/tmp}
3173does not have any effect on what the G-expression does.
3174@code{plain-file} can be used similarly; it differs in that the file
3175content is directly passed as a string.
3176
d9ae938f
LC
3177@deffn {Scheme Procedure} local-file @var{file} [@var{name}] @
3178 [#:recursive? #t]
3179Return an object representing local file @var{file} to add to the store; this
3180object can be used in a gexp. @var{file} will be added to the store under @var{name}--by
3181default the base name of @var{file}.
3182
3183When @var{recursive?} is true, the contents of @var{file} are added recursively; if @var{file}
3184designates a flat file and @var{recursive?} is true, its contents are added, and its
3185permission bits are kept.
3186
3187This is the declarative counterpart of the @code{interned-file} monadic
3188procedure (@pxref{The Store Monad, @code{interned-file}}).
3189@end deffn
3190
558e8b11
LC
3191@deffn {Scheme Procedure} plain-file @var{name} @var{content}
3192Return an object representing a text file called @var{name} with the given
3193@var{content} (a string) to be added to the store.
3194
3195This is the declarative counterpart of @code{text-file}.
3196@end deffn
3197
21b679f6
LC
3198@deffn {Monadic Procedure} gexp->script @var{name} @var{exp}
3199Return an executable script @var{name} that runs @var{exp} using
3200@var{guile} with @var{modules} in its search path.
3201
3202The example below builds a script that simply invokes the @command{ls}
3203command:
3204
3205@example
3206(use-modules (guix gexp) (gnu packages base))
3207
3208(gexp->script "list-files"
3209 #~(execl (string-append #$coreutils "/bin/ls")
3210 "ls"))
3211@end example
3212
3213When ``running'' it through the store (@pxref{The Store Monad,
e20fd1bf 3214@code{run-with-store}}), we obtain a derivation that produces an
21b679f6
LC
3215executable file @file{/gnu/store/@dots{}-list-files} along these lines:
3216
3217@example
3218#!/gnu/store/@dots{}-guile-2.0.11/bin/guile -ds
3219!#
3220(execl (string-append "/gnu/store/@dots{}-coreutils-8.22"/bin/ls")
3221 "ls")
3222@end example
3223@end deffn
3224
3225@deffn {Monadic Procedure} gexp->file @var{name} @var{exp}
3226Return a derivation that builds a file @var{name} containing @var{exp}.
3227
3228The resulting file holds references to all the dependencies of @var{exp}
3229or a subset thereof.
3230@end deffn
1ed19464
LC
3231
3232@deffn {Monadic Procedure} text-file* @var{name} @var{text} @dots{}
3233Return as a monadic value a derivation that builds a text file
3234containing all of @var{text}. @var{text} may list, in addition to
d9ae938f
LC
3235strings, objects of any type that can be used in a gexp: packages,
3236derivations, local file objects, etc. The resulting store file holds
3237references to all these.
1ed19464
LC
3238
3239This variant should be preferred over @code{text-file} anytime the file
3240to create will reference items from the store. This is typically the
3241case when building a configuration file that embeds store file names,
3242like this:
3243
3244@example
3245(define (profile.sh)
3246 ;; Return the name of a shell script in the store that
3247 ;; initializes the 'PATH' environment variable.
3248 (text-file* "profile.sh"
3249 "export PATH=" coreutils "/bin:"
3250 grep "/bin:" sed "/bin\n"))
3251@end example
3252
3253In this example, the resulting @file{/gnu/store/@dots{}-profile.sh} file
3254will references @var{coreutils}, @var{grep}, and @var{sed}, thereby
3255preventing them from being garbage-collected during its lifetime.
3256@end deffn
21b679f6
LC
3257
3258Of course, in addition to gexps embedded in ``host'' code, there are
3259also modules containing build tools. To make it clear that they are
3260meant to be used in the build stratum, these modules are kept in the
3261@code{(guix build @dots{})} name space.
3262
3263
568717fd
LC
3264@c *********************************************************************
3265@node Utilities
3266@chapter Utilities
3267
210cc920
LC
3268This section describes tools primarily targeted at developers and users
3269who write new package definitions. They complement the Scheme
3270programming interface of Guix in a convenient way.
3271
568717fd 3272@menu
37166310 3273* Invoking guix build:: Building packages from the command line.
39bee8a2 3274* Invoking guix edit:: Editing package definitions.
210cc920 3275* Invoking guix download:: Downloading a file and printing its hash.
37166310 3276* Invoking guix hash:: Computing the cryptographic hash of a file.
2f7d2d91 3277* Invoking guix import:: Importing package definitions.
37166310 3278* Invoking guix refresh:: Updating package definitions.
b4f5e0e8 3279* Invoking guix lint:: Finding errors in package definitions.
fcc58db6 3280* Invoking guix size:: Profiling disk usage.
372c4bbc 3281* Invoking guix environment:: Setting up development environments.
aff8ce7c 3282* Invoking guix publish:: Sharing substitutes.
568717fd
LC
3283@end menu
3284
e49951eb
MW
3285@node Invoking guix build
3286@section Invoking @command{guix build}
568717fd 3287
e49951eb 3288The @command{guix build} command builds packages or derivations and
6798a8e4
LC
3289their dependencies, and prints the resulting store paths. Note that it
3290does not modify the user's profile---this is the job of the
e49951eb 3291@command{guix package} command (@pxref{Invoking guix package}). Thus,
6798a8e4
LC
3292it is mainly useful for distribution developers.
3293
3294The general syntax is:
c78bd12b
LC
3295
3296@example
e49951eb 3297guix build @var{options} @var{package-or-derivation}@dots{}
c78bd12b
LC
3298@end example
3299
3300@var{package-or-derivation} may be either the name of a package found in
5401dd75
LC
3301the software distribution such as @code{coreutils} or
3302@code{coreutils-8.20}, or a derivation such as
834129e0 3303@file{/gnu/store/@dots{}-coreutils-8.19.drv}. In the former case, a
e7f34eb0
LC
3304package with the corresponding name (and optionally version) is searched
3305for among the GNU distribution modules (@pxref{Package Modules}).
3306
3307Alternatively, the @code{--expression} option may be used to specify a
3308Scheme expression that evaluates to a package; this is useful when
3309disambiguation among several same-named packages or package variants is
3310needed.
c78bd12b
LC
3311
3312The @var{options} may be zero or more of the following:
3313
3314@table @code
3315
3316@item --expression=@var{expr}
3317@itemx -e @var{expr}
ac5de156 3318Build the package or derivation @var{expr} evaluates to.
c78bd12b 3319
5401dd75 3320For example, @var{expr} may be @code{(@@ (gnu packages guile)
c78bd12b
LC
3321guile-1.8)}, which unambiguously designates this specific variant of
3322version 1.8 of Guile.
3323
56b82106
LC
3324Alternately, @var{expr} may be a G-expression, in which case it is used
3325as a build program passed to @code{gexp->derivation}
3326(@pxref{G-Expressions}).
3327
3328Lastly, @var{expr} may refer to a zero-argument monadic procedure
ac5de156
LC
3329(@pxref{The Store Monad}). The procedure must return a derivation as a
3330monadic value, which is then passed through @code{run-with-store}.
3331
c78bd12b
LC
3332@item --source
3333@itemx -S
3334Build the packages' source derivations, rather than the packages
3335themselves.
3336
e49951eb 3337For instance, @code{guix build -S gcc} returns something like
834129e0 3338@file{/gnu/store/@dots{}-gcc-4.7.2.tar.bz2}, which is GCC's source tarball.
c78bd12b 3339
f9cc8971
LC
3340The returned source tarball is the result of applying any patches and
3341code snippets specified in the package's @code{origin} (@pxref{Defining
3342Packages}).
3343
2cdfe13d
EB
3344@item --sources
3345Fetch and return the source of @var{package-or-derivation} and all their
3346dependencies, recursively. This is a handy way to obtain a local copy
3347of all the source code needed to build @var{packages}, allowing you to
3348eventually build them even without network access. It is an extension
3349of the @code{--source} option and can accept one of the following
3350optional argument values:
3351
3352@table @code
3353@item package
3354This value causes the @code{--sources} option to behave in the same way
3355as the @code{--source} option.
3356
3357@item all
3358Build all packages' source derivations, including any source that might
3359be listed as @code{inputs}. This is the default value.
3360
3361@example
3362$ guix build --sources tzdata
3363The following derivations will be built:
3364 /gnu/store/@dots{}-tzdata2015b.tar.gz.drv
3365 /gnu/store/@dots{}-tzcode2015b.tar.gz.drv
3366@end example
3367
3368@item transitive
3369Build all packages' source derivations, as well as all source
3370derivations for packages' transitive inputs. This can be used e.g. to
3371prefetch package source for later offline building.
3372
3373@example
3374$ guix build --sources=transitive tzdata
3375The following derivations will be built:
3376 /gnu/store/@dots{}-tzcode2015b.tar.gz.drv
3377 /gnu/store/@dots{}-findutils-4.4.2.tar.xz.drv
3378 /gnu/store/@dots{}-grep-2.21.tar.xz.drv
3379 /gnu/store/@dots{}-coreutils-8.23.tar.xz.drv
3380 /gnu/store/@dots{}-make-4.1.tar.xz.drv
3381 /gnu/store/@dots{}-bash-4.3.tar.xz.drv
3382@dots{}
3383@end example
3384
3385@end table
3386
c78bd12b
LC
3387@item --system=@var{system}
3388@itemx -s @var{system}
3389Attempt to build for @var{system}---e.g., @code{i686-linux}---instead of
3390the host's system type.
3391
3392An example use of this is on Linux-based systems, which can emulate
3393different personalities. For instance, passing
3394@code{--system=i686-linux} on an @code{x86_64-linux} system allows users
3395to build packages in a complete 32-bit environment.
3396
e55ec43d
LC
3397@item --target=@var{triplet}
3398@cindex cross-compilation
3399Cross-build for @var{triplet}, which must be a valid GNU triplet, such
3400as @code{"mips64el-linux-gnu"} (@pxref{Configuration Names, GNU
3401configuration triplets,, configure, GNU Configure and Build System}).
3402
7f3673f2
LC
3403@item --with-source=@var{source}
3404Use @var{source} as the source of the corresponding package.
3405@var{source} must be a file name or a URL, as for @command{guix
3406download} (@pxref{Invoking guix download}).
3407
3408The ``corresponding package'' is taken to be one specified on the
3409command line whose name matches the base of @var{source}---e.g., if
3410@var{source} is @code{/src/guile-2.0.10.tar.gz}, the corresponding
3411package is @code{guile}. Likewise, the version string is inferred from
3412@var{source}; in the previous example, it's @code{2.0.10}.
3413
3414This option allows users to try out versions of packages other than the
3415one provided by the distribution. The example below downloads
3416@file{ed-1.7.tar.gz} from a GNU mirror and uses that as the source for
3417the @code{ed} package:
3418
3419@example
3420guix build ed --with-source=mirror://gnu/ed/ed-1.7.tar.gz
3421@end example
3422
3423As a developer, @code{--with-source} makes it easy to test release
3424candidates:
3425
3426@example
3427guix build guile --with-source=../guile-2.0.9.219-e1bb7.tar.xz
3428@end example
3429
a43b55f1
LC
3430@dots{} or to build from a checkout in a pristine environment:
3431
3432@example
3433$ git clone git://git.sv.gnu.org/guix.git
3434$ guix build guix --with-source=./guix
3435@end example
3436
05962f29
LC
3437@item --no-grafts
3438Do not ``graft'' packages. In practice, this means that package updates
3439available as grafts are not applied. @xref{Security Updates}, for more
3440information on grafts.
7f3673f2 3441
c78bd12b
LC
3442@item --derivations
3443@itemx -d
3444Return the derivation paths, not the output paths, of the given
3445packages.
3446
70ee5642
LC
3447@item --root=@var{file}
3448@itemx -r @var{file}
3449Make @var{file} a symlink to the result, and register it as a garbage
3450collector root.
3451
3452@item --log-file
3453Return the build log file names for the given
3454@var{package-or-derivation}s, or raise an error if build logs are
3455missing.
3456
3457This works regardless of how packages or derivations are specified. For
3458instance, the following invocations are equivalent:
3459
3460@example
3461guix build --log-file `guix build -d guile`
3462guix build --log-file `guix build guile`
3463guix build --log-file guile
3464guix build --log-file -e '(@@ (gnu packages guile) guile-2.0)'
3465@end example
3466
3467
3468@end table
3469
3470@cindex common build options
3471In addition, a number of options that control the build process are
3472common to @command{guix build} and other commands that can spawn builds,
3473such as @command{guix package} or @command{guix archive}. These are the
3474following:
3475
3476@table @code
3477
300868ba
LC
3478@item --load-path=@var{directory}
3479@itemx -L @var{directory}
3480Add @var{directory} to the front of the package module search path
3481(@pxref{Package Modules}).
3482
3483This allows users to define their own packages and make them visible to
3484the command-line tools.
3485
c78bd12b
LC
3486@item --keep-failed
3487@itemx -K
3488Keep the build tree of failed builds. Thus, if a build fail, its build
3489tree is kept under @file{/tmp}, in a directory whose name is shown at
3490the end of the build log. This is useful when debugging build issues.
3491
3492@item --dry-run
3493@itemx -n
3494Do not build the derivations.
3495
56b1f4b7
LC
3496@item --fallback
3497When substituting a pre-built binary fails, fall back to building
3498packages locally.
3499
c78bd12b 3500@item --no-substitutes
b5385b52 3501Do not use substitutes for build products. That is, always build things
c4202d60
LC
3502locally instead of allowing downloads of pre-built binaries
3503(@pxref{Substitutes}).
c78bd12b 3504
425b0bfc 3505@item --no-build-hook
4ec2e92d
LC
3506Do not attempt to offload builds @i{via} the daemon's ``build hook''
3507(@pxref{Daemon Offload Setup}). That is, always build things locally
3508instead of offloading builds to remote machines.
425b0bfc 3509
969e678e
LC
3510@item --max-silent-time=@var{seconds}
3511When the build or substitution process remains silent for more than
3512@var{seconds}, terminate it and report a build failure.
3513
002622b6
LC
3514@item --timeout=@var{seconds}
3515Likewise, when the build or substitution process lasts for more than
3516@var{seconds}, terminate it and report a build failure.
3517
3518By default there is no timeout. This behavior can be restored with
3519@code{--timeout=0}.
3520
07ab4bf1
LC
3521@item --verbosity=@var{level}
3522Use the given verbosity level. @var{level} must be an integer between 0
3523and 5; higher means more verbose output. Setting a level of 4 or more
3524may be helpful when debugging setup issues with the build daemon.
3525
70ee5642
LC
3526@item --cores=@var{n}
3527@itemx -c @var{n}
3528Allow the use of up to @var{n} CPU cores for the build. The special
3529value @code{0} means to use as many CPU cores as available.
bf421152 3530
f6526eb3
LC
3531@item --max-jobs=@var{n}
3532@itemx -M @var{n}
3533Allow at most @var{n} build jobs in parallel. @xref{Invoking
3534guix-daemon, @code{--max-jobs}}, for details about this option and the
3535equivalent @command{guix-daemon} option.
3536
c78bd12b
LC
3537@end table
3538
e49951eb 3539Behind the scenes, @command{guix build} is essentially an interface to
c78bd12b
LC
3540the @code{package-derivation} procedure of the @code{(guix packages)}
3541module, and to the @code{build-derivations} procedure of the @code{(guix
01d8ac64 3542derivations)} module.
c78bd12b 3543
16eb115e
DP
3544In addition to options explicitly passed on the command line,
3545@command{guix build} and other @command{guix} commands that support
3546building honor the @code{GUIX_BUILD_OPTIONS} environment variable.
3547
3548@defvr {Environment Variable} GUIX_BUILD_OPTIONS
3549Users can define this variable to a list of command line options that
3550will automatically be used by @command{guix build} and other
3551@command{guix} commands that can perform builds, as in the example
3552below:
3553
3554@example
3555$ export GUIX_BUILD_OPTIONS="--no-substitutes -c 2 -L /foo/bar"
3556@end example
3557
847391fe
DP
3558These options are parsed independently, and the result is appended to
3559the parsed command-line options.
16eb115e
DP
3560@end defvr
3561
3562
39bee8a2
LC
3563@node Invoking guix edit
3564@section Invoking @command{guix edit}
3565
3566@cindex package definition, editing
3567So many packages, so many source files! The @command{guix edit} command
3568facilitates the life of packagers by pointing their editor at the source
3569file containing the definition of the specified packages. For instance:
3570
3571@example
3572guix edit gcc-4.8 vim
3573@end example
3574
3575@noindent
3576launches the program specified in the @code{EDITOR} environment variable
3577to edit the recipe of GCC@tie{}4.8.4 and that of Vim.
3578
3579If you are using Emacs, note that the Emacs user interface provides
6248e326
AK
3580similar functionality in the ``package info'' and ``package list''
3581buffers created by @kbd{M-x guix-search-by-name} and similar commands
3582(@pxref{Emacs Commands}).
39bee8a2
LC
3583
3584
210cc920
LC
3585@node Invoking guix download
3586@section Invoking @command{guix download}
3587
3588When writing a package definition, developers typically need to download
3589the package's source tarball, compute its SHA256 hash, and write that
3590hash in the package definition (@pxref{Defining Packages}). The
3591@command{guix download} tool helps with this task: it downloads a file
3592from the given URI, adds it to the store, and prints both its file name
3593in the store and its SHA256 hash.
3594
3595The fact that the downloaded file is added to the store saves bandwidth:
3596when the developer eventually tries to build the newly defined package
3597with @command{guix build}, the source tarball will not have to be
3598downloaded again because it is already in the store. It is also a
3599convenient way to temporarily stash files, which may be deleted
3600eventually (@pxref{Invoking guix gc}).
3601
3602The @command{guix download} command supports the same URIs as used in
3603package definitions. In particular, it supports @code{mirror://} URIs.
3604@code{https} URIs (HTTP over TLS) are supported @emph{provided} the
3605Guile bindings for GnuTLS are available in the user's environment; when
537c8bb3
LC
3606they are not available, an error is raised. @xref{Guile Preparations,
3607how to install the GnuTLS bindings for Guile,, gnutls-guile,
3608GnuTLS-Guile}, for more information.
210cc920
LC
3609
3610The following option is available:
3611
3612@table @code
3613@item --format=@var{fmt}
3614@itemx -f @var{fmt}
3615Write the hash in the format specified by @var{fmt}. For more
081145cf 3616information on the valid values for @var{fmt}, @pxref{Invoking guix hash}.
210cc920
LC
3617@end table
3618
6c365eca
NK
3619@node Invoking guix hash
3620@section Invoking @command{guix hash}
3621
210cc920 3622The @command{guix hash} command computes the SHA256 hash of a file.
6c365eca
NK
3623It is primarily a convenience tool for anyone contributing to the
3624distribution: it computes the cryptographic hash of a file, which can be
3625used in the definition of a package (@pxref{Defining Packages}).
3626
3627The general syntax is:
3628
3629@example
3630guix hash @var{option} @var{file}
3631@end example
3632
3633@command{guix hash} has the following option:
3634
3635@table @code
3636
3637@item --format=@var{fmt}
3638@itemx -f @var{fmt}
210cc920 3639Write the hash in the format specified by @var{fmt}.
6c365eca
NK
3640
3641Supported formats: @code{nix-base32}, @code{base32}, @code{base16}
3642(@code{hex} and @code{hexadecimal} can be used as well).
3643
3644If the @option{--format} option is not specified, @command{guix hash}
3645will output the hash in @code{nix-base32}. This representation is used
3646in the definitions of packages.
3647
3140f2df
LC
3648@item --recursive
3649@itemx -r
3650Compute the hash on @var{file} recursively.
3651
3652In this case, the hash is computed on an archive containing @var{file},
3653including its children if it is a directory. Some of @var{file}'s
3654meta-data is part of the archive; for instance, when @var{file} is a
3655regular file, the hash is different depending on whether @var{file} is
3656executable or not. Meta-data such as time stamps has no impact on the
3657hash (@pxref{Invoking guix archive}).
3658@c FIXME: Replace xref above with xref to an ``Archive'' section when
3659@c it exists.
3660
6c365eca
NK
3661@end table
3662
2f7d2d91
LC
3663@node Invoking guix import
3664@section Invoking @command{guix import}
3665
3666@cindex importing packages
3667@cindex package import
3668@cindex package conversion
3669The @command{guix import} command is useful for people willing to add a
3670package to the distribution but who'd rather do as little work as
3671possible to get there---a legitimate demand. The command knows of a few
3672repositories from which it can ``import'' package meta-data. The result
3673is a package definition, or a template thereof, in the format we know
3674(@pxref{Defining Packages}).
3675
3676The general syntax is:
3677
3678@example
3679guix import @var{importer} @var{options}@dots{}
3680@end example
3681
3682@var{importer} specifies the source from which to import package
3683meta-data, and @var{options} specifies a package identifier and other
3684options specific to @var{importer}. Currently, the available
3685``importers'' are:
3686
3687@table @code
3688@item gnu
3689Import meta-data for the given GNU package. This provides a template
3690for the latest version of that GNU package, including the hash of its
3691source tarball, and its canonical synopsis and description.
3692
3693Additional information such as the package's dependencies and its
3694license needs to be figured out manually.
3695
3696For example, the following command returns a package definition for
3697GNU@tie{}Hello:
3698
3699@example
3700guix import gnu hello
3701@end example
3702
3703Specific command-line options are:
3704
3705@table @code
3706@item --key-download=@var{policy}
3707As for @code{guix refresh}, specify the policy to handle missing OpenPGP
3708keys when verifying the package's signature. @xref{Invoking guix
3709refresh, @code{--key-download}}.
3710@end table
3711
3712@item pypi
3713@cindex pypi
3714Import meta-data from the @uref{https://pypi.python.org/, Python Package
3715Index}@footnote{This functionality requires Guile-JSON to be installed.
3716@xref{Requirements}.}. Information is taken from the JSON-formatted
3717description available at @code{pypi.python.org} and usually includes all
3718the relevant information, including package dependencies.
3719
3720The command below imports meta-data for the @code{itsdangerous} Python
3721package:
3722
3723@example
3724guix import pypi itsdangerous
3725@end example
3726
d45dc6da
EB
3727@item cpan
3728@cindex CPAN
3729Import meta-data from @uref{https://www.metacpan.org/, MetaCPAN}.
3730Information is taken from the JSON-formatted meta-data provided through
3731@uref{https://api.metacpan.org/, MetaCPAN's API} and includes most
66392e47
EB
3732relevant information, such as module dependencies. License information
3733should be checked closely. If Perl is available in the store, then the
3734@code{corelist} utility will be used to filter core modules out of the
3735list of dependencies.
d45dc6da
EB
3736
3737The command command below imports meta-data for the @code{Acme::Boolean}
3738Perl module:
3739
3740@example
3741guix import cpan Acme::Boolean
3742@end example
3743
2f7d2d91
LC
3744@item nix
3745Import meta-data from a local copy of the source of the
3746@uref{http://nixos.org/nixpkgs/, Nixpkgs distribution}@footnote{This
3747relies on the @command{nix-instantiate} command of
3748@uref{http://nixos.org/nix/, Nix}.}. Package definitions in Nixpkgs are
3749typically written in a mixture of Nix-language and Bash code. This
3750command only imports the high-level package structure that is written in
3751the Nix language. It normally includes all the basic fields of a
3752package definition.
3753
3754When importing a GNU package, the synopsis and descriptions are replaced
3755by their canonical upstream variant.
3756
3757As an example, the command below imports the package definition of
3758LibreOffice (more precisely, it imports the definition of the package
3759bound to the @code{libreoffice} top-level attribute):
3760
3761@example
3762guix import nix ~/path/to/nixpkgs libreoffice
3763@end example
863af4e1
FB
3764
3765@item hackage
3766@cindex hackage
3767Import meta-data from Haskell community's central package archive
3768@uref{https://hackage.haskell.org/, Hackage}. Information is taken from
3769Cabal files and includes all the relevant information, including package
3770dependencies.
3771
3772Specific command-line options are:
3773
3774@table @code
a4154748
FB
3775@item --stdin
3776@itemx -s
3777Read a Cabal file from the standard input.
863af4e1
FB
3778@item --no-test-dependencies
3779@itemx -t
a4154748
FB
3780Do not include dependencies required by the test suites only.
3781@item --cabal-environment=@var{alist}
3782@itemx -e @var{alist}
3783@var{alist} is a Scheme alist defining the environment in which the
3784Cabal conditionals are evaluated. The accepted keys are: @code{os},
3785@code{arch}, @code{impl} and a string representing the name of a flag.
3786The value associated with a flag has to be either the symbol
3787@code{true} or @code{false}. The value associated with other keys
3788has to conform to the Cabal file format definition. The default value
3789associated with the keys @code{os}, @code{arch} and @code{impl} is
3790@samp{linux}, @samp{x86_64} and @samp{ghc} respectively.
863af4e1
FB
3791@end table
3792
3793The command below imports meta-data for the latest version of the
a4154748
FB
3794@code{HTTP} Haskell package without including test dependencies and
3795specifying the value of the flag @samp{network-uri} as @code{false}:
863af4e1
FB
3796
3797@example
a4154748 3798guix import hackage -t -e "'((\"network-uri\" . false))" HTTP
863af4e1
FB
3799@end example
3800
3801A specific package version may optionally be specified by following the
3802package name by a hyphen and a version number as in the following example:
3803
3804@example
3805guix import hackage mtl-2.1.3.1
3806@end example
2f7d2d91
LC
3807@end table
3808
3809The structure of the @command{guix import} code is modular. It would be
3810useful to have more importers for other package formats, and your help
3811is welcome here (@pxref{Contributing}).
3812
37166310
LC
3813@node Invoking guix refresh
3814@section Invoking @command{guix refresh}
3815
3816The primary audience of the @command{guix refresh} command is developers
3817of the GNU software distribution. By default, it reports any packages
3818provided by the distribution that are outdated compared to the latest
3819upstream version, like this:
3820
3821@example
3822$ guix refresh
3823gnu/packages/gettext.scm:29:13: gettext would be upgraded from 0.18.1.1 to 0.18.2.1
3824gnu/packages/glib.scm:77:12: glib would be upgraded from 2.34.3 to 2.37.0
3825@end example
3826
3827It does so by browsing each package's FTP directory and determining the
3828highest version number of the source tarballs
3829therein@footnote{Currently, this only works for GNU packages.}.
3830
3831When passed @code{--update}, it modifies distribution source files to
3832update the version numbers and source tarball hashes of those packages'
3833recipes (@pxref{Defining Packages}). This is achieved by downloading
3834each package's latest source tarball and its associated OpenPGP
3835signature, authenticating the downloaded tarball against its signature
3836using @command{gpg}, and finally computing its hash. When the public
3837key used to sign the tarball is missing from the user's keyring, an
3838attempt is made to automatically retrieve it from a public key server;
3839when it's successful, the key is added to the user's keyring; otherwise,
3840@command{guix refresh} reports an error.
3841
3842The following options are supported:
3843
3844@table @code
3845
3846@item --update
3847@itemx -u
3848Update distribution source files (package recipes) in place.
081145cf 3849@xref{Defining Packages}, for more information on package definitions.
37166310
LC
3850
3851@item --select=[@var{subset}]
3852@itemx -s @var{subset}
3853Select all the packages in @var{subset}, one of @code{core} or
3854@code{non-core}.
3855
3856The @code{core} subset refers to all the packages at the core of the
3857distribution---i.e., packages that are used to build ``everything
3858else''. This includes GCC, libc, Binutils, Bash, etc. Usually,
3859changing one of these packages in the distribution entails a rebuild of
3860all the others. Thus, such updates are an inconvenience to users in
3861terms of build time or bandwidth used to achieve the upgrade.
3862
3863The @code{non-core} subset refers to the remaining packages. It is
3864typically useful in cases where an update of the core packages would be
3865inconvenient.
3866
3867@end table
3868
3869In addition, @command{guix refresh} can be passed one or more package
3870names, as in this example:
3871
3872@example
4b9b3cbb 3873guix refresh -u emacs idutils gcc-4.8.4
37166310
LC
3874@end example
3875
3876@noindent
3877The command above specifically updates the @code{emacs} and
3878@code{idutils} packages. The @code{--select} option would have no
3879effect in this case.
3880
7d193ec3
EB
3881When considering whether to upgrade a package, it is sometimes
3882convenient to know which packages would be affected by the upgrade and
3883should be checked for compatibility. For this the following option may
3884be used when passing @command{guix refresh} one or more package names:
3885
3886@table @code
3887
3888@item --list-dependent
3889@itemx -l
3890List top-level dependent packages that would need to be rebuilt as a
3891result of upgrading one or more packages.
3892
3893@end table
3894
3895Be aware that the @code{--list-dependent} option only
3896@emph{approximates} the rebuilds that would be required as a result of
3897an upgrade. More rebuilds might be required under some circumstances.
3898
3899@example
7779ab61
LC
3900$ guix refresh --list-dependent flex
3901Building the following 120 packages would ensure 213 dependent packages are rebuilt:
3902hop-2.4.0 geiser-0.4 notmuch-0.18 mu-0.9.9.5 cflow-1.4 idutils-4.6 @dots{}
7d193ec3
EB
3903@end example
3904
3905The command above lists a set of packages that could be built to check
3906for compatibility with an upgraded @code{flex} package.
3907
f9230085
LC
3908The following options can be used to customize GnuPG operation:
3909
3910@table @code
3911
f9230085
LC
3912@item --gpg=@var{command}
3913Use @var{command} as the GnuPG 2.x command. @var{command} is searched
3914for in @code{$PATH}.
3915
2bc53ba9
LC
3916@item --key-download=@var{policy}
3917Handle missing OpenPGP keys according to @var{policy}, which may be one
3918of:
3919
3920@table @code
3921@item always
3922Always download missing OpenPGP keys from the key server, and add them
3923to the user's GnuPG keyring.
3924
3925@item never
3926Never try to download missing OpenPGP keys. Instead just bail out.
3927
3928@item interactive
3929When a package signed with an unknown OpenPGP key is encountered, ask
3930the user whether to download it or not. This is the default behavior.
3931@end table
3932
3933@item --key-server=@var{host}
3934Use @var{host} as the OpenPGP key server when importing a public key.
3935
f9230085
LC
3936@end table
3937
b4f5e0e8
CR
3938@node Invoking guix lint
3939@section Invoking @command{guix lint}
3940The @command{guix lint} is meant to help package developers avoid common
873c4085
LC
3941errors and use a consistent style. It runs a number of checks on a
3942given set of packages in order to find common mistakes in their
3943definitions. Available @dfn{checkers} include (see
3944@code{--list-checkers} for a complete list):
3945
3946@table @code
3947@item synopsis
3948@itemx description
3949Validate certain typographical and stylistic rules about package
3950descriptions and synopses.
3951
3952@item inputs-should-be-native
3953Identify inputs that should most likely be native inputs.
3954
3955@item source
3956@itemx home-page
3957Probe @code{home-page} and @code{source} URLs and report those that are
3958invalid.
3959@end table
b4f5e0e8
CR
3960
3961The general syntax is:
3962
3963@example
3964guix lint @var{options} @var{package}@dots{}
3965@end example
3966
3967If no package is given on the command line, then all packages are checked.
3968The @var{options} may be zero or more of the following:
3969
3970@table @code
3971
dd7c013d
CR
3972@item --checkers
3973@itemx -c
3974Only enable the checkers specified in a comma-separated list using the
3975names returned by @code{--list-checkers}.
3976
b4f5e0e8
CR
3977@item --list-checkers
3978@itemx -l
3979List and describe all the available checkers that will be run on packages
3980and exit.
3981
3982@end table
37166310 3983
fcc58db6
LC
3984@node Invoking guix size
3985@section Invoking @command{guix size}
3986
3987The @command{guix size} command helps package developers profile the
3988disk usage of packages. It is easy to overlook the impact of an
3989additional dependency added to a package, or the impact of using a
3990single output for a package that could easily be split (@pxref{Packages
3991with Multiple Outputs}). These are the typical issues that
3992@command{guix size} can highlight.
3993
3994The command can be passed a package specification such as @code{gcc-4.8}
3995or @code{guile:debug}, or a file name in the store. Consider this
3996example:
3997
3998@example
3999$ guix size coreutils
4000store item total self
4001/gnu/store/@dots{}-coreutils-8.23 70.0 13.9 19.8%
4002/gnu/store/@dots{}-gmp-6.0.0a 55.3 2.5 3.6%
4003/gnu/store/@dots{}-acl-2.2.52 53.7 0.5 0.7%
4004/gnu/store/@dots{}-attr-2.4.46 53.2 0.3 0.5%
4005/gnu/store/@dots{}-gcc-4.8.4-lib 52.9 15.7 22.4%
4006/gnu/store/@dots{}-glibc-2.21 37.2 37.2 53.1%
4007@end example
4008
4009@cindex closure
4010The store items listed here constitute the @dfn{transitive closure} of
4011Coreutils---i.e., Coreutils and all its dependencies, recursively---as
4012would be returned by:
4013
4014@example
4015$ guix gc -R /gnu/store/@dots{}-coreutils-8.23
4016@end example
4017
4018Here the output shows 3 columns next to store items. The first column,
4019labeled ``total'', shows the size in mebibytes (MiB) of the closure of
4020the store item---that is, its own size plus the size of all its
4021dependencies. The next column, labeled ``self'', shows the size of the
4022item itself. The last column shows the ratio of the item's size to the
4023space occupied by all the items listed here.
4024
4025In this example, we see that the closure of Coreutils weighs in at
402670@tie{}MiB, half of which is taken by libc. (That libc represents a
4027large fraction of the closure is not a problem @i{per se} because it is
4028always available on the system anyway.)
4029
4030When the package passed to @command{guix size} is available in the
4031store, @command{guix size} queries the daemon to determine its
4032dependencies, and measures its size in the store, similar to @command{du
4033-ms --apparent-size} (@pxref{du invocation,,, coreutils, GNU
4034Coreutils}).
4035
4036When the given package is @emph{not} in the store, @command{guix size}
4037reports information based on information about the available substitutes
4038(@pxref{Substitutes}). This allows it to profile disk usage of store
4039items that are not even on disk, only available remotely.
4040
a8f996c6 4041The available options are:
fcc58db6
LC
4042
4043@table @option
4044
a8f996c6
LC
4045@item --map-file=@var{file}
4046Write to @var{file} a graphical map of disk usage as a PNG file.
4047
4048For the example above, the map looks like this:
4049
4050@image{images/coreutils-size-map,5in,, map of Coreutils disk usage
4051produced by @command{guix size}}
4052
4053This option requires that
4054@uref{http://wingolog.org/software/guile-charting/, Guile-Charting} be
4055installed and visible in Guile's module search path. When that is not
4056the case, @command{guix size} fails as it tries to load it.
4057
fcc58db6
LC
4058@item --system=@var{system}
4059@itemx -s @var{system}
4060Consider packages for @var{system}---e.g., @code{x86_64-linux}.
4061
4062@end table
4063
372c4bbc
DT
4064@node Invoking guix environment
4065@section Invoking @command{guix environment}
4066
f5fd4fd2 4067@cindex reproducible build environments
372c4bbc
DT
4068The purpose of @command{guix environment} is to assist hackers in
4069creating reproducible development environments without polluting their
4070package profile. The @command{guix environment} tool takes one or more
4071packages, builds all of the necessary inputs, and creates a shell
4072environment to use them.
4073
4074The general syntax is:
4075
4076@example
4077guix environment @var{options} @var{package}@dots{}
4078@end example
4079
4080The following examples spawns a new shell that is capable of building
4081the GNU Guile source code:
4082
4083@example
4084guix environment guile
4085@end example
4086
4087If the specified packages are not built yet, @command{guix environment}
4088automatically builds them. The new shell's environment is an augmented
4089version of the environment that @command{guix environment} was run in.
4090It contains the necessary search paths for building the given package
4091added to the existing environment variables. To create a ``pure''
4092environment in which the original environment variables have been unset,
4093use the @code{--pure} option.
4094
4095Additionally, more than one package may be specified, in which case the
4096union of the inputs for the given packages are used. For example, the
4097command below spawns a shell where all of the dependencies of both Guile
4098and Emacs are available:
4099
4100@example
4101guix environment guile emacs
4102@end example
4103
4104Sometimes an interactive shell session is not desired. The
4105@code{--exec} option can be used to specify the command to run instead.
4106
4107@example
4108guix environment guile --exec=make
4109@end example
4110
4111The following options are available:
4112
4113@table @code
4114@item --expression=@var{expr}
4115@itemx -e @var{expr}
4116Create an environment for the package that @var{expr} evaluates to.
4117
4118@item --load=@var{file}
4119@itemx -l @var{file}
4120Create an environment for the package that the code within @var{file}
4121evaluates to.
4122
4123@item --exec=@var{command}
4124@item -E @var{command}
4125Execute @var{command} in the new environment.
4126
a54bd6d7
DT
4127@item --ad-hoc
4128Include all specified packages in the resulting environment, as if an
4129@i{ad hoc} package were defined with them as inputs. This option is
4130useful for quickly creating an environment without having to write a
4131package expression to contain the desired inputs.
4132
4133For instance, the command:
4134
4135@example
4136guix environment --ad-hoc guile guile-sdl -E guile
4137@end example
4138
4139runs @command{guile} in an environment where Guile and Guile-SDL are
4140available.
4141
372c4bbc
DT
4142@item --pure
4143Unset existing environment variables when building the new environment.
4144This has the effect of creating an environment in which search paths
4145only contain package inputs.
4146
4147@item --search-paths
4148Display the environment variable definitions that make up the
4149environment.
4150@end table
4151
4152It also supports all of the common build options that @command{guix
4153build} supports (@pxref{Invoking guix build, common build options}).
4154
aff8ce7c
DT
4155@node Invoking guix publish
4156@section Invoking @command{guix publish}
4157
4158The purpose of @command{guix publish} is to enable users to easily share
8ce229fc
LC
4159their store with others, which can then use it as a substitute server
4160(@pxref{Substitutes}).
4161
4162When @command{guix publish} runs, it spawns an HTTP server which allows
4163anyone with network access to obtain substitutes from it. This means
4164that any machine running Guix can also act as if it were a build farm,
4165since the HTTP interface is compatible with Hydra, the software behind
4166the @code{hydra.gnu.org} build farm.
aff8ce7c
DT
4167
4168For security, each substitute is signed, allowing recipients to check
4169their authenticity and integrity (@pxref{Substitutes}). Because
4170@command{guix publish} uses the system's signing key, which is only
5463fe51
LC
4171readable by the system administrator, it must be started as root; the
4172@code{--user} option makes it drop root privileges early on.
aff8ce7c
DT
4173
4174The general syntax is:
4175
4176@example
4177guix publish @var{options}@dots{}
4178@end example
4179
4180Running @command{guix publish} without any additional arguments will
4181spawn an HTTP server on port 8080:
4182
4183@example
4184guix publish
4185@end example
4186
4187Once a publishing server has been authorized (@pxref{Invoking guix
4188archive}), the daemon may download substitutes from it:
4189
4190@example
4191guix-daemon --substitute-urls=http://example.org:8080
4192@end example
4193
4194The following options are available:
4195
4196@table @code
4197@item --port=@var{port}
4198@itemx -p @var{port}
4199Listen for HTTP requests on @var{port}.
4200
9e2292ef
LC
4201@item --listen=@var{host}
4202Listen on the network interface for @var{host}. The default is to
4203accept connections from any interface.
4204
5463fe51
LC
4205@item --user=@var{user}
4206@itemx -u @var{user}
4207Change privileges to @var{user} as soon as possible---i.e., once the
4208server socket is open and the signing key has been read.
4209
aff8ce7c
DT
4210@item --repl[=@var{port}]
4211@itemx -r [@var{port}]
4212Spawn a Guile REPL server (@pxref{REPL Servers,,, guile, GNU Guile
8ce229fc
LC
4213Reference Manual}) on @var{port} (37146 by default). This is used
4214primarily for debugging a running @command{guix publish} server.
aff8ce7c
DT
4215@end table
4216
a1ba8475
LC
4217@c *********************************************************************
4218@node GNU Distribution
4219@chapter GNU Distribution
4220
3ca2731c 4221@cindex Guix System Distribution
4705641f 4222@cindex GuixSD
3ca2731c
LC
4223Guix comes with a distribution of the GNU system consisting entirely of
4224free software@footnote{The term ``free'' here refers to the
a1ba8475 4225@url{http://www.gnu.org/philosophy/free-sw.html,freedom provided to
3ca2731c 4226users of that software}.}. The
35ed9306
LC
4227distribution can be installed on its own (@pxref{System Installation}),
4228but it is also possible to install Guix as a package manager on top of
4229an installed GNU/Linux system (@pxref{Installation}). To distinguish
3ca2731c 4230between the two, we refer to the standalone distribution as the Guix
4705641f 4231System Distribution, or GuixSD.
35ed9306
LC
4232
4233The distribution provides core GNU packages such as GNU libc, GCC, and
4234Binutils, as well as many GNU and non-GNU applications. The complete
4235list of available packages can be browsed
d03bb653
LC
4236@url{http://www.gnu.org/software/guix/package-list.html,on-line} or by
4237running @command{guix package} (@pxref{Invoking guix package}):
a1ba8475
LC
4238
4239@example
e49951eb 4240guix package --list-available
a1ba8475
LC
4241@end example
4242
35ed9306 4243Our goal has been to provide a practical 100% free software distribution of
401c53c4
LC
4244Linux-based and other variants of GNU, with a focus on the promotion and
4245tight integration of GNU components, and an emphasis on programs and
4246tools that help users exert that freedom.
4247
3ca2731c 4248Packages are currently available on the following platforms:
c320011d
LC
4249
4250@table @code
4251
4252@item x86_64-linux
4253Intel/AMD @code{x86_64} architecture, Linux-Libre kernel;
4254
4255@item i686-linux
4256Intel 32-bit architecture (IA32), Linux-Libre kernel;
4257
aa1e1947
MW
4258@item armhf-linux
4259ARMv7-A architecture with hard float, Thumb-2 and VFP3D16 coprocessor,
4260using the EABI hard-float ABI, and Linux-Libre kernel.
4261
c320011d
LC
4262@item mips64el-linux
4263little-endian 64-bit MIPS processors, specifically the Loongson series,
4264n32 application binary interface (ABI), and Linux-Libre kernel.
4265
4266@end table
4267
4705641f 4268GuixSD itself is currently only available on @code{i686} and @code{x86_64}.
3ca2731c 4269
c320011d
LC
4270@noindent
4271For information on porting to other architectures or kernels,
4272@xref{Porting}.
4273
401c53c4 4274@menu
5af6de3e 4275* System Installation:: Installing the whole operating system.
35ed9306 4276* System Configuration:: Configuring the operating system.
91ef73d4 4277* Installing Debugging Files:: Feeding the debugger.
05962f29 4278* Security Updates:: Deploying security fixes quickly.
401c53c4 4279* Package Modules:: Packages from the programmer's viewpoint.
da7cabd4 4280* Packaging Guidelines:: Growing the distribution.
401c53c4 4281* Bootstrapping:: GNU/Linux built from scratch.
8b315a6d 4282* Porting:: Targeting another platform or kernel.
401c53c4
LC
4283@end menu
4284
4285Building this distribution is a cooperative effort, and you are invited
081145cf 4286to join! @xref{Contributing}, for information about how you can help.
401c53c4 4287
5af6de3e
LC
4288@node System Installation
4289@section System Installation
4290
3ca2731c
LC
4291@cindex Guix System Distribution
4292This section explains how to install the Guix System Distribution
4293on a machine. The Guix package manager can
35ed9306
LC
4294also be installed on top of a running GNU/Linux system,
4295@pxref{Installation}.
5af6de3e
LC
4296
4297@ifinfo
4298@c This paragraph is for people reading this from tty2 of the
4299@c installation image.
4300You're reading this documentation with an Info reader. For details on
4301how to use it, hit the @key{RET} key (``return'' or ``enter'') on the
6621cdb6 4302link that follows: @pxref{Help,,, info, Info: An Introduction}. Hit
5af6de3e
LC
4303@kbd{l} afterwards to come back here.
4304@end ifinfo
4305
8aaaae38
LC
4306@subsection Limitations
4307
4705641f 4308As of version @value{VERSION}, the Guix System Distribution (GuixSD) is
3ca2731c 4309not production-ready. It may contain bugs and lack important
8aaaae38
LC
4310features. Thus, if you are looking for a stable production system that
4311respects your freedom as a computer user, a good solution at this point
4312is to consider @url{http://www.gnu.org/distros/free-distros.html, one of
4313more established GNU/Linux distributions}. We hope you can soon switch
4705641f 4314to the GuixSD without fear, of course. In the meantime, you can
8aaaae38
LC
4315also keep using your distribution and try out the package manager on top
4316of it (@pxref{Installation}).
4317
4318Before you proceed with the installation, be aware of the following
4319noteworthy limitations applicable to version @value{VERSION}:
4320
4321@itemize
4322@item
4323The installation process does not include a graphical user interface and
4324requires familiarity with GNU/Linux (see the following subsections to
4325get a feel of what that means.)
4326
4327@item
b1e95eca
LC
4328The system does not yet provide GNOME and KDE; it provides Xfce, though,
4329if graphical desktop environments are your thing.
8aaaae38
LC
4330
4331@item
dbcb0ab1 4332Support for the Logical Volume Manager (LVM) is missing.
8aaaae38
LC
4333
4334@item
4335Few system services are currently supported out-of-the-box
4336(@pxref{Services}).
4337
4338@item
49607566 4339On the order of 1,900 packages are available, which means that you may
8aaaae38
LC
4340occasionally find that a useful package is missing.
4341@end itemize
4342
4343You've been warned. But more than a disclaimer, this is an invitation
4344to report issues (and success stories!), and join us in improving it.
4345@xref{Contributing}, for more info.
5af6de3e
LC
4346
4347@subsection USB Stick Installation
4348
4349An installation image for USB sticks can be downloaded from
4705641f 4350@indicateurl{ftp://alpha.gnu.org/gnu/guix/guixsd-usb-install-@value{VERSION}.@var{system}.xz},
5af6de3e
LC
4351where @var{system} is one of:
4352
4353@table @code
4354@item x86_64-linux
4355for a GNU/Linux system on Intel/AMD-compatible 64-bit CPUs;
4356
4357@item i686-linux
4358for a 32-bit GNU/Linux system on Intel-compatible CPUs.
4359@end table
4360
4361This image contains a single partition with the tools necessary for an
4362installation. It is meant to be copied @emph{as is} to a large-enough
4363USB stick.
4364
4365To copy the image to a USB stick, follow these steps:
4366
4367@enumerate
4368@item
4369Decompress the image using the @command{xz} command:
4370
4371@example
4705641f 4372xz -d guixsd-usb-install-@value{VERSION}.@var{system}.xz
5af6de3e
LC
4373@end example
4374
4375@item
4376Insert a USB stick of 1@tie{}GiB or more in your machine, and determine
4377its device name. Assuming that USB stick is known as @file{/dev/sdX},
4378copy the image with:
4379
4380@example
4705641f 4381dd if=guixsd-usb-install-@value{VERSION}.x86_64 of=/dev/sdX
5af6de3e
LC
4382@end example
4383
4384Access to @file{/dev/sdX} usually requires root privileges.
4385@end enumerate
4386
4387Once this is done, you should be able to reboot the system and boot from
4388the USB stick. The latter usually requires you to get in the BIOS' boot
4389menu, where you can choose to boot from the USB stick.
4390
4391@subsection Preparing for Installation
4392
4393Once you have successfully booted the image on the USB stick, you should
4394end up with a root prompt. Several console TTYs are configured and can
4395be used to run commands as root. TTY2 shows this documentation,
4396browsable using the Info reader commands (@pxref{Help,,, info, Info: An
4397Introduction}).
4398
4399To install the system, you would:
4400
4401@enumerate
4402
4403@item
152dd61c
LC
4404Configure the network, by running @command{ifconfig eno1 up && dhclient
4405eno1} (to get an automatically assigned IP address from the wired
4406network interface controller@footnote{
95c559c1
LC
4407@c http://cgit.freedesktop.org/systemd/systemd/tree/src/udev/udev-builtin-net_id.c#n20
4408The name @code{eno1} is for the first on-board Ethernet controller. The
4409interface name for an Ethernet controller that is in the first slot of
4410the first PCI bus, for instance, would be @code{enp1s0}. Use
4411@command{ifconfig -a} to list all the available network interfaces.}),
4412or using the @command{ifconfig} command.
5af6de3e
LC
4413
4414The system automatically loads drivers for your network interface
4415controllers.
4416
4417Setting up network access is almost always a requirement because the
4418image does not contain all the software and tools that may be needed.
4419
4420@item
4421Unless this has already been done, you must partition and format the
4422target partitions.
4423
7ab44369
LC
4424Preferably, assign partitions a label so that you can easily and
4425reliably refer to them in @code{file-system} declarations (@pxref{File
4426Systems}). This is typically done using the @code{-L} option of
4427@command{mkfs.ext4} and related commands.
4428
5af6de3e 4429The installation image includes Parted (@pxref{Overview,,, parted, GNU
b419c7f5
LC
4430Parted User Manual}), @command{fdisk}, Cryptsetup/LUKS for disk
4431encryption, and e2fsprogs, the suite of tools to manipulate
4432ext2/ext3/ext4 file systems.
5af6de3e 4433
83a17b62
LC
4434@item
4435Once that is done, mount the target root partition under @file{/mnt}.
4436
4437@item
4438Lastly, run @code{deco start cow-store /mnt}.
4439
4440This will make @file{/gnu/store} copy-on-write, such that packages added
4441to it during the installation phase will be written to the target disk
4442rather than kept in memory.
4443
5af6de3e
LC
4444@end enumerate
4445
5af6de3e
LC
4446
4447@subsection Proceeding with the Installation
4448
4449With the target partitions ready, you now have to edit a file and
4450provide the declaration of the operating system to be installed. To
4451that end, the installation system comes with two text editors: GNU nano
4452(@pxref{Top,,, nano, GNU nano Manual}), and GNU Zile, an Emacs clone.
4453It is better to store that file on the target root file system, say, as
4454@file{/mnt/etc/config.scm}.
4455
dd51caac
LC
4456@xref{Using the Configuration System}, for examples of operating system
4457configurations. These examples are available under
4458@file{/etc/configuration} in the installation image, so you can copy
4459them and use them as a starting point for your own configuration.
5af6de3e 4460
dd51caac
LC
4461Once you are done preparing the configuration file, the new system must
4462be initialized (remember that the target root file system is mounted
4463under @file{/mnt}):
5af6de3e
LC
4464
4465@example
4466guix system init /mnt/etc/config.scm /mnt
4467@end example
4468
4469@noindent
4470This will copy all the necessary files, and install GRUB on
4471@file{/dev/sdX}, unless you pass the @option{--no-grub} option. For
6621cdb6 4472more information, @pxref{Invoking guix system}. This command may trigger
5af6de3e
LC
4473downloads or builds of missing packages, which can take some time.
4474
4475Once that command has completed---and hopefully succeeded!---you can
ad14d9e7 4476run @command{reboot} and boot into the new system. Cross fingers, and
5af6de3e
LC
4477join us on @code{#guix} on the Freenode IRC network or on
4478@file{guix-devel@@gnu.org} to share your experience---good or not so
4479good.
4480
4481@subsection Building the Installation Image
4482
4483The installation image described above was built using the @command{guix
4484system} command, specifically:
4485
4486@example
8a225c66 4487guix system disk-image --image-size=850MiB gnu/system/install.scm
5af6de3e
LC
4488@end example
4489
4490@xref{Invoking guix system}, for more information. See
4491@file{gnu/system/install.scm} in the source tree for more information
4492about the installation image.
4493
cf4a9129
LC
4494@node System Configuration
4495@section System Configuration
b208a005 4496
cf4a9129 4497@cindex system configuration
3ca2731c 4498The Guix System Distribution supports a consistent whole-system configuration
cf4a9129
LC
4499mechanism. By that we mean that all aspects of the global system
4500configuration---such as the available system services, timezone and
4501locale settings, user accounts---are declared in a single place. Such
4502a @dfn{system configuration} can be @dfn{instantiated}---i.e., effected.
91ef73d4 4503
cf4a9129
LC
4504One of the advantages of putting all the system configuration under the
4505control of Guix is that it supports transactional system upgrades, and
4506makes it possible to roll-back to a previous system instantiation,
4507should something go wrong with the new one (@pxref{Features}). Another
4508one is that it makes it easy to replicate the exact same configuration
4509across different machines, or at different points in time, without
4510having to resort to additional administration tools layered on top of
4511the system's own tools.
4512@c Yes, we're talking of Puppet, Chef, & co. here. ↑
91ef73d4 4513
cf4a9129
LC
4514This section describes this mechanism. First we focus on the system
4515administrator's viewpoint---explaining how the system is configured and
4516instantiated. Then we show how this mechanism can be extended, for
4517instance to support new system services.
91ef73d4 4518
cf4a9129
LC
4519@menu
4520* Using the Configuration System:: Customizing your GNU system.
7313a52e 4521* operating-system Reference:: Detail of operating-system declarations.
cf4a9129 4522* File Systems:: Configuring file system mounts.
510f9d86 4523* Mapped Devices:: Block device extra processing.
cf4a9129 4524* User Accounts:: Specifying user accounts.
598e19dc 4525* Locales:: Language and cultural convention settings.
cf4a9129 4526* Services:: Specifying system services.
0ae8c15a 4527* Setuid Programs:: Programs running with root privileges.
efb5e833 4528* X.509 Certificates:: Authenticating HTTPS servers.
996ed739 4529* Name Service Switch:: Configuring libc's name service switch.
fd1b1fa2 4530* Initial RAM Disk:: Linux-Libre bootstrapping.
88faf933 4531* GRUB Configuration:: Configuring the boot loader.
cf4a9129
LC
4532* Invoking guix system:: Instantiating a system configuration.
4533* Defining Services:: Adding new service definitions.
4534@end menu
91ef73d4 4535
cf4a9129
LC
4536@node Using the Configuration System
4537@subsection Using the Configuration System
64d76fa6 4538
cf4a9129
LC
4539The operating system is configured by providing an
4540@code{operating-system} declaration in a file that can then be passed to
4541the @command{guix system} command (@pxref{Invoking guix system}). A
4542simple setup, with the default system services, the default Linux-Libre
4543kernel, initial RAM disk, and boot loader looks like this:
91ef73d4 4544
cf4a9129
LC
4545@findex operating-system
4546@lisp
dd51caac 4547@include os-config-bare-bones.texi
cf4a9129 4548@end lisp
401c53c4 4549
cf4a9129
LC
4550This example should be self-describing. Some of the fields defined
4551above, such as @code{host-name} and @code{bootloader}, are mandatory.
4552Others, such as @code{packages} and @code{services}, can be omitted, in
4553which case they get a default value.
e7f34eb0 4554
cf4a9129
LC
4555@vindex %base-packages
4556The @code{packages} field lists
4557packages that will be globally visible on the system, for all user
4558accounts---i.e., in every user's @code{PATH} environment variable---in
4559addition to the per-user profiles (@pxref{Invoking guix package}). The
4560@var{%base-packages} variable provides all the tools one would expect
4561for basic user and administrator tasks---including the GNU Core
4562Utilities, the GNU Networking Utilities, the GNU Zile lightweight text
4563editor, @command{find}, @command{grep}, etc. The example above adds
4564Emacs to those, taken from the @code{(gnu packages emacs)} module
4565(@pxref{Package Modules}).
e7f34eb0 4566
cf4a9129
LC
4567@vindex %base-services
4568The @code{services} field lists @dfn{system services} to be made
4569available when the system starts (@pxref{Services}).
4570The @code{operating-system} declaration above specifies that, in
4571addition to the basic services, we want the @command{lshd} secure shell
4572daemon listening on port 2222, and allowing remote @code{root} logins
4573(@pxref{Invoking lshd,,, lsh, GNU lsh Manual}). Under the hood,
4574@code{lsh-service} arranges so that @code{lshd} is started with the
4575right command-line options, possibly with supporting configuration files
7313a52e
LC
4576generated as needed (@pxref{Defining Services}). @xref{operating-system
4577Reference}, for details about the available @code{operating-system}
4578fields.
a1ba8475 4579
dd51caac
LC
4580The configuration for a typical ``desktop'' usage, with the X11 display
4581server, a desktop environment, network management, an SSH server, and
4582more, would look like this:
4583
4584@lisp
4585@include os-config-desktop.texi
4586@end lisp
4587
4588@xref{Desktop Services}, for the exact list of services provided by
efb5e833
LC
4589@var{%desktop-services}. @xref{X.509 Certificates}, for background
4590information about the @code{nss-certs} package that is used here.
dd51caac 4591
cf4a9129
LC
4592Assuming the above snippet is stored in the @file{my-system-config.scm}
4593file, the @command{guix system reconfigure my-system-config.scm} command
4594instantiates that configuration, and makes it the default GRUB boot
4595entry (@pxref{Invoking guix system}). The normal way to change the
4596system's configuration is by updating this file and re-running the
4597@command{guix system} command.
b81e1947 4598
cf4a9129
LC
4599At the Scheme level, the bulk of an @code{operating-system} declaration
4600is instantiated with the following monadic procedure (@pxref{The Store
4601Monad}):
b81e1947 4602
cf4a9129
LC
4603@deffn {Monadic Procedure} operating-system-derivation os
4604Return a derivation that builds @var{os}, an @code{operating-system}
4605object (@pxref{Derivations}).
b81e1947 4606
cf4a9129
LC
4607The output of the derivation is a single directory that refers to all
4608the packages, configuration files, and other supporting files needed to
4609instantiate @var{os}.
4610@end deffn
b81e1947 4611
7313a52e
LC
4612@node operating-system Reference
4613@subsection @code{operating-system} Reference
4614
4615This section summarizes all the options available in
4616@code{operating-system} declarations (@pxref{Using the Configuration
4617System}).
4618
4619@deftp {Data Type} operating-system
4620This is the data type representing an operating system configuration.
4621By that, we mean all the global system configuration, not per-user
4622configuration (@pxref{Using the Configuration System}).
4623
4624@table @asis
4625@item @code{kernel} (default: @var{linux-libre})
fbb25e56 4626The package object of the operating system kernel to use@footnote{Currently
7313a52e
LC
4627only the Linux-libre kernel is supported. In the future, it will be
4628possible to use the GNU@tie{}Hurd.}.
4629
4630@item @code{bootloader}
88faf933 4631The system bootloader configuration object. @xref{GRUB Configuration}.
7313a52e
LC
4632
4633@item @code{initrd} (default: @code{base-initrd})
4634A two-argument monadic procedure that returns an initial RAM disk for
4635the Linux kernel. @xref{Initial RAM Disk}.
4636
f34c56be
LC
4637@item @code{firmware} (default: @var{%base-firmware})
4638@cindex firmware
4639List of firmware packages loadable by the operating system kernel.
4640
4641The default includes firmware needed for Atheros-based WiFi devices
4642(Linux-libre module @code{ath9k}.)
4643
7313a52e
LC
4644@item @code{host-name}
4645The host name.
4646
4647@item @code{hosts-file}
4648@cindex hosts file
24e02c28 4649A file-like object (@pxref{G-Expressions, file-like objects}) for use as
7313a52e 4650@file{/etc/hosts} (@pxref{Host Names,,, libc, The GNU C Library
24e02c28 4651Reference Manual}). The default is a file with entries for
7313a52e
LC
4652@code{localhost} and @var{host-name}.
4653
4654@item @code{mapped-devices} (default: @code{'()})
4655A list of mapped devices. @xref{Mapped Devices}.
4656
4657@item @code{file-systems}
4658A list of file systems. @xref{File Systems}.
4659
4660@item @code{swap-devices} (default: @code{'()})
4661@cindex swap devices
4662A list of strings identifying devices to be used for ``swap space''
4663(@pxref{Memory Concepts,,, libc, The GNU C Library Reference Manual}).
4664For example, @code{'("/dev/sda3")}.
4665
bf87f38a 4666@item @code{users} (default: @code{%base-user-accounts})
7313a52e
LC
4667@itemx @code{groups} (default: @var{%base-groups})
4668List of user accounts and groups. @xref{User Accounts}.
4669
4670@item @code{skeletons} (default: @code{(default-skeletons)})
4671A monadic list of pairs of target file name and files. These are the
4672files that will be used as skeletons as new accounts are created.
4673
4674For instance, a valid value may look like this:
4675
4676@example
4677(mlet %store-monad ((bashrc (text-file "bashrc" "\
4678 export PATH=$HOME/.guix-profile/bin")))
4679 (return `((".bashrc" ,bashrc))))
4680@end example
4681
4682@item @code{issue} (default: @var{%default-issue})
4683A string denoting the contents of the @file{/etc/issue} file, which is
4684what displayed when users log in on a text console.
4685
4686@item @code{packages} (default: @var{%base-packages})
4687The set of packages installed in the global profile, which is accessible
4688at @file{/run/current-system/profile}.
4689
4690The default set includes core utilities, but it is good practice to
4691install non-core utilities in user profiles (@pxref{Invoking guix
4692package}).
4693
4694@item @code{timezone}
4695A timezone identifying string---e.g., @code{"Europe/Paris"}.
4696
598e19dc
LC
4697@item @code{locale} (default: @code{"en_US.utf8"})
4698The name of the default locale (@pxref{Locale Names,,, libc, The GNU C
4699Library Reference Manual}). @xref{Locales}, for more information.
4700
4701@item @code{locale-definitions} (default: @var{%default-locale-definitions})
4702The list of locale definitions to be compiled and that may be used at
4703run time. @xref{Locales}.
7313a52e 4704
996ed739
LC
4705@item @code{name-service-switch} (default: @var{%default-nss})
4706Configuration of libc's name service switch (NSS)---a
4707@code{<name-service-switch>} object. @xref{Name Service Switch}, for
4708details.
4709
7313a52e
LC
4710@item @code{services} (default: @var{%base-services})
4711A list of monadic values denoting system services. @xref{Services}.
4712
4713@item @code{pam-services} (default: @code{(base-pam-services)})
4714@cindex PAM
4715@cindex pluggable authentication modules
4716Linux @dfn{pluggable authentication module} (PAM) services.
4717@c FIXME: Add xref to PAM services section.
4718
4719@item @code{setuid-programs} (default: @var{%setuid-programs})
4720List of string-valued G-expressions denoting setuid programs.
4721@xref{Setuid Programs}.
4722
f5a9ffa0
AK
4723@item @code{sudoers-file} (default: @var{%sudoers-specification})
4724@cindex sudoers file
84765839
LC
4725The contents of the @file{/etc/sudoers} file as a file-like object
4726(@pxref{G-Expressions, @code{local-file} and @code{plain-file}}).
7313a52e
LC
4727
4728This file specifies which users can use the @command{sudo} command, what
4729they are allowed to do, and what privileges they may gain. The default
4730is that only @code{root} and members of the @code{wheel} group may use
4731@code{sudo}.
4732
4733@end table
4734@end deftp
4735
cf4a9129
LC
4736@node File Systems
4737@subsection File Systems
b81e1947 4738
cf4a9129
LC
4739The list of file systems to be mounted is specified in the
4740@code{file-systems} field of the operating system's declaration
4741(@pxref{Using the Configuration System}). Each file system is declared
4742using the @code{file-system} form, like this:
b81e1947
LC
4743
4744@example
cf4a9129
LC
4745(file-system
4746 (mount-point "/home")
4747 (device "/dev/sda3")
4748 (type "ext4"))
b81e1947
LC
4749@end example
4750
cf4a9129
LC
4751As usual, some of the fields are mandatory---those shown in the example
4752above---while others can be omitted. These are described below.
b81e1947 4753
cf4a9129
LC
4754@deftp {Data Type} file-system
4755Objects of this type represent file systems to be mounted. They
4756contain the following members:
5ff3c4b8 4757
cf4a9129
LC
4758@table @asis
4759@item @code{type}
4760This is a string specifying the type of the file system---e.g.,
4761@code{"ext4"}.
5ff3c4b8 4762
cf4a9129
LC
4763@item @code{mount-point}
4764This designates the place where the file system is to be mounted.
b81e1947 4765
cf4a9129
LC
4766@item @code{device}
4767This names the ``source'' of the file system. By default it is the name
4768of a node under @file{/dev}, but its meaning depends on the @code{title}
4769field described below.
401c53c4 4770
cf4a9129
LC
4771@item @code{title} (default: @code{'device})
4772This is a symbol that specifies how the @code{device} field is to be
4773interpreted.
401c53c4 4774
cf4a9129
LC
4775When it is the symbol @code{device}, then the @code{device} field is
4776interpreted as a file name; when it is @code{label}, then @code{device}
4777is interpreted as a partition label name; when it is @code{uuid},
4778@code{device} is interpreted as a partition unique identifier (UUID).
da7cabd4 4779
cf4a9129
LC
4780The @code{label} and @code{uuid} options offer a way to refer to disk
4781partitions without having to hard-code their actual device name.
da7cabd4 4782
5f86a66e
LC
4783However, when a file system's source is a mapped device (@pxref{Mapped
4784Devices}), its @code{device} field @emph{must} refer to the mapped
4785device name---e.g., @file{/dev/mapper/root-partition}---and consequently
4786@code{title} must be set to @code{'device}. This is required so that
4787the system knows that mounting the file system depends on having the
4788corresponding device mapping established.
4789
cf4a9129
LC
4790@item @code{flags} (default: @code{'()})
4791This is a list of symbols denoting mount flags. Recognized flags
2c071ce9
LC
4792include @code{read-only}, @code{bind-mount}, @code{no-dev} (disallow
4793access to special files), @code{no-suid} (ignore setuid and setgid
4794bits), and @code{no-exec} (disallow program execution.)
da7cabd4 4795
cf4a9129
LC
4796@item @code{options} (default: @code{#f})
4797This is either @code{#f}, or a string denoting mount options.
da7cabd4 4798
cf4a9129
LC
4799@item @code{needed-for-boot?} (default: @code{#f})
4800This Boolean value indicates whether the file system is needed when
4801booting. If that is true, then the file system is mounted when the
4802initial RAM disk (initrd) is loaded. This is always the case, for
4803instance, for the root file system.
da7cabd4 4804
cf4a9129
LC
4805@item @code{check?} (default: @code{#t})
4806This Boolean indicates whether the file system needs to be checked for
4807errors before being mounted.
f9cc8971 4808
4e469051
LC
4809@item @code{create-mount-point?} (default: @code{#f})
4810When true, the mount point is created if it does not exist yet.
4811
cf4a9129
LC
4812@end table
4813@end deftp
da7cabd4 4814
a69576ea
LC
4815The @code{(gnu system file-systems)} exports the following useful
4816variables.
4817
4818@defvr {Scheme Variable} %base-file-systems
4819These are essential file systems that are required on normal systems,
3392ce5d
LC
4820such as @var{%devtmpfs-file-system} and @var{%immutable-store} (see
4821below.) Operating system declarations should always contain at least
4822these.
a69576ea
LC
4823@end defvr
4824
4825@defvr {Scheme Variable} %devtmpfs-file-system
4826The @code{devtmpfs} file system to be mounted on @file{/dev}. This is a
4827requirement for udev (@pxref{Base Services, @code{udev-service}}).
4828@end defvr
4829
7f239fd3
LC
4830@defvr {Scheme Variable} %pseudo-terminal-file-system
4831This is the file system to be mounted as @file{/dev/pts}. It supports
4832@dfn{pseudo-terminals} created @i{via} @code{openpty} and similar
4833functions (@pxref{Pseudo-Terminals,,, libc, The GNU C Library Reference
4834Manual}). Pseudo-terminals are used by terminal emulators such as
4835@command{xterm}.
4836@end defvr
4837
db17ae5c
LC
4838@defvr {Scheme Variable} %shared-memory-file-system
4839This file system is mounted as @file{/dev/shm} and is used to support
4840memory sharing across processes (@pxref{Memory-mapped I/O,
4841@code{shm_open},, libc, The GNU C Library Reference Manual}).
4842@end defvr
4843
3392ce5d
LC
4844@defvr {Scheme Variable} %immutable-store
4845This file system performs a read-only ``bind mount'' of
4846@file{/gnu/store}, making it read-only for all the users including
4847@code{root}. This prevents against accidental modification by software
4848running as @code{root} or by system administrators.
4849
4850The daemon itself is still able to write to the store: it remounts it
4851read-write in its own ``name space.''
4852@end defvr
4853
a69576ea
LC
4854@defvr {Scheme Variable} %binary-format-file-system
4855The @code{binfmt_misc} file system, which allows handling of arbitrary
4856executable file types to be delegated to user space. This requires the
4857@code{binfmt.ko} kernel module to be loaded.
4858@end defvr
4859
4860@defvr {Scheme Variable} %fuse-control-file-system
4861The @code{fusectl} file system, which allows unprivileged users to mount
4862and unmount user-space FUSE file systems. This requires the
4863@code{fuse.ko} kernel module to be loaded.
4864@end defvr
4865
510f9d86
LC
4866@node Mapped Devices
4867@subsection Mapped Devices
4868
4869@cindex device mapping
4870@cindex mapped devices
4871The Linux kernel has a notion of @dfn{device mapping}: a block device,
4872such as a hard disk partition, can be @dfn{mapped} into another device,
4873with additional processing over the data that flows through
4874it@footnote{Note that the GNU@tie{}Hurd makes no difference between the
4875concept of a ``mapped device'' and that of a file system: both boil down
4876to @emph{translating} input/output operations made on a file to
4877operations on its backing store. Thus, the Hurd implements mapped
4878devices, like file systems, using the generic @dfn{translator} mechanism
4879(@pxref{Translators,,, hurd, The GNU Hurd Reference Manual}).}. A
4880typical example is encryption device mapping: all writes to the mapped
4881device are encrypted, and all reads are deciphered, transparently.
4882
4883Mapped devices are declared using the @code{mapped-device} form:
4884
4885@example
4886(mapped-device
4887 (source "/dev/sda3")
4888 (target "home")
4889 (type luks-device-mapping))
4890@end example
4891
4892@noindent
4893@cindex disk encryption
4894@cindex LUKS
4895This example specifies a mapping from @file{/dev/sda3} to
4896@file{/dev/mapper/home} using LUKS---the
4897@url{http://code.google.com/p/cryptsetup,Linux Unified Key Setup}, a
4898standard mechanism for disk encryption. The @file{/dev/mapper/home}
4899device can then be used as the @code{device} of a @code{file-system}
4900declaration (@pxref{File Systems}). The @code{mapped-device} form is
4901detailed below.
4902
4903@deftp {Data Type} mapped-device
4904Objects of this type represent device mappings that will be made when
4905the system boots up.
4906
9cb426b8
LC
4907@table @code
4908@item source
510f9d86
LC
4909This string specifies the name of the block device to be mapped, such as
4910@code{"/dev/sda3"}.
4911
9cb426b8 4912@item target
510f9d86
LC
4913This string specifies the name of the mapping to be established. For
4914example, specifying @code{"my-partition"} will lead to the creation of
4915the @code{"/dev/mapper/my-partition"} device.
4916
9cb426b8 4917@item type
510f9d86
LC
4918This must be a @code{mapped-device-kind} object, which specifies how
4919@var{source} is mapped to @var{target}.
4920@end table
4921@end deftp
4922
4923@defvr {Scheme Variable} luks-device-mapping
4924This defines LUKS block device encryption using the @command{cryptsetup}
4925command, from the same-named package. This relies on the
4926@code{dm-crypt} Linux kernel module.
4927@end defvr
4928
cf4a9129
LC
4929@node User Accounts
4930@subsection User Accounts
ee85f3db 4931
9bea87a5
LC
4932User accounts and groups are entirely managed through the
4933@code{operating-system} declaration. They are specified with the
4934@code{user-account} and @code{user-group} forms:
ee85f3db 4935
cf4a9129
LC
4936@example
4937(user-account
4938 (name "alice")
4939 (group "users")
24e752c0
LC
4940 (supplementary-groups '("wheel" ;allow use of sudo, etc.
4941 "audio" ;sound card
4942 "video" ;video devices such as webcams
4943 "cdrom")) ;the good ol' CD-ROM
cf4a9129
LC
4944 (comment "Bob's sister")
4945 (home-directory "/home/alice"))
4946@end example
25083588 4947
9bea87a5
LC
4948When booting or upon completion of @command{guix system reconfigure},
4949the system ensures that only the user accounts and groups specified in
4950the @code{operating-system} declaration exist, and with the specified
4951properties. Thus, account or group creations or modifications made by
4952directly invoking commands such as @command{useradd} are lost upon
4953reconfiguration or reboot. This ensures that the system remains exactly
4954as declared.
4955
cf4a9129
LC
4956@deftp {Data Type} user-account
4957Objects of this type represent user accounts. The following members may
4958be specified:
ee85f3db 4959
cf4a9129
LC
4960@table @asis
4961@item @code{name}
4962The name of the user account.
ee85f3db 4963
cf4a9129
LC
4964@item @code{group}
4965This is the name (a string) or identifier (a number) of the user group
4966this account belongs to.
ee85f3db 4967
cf4a9129
LC
4968@item @code{supplementary-groups} (default: @code{'()})
4969Optionally, this can be defined as a list of group names that this
4970account belongs to.
ee85f3db 4971
cf4a9129
LC
4972@item @code{uid} (default: @code{#f})
4973This is the user ID for this account (a number), or @code{#f}. In the
4974latter case, a number is automatically chosen by the system when the
4975account is created.
ee85f3db 4976
cf4a9129
LC
4977@item @code{comment} (default: @code{""})
4978A comment about the account, such as the account's owner full name.
c8c871d1 4979
cf4a9129
LC
4980@item @code{home-directory}
4981This is the name of the home directory for the account.
ee85f3db 4982
cf4a9129
LC
4983@item @code{shell} (default: Bash)
4984This is a G-expression denoting the file name of a program to be used as
4985the shell (@pxref{G-Expressions}).
ee85f3db 4986
cf4a9129
LC
4987@item @code{system?} (default: @code{#f})
4988This Boolean value indicates whether the account is a ``system''
4989account. System accounts are sometimes treated specially; for instance,
4990graphical login managers do not list them.
ee85f3db 4991
cf4a9129 4992@item @code{password} (default: @code{#f})
eb59595c
LC
4993You would normally leave this field to @code{#f}, initialize user
4994passwords as @code{root} with the @command{passwd} command, and then let
9bea87a5
LC
4995users change it with @command{passwd}. Passwords set with
4996@command{passwd} are of course preserved across reboot and
4997reconfiguration.
eb59595c
LC
4998
4999If you @emph{do} want to have a preset password for an account, then
5000this field must contain the encrypted password, as a string.
5d1f1177
LC
5001@xref{crypt,,, libc, The GNU C Library Reference Manual}, for more information
5002on password encryption, and @ref{Encryption,,, guile, GNU Guile Reference
eb59595c 5003Manual}, for information on Guile's @code{crypt} procedure.
c8c871d1 5004
cf4a9129
LC
5005@end table
5006@end deftp
ee85f3db 5007
cf4a9129 5008User group declarations are even simpler:
ee85f3db 5009
cf4a9129
LC
5010@example
5011(user-group (name "students"))
5012@end example
ee85f3db 5013
cf4a9129
LC
5014@deftp {Data Type} user-group
5015This type is for, well, user groups. There are just a few fields:
af8a56b8 5016
cf4a9129
LC
5017@table @asis
5018@item @code{name}
5019The group's name.
ee85f3db 5020
cf4a9129
LC
5021@item @code{id} (default: @code{#f})
5022The group identifier (a number). If @code{#f}, a new number is
5023automatically allocated when the group is created.
ee85f3db 5024
c8fa3426
LC
5025@item @code{system?} (default: @code{#f})
5026This Boolean value indicates whether the group is a ``system'' group.
5027System groups have low numerical IDs.
5028
cf4a9129
LC
5029@item @code{password} (default: @code{#f})
5030What, user groups can have a password? Well, apparently yes. Unless
5031@code{#f}, this field specifies the group's password.
ee85f3db 5032
cf4a9129
LC
5033@end table
5034@end deftp
401c53c4 5035
cf4a9129
LC
5036For convenience, a variable lists all the basic user groups one may
5037expect:
401c53c4 5038
cf4a9129
LC
5039@defvr {Scheme Variable} %base-groups
5040This is the list of basic user groups that users and/or packages expect
5041to be present on the system. This includes groups such as ``root'',
5042``wheel'', and ``users'', as well as groups used to control access to
5043specific devices such as ``audio'', ``disk'', and ``cdrom''.
5044@end defvr
401c53c4 5045
bf87f38a
LC
5046@defvr {Scheme Variable} %base-user-accounts
5047This is the list of basic system accounts that programs may expect to
5048find on a GNU/Linux system, such as the ``nobody'' account.
5049
5050Note that the ``root'' account is not included here. It is a
5051special-case and is automatically added whether or not it is specified.
5052@end defvr
5053
598e19dc
LC
5054@node Locales
5055@subsection Locales
5056
5057@cindex locale
5058A @dfn{locale} defines cultural conventions for a particular language
5059and region of the world (@pxref{Locales,,, libc, The GNU C Library
5060Reference Manual}). Each locale has a name that typically has the form
5061@code{@var{language}_@var{territory}.@var{charset}}---e.g.,
5062@code{fr_LU.utf8} designates the locale for the French language, with
5063cultural conventions from Luxembourg, and using the UTF-8 encoding.
5064
5065@cindex locale definition
5066Usually, you will want to specify the default locale for the machine
5067using the @code{locale} field of the @code{operating-system} declaration
5068(@pxref{operating-system Reference, @code{locale}}).
5069
5070That locale must be among the @dfn{locale definitions} that are known to
5071the system---and these are specified in the @code{locale-definitions}
5072slot of @code{operating-system}. The default value includes locale
5073definition for some widely used locales, but not for all the available
5074locales, in order to save space.
5075
5076If the locale specified in the @code{locale} field is not among the
5077definitions listed in @code{locale-definitions}, @command{guix system}
5078raises an error. In that case, you should add the locale definition to
5079the @code{locale-definitions} field. For instance, to add the North
5080Frisian locale for Germany, the value of that field may be:
5081
5082@example
5083(cons (locale-definition
5084 (name "fy_DE.utf8") (source "fy_DE"))
5085 %default-locale-definitions)
5086@end example
5087
5088Likewise, to save space, one might want @code{locale-definitions} to
5089list only the locales that are actually used, as in:
5090
5091@example
5092(list (locale-definition
5093 (name "ja_JP.eucjp") (source "ja_JP")
5094 (charset "EUC-JP")))
5095@end example
5096
5097The @code{locale-definition} form is provided by the @code{(gnu system
5098locale)} module. Details are given below.
5099
5100@deftp {Data Type} locale-definition
5101This is the data type of a locale definition.
5102
5103@table @asis
5104
5105@item @code{name}
5106The name of the locale. @xref{Locale Names,,, libc, The GNU C Library
5107Reference Manual}, for more information on locale names.
5108
5109@item @code{source}
5110The name of the source for that locale. This is typically the
5111@code{@var{language}_@var{territory}} part of the locale name.
5112
5113@item @code{charset} (default: @code{"UTF-8"})
5114The ``character set'' or ``code set'' for that locale,
5115@uref{http://www.iana.org/assignments/character-sets, as defined by
5116IANA}.
5117
5118@end table
5119@end deftp
5120
5121@defvr {Scheme Variable} %default-locale-definitions
5122An arbitrary list of commonly used locales, used as the default value of
5123the @code{locale-definitions} field of @code{operating-system}
5124declarations.
5125@end defvr
401c53c4 5126
cf4a9129
LC
5127@node Services
5128@subsection Services
401c53c4 5129
cf4a9129
LC
5130@cindex system services
5131An important part of preparing an @code{operating-system} declaration is
5132listing @dfn{system services} and their configuration (@pxref{Using the
5133Configuration System}). System services are typically daemons launched
5134when the system boots, or other actions needed at that time---e.g.,
d8b94dbd
LC
5135configuring network access.
5136
5137Services are managed by GNU@tie{}dmd (@pxref{Introduction,,, dmd, GNU
5138dmd Manual}). On a running system, the @command{deco} command allows
5139you to list the available services, show their status, start and stop
5140them, or do other specific operations (@pxref{Jump Start,,, dmd, GNU dmd
5141Manual}). For example:
5142
5143@example
5144# deco status dmd
5145@end example
5146
5147The above command, run as @code{root}, lists the currently defined
5148services. The @command{deco doc} command shows a synopsis of the given
5149service:
5150
5151@example
5152# deco doc nscd
5153Run libc's name service cache daemon (nscd).
5154@end example
5155
5156The @command{start}, @command{stop}, and @command{restart} sub-commands
5157have the effect you would expect. For instance, the commands below stop
5158the nscd service and restart the Xorg display server:
5159
5160@example
5161# deco stop nscd
5162Service nscd has been stopped.
5163# deco restart xorg-server
5164Service xorg-server has been stopped.
5165Service xorg-server has been started.
5166@end example
401c53c4 5167
cf4a9129 5168The following sections document the available services, starting with
d8b94dbd
LC
5169the core services, that may be used in an @code{operating-system}
5170declaration.
401c53c4 5171
cf4a9129
LC
5172@menu
5173* Base Services:: Essential system services.
5174* Networking Services:: Network setup, SSH daemon, etc.
5175* X Window:: Graphical display.
fe1a39d3 5176* Desktop Services:: D-Bus and desktop services.
105369a4 5177* Database Services:: SQL databases.
aa4ed923 5178* Various Services:: Other services.
cf4a9129 5179@end menu
401c53c4 5180
cf4a9129
LC
5181@node Base Services
5182@subsubsection Base Services
a1ba8475 5183
cf4a9129
LC
5184The @code{(gnu services base)} module provides definitions for the basic
5185services that one expects from the system. The services exported by
5186this module are listed below.
401c53c4 5187
cf4a9129
LC
5188@defvr {Scheme Variable} %base-services
5189This variable contains a list of basic services@footnote{Technically,
5190this is a list of monadic services. @xref{The Store Monad}.} one would
5191expect from the system: a login service (mingetty) on each tty, syslogd,
5192libc's name service cache daemon (nscd), the udev device manager, and
5193more.
401c53c4 5194
cf4a9129
LC
5195This is the default value of the @code{services} field of
5196@code{operating-system} declarations. Usually, when customizing a
5197system, you will want to append services to @var{%base-services}, like
5198this:
401c53c4 5199
cf4a9129 5200@example
fa1e31b8 5201(cons* (avahi-service) (lsh-service) %base-services)
cf4a9129
LC
5202@end example
5203@end defvr
401c53c4 5204
cf4a9129
LC
5205@deffn {Monadic Procedure} host-name-service @var{name}
5206Return a service that sets the host name to @var{name}.
5207@end deffn
401c53c4 5208
cf4a9129
LC
5209@deffn {Monadic Procedure} mingetty-service @var{tty} [#:motd] @
5210 [#:auto-login #f] [#:login-program] [#:login-pause? #f] @
5211 [#:allow-empty-passwords? #f]
5212Return a service to run mingetty on @var{tty}.
401c53c4 5213
cf4a9129
LC
5214When @var{allow-empty-passwords?} is true, allow empty log-in password. When
5215@var{auto-login} is true, it must be a user name under which to log-in
5216automatically. @var{login-pause?} can be set to @code{#t} in conjunction with
5217@var{auto-login}, in which case the user will have to press a key before the
5218login shell is launched.
401c53c4 5219
cf4a9129
LC
5220When true, @var{login-program} is a gexp or a monadic gexp denoting the name
5221of the log-in program (the default is the @code{login} program from the Shadow
5222tool suite.)
401c53c4 5223
cf4a9129
LC
5224@var{motd} is a monadic value containing a text file to use as
5225the ``message of the day''.
5226@end deffn
401c53c4 5227
6454b333
LC
5228@cindex name service cache daemon
5229@cindex nscd
4aee6e60
LC
5230@deffn {Monadic Procedure} nscd-service [@var{config}] [#:glibc glibc] @
5231 [#:name-services '()]
5232Return a service that runs libc's name service cache daemon (nscd) with
5233the given @var{config}---an @code{<nscd-configuration>} object.
5234Optionally, @code{#:name-services} is a list of packages that provide
4c9050c6
LC
5235name service switch (NSS) modules needed by nscd. @xref{Name Service
5236Switch}, for an example.
cf4a9129 5237@end deffn
401c53c4 5238
6454b333
LC
5239@defvr {Scheme Variable} %nscd-default-configuration
5240This is the default @code{<nscd-configuration>} value (see below) used
5241by @code{nscd-service}. This uses the caches defined by
5242@var{%nscd-default-caches}; see below.
5243@end defvr
5244
5245@deftp {Data Type} nscd-configuration
5246This is the type representing the name service cache daemon (nscd)
5247configuration.
5248
5249@table @asis
5250
5251@item @code{log-file} (default: @code{"/var/log/nscd.log"})
5252Name of nscd's log file. This is where debugging output goes when
5253@code{debug-level} is strictly positive.
5254
5255@item @code{debug-level} (default: @code{0})
5256Integer denoting the debugging levels. Higher numbers mean more
5257debugging output is logged.
5258
5259@item @code{caches} (default: @var{%nscd-default-caches})
5260List of @code{<nscd-cache>} objects denoting things to be cached; see
5261below.
5262
5263@end table
5264@end deftp
5265
5266@deftp {Data Type} nscd-cache
5267Data type representing a cache database of nscd and its parameters.
5268
5269@table @asis
5270
5271@item @code{database}
5272This is a symbol representing the name of the database to be cached.
5273Valid values are @code{passwd}, @code{group}, @code{hosts}, and
5274@code{services}, which designate the corresponding NSS database
5275(@pxref{NSS Basics,,, libc, The GNU C Library Reference Manual}).
5276
5277@item @code{positive-time-to-live}
5278@itemx @code{negative-time-to-live} (default: @code{20})
5279A number representing the number of seconds during which a positive or
5280negative lookup result remains in cache.
5281
5282@item @code{check-files?} (default: @code{#t})
5283Whether to check for updates of the files corresponding to
5284@var{database}.
5285
5286For instance, when @var{database} is @code{hosts}, setting this flag
5287instructs nscd to check for updates in @file{/etc/hosts} and to take
5288them into account.
5289
5290@item @code{persistent?} (default: @code{#t})
5291Whether the cache should be stored persistently on disk.
5292
5293@item @code{shared?} (default: @code{#t})
5294Whether the cache should be shared among users.
5295
5296@item @code{max-database-size} (default: 32@tie{}MiB)
5297Maximum size in bytes of the database cache.
5298
5299@c XXX: 'suggested-size' and 'auto-propagate?' seem to be expert
5300@c settings, so leave them out.
5301
5302@end table
5303@end deftp
5304
5305@defvr {Scheme Variable} %nscd-default-caches
5306List of @code{<nscd-cache>} objects used by default by
5307@code{nscd-configuration} (see above.)
5308
5309It enables persistent and aggressive caching of service and host name
5310lookups. The latter provides better host name lookup performance,
5311resilience in the face of unreliable name servers, and also better
5312privacy---often the result of host name lookups is in local cache, so
5313external name servers do not even need to be queried.
5314@end defvr
5315
5316
1bb76f75
AK
5317@deffn {Monadic Procedure} syslog-service [#:config-file #f]
5318Return a service that runs @code{syslogd}. If configuration file name
5319@var{config-file} is not specified, use some reasonable default
cf4a9129
LC
5320settings.
5321@end deffn
401c53c4 5322
cf4a9129
LC
5323@deffn {Monadic Procedure} guix-service [#:guix guix] @
5324 [#:builder-group "guixbuild"] [#:build-accounts 10] @
02bb6b45 5325 [#:authorize-hydra-key? #t] [#:use-substitutes? #t] @
cf4a9129
LC
5326 [#:extra-options '()]
5327Return a service that runs the build daemon from @var{guix}, and has
5328@var{build-accounts} user accounts available under @var{builder-group}.
401c53c4 5329
cf4a9129
LC
5330When @var{authorize-hydra-key?} is true, the @code{hydra.gnu.org} public key
5331provided by @var{guix} is authorized upon activation, meaning that substitutes
5332from @code{hydra.gnu.org} are used by default.
401c53c4 5333
cf4a9129
LC
5334If @var{use-substitutes?} is false, the daemon is run with
5335@option{--no-substitutes} (@pxref{Invoking guix-daemon,
5336@option{--no-substitutes}}).
401c53c4 5337
cf4a9129
LC
5338Finally, @var{extra-options} is a list of additional command-line options
5339passed to @command{guix-daemon}.
5340@end deffn
a1ba8475 5341
cf4a9129
LC
5342@deffn {Monadic Procedure} udev-service [#:udev udev]
5343Run @var{udev}, which populates the @file{/dev} directory dynamically.
5344@end deffn
401c53c4 5345
5eca9459
AK
5346@deffn {Monadic Procedure} console-keymap-service @var{file}
5347Return a service to load console keymap from @var{file} using
5348@command{loadkeys} command.
5349@end deffn
5350
a69576ea 5351
cf4a9129
LC
5352@node Networking Services
5353@subsubsection Networking Services
401c53c4 5354
fa1e31b8 5355The @code{(gnu services networking)} module provides services to configure
cf4a9129 5356the network interface.
a1ba8475 5357
a023cca8
LC
5358@cindex DHCP, networking service
5359@deffn {Monadic Procedure} dhcp-client-service [#:dhcp @var{isc-dhcp}]
5360Return a service that runs @var{dhcp}, a Dynamic Host Configuration
5361Protocol (DHCP) client, on all the non-loopback network interfaces.
5362@end deffn
5363
cf4a9129
LC
5364@deffn {Monadic Procedure} static-networking-service @var{interface} @var{ip} @
5365 [#:gateway #f] [#:name-services @code{'()}]
5366Return a service that starts @var{interface} with address @var{ip}. If
5367@var{gateway} is true, it must be a string specifying the default network
5368gateway.
5369@end deffn
8b315a6d 5370
b7d0c494
MW
5371@cindex wicd
5372@deffn {Monadic Procedure} wicd-service [#:wicd @var{wicd}]
5373Return a service that runs @url{https://launchpad.net/wicd,Wicd}, a
5374network manager that aims to simplify wired and wireless networking.
5375@end deffn
5376
63854bcb
LC
5377@deffn {Monadic Procedure} ntp-service [#:ntp @var{ntp}] @
5378 [#:name-service @var{%ntp-servers}]
5379Return a service that runs the daemon from @var{ntp}, the
5380@uref{http://www.ntp.org, Network Time Protocol package}. The daemon will
5381keep the system clock synchronized with that of @var{servers}.
5382@end deffn
5383
5384@defvr {Scheme Variable} %ntp-servers
5385List of host names used as the default NTP servers.
5386@end defvr
5387
cf4a9129
LC
5388@deffn {Monadic Procedure} tor-service [#:tor tor]
5389Return a service to run the @uref{https://torproject.org,Tor} daemon.
8b315a6d 5390
cf4a9129
LC
5391The daemon runs with the default settings (in particular the default exit
5392policy) as the @code{tor} unprivileged user.
5393@end deffn
8b315a6d 5394
4627a464
LC
5395@deffn {Monadic Procedure} bitlbee-service [#:bitlbee bitlbee] @
5396 [#:interface "127.0.0.1"] [#:port 6667] @
5397 [#:extra-settings ""]
5398Return a service that runs @url{http://bitlbee.org,BitlBee}, a daemon that
5399acts as a gateway between IRC and chat networks.
5400
5401The daemon will listen to the interface corresponding to the IP address
5402specified in @var{interface}, on @var{port}. @code{127.0.0.1} means that only
5403local clients can connect, whereas @code{0.0.0.0} means that connections can
5404come from any networking interface.
5405
5406In addition, @var{extra-settings} specifies a string to append to the
5407configuration file.
5408@end deffn
5409
f4391bec 5410Furthermore, @code{(gnu services ssh)} provides the following service.
8b315a6d 5411
cf4a9129 5412@deffn {Monadic Procedure} lsh-service [#:host-key "/etc/lsh/host-key"] @
5833bf33 5413 [#:daemonic? #t] [#:interfaces '()] [#:port-number 22] @
cf4a9129
LC
5414 [#:allow-empty-passwords? #f] [#:root-login? #f] @
5415 [#:syslog-output? #t] [#:x11-forwarding? #t] @
5416 [#:tcp/ip-forwarding? #t] [#:password-authentication? #t] @
21cc905a 5417 [#:public-key-authentication? #t] [#:initialize? #t]
cf4a9129
LC
5418Run the @command{lshd} program from @var{lsh} to listen on port @var{port-number}.
5419@var{host-key} must designate a file containing the host key, and readable
5420only by root.
72e25e35 5421
5833bf33
DP
5422When @var{daemonic?} is true, @command{lshd} will detach from the
5423controlling terminal and log its output to syslogd, unless one sets
5424@var{syslog-output?} to false. Obviously, it also makes lsh-service
5425depend on existence of syslogd service. When @var{pid-file?} is true,
5426@command{lshd} writes its PID to the file called @var{pid-file}.
5427
cf4a9129
LC
5428When @var{initialize?} is true, automatically create the seed and host key
5429upon service activation if they do not exist yet. This may take long and
5430require interaction.
8b315a6d 5431
20dd519c
LC
5432When @var{initialize?} is false, it is up to the user to initialize the
5433randomness generator (@pxref{lsh-make-seed,,, lsh, LSH Manual}), and to create
5434a key pair with the private key stored in file @var{host-key} (@pxref{lshd
5435basics,,, lsh, LSH Manual}).
5436
cf4a9129
LC
5437When @var{interfaces} is empty, lshd listens for connections on all the
5438network interfaces; otherwise, @var{interfaces} must be a list of host names
5439or addresses.
9bf3c1a7 5440
20dd519c
LC
5441@var{allow-empty-passwords?} specifies whether to accept log-ins with empty
5442passwords, and @var{root-login?} specifies whether to accept log-ins as
cf4a9129 5443root.
4af2447e 5444
cf4a9129
LC
5445The other options should be self-descriptive.
5446@end deffn
4af2447e 5447
fa0c1d61
LC
5448@defvr {Scheme Variable} %facebook-host-aliases
5449This variable contains a string for use in @file{/etc/hosts}
5450(@pxref{Host Names,,, libc, The GNU C Library Reference Manual}). Each
5451line contains a entry that maps a known server name of the Facebook
5452on-line service---e.g., @code{www.facebook.com}---to the local
5453host---@code{127.0.0.1} or its IPv6 equivalent, @code{::1}.
5454
5455This variable is typically used in the @code{hosts-file} field of an
7313a52e
LC
5456@code{operating-system} declaration (@pxref{operating-system Reference,
5457@file{/etc/hosts}}):
fa0c1d61
LC
5458
5459@example
5460(use-modules (gnu) (guix))
5461
5462(operating-system
5463 (host-name "mymachine")
5464 ;; ...
5465 (hosts-file
5466 ;; Create a /etc/hosts file with aliases for "localhost"
5467 ;; and "mymachine", as well as for Facebook servers.
24e02c28
LC
5468 (plain-file "hosts"
5469 (string-append (local-host-aliases host-name)
5470 %facebook-host-aliases))))
fa0c1d61
LC
5471@end example
5472
5473This mechanism can prevent programs running locally, such as Web
5474browsers, from accessing Facebook.
5475@end defvr
5476
965a7332
LC
5477The @code{(gnu services avahi)} provides the following definition.
5478
5479@deffn {Monadic Procedure} avahi-service [#:avahi @var{avahi}] @
5480 [#:host-name #f] [#:publish? #t] [#:ipv4? #t] @
5481 [#:ipv6? #t] [#:wide-area? #f] @
5482 [#:domains-to-browse '()]
5483Return a service that runs @command{avahi-daemon}, a system-wide
5484mDNS/DNS-SD responder that allows for service discovery and
5485"zero-configuration" host name lookups (see @uref{http://avahi.org/}).
5486
5487If @var{host-name} is different from @code{#f}, use that as the host name to
5488publish for this machine; otherwise, use the machine's actual host name.
5489
5490When @var{publish?} is true, publishing of host names and services is allowed;
5491in particular, avahi-daemon will publish the machine's host name and IP
5492address via mDNS on the local network.
5493
5494When @var{wide-area?} is true, DNS-SD over unicast DNS is enabled.
5495
5496Boolean values @var{ipv4?} and @var{ipv6?} determine whether to use IPv4/IPv6
5497sockets.
5498@end deffn
5499
5500
cf4a9129
LC
5501@node X Window
5502@subsubsection X Window
68ad877c 5503
cf4a9129
LC
5504Support for the X Window graphical display system---specifically
5505Xorg---is provided by the @code{(gnu services xorg)} module. Note that
5506there is no @code{xorg-service} procedure. Instead, the X server is
5507started by the @dfn{login manager}, currently SLiM.
4af2447e 5508
cf4a9129 5509@deffn {Monadic Procedure} slim-service [#:allow-empty-passwords? #f] @
0ecc3bf3
LC
5510 [#:auto-login? #f] [#:default-user ""] [#:startx] @
5511 [#:theme @var{%default-slim-theme}] @
4bd43bbe 5512 [#:theme-name @var{%default-slim-theme-name}]
cf4a9129
LC
5513Return a service that spawns the SLiM graphical login manager, which in
5514turn starts the X display server with @var{startx}, a command as returned by
5515@code{xorg-start-command}.
4af2447e 5516
04e4e6ab
LC
5517@cindex X session
5518
5519SLiM automatically looks for session types described by the @file{.desktop}
5520files in @file{/run/current-system/profile/share/xsessions} and allows users
5521to choose a session from the log-in screen using @kbd{F1}. Packages such as
5522@var{xfce}, @var{sawfish}, and @var{ratpoison} provide @file{.desktop} files;
5523adding them to the system-wide set of packages automatically makes them
5524available at the log-in screen.
5525
5526In addition, @file{~/.xsession} files are honored. When available,
5527@file{~/.xsession} must be an executable that starts a window manager
5528and/or other X clients.
5529
cf4a9129
LC
5530When @var{allow-empty-passwords?} is true, allow logins with an empty
5531password. When @var{auto-login?} is true, log in automatically as
5532@var{default-user}.
0ecc3bf3
LC
5533
5534If @var{theme} is @code{#f}, the use the default log-in theme; otherwise
5535@var{theme} must be a gexp denoting the name of a directory containing the
5536theme to use. In that case, @var{theme-name} specifies the name of the
5537theme.
cf4a9129 5538@end deffn
4af2447e 5539
0ecc3bf3
LC
5540@defvr {Scheme Variable} %default-theme
5541@defvrx {Scheme Variable} %default-theme-name
5542The G-Expression denoting the default SLiM theme and its name.
5543@end defvr
5544
f703413e 5545@deffn {Monadic Procedure} xorg-start-command [#:guile] @
d1cdd7ba 5546 [#:configuration-file #f] [#:xorg-server @var{xorg-server}]
f703413e 5547Return a derivation that builds a @var{guile} script to start the X server
d1cdd7ba
LC
5548from @var{xorg-server}. @var{configuration-file} is the server configuration
5549file or a derivation that builds it; when omitted, the result of
5550@code{xorg-configuration-file} is used.
5551
5552Usually the X server is started by a login manager.
5553@end deffn
5554
5555@deffn {Monadic Procedure} xorg-configuration-file @
12422c9d 5556 [#:drivers '()] [#:resolutions '()] [#:extra-config '()]
d1cdd7ba
LC
5557Return a configuration file for the Xorg server containing search paths for
5558all the common drivers.
f703413e
LC
5559
5560@var{drivers} must be either the empty list, in which case Xorg chooses a
5561graphics driver automatically, or a list of driver names that will be tried in
d1cdd7ba 5562this order---e.g., @code{(\"modesetting\" \"vesa\")}.
d2e59637
LC
5563
5564Likewise, when @var{resolutions} is the empty list, Xorg chooses an
5565appropriate screen resolution; otherwise, it must be a list of
5566resolutions---e.g., @code{((1024 768) (640 480))}.
12422c9d
LC
5567
5568Last, @var{extra-config} is a list of strings or objects appended to the
5569@code{text-file*} argument list. It is used to pass extra text to be added
5570verbatim to the configuration file.
f703413e 5571@end deffn
4af2447e 5572
fe1a39d3
LC
5573@node Desktop Services
5574@subsubsection Desktop Services
aa4ed923 5575
fe1a39d3
LC
5576The @code{(gnu services desktop)} module provides services that are
5577usually useful in the context of a ``desktop'' setup---that is, on a
5578machine running a graphical display server, possibly with graphical user
5579interfaces, etc.
aa4ed923 5580
4467be21
LC
5581To simplify things, the module defines a variable containing the set of
5582services that users typically expect on a machine with a graphical
5583environment and networking:
5584
5585@defvr {Scheme Variable} %desktop-services
5586This is a list of services that builds upon @var{%base-services} and
5587adds or adjust services for a typical ``desktop'' setup.
5588
5589In particular, it adds a graphical login manager (@pxref{X Window,
5590@code{slim-service}}), a network management tool (@pxref{Networking
5591Services, @code{wicd-service}}), energy and color management services,
4a3bcaee 5592an NTP client (@pxref{Networking Services}), the Avahi
4467be21
LC
5593daemon, and has the name service switch service configured to be able to
5594use @code{nss-mdns} (@pxref{Name Service Switch, mDNS}).
5595@end defvr
5596
5597The @var{%desktop-services} variable can be used as the @code{services}
5598field of an @code{operating-system} declaration (@pxref{operating-system
5599Reference, @code{services}}).
5600
5601The actual service definitions provided by @code{(gnu services desktop)}
5602are described below.
5603
fe1a39d3
LC
5604@deffn {Monadic Procedure} dbus-service @var{services} @
5605 [#:dbus @var{dbus}]
5606Return a service that runs the ``system bus'', using @var{dbus}, with
5607support for @var{services}.
aa4ed923 5608
fe1a39d3
LC
5609@uref{http://dbus.freedesktop.org/, D-Bus} is an inter-process communication
5610facility. Its system bus is used to allow system services to communicate
5611and be notified of system-wide events.
aa4ed923 5612
fe1a39d3
LC
5613@var{services} must be a list of packages that provide an
5614@file{etc/dbus-1/system.d} directory containing additional D-Bus configuration
5615and policy files. For example, to allow avahi-daemon to use the system bus,
5616@var{services} must be equal to @code{(list avahi)}.
aa4ed923
AK
5617@end deffn
5618
be234128
AW
5619@deffn {Monadic Procedure} upower-service [#:upower @var{upower}] @
5620 [#:watts-up-pro? #f] @
5621 [#:poll-batteries? #t] @
5622 [#:ignore-lid? #f] @
5623 [#:use-percentage-for-policy? #f] @
5624 [#:percentage-low 10] @
5625 [#:percentage-critical 3] @
5626 [#:percentage-action 2] @
5627 [#:time-low 1200] @
5628 [#:time-critical 300] @
5629 [#:time-action 120] @
5630 [#:critical-power-action 'hybrid-sleep]
5631Return a service that runs @uref{http://upower.freedesktop.org/,
5632@command{upowerd}}, a system-wide monitor for power consumption and battery
5633levels, with the given configuration settings. It implements the
5634@code{org.freedesktop.UPower} D-Bus interface, and is notably used by
5635GNOME.
5636@end deffn
5637
7ce597ff
AW
5638@deffn {Monadic Procedure} colord-service [#:colord @var{colord}]
5639Return a service that runs @command{colord}, a system service with a D-Bus
5640interface to manage the color profiles of input and output devices such as
5641screens and scanners. It is notably used by the GNOME Color Manager graphical
5642tool. See @uref{http://www.freedesktop.org/software/colord/, the colord web
5643site} for more information.
5644@end deffn
5645
105369a4
DT
5646@node Database Services
5647@subsubsection Database Services
5648
5649The @code{(gnu services databases)} module provides the following service.
5650
5651@deffn {Monadic Procedure} postgresql-service [#:postgresql postgresql] @
5652 [#:config-file] [#:data-directory ``/var/lib/postgresql/data'']
5653Return a service that runs @var{postgresql}, the PostgreSQL database
5654server.
5655
5656The PostgreSQL daemon loads its runtime configuration from
5657@var{config-file} and stores the database cluster in
5658@var{data-directory}.
5659@end deffn
fe1a39d3
LC
5660
5661@node Various Services
5662@subsubsection Various Services
5663
5664The @code{(gnu services lirc)} module provides the following service.
5665
5666@deffn {Monadic Procedure} lirc-service [#:lirc lirc] @
5667 [#:device #f] [#:driver #f] [#:config-file #f] @
5668 [#:extra-options '()]
5669Return a service that runs @url{http://www.lirc.org,LIRC}, a daemon that
5670decodes infrared signals from remote controls.
5671
5672Optionally, @var{device}, @var{driver} and @var{config-file}
5673(configuration file name) may be specified. See @command{lircd} manual
5674for details.
5675
5676Finally, @var{extra-options} is a list of additional command-line options
5677passed to @command{lircd}.
5678@end deffn
5679
5680
0ae8c15a
LC
5681@node Setuid Programs
5682@subsection Setuid Programs
5683
5684@cindex setuid programs
5685Some programs need to run with ``root'' privileges, even when they are
5686launched by unprivileged users. A notorious example is the
5687@command{passwd} programs, which can users can run to change their
5688password, and which requires write access to the @file{/etc/passwd} and
5689@file{/etc/shadow} files---something normally restricted to root, for
5690obvious security reasons. To address that, these executables are
5691@dfn{setuid-root}, meaning that they always run with root privileges
5692(@pxref{How Change Persona,,, libc, The GNU C Library Reference Manual},
5693for more info about the setuid mechanisms.)
5694
5695The store itself @emph{cannot} contain setuid programs: that would be a
5696security issue since any user on the system can write derivations that
5697populate the store (@pxref{The Store}). Thus, a different mechanism is
5698used: instead of changing the setuid bit directly on files that are in
5699the store, we let the system administrator @emph{declare} which programs
5700should be setuid root.
5701
5702The @code{setuid-programs} field of an @code{operating-system}
5703declaration contains a list of G-expressions denoting the names of
5704programs to be setuid-root (@pxref{Using the Configuration System}).
5705For instance, the @command{passwd} program, which is part of the Shadow
5706package, can be designated by this G-expression (@pxref{G-Expressions}):
5707
5708@example
5709#~(string-append #$shadow "/bin/passwd")
5710@end example
5711
5712A default set of setuid programs is defined by the
5713@code{%setuid-programs} variable of the @code{(gnu system)} module.
5714
5715@defvr {Scheme Variable} %setuid-programs
5716A list of G-expressions denoting common programs that are setuid-root.
5717
5718The list includes commands such as @command{passwd}, @command{ping},
5719@command{su}, and @command{sudo}.
5720@end defvr
5721
5722Under the hood, the actual setuid programs are created in the
5723@file{/run/setuid-programs} directory at system activation time. The
5724files in this directory refer to the ``real'' binaries, which are in the
5725store.
5726
efb5e833
LC
5727@node X.509 Certificates
5728@subsection X.509 Certificates
5729
5730@cindex HTTPS, certificates
5731@cindex X.509 certificates
5732@cindex TLS
5733Web servers available over HTTPS (that is, HTTP over the transport-layer
5734security mechanism, TLS) send client programs an @dfn{X.509 certificate}
5735that the client can then use to @emph{authenticate} the server. To do
5736that, clients verify that the server's certificate is signed by a
5737so-called @dfn{certificate authority} (CA). But to verify the CA's
5738signature, clients must have first acquired the CA's certificate.
5739
5740Web browsers such as GNU@tie{}IceCat include their own set of CA
5741certificates, such that they are able to verify CA signatures
5742out-of-the-box.
5743
5744However, most other programs that can talk HTTPS---@command{wget},
5745@command{git}, @command{w3m}, etc.---need to be told where CA
5746certificates can be found.
5747
5748@cindex @code{nss-certs}
5749In GuixSD, this is done by adding a package that provides certificates
5750to the @code{packages} field of the @code{operating-system} declaration
5751(@pxref{operating-system Reference}). GuixSD includes one such package,
5752@code{nss-certs}, which is a set of CA certificates provided as part of
5753Mozilla's Network Security Services.
5754
5755Note that it is @emph{not} part of @var{%base-packages}, so you need to
5756explicitly add it. The @file{/etc/ssl/certs} directory, which is where
5757most applications and libraries look for certificates by default, points
5758to the certificates installed globally.
5759
5760Unprivileged users can also install their own certificate package in
5761their profile. A number of environment variables need to be defined so
5762that applications and libraries know where to find them. Namely, the
5763OpenSSL library honors the @code{SSL_CERT_DIR} and @code{SSL_CERT_FILE}
5764variables. Some applications add their own environment variables; for
5765instance, the Git version control system honors the certificate bundle
5766pointed to by the @code{GIT_SSL_CAINFO} environment variable.
5767
5768
996ed739
LC
5769@node Name Service Switch
5770@subsection Name Service Switch
5771
5772@cindex name service switch
5773@cindex NSS
5774The @code{(gnu system nss)} module provides bindings to the
5775configuration file of libc's @dfn{name service switch} or @dfn{NSS}
5776(@pxref{NSS Configuration File,,, libc, The GNU C Library Reference
5777Manual}). In a nutshell, the NSS is a mechanism that allows libc to be
5778extended with new ``name'' lookup methods for system databases, which
5779includes host names, service names, user accounts, and more (@pxref{Name
5780Service Switch, System Databases and Name Service Switch,, libc, The GNU
5781C Library Reference Manual}).
5782
5783The NSS configuration specifies, for each system database, which lookup
5784method is to be used, and how the various methods are chained
5785together---for instance, under which circumstances NSS should try the
5786next method in the list. The NSS configuration is given in the
5787@code{name-service-switch} field of @code{operating-system} declarations
5788(@pxref{operating-system Reference, @code{name-service-switch}}).
5789
4c9050c6
LC
5790@cindex nss-mdns
5791@cindex .local, host name lookup
996ed739 5792As an example, the declaration below configures the NSS to use the
4c9050c6
LC
5793@uref{http://0pointer.de/lennart/projects/nss-mdns/, @code{nss-mdns}
5794back-end}, which supports host name lookups over multicast DNS (mDNS)
5795for host names ending in @code{.local}:
996ed739
LC
5796
5797@example
5798(name-service-switch
5799 (hosts (list %files ;first, check /etc/hosts
5800
5801 ;; If the above did not succeed, try
5802 ;; with 'mdns_minimal'.
5803 (name-service
5804 (name "mdns_minimal")
5805
5806 ;; 'mdns_minimal' is authoritative for
5807 ;; '.local'. When it returns "not found",
5808 ;; no need to try the next methods.
5809 (reaction (lookup-specification
5810 (not-found => return))))
5811
5812 ;; Then fall back to DNS.
5813 (name-service
5814 (name "dns"))
5815
5816 ;; Finally, try with the "full" 'mdns'.
5817 (name-service
5818 (name "mdns")))))
5819@end example
5820
15137a29
LC
5821Don't worry: the @code{%mdns-host-lookup-nss} variable (see below)
5822contains this configuration, so you won't have to type it if all you
5823want is to have @code{.local} host lookup working.
5824
4c9050c6
LC
5825Note that, in this case, in addition to setting the
5826@code{name-service-switch} of the @code{operating-system} declaration,
5827@code{nscd-service} must be told where to find the @code{nss-mdns}
5828shared library (@pxref{Base Services, @code{nscd-service}}). Since the
5829@code{nscd} service is part of @var{%base-services}, you may want to
5830customize it by adding this snippet in the operating system
5831configuration file:
5832
5833@example
5834(use-modules (guix) (gnu))
5835
5836(define %my-base-services
5837 ;; Replace the default nscd service with one that knows
5838 ;; about nss-mdns.
5839 (map (lambda (mservice)
5840 ;; "Bind" the MSERVICE monadic value to inspect it.
5841 (mlet %store-monad ((service mservice))
5842 (if (member 'nscd (service-provision service))
5843 (nscd-service (nscd-configuration)
5844 #:name-services (list nss-mdns))
5845 mservice)))
5846 %base-services))
5847@end example
5848
5849@noindent
5850@dots{} and then refer to @var{%my-base-services} instead of
5851@var{%base-services} in the @code{operating-system} declaration.
15137a29 5852Lastly, this relies on the availability of the Avahi service
965a7332 5853(@pxref{Networking Services, @code{avahi-service}}).
15137a29
LC
5854
5855For convenience, the following variables provide typical NSS
5856configurations.
5857
5858@defvr {Scheme Variable} %default-nss
5859This is the default name service switch configuration, a
5860@code{name-service-switch} object.
5861@end defvr
5862
5863@defvr {Scheme Variable} %mdns-host-lookup-nss
5864This is the name service switch configuration with support for host name
5865lookup over multicast DNS (mDNS) for host names ending in @code{.local}.
5866@end defvr
4c9050c6 5867
996ed739
LC
5868The reference for name service switch configuration is given below. It
5869is a direct mapping of the C library's configuration file format, so
5870please refer to the C library manual for more information (@pxref{NSS
5871Configuration File,,, libc, The GNU C Library Reference Manual}).
5872Compared to libc's NSS configuration file format, it has the advantage
5873not only of adding this warm parenthetic feel that we like, but also
5874static checks: you'll know about syntax errors and typos as soon as you
5875run @command{guix system}.
5876
996ed739
LC
5877@deftp {Data Type} name-service-switch
5878
5879This is the data type representation the configuration of libc's name
5880service switch (NSS). Each field below represents one of the supported
5881system databases.
5882
5883@table @code
5884@item aliases
5885@itemx ethers
5886@itemx group
5887@itemx gshadow
5888@itemx hosts
5889@itemx initgroups
5890@itemx netgroup
5891@itemx networks
5892@itemx password
5893@itemx public-key
5894@itemx rpc
5895@itemx services
5896@itemx shadow
5897The system databases handled by the NSS. Each of these fields must be a
5898list of @code{<name-service>} objects (see below.)
5899@end table
5900@end deftp
5901
5902@deftp {Data Type} name-service
5903
5904This is the data type representing an actual name service and the
5905associated lookup action.
5906
5907@table @code
5908@item name
5909A string denoting the name service (@pxref{Services in the NSS
5910configuration,,, libc, The GNU C Library Reference Manual}).
5911
4aee6e60
LC
5912Note that name services listed here must be visible to nscd. This is
5913achieved by passing the @code{#:name-services} argument to
5914@code{nscd-service} the list of packages providing the needed name
5915services (@pxref{Base Services, @code{nscd-service}}).
5916
996ed739
LC
5917@item reaction
5918An action specified using the @code{lookup-specification} macro
5919(@pxref{Actions in the NSS configuration,,, libc, The GNU C Library
5920Reference Manual}). For example:
5921
5922@example
5923(lookup-specification (unavailable => continue)
5924 (success => return))
5925@end example
5926@end table
5927@end deftp
0ae8c15a 5928
fd1b1fa2
LC
5929@node Initial RAM Disk
5930@subsection Initial RAM Disk
5931
5932@cindex initial RAM disk (initrd)
5933@cindex initrd (initial RAM disk)
5934For bootstrapping purposes, the Linux-Libre kernel is passed an
5935@dfn{initial RAM disk}, or @dfn{initrd}. An initrd contains a temporary
5936root file system, as well as an initialization script. The latter is
5937responsible for mounting the real root file system, and for loading any
5938kernel modules that may be needed to achieve that.
5939
5940The @code{initrd} field of an @code{operating-system} declaration allows
5941you to specify which initrd you would like to use. The @code{(gnu
5942system linux-initrd)} module provides two ways to build an initrd: the
5943high-level @code{base-initrd} procedure, and the low-level
5944@code{expression->initrd} procedure.
5945
5946The @code{base-initrd} procedure is intended to cover most common uses.
5947For example, if you want to add a bunch of kernel modules to be loaded
5948at boot time, you can define the @code{initrd} field of the operating
5949system declaration like this:
5950
5951@example
52ac153e 5952(initrd (lambda (file-systems . rest)
027981d6
LC
5953 ;; Create a standard initrd that has modules "foo.ko"
5954 ;; and "bar.ko", as well as their dependencies, in
5955 ;; addition to the modules available by default.
52ac153e 5956 (apply base-initrd file-systems
027981d6 5957 #:extra-modules '("foo" "bar")
52ac153e 5958 rest)))
fd1b1fa2
LC
5959@end example
5960
52ac153e
LC
5961The @code{base-initrd} procedure also handles common use cases that
5962involves using the system as a QEMU guest, or as a ``live'' system whose
5963root file system is volatile.
fd1b1fa2
LC
5964
5965@deffn {Monadic Procedure} base-initrd @var{file-systems} @
5966 [#:qemu-networking? #f] [#:virtio? #f] [#:volatile-root? #f] @
52ac153e 5967 [#:extra-modules '()] [#:mapped-devices '()]
fd1b1fa2
LC
5968Return a monadic derivation that builds a generic initrd. @var{file-systems} is
5969a list of file-systems to be mounted by the initrd, possibly in addition to
5970the root file system specified on the kernel command line via @code{--root}.
52ac153e
LC
5971@var{mapped-devices} is a list of device mappings to realize before
5972@var{file-systems} are mounted (@pxref{Mapped Devices}).
fd1b1fa2
LC
5973
5974When @var{qemu-networking?} is true, set up networking with the standard QEMU
5975parameters. When @var{virtio?} is true, load additional modules so the initrd can
5976be used as a QEMU guest with para-virtualized I/O drivers.
5977
5978When @var{volatile-root?} is true, the root file system is writable but any changes
5979to it are lost.
5980
5981The initrd is automatically populated with all the kernel modules necessary
5982for @var{file-systems} and for the given options. However, additional kernel
5983modules can be listed in @var{extra-modules}. They will be added to the initrd, and
5984loaded at boot time in the order in which they appear.
5985@end deffn
5986
5987Needless to say, the initrds we produce and use embed a
5988statically-linked Guile, and the initialization program is a Guile
5989program. That gives a lot of flexibility. The
5990@code{expression->initrd} procedure builds such an initrd, given the
5991program to run in that initrd.
5992
5993@deffn {Monadic Procedure} expression->initrd @var{exp} @
5994 [#:guile %guile-static-stripped] [#:name "guile-initrd"] @
42d10464 5995 [#:modules '()]
fd1b1fa2
LC
5996Return a derivation that builds a Linux initrd (a gzipped cpio archive)
5997containing @var{guile} and that evaluates @var{exp}, a G-expression,
df650fa8
LC
5998upon booting. All the derivations referenced by @var{exp} are
5999automatically copied to the initrd.
fd1b1fa2 6000
42d10464
LC
6001@var{modules} is a list of Guile module names to be embedded in the
6002initrd.
fd1b1fa2
LC
6003@end deffn
6004
88faf933
LC
6005@node GRUB Configuration
6006@subsection GRUB Configuration
6007
6008@cindex GRUB
6009@cindex boot loader
6010
6011The operating system uses GNU@tie{}GRUB as its boot loader
6012(@pxref{Overview, overview of GRUB,, grub, GNU GRUB Manual}). It is
6013configured using @code{grub-configuration} declarations. This data type
6014is exported by the @code{(gnu system grub)} module, and described below.
6015
6016@deftp {Data Type} grub-configuration
6017The type of a GRUB configuration declaration.
6018
6019@table @asis
6020
6021@item @code{device}
6022This is a string denoting the boot device. It must be a device name
6023understood by the @command{grub-install} command, such as
6024@code{/dev/sda} or @code{(hd0)} (@pxref{Invoking grub-install,,, grub,
6025GNU GRUB Manual}).
6026
6027@item @code{menu-entries} (default: @code{()})
6028A possibly empty list of @code{menu-entry} objects (see below), denoting
6029entries to appear in the GRUB boot menu, in addition to the current
6030system entry and the entry pointing to previous system generations.
6031
6032@item @code{default-entry} (default: @code{0})
6033The index of the default boot menu entry. Index 0 is for the current
6034system's entry.
6035
6036@item @code{timeout} (default: @code{5})
6037The number of seconds to wait for keyboard input before booting. Set to
60380 to boot immediately, and to -1 to wait indefinitely.
6039
6040@item @code{theme} (default: @var{%default-theme})
6041The @code{grub-theme} object describing the theme to use.
6042@end table
6043
6044@end deftp
6045
6046Should you want to list additional boot menu entries @i{via} the
6047@code{menu-entries} field above, you will need to create them with the
6048@code{menu-entry} form:
6049
6050@deftp {Data Type} menu-entry
6051The type of an entry in the GRUB boot menu.
6052
6053@table @asis
6054
6055@item @code{label}
35ed9306 6056The label to show in the menu---e.g., @code{"GNU"}.
88faf933
LC
6057
6058@item @code{linux}
6059The Linux kernel to boot.
6060
6061@item @code{linux-arguments} (default: @code{()})
6062The list of extra Linux kernel command-line arguments---e.g.,
6063@code{("console=ttyS0")}.
6064
6065@item @code{initrd}
6066A G-Expression or string denoting the file name of the initial RAM disk
6067to use (@pxref{G-Expressions}).
6068
6069@end table
6070@end deftp
6071
6072@c FIXME: Write documentation once it's stable.
6073Themes are created using the @code{grub-theme} form, which is not
6074documented yet.
6075
6076@defvr {Scheme Variable} %default-theme
6077This is the default GRUB theme used by the operating system, with a
6078fancy background image displaying the GNU and Guix logos.
6079@end defvr
6080
6081
cf4a9129
LC
6082@node Invoking guix system
6083@subsection Invoking @code{guix system}
0918e64a 6084
cf4a9129
LC
6085Once you have written an operating system declaration, as seen in the
6086previous section, it can be @dfn{instantiated} using the @command{guix
6087system} command. The synopsis is:
4af2447e 6088
cf4a9129
LC
6089@example
6090guix system @var{options}@dots{} @var{action} @var{file}
6091@end example
4af2447e 6092
cf4a9129
LC
6093@var{file} must be the name of a file containing an
6094@code{operating-system} declaration. @var{action} specifies how the
6095operating system is instantiate. Currently the following values are
6096supported:
4af2447e 6097
cf4a9129
LC
6098@table @code
6099@item reconfigure
6100Build the operating system described in @var{file}, activate it, and
6101switch to it@footnote{This action is usable only on systems already
6102running GNU.}.
4af2447e 6103
cf4a9129
LC
6104This effects all the configuration specified in @var{file}: user
6105accounts, system services, global package list, setuid programs, etc.
4af2447e 6106
cf4a9129
LC
6107It also adds a GRUB menu entry for the new OS configuration, and moves
6108entries for older configurations to a submenu---unless
6109@option{--no-grub} is passed.
4af2447e 6110
bf2479c7
LC
6111@c The paragraph below refers to the problem discussed at
6112@c <http://lists.gnu.org/archive/html/guix-devel/2014-08/msg00057.html>.
6113It is highly recommended to run @command{guix pull} once before you run
6114@command{guix system reconfigure} for the first time (@pxref{Invoking
6115guix pull}). Failing to do that you would see an older version of Guix
6116once @command{reconfigure} has completed.
6117
cf4a9129
LC
6118@item build
6119Build the operating system's derivation, which includes all the
6120configuration files and programs needed to boot and run the system.
6121This action does not actually install anything.
113daf62 6122
cf4a9129
LC
6123@item init
6124Populate the given directory with all the files necessary to run the
6125operating system specified in @var{file}. This is useful for first-time
4705641f 6126installations of GuixSD. For instance:
113daf62
LC
6127
6128@example
cf4a9129 6129guix system init my-os-config.scm /mnt
113daf62
LC
6130@end example
6131
cf4a9129
LC
6132copies to @file{/mnt} all the store items required by the configuration
6133specified in @file{my-os-config.scm}. This includes configuration
6134files, packages, and so on. It also creates other essential files
6135needed for the system to operate correctly---e.g., the @file{/etc},
6136@file{/var}, and @file{/run} directories, and the @file{/bin/sh} file.
113daf62 6137
cf4a9129
LC
6138This command also installs GRUB on the device specified in
6139@file{my-os-config}, unless the @option{--no-grub} option was passed.
113daf62 6140
cf4a9129
LC
6141@item vm
6142@cindex virtual machine
0276f697 6143@cindex VM
cf4a9129
LC
6144Build a virtual machine that contain the operating system declared in
6145@var{file}, and return a script to run that virtual machine (VM).
810568b3 6146Arguments given to the script are passed as is to QEMU.
113daf62 6147
cf4a9129 6148The VM shares its store with the host system.
113daf62 6149
0276f697
LC
6150Additional file systems can be shared between the host and the VM using
6151the @code{--share} and @code{--expose} command-line options: the former
6152specifies a directory to be shared with write access, while the latter
6153provides read-only access to the shared directory.
6154
6155The example below creates a VM in which the user's home directory is
6156accessible read-only, and where the @file{/exchange} directory is a
6157read-write mapping of the host's @file{$HOME/tmp}:
6158
6159@example
6160guix system vm my-config.scm \
6161 --expose=$HOME --share=$HOME/tmp=/exchange
6162@end example
6163
6aa260af
LC
6164On GNU/Linux, the default is to boot directly to the kernel; this has
6165the advantage of requiring only a very tiny root disk image since the
6166host's store can then be mounted.
6167
6168The @code{--full-boot} option forces a complete boot sequence, starting
6169with the bootloader. This requires more disk space since a root image
6170containing at least the kernel, initrd, and bootloader data files must
6171be created. The @code{--image-size} option can be used to specify the
6172image's size.
ab11f0be 6173
cf4a9129
LC
6174@item vm-image
6175@itemx disk-image
6176Return a virtual machine or disk image of the operating system declared
6177in @var{file} that stands alone. Use the @option{--image-size} option
6178to specify the size of the image.
113daf62 6179
cf4a9129
LC
6180When using @code{vm-image}, the returned image is in qcow2 format, which
6181the QEMU emulator can efficiently use.
113daf62 6182
cf4a9129
LC
6183When using @code{disk-image}, a raw disk image is produced; it can be
6184copied as is to a USB stick, for instance. Assuming @code{/dev/sdc} is
6185the device corresponding to a USB stick, one can copy the image on it
6186using the following command:
113daf62 6187
cf4a9129
LC
6188@example
6189# dd if=$(guix system disk-image my-os.scm) of=/dev/sdc
6190@end example
113daf62 6191
cf4a9129 6192@end table
113daf62 6193
cf4a9129
LC
6194@var{options} can contain any of the common build options provided by
6195@command{guix build} (@pxref{Invoking guix build}). In addition,
6196@var{options} can contain one of the following:
113daf62 6197
cf4a9129
LC
6198@table @option
6199@item --system=@var{system}
6200@itemx -s @var{system}
6201Attempt to build for @var{system} instead of the host's system type.
6202This works as per @command{guix build} (@pxref{Invoking guix build}).
113daf62 6203
cf4a9129
LC
6204@item --image-size=@var{size}
6205For the @code{vm-image} and @code{disk-image} actions, create an image
6206of the given @var{size}. @var{size} may be a number of bytes, or it may
4a44d7bb
LC
6207include a unit as a suffix (@pxref{Block size, size specifications,,
6208coreutils, GNU Coreutils}).
db030303
LC
6209
6210@item --on-error=@var{strategy}
6211Apply @var{strategy} when an error occurs when reading @var{file}.
6212@var{strategy} may be one of the following:
6213
6214@table @code
6215@item nothing-special
6216Report the error concisely and exit. This is the default strategy.
6217
6218@item backtrace
6219Likewise, but also display a backtrace.
6220
6221@item debug
6222Report the error and enter Guile's debugger. From there, you can run
6223commands such as @code{,bt} to get a backtrace, @code{,locals} to
6224display local variable values, and more generally inspect the program's
6225state. @xref{Debug Commands,,, guile, GNU Guile Reference Manual}, for
6226a list of available debugging commands.
6227@end table
113daf62 6228@end table
113daf62 6229
cf4a9129
LC
6230Note that all the actions above, except @code{build} and @code{init},
6231rely on KVM support in the Linux-Libre kernel. Specifically, the
6232machine should have hardware virtualization support, the corresponding
6233KVM kernel module should be loaded, and the @file{/dev/kvm} device node
6234must exist and be readable and writable by the user and by the daemon's
6235build users.
8451a568 6236
cf4a9129
LC
6237@node Defining Services
6238@subsection Defining Services
8451a568 6239
cf4a9129
LC
6240The @code{(gnu services @dots{})} modules define several procedures that allow
6241users to declare the operating system's services (@pxref{Using the
6242Configuration System}). These procedures are @emph{monadic
6243procedures}---i.e., procedures that return a monadic value in the store
6244monad (@pxref{The Store Monad}). For examples of such procedures,
6245@xref{Services}.
8451a568 6246
cf4a9129
LC
6247@cindex service definition
6248The monadic value returned by those procedures is a @dfn{service
6249definition}---a structure as returned by the @code{service} form.
6250Service definitions specifies the inputs the service depends on, and an
6251expression to start and stop the service. Behind the scenes, service
6252definitions are ``translated'' into the form suitable for the
6253configuration file of dmd, the init system (@pxref{Services,,, dmd, GNU
6254dmd Manual}).
8451a568 6255
cf4a9129
LC
6256As an example, here is what the @code{nscd-service} procedure looks
6257like:
8451a568 6258
cf4a9129
LC
6259@lisp
6260(define (nscd-service)
6261 (with-monad %store-monad
6262 (return (service
6263 (documentation "Run libc's name service cache daemon.")
6264 (provision '(nscd))
6265 (activate #~(begin
6266 (use-modules (guix build utils))
6267 (mkdir-p "/var/run/nscd")))
6268 (start #~(make-forkexec-constructor
6269 (string-append #$glibc "/sbin/nscd")
6270 "-f" "/dev/null" "--foreground"))
6271 (stop #~(make-kill-destructor))
6272 (respawn? #f)))))
6273@end lisp
8451a568 6274
cf4a9129
LC
6275@noindent
6276The @code{activate}, @code{start}, and @code{stop} fields are G-expressions
6277(@pxref{G-Expressions}). The @code{activate} field contains a script to
6278run at ``activation'' time; it makes sure that the @file{/var/run/nscd}
6279directory exists before @command{nscd} is started.
8451a568 6280
cf4a9129
LC
6281The @code{start} and @code{stop} fields refer to dmd's facilities to
6282start and stop processes (@pxref{Service De- and Constructors,,, dmd,
6283GNU dmd Manual}). The @code{provision} field specifies the name under
6284which this service is known to dmd, and @code{documentation} specifies
6285on-line documentation. Thus, the commands @command{deco start ncsd},
6286@command{deco stop nscd}, and @command{deco doc nscd} will do what you
6287would expect (@pxref{Invoking deco,,, dmd, GNU dmd Manual}).
8451a568 6288
8451a568 6289
cf4a9129
LC
6290@node Installing Debugging Files
6291@section Installing Debugging Files
8451a568 6292
cf4a9129
LC
6293@cindex debugging files
6294Program binaries, as produced by the GCC compilers for instance, are
6295typically written in the ELF format, with a section containing
6296@dfn{debugging information}. Debugging information is what allows the
6297debugger, GDB, to map binary code to source code; it is required to
6298debug a compiled program in good conditions.
8451a568 6299
cf4a9129
LC
6300The problem with debugging information is that is takes up a fair amount
6301of disk space. For example, debugging information for the GNU C Library
6302weighs in at more than 60 MiB. Thus, as a user, keeping all the
6303debugging info of all the installed programs is usually not an option.
6304Yet, space savings should not come at the cost of an impediment to
6305debugging---especially in the GNU system, which should make it easier
6306for users to exert their computing freedom (@pxref{GNU Distribution}).
8451a568 6307
cf4a9129
LC
6308Thankfully, the GNU Binary Utilities (Binutils) and GDB provide a
6309mechanism that allows users to get the best of both worlds: debugging
6310information can be stripped from the binaries and stored in separate
6311files. GDB is then able to load debugging information from those files,
6312when they are available (@pxref{Separate Debug Files,,, gdb, Debugging
6313with GDB}).
8451a568 6314
cf4a9129
LC
6315The GNU distribution takes advantage of this by storing debugging
6316information in the @code{lib/debug} sub-directory of a separate package
6317output unimaginatively called @code{debug} (@pxref{Packages with
6318Multiple Outputs}). Users can choose to install the @code{debug} output
6319of a package when they need it. For instance, the following command
6320installs the debugging information for the GNU C Library and for GNU
6321Guile:
8451a568
LC
6322
6323@example
cf4a9129 6324guix package -i glibc:debug guile:debug
8451a568
LC
6325@end example
6326
cf4a9129
LC
6327GDB must then be told to look for debug files in the user's profile, by
6328setting the @code{debug-file-directory} variable (consider setting it
6329from the @file{~/.gdbinit} file, @pxref{Startup,,, gdb, Debugging with
6330GDB}):
8451a568 6331
cf4a9129
LC
6332@example
6333(gdb) set debug-file-directory ~/.guix-profile/lib/debug
6334@end example
8451a568 6335
cf4a9129
LC
6336From there on, GDB will pick up debugging information from the
6337@code{.debug} files under @file{~/.guix-profile/lib/debug}.
8451a568 6338
cf4a9129
LC
6339In addition, you will most likely want GDB to be able to show the source
6340code being debugged. To do that, you will have to unpack the source
6341code of the package of interest (obtained with @code{guix build
6342--source}, @pxref{Invoking guix build}), and to point GDB to that source
6343directory using the @code{directory} command (@pxref{Source Path,
6344@code{directory},, gdb, Debugging with GDB}).
8451a568 6345
cf4a9129
LC
6346@c XXX: keep me up-to-date
6347The @code{debug} output mechanism in Guix is implemented by the
6348@code{gnu-build-system} (@pxref{Build Systems}). Currently, it is
6349opt-in---debugging information is available only for those packages
6350whose definition explicitly declares a @code{debug} output. This may be
6351changed to opt-out in the future, if our build farm servers can handle
6352the load. To check whether a package has a @code{debug} output, use
6353@command{guix package --list-available} (@pxref{Invoking guix package}).
8451a568 6354
8451a568 6355
05962f29
LC
6356@node Security Updates
6357@section Security Updates
6358
843858b8
LC
6359@quotation Note
6360As of version @value{VERSION}, the feature described in this section is
6361experimental.
6362@end quotation
05962f29
LC
6363
6364@cindex security updates
6365Occasionally, important security vulnerabilities are discovered in core
6366software packages and must be patched. Guix follows a functional
6367package management discipline (@pxref{Introduction}), which implies
6368that, when a package is changed, @emph{every package that depends on it}
6369must be rebuilt. This can significantly slow down the deployment of
6370fixes in core packages such as libc or Bash, since basically the whole
6371distribution would need to be rebuilt. Using pre-built binaries helps
6372(@pxref{Substitutes}), but deployment may still take more time than
6373desired.
6374
6375@cindex grafts
6376To address that, Guix implements @dfn{grafts}, a mechanism that allows
6377for fast deployment of critical updates without the costs associated
6378with a whole-distribution rebuild. The idea is to rebuild only the
6379package that needs to be patched, and then to ``graft'' it onto packages
6380explicitly installed by the user and that were previously referring to
6381the original package. The cost of grafting is typically very low, and
6382order of magnitudes lower than a full rebuild of the dependency chain.
6383
6384@cindex replacements of packages, for grafts
6385For instance, suppose a security update needs to be applied to Bash.
6386Guix developers will provide a package definition for the ``fixed''
6387Bash, say @var{bash-fixed}, in the usual way (@pxref{Defining
6388Packages}). Then, the original package definition is augmented with a
6389@code{replacement} field pointing to the package containing the bug fix:
6390
6391@example
6392(define bash
6393 (package
6394 (name "bash")
6395 ;; @dots{}
6396 (replacement bash-fixed)))
6397@end example
6398
6399From there on, any package depending directly or indirectly on Bash that
6400is installed will automatically be ``rewritten'' to refer to
6401@var{bash-fixed} instead of @var{bash}. This grafting process takes
6402time proportional to the size of the package, but expect less than a
6403minute for an ``average'' package on a recent machine.
6404
6405Currently, the graft and the package it replaces (@var{bash-fixed} and
6406@var{bash} in the example above) must have the exact same @code{name}
6407and @code{version} fields. This restriction mostly comes from the fact
6408that grafting works by patching files, including binary files, directly.
6409Other restrictions may apply: for instance, when adding a graft to a
6410package providing a shared library, the original shared library and its
6411replacement must have the same @code{SONAME} and be binary-compatible.
6412
6413
cf4a9129
LC
6414@node Package Modules
6415@section Package Modules
8451a568 6416
cf4a9129
LC
6417From a programming viewpoint, the package definitions of the
6418GNU distribution are provided by Guile modules in the @code{(gnu packages
6419@dots{})} name space@footnote{Note that packages under the @code{(gnu
6420packages @dots{})} module name space are not necessarily ``GNU
6421packages''. This module naming scheme follows the usual Guile module
6422naming convention: @code{gnu} means that these modules are distributed
6423as part of the GNU system, and @code{packages} identifies modules that
6424define packages.} (@pxref{Modules, Guile modules,, guile, GNU Guile
6425Reference Manual}). For instance, the @code{(gnu packages emacs)}
6426module exports a variable named @code{emacs}, which is bound to a
6427@code{<package>} object (@pxref{Defining Packages}).
113daf62 6428
300868ba 6429The @code{(gnu packages @dots{})} module name space is
cf4a9129
LC
6430automatically scanned for packages by the command-line tools. For
6431instance, when running @code{guix package -i emacs}, all the @code{(gnu
6432packages @dots{})} modules are scanned until one that exports a package
6433object whose name is @code{emacs} is found. This package search
6434facility is implemented in the @code{(gnu packages)} module.
113daf62 6435
300868ba 6436@cindex customization, of packages
8689901f 6437@cindex package module search path
cf4a9129 6438Users can store package definitions in modules with different
60142854 6439names---e.g., @code{(my-packages emacs)}@footnote{Note that the file
c95ded7e
LC
6440name and module name must match. For instance, the @code{(my-packages
6441emacs)} module must be stored in a @file{my-packages/emacs.scm} file
6442relative to the load path specified with @option{--load-path} or
6443@code{GUIX_PACKAGE_PATH}. @xref{Modules and the File System,,,
6444guile, GNU Guile Reference Manual}, for details.}. These package definitions
300868ba
LC
6445will not be visible by default. Thus, users can invoke commands such as
6446@command{guix package} and @command{guix build} have to be used with the
c95ded7e
LC
6447@code{-e} option so that they know where to find the package. Better
6448yet, they can use the
300868ba 6449@code{-L} option of these commands to make those modules visible
8689901f
LC
6450(@pxref{Invoking guix build, @code{--load-path}}), or define the
6451@code{GUIX_PACKAGE_PATH} environment variable. This environment
6452variable makes it easy to extend or customize the distribution and is
6453honored by all the user interfaces.
6454
6455@defvr {Environment Variable} GUIX_PACKAGE_PATH
6456This is a colon-separated list of directories to search for package
6457modules. Directories listed in this variable take precedence over the
6458distribution's own modules.
6459@end defvr
ef5dd60a 6460
cf4a9129
LC
6461The distribution is fully @dfn{bootstrapped} and @dfn{self-contained}:
6462each package is built based solely on other packages in the
6463distribution. The root of this dependency graph is a small set of
6464@dfn{bootstrap binaries}, provided by the @code{(gnu packages
6465bootstrap)} module. For more information on bootstrapping,
081145cf 6466@pxref{Bootstrapping}.
ef5dd60a 6467
cf4a9129
LC
6468@node Packaging Guidelines
6469@section Packaging Guidelines
ef5dd60a 6470
cf4a9129
LC
6471The GNU distribution is nascent and may well lack some of your favorite
6472packages. This section describes how you can help make the distribution
6473grow. @xref{Contributing}, for additional information on how you can
6474help.
ef5dd60a 6475
cf4a9129
LC
6476Free software packages are usually distributed in the form of
6477@dfn{source code tarballs}---typically @file{tar.gz} files that contain
6478all the source files. Adding a package to the distribution means
6479essentially two things: adding a @dfn{recipe} that describes how to
6480build the package, including a list of other packages required to build
6481it, and adding @dfn{package meta-data} along with that recipe, such as a
6482description and licensing information.
ef5dd60a 6483
cf4a9129
LC
6484In Guix all this information is embodied in @dfn{package definitions}.
6485Package definitions provide a high-level view of the package. They are
6486written using the syntax of the Scheme programming language; in fact,
6487for each package we define a variable bound to the package definition,
6488and export that variable from a module (@pxref{Package Modules}).
6489However, in-depth Scheme knowledge is @emph{not} a prerequisite for
6490creating packages. For more information on package definitions,
081145cf 6491@pxref{Defining Packages}.
ef5dd60a 6492
cf4a9129
LC
6493Once a package definition is in place, stored in a file in the Guix
6494source tree, it can be tested using the @command{guix build} command
6495(@pxref{Invoking guix build}). For example, assuming the new package is
c71979f4
LC
6496called @code{gnew}, you may run this command from the Guix build tree
6497(@pxref{Running Guix Before It Is Installed}):
ef5dd60a
LC
6498
6499@example
cf4a9129 6500./pre-inst-env guix build gnew --keep-failed
ef5dd60a 6501@end example
ef5dd60a 6502
cf4a9129
LC
6503Using @code{--keep-failed} makes it easier to debug build failures since
6504it provides access to the failed build tree. Another useful
6505command-line option when debugging is @code{--log-file}, to access the
6506build log.
ef5dd60a 6507
cf4a9129
LC
6508If the package is unknown to the @command{guix} command, it may be that
6509the source file contains a syntax error, or lacks a @code{define-public}
6510clause to export the package variable. To figure it out, you may load
6511the module from Guile to get more information about the actual error:
ef5dd60a 6512
cf4a9129
LC
6513@example
6514./pre-inst-env guile -c '(use-modules (gnu packages gnew))'
6515@end example
ef5dd60a 6516
cf4a9129
LC
6517Once your package builds correctly, please send us a patch
6518(@pxref{Contributing}). Well, if you need help, we will be happy to
6519help you too. Once the patch is committed in the Guix repository, the
6520new package automatically gets built on the supported platforms by
2b1cee21 6521@url{http://hydra.gnu.org/jobset/gnu/master, our continuous integration
cf4a9129 6522system}.
ef5dd60a 6523
cf4a9129
LC
6524@cindex substituter
6525Users can obtain the new package definition simply by running
6526@command{guix pull} (@pxref{Invoking guix pull}). When
6527@code{hydra.gnu.org} is done building the package, installing the
6528package automatically downloads binaries from there
6529(@pxref{Substitutes}). The only place where human intervention is
6530needed is to review and apply the patch.
ef5dd60a 6531
ef5dd60a 6532
cf4a9129 6533@menu
ec0339cd
LC
6534* Software Freedom:: What may go into the distribution.
6535* Package Naming:: What's in a name?
6536* Version Numbers:: When the name is not enough.
6537* Python Modules:: Taming the snake.
6538* Perl Modules:: Little pearls.
6539* Fonts:: Fond of fonts.
cf4a9129 6540@end menu
ef5dd60a 6541
cf4a9129
LC
6542@node Software Freedom
6543@subsection Software Freedom
ef5dd60a 6544
cf4a9129 6545@c Adapted from http://www.gnu.org/philosophy/philosophy.html.
c11a6eb1 6546
cf4a9129
LC
6547The GNU operating system has been developed so that users can have
6548freedom in their computing. GNU is @dfn{free software}, meaning that
6549users have the @url{http://www.gnu.org/philosophy/free-sw.html,four
6550essential freedoms}: to run the program, to study and change the program
6551in source code form, to redistribute exact copies, and to distribute
6552modified versions. Packages found in the GNU distribution provide only
6553software that conveys these four freedoms.
c11a6eb1 6554
cf4a9129
LC
6555In addition, the GNU distribution follow the
6556@url{http://www.gnu.org/distros/free-system-distribution-guidelines.html,free
6557software distribution guidelines}. Among other things, these guidelines
6558reject non-free firmware, recommendations of non-free software, and
6559discuss ways to deal with trademarks and patents.
ef5dd60a 6560
cf4a9129
LC
6561Some packages contain a small and optional subset that violates the
6562above guidelines, for instance because this subset is itself non-free
6563code. When that happens, the offending items are removed with
6564appropriate patches or code snippets in the package definition's
6565@code{origin} form (@pxref{Defining Packages}). That way, @code{guix
6566build --source} returns the ``freed'' source rather than the unmodified
6567upstream source.
ef5dd60a 6568
ef5dd60a 6569
cf4a9129
LC
6570@node Package Naming
6571@subsection Package Naming
ef5dd60a 6572
cf4a9129
LC
6573A package has actually two names associated with it:
6574First, there is the name of the @emph{Scheme variable}, the one following
6575@code{define-public}. By this name, the package can be made known in the
6576Scheme code, for instance as input to another package. Second, there is
6577the string in the @code{name} field of a package definition. This name
6578is used by package management commands such as
6579@command{guix package} and @command{guix build}.
ef5dd60a 6580
cf4a9129
LC
6581Both are usually the same and correspond to the lowercase conversion of
6582the project name chosen upstream, with underscores replaced with
6583hyphens. For instance, GNUnet is available as @code{gnunet}, and
6584SDL_net as @code{sdl-net}.
927097ef 6585
cf4a9129 6586We do not add @code{lib} prefixes for library packages, unless these are
081145cf 6587already part of the official project name. But @pxref{Python
cf4a9129
LC
6588Modules} and @ref{Perl Modules} for special rules concerning modules for
6589the Python and Perl languages.
927097ef 6590
1b366ee4 6591Font package names are handled differently, @pxref{Fonts}.
7fec52b7 6592
ef5dd60a 6593
cf4a9129
LC
6594@node Version Numbers
6595@subsection Version Numbers
ef5dd60a 6596
cf4a9129
LC
6597We usually package only the latest version of a given free software
6598project. But sometimes, for instance for incompatible library versions,
6599two (or more) versions of the same package are needed. These require
6600different Scheme variable names. We use the name as defined
6601in @ref{Package Naming}
6602for the most recent version; previous versions use the same name, suffixed
6603by @code{-} and the smallest prefix of the version number that may
6604distinguish the two versions.
ef5dd60a 6605
cf4a9129
LC
6606The name inside the package definition is the same for all versions of a
6607package and does not contain any version number.
ef5dd60a 6608
cf4a9129 6609For instance, the versions 2.24.20 and 3.9.12 of GTK+ may be packaged as follows:
ef5dd60a 6610
cf4a9129
LC
6611@example
6612(define-public gtk+
6613 (package
6614 (name "gtk+")
6615 (version "3.9.12")
6616 ...))
6617(define-public gtk+-2
6618 (package
6619 (name "gtk+")
6620 (version "2.24.20")
6621 ...))
6622@end example
6623If we also wanted GTK+ 3.8.2, this would be packaged as
6624@example
6625(define-public gtk+-3.8
6626 (package
6627 (name "gtk+")
6628 (version "3.8.2")
6629 ...))
6630@end example
ef5dd60a 6631
ef5dd60a 6632
cf4a9129
LC
6633@node Python Modules
6634@subsection Python Modules
ef5dd60a 6635
cf4a9129
LC
6636We currently package Python 2 and Python 3, under the Scheme variable names
6637@code{python-2} and @code{python} as explained in @ref{Version Numbers}.
6638To avoid confusion and naming clashes with other programming languages, it
6639seems desirable that the name of a package for a Python module contains
6640the word @code{python}.
ef5dd60a 6641
cf4a9129
LC
6642Some modules are compatible with only one version of Python, others with both.
6643If the package Foo compiles only with Python 3, we name it
6644@code{python-foo}; if it compiles only with Python 2, we name it
6645@code{python2-foo}. If it is compatible with both versions, we create two
6646packages with the corresponding names.
ef5dd60a 6647
cf4a9129
LC
6648If a project already contains the word @code{python}, we drop this;
6649for instance, the module python-dateutil is packaged under the names
6650@code{python-dateutil} and @code{python2-dateutil}.
113daf62 6651
523e4896 6652
cf4a9129
LC
6653@node Perl Modules
6654@subsection Perl Modules
523e4896 6655
cf4a9129
LC
6656Perl programs standing for themselves are named as any other package,
6657using the lowercase upstream name.
6658For Perl packages containing a single class, we use the lowercase class name,
6659replace all occurrences of @code{::} by dashes and prepend the prefix
6660@code{perl-}.
6661So the class @code{XML::Parser} becomes @code{perl-xml-parser}.
6662Modules containing several classes keep their lowercase upstream name and
6663are also prepended by @code{perl-}. Such modules tend to have the word
6664@code{perl} somewhere in their name, which gets dropped in favor of the
6665prefix. For instance, @code{libwww-perl} becomes @code{perl-libwww}.
523e4896 6666
523e4896 6667
7fec52b7
AE
6668@node Fonts
6669@subsection Fonts
6670
6671For fonts that are in general not installed by a user for typesetting
6672purposes, or that are distributed as part of a larger software package,
6673we rely on the general packaging rules for software; for instance, this
6674applies to the fonts delivered as part of the X.Org system or fonts that
6675are part of TeX Live.
6676
6677To make it easier for a user to search for fonts, names for other packages
6678containing only fonts are constructed as follows, independently of the
6679upstream package name.
6680
6681The name of a package containing only one font family starts with
6682@code{font-}; it is followed by the foundry name and a dash @code{-}
6683if the foundry is known, and the font family name, in which spaces are
6684replaced by dashes (and as usual, all upper case letters are transformed
6685to lower case).
6686For example, the Gentium font family by SIL is packaged under the name
6687@code{font-sil-gentium}.
6688
6689For a package containing several font families, the name of the collection
6690is used in the place of the font family name.
6691For instance, the Liberation fonts consist of three families,
6692Liberation Sans, Liberation Serif and Liberation Mono.
6693These could be packaged separately under the names
6694@code{font-liberation-sans} and so on; but as they are distributed together
6695under a common name, we prefer to package them together as
6696@code{font-liberation}.
6697
6698In the case where several formats of the same font family or font collection
6699are packaged separately, a short form of the format, prepended by a dash,
6700is added to the package name. We use @code{-ttf} for TrueType fonts,
1b366ee4 6701@code{-otf} for OpenType fonts and @code{-type1} for PostScript Type 1
7fec52b7
AE
6702fonts.
6703
6704
b25937e3 6705
cf4a9129
LC
6706@node Bootstrapping
6707@section Bootstrapping
b25937e3 6708
cf4a9129 6709@c Adapted from the ELS 2013 paper.
b25937e3 6710
cf4a9129 6711@cindex bootstrapping
7889394e 6712
cf4a9129
LC
6713Bootstrapping in our context refers to how the distribution gets built
6714``from nothing''. Remember that the build environment of a derivation
6715contains nothing but its declared inputs (@pxref{Introduction}). So
6716there's an obvious chicken-and-egg problem: how does the first package
6717get built? How does the first compiler get compiled? Note that this is
6718a question of interest only to the curious hacker, not to the regular
6719user, so you can shamelessly skip this section if you consider yourself
6720a ``regular user''.
72b9d60d 6721
cf4a9129
LC
6722@cindex bootstrap binaries
6723The GNU system is primarily made of C code, with libc at its core. The
6724GNU build system itself assumes the availability of a Bourne shell and
6725command-line tools provided by GNU Coreutils, Awk, Findutils, `sed', and
6726`grep'. Furthermore, build programs---programs that run
6727@code{./configure}, @code{make}, etc.---are written in Guile Scheme
6728(@pxref{Derivations}). Consequently, to be able to build anything at
6729all, from scratch, Guix relies on pre-built binaries of Guile, GCC,
6730Binutils, libc, and the other packages mentioned above---the
6731@dfn{bootstrap binaries}.
72b9d60d 6732
cf4a9129
LC
6733These bootstrap binaries are ``taken for granted'', though we can also
6734re-create them if needed (more on that later).
72b9d60d 6735
cf4a9129 6736@unnumberedsubsec Preparing to Use the Bootstrap Binaries
c79d54fe 6737
cf4a9129
LC
6738@c As of Emacs 24.3, Info-mode displays the image, but since it's a
6739@c large image, it's hard to scroll. Oh well.
6740@image{images/bootstrap-graph,6in,,Dependency graph of the early bootstrap derivations}
523e4896 6741
cf4a9129
LC
6742The figure above shows the very beginning of the dependency graph of the
6743distribution, corresponding to the package definitions of the @code{(gnu
6744packages bootstrap)} module. At this level of detail, things are
6745slightly complex. First, Guile itself consists of an ELF executable,
6746along with many source and compiled Scheme files that are dynamically
6747loaded when it runs. This gets stored in the @file{guile-2.0.7.tar.xz}
6748tarball shown in this graph. This tarball is part of Guix's ``source''
6749distribution, and gets inserted into the store with @code{add-to-store}
6750(@pxref{The Store}).
2e7b5cea 6751
cf4a9129
LC
6752But how do we write a derivation that unpacks this tarball and adds it
6753to the store? To solve this problem, the @code{guile-bootstrap-2.0.drv}
6754derivation---the first one that gets built---uses @code{bash} as its
6755builder, which runs @code{build-bootstrap-guile.sh}, which in turn calls
6756@code{tar} to unpack the tarball. Thus, @file{bash}, @file{tar},
6757@file{xz}, and @file{mkdir} are statically-linked binaries, also part of
6758the Guix source distribution, whose sole purpose is to allow the Guile
6759tarball to be unpacked.
fb729425 6760
cf4a9129
LC
6761Once @code{guile-bootstrap-2.0.drv} is built, we have a functioning
6762Guile that can be used to run subsequent build programs. Its first task
6763is to download tarballs containing the other pre-built binaries---this
6764is what the @code{.tar.xz.drv} derivations do. Guix modules such as
6765@code{ftp-client.scm} are used for this purpose. The
6766@code{module-import.drv} derivations import those modules in a directory
6767in the store, using the original layout. The
6768@code{module-import-compiled.drv} derivations compile those modules, and
6769write them in an output directory with the right layout. This
6770corresponds to the @code{#:modules} argument of
6771@code{build-expression->derivation} (@pxref{Derivations}).
fb729425 6772
cf4a9129
LC
6773Finally, the various tarballs are unpacked by the
6774derivations @code{gcc-bootstrap-0.drv}, @code{glibc-bootstrap-0.drv},
6775etc., at which point we have a working C tool chain.
fb729425 6776
fb729425 6777
cf4a9129 6778@unnumberedsubsec Building the Build Tools
523e4896 6779
cf4a9129
LC
6780@c TODO: Add a package-level dependency graph generated from (gnu
6781@c packages base).
df2ce343 6782
cf4a9129
LC
6783Bootstrapping is complete when we have a full tool chain that does not
6784depend on the pre-built bootstrap tools discussed above. This
6785no-dependency requirement is verified by checking whether the files of
6786the final tool chain contain references to the @file{/gnu/store}
6787directories of the bootstrap inputs. The process that leads to this
6788``final'' tool chain is described by the package definitions found in
1f6f57df 6789the @code{(gnu packages commencement)} module.
df2ce343 6790
cf4a9129
LC
6791@c See <http://lists.gnu.org/archive/html/gnu-system-discuss/2012-10/msg00000.html>.
6792The first tool that gets built with the bootstrap binaries is
6793GNU Make, which is a prerequisite for all the following packages.
6794From there Findutils and Diffutils get built.
523e4896 6795
cf4a9129
LC
6796Then come the first-stage Binutils and GCC, built as pseudo cross
6797tools---i.e., with @code{--target} equal to @code{--host}. They are
6798used to build libc. Thanks to this cross-build trick, this libc is
6799guaranteed not to hold any reference to the initial tool chain.
4af2447e 6800
cf4a9129
LC
6801From there the final Binutils and GCC are built. GCC uses @code{ld}
6802from the final Binutils, and links programs against the just-built libc.
6803This tool chain is used to build the other packages used by Guix and by
6804the GNU Build System: Guile, Bash, Coreutils, etc.
4af2447e 6805
cf4a9129
LC
6806And voilà! At this point we have the complete set of build tools that
6807the GNU Build System expects. These are in the @code{%final-inputs}
dd164244
MW
6808variable of the @code{(gnu packages commencement)} module, and are
6809implicitly used by any package that uses @code{gnu-build-system}
1f6f57df 6810(@pxref{Build Systems, @code{gnu-build-system}}).
4af2447e 6811
4af2447e 6812
cf4a9129 6813@unnumberedsubsec Building the Bootstrap Binaries
4af2447e 6814
cf4a9129
LC
6815Because the final tool chain does not depend on the bootstrap binaries,
6816those rarely need to be updated. Nevertheless, it is useful to have an
6817automated way to produce them, should an update occur, and this is what
6818the @code{(gnu packages make-bootstrap)} module provides.
4af2447e 6819
cf4a9129
LC
6820The following command builds the tarballs containing the bootstrap
6821binaries (Guile, Binutils, GCC, libc, and a tarball containing a mixture
6822of Coreutils and other basic command-line tools):
4b2615e1 6823
cf4a9129
LC
6824@example
6825guix build bootstrap-tarballs
6826@end example
6827
6828The generated tarballs are those that should be referred to in the
6829@code{(gnu packages bootstrap)} module mentioned at the beginning of
6830this section.
6831
6832Still here? Then perhaps by now you've started to wonder: when do we
6833reach a fixed point? That is an interesting question! The answer is
6834unknown, but if you would like to investigate further (and have
6835significant computational and storage resources to do so), then let us
6836know.
6837
6838@node Porting
6839@section Porting to a New Platform
6840
6841As discussed above, the GNU distribution is self-contained, and
6842self-containment is achieved by relying on pre-built ``bootstrap
6843binaries'' (@pxref{Bootstrapping}). These binaries are specific to an
6844operating system kernel, CPU architecture, and application binary
6845interface (ABI). Thus, to port the distribution to a platform that is
6846not yet supported, one must build those bootstrap binaries, and update
6847the @code{(gnu packages bootstrap)} module to use them on that platform.
6848
6849Fortunately, Guix can @emph{cross compile} those bootstrap binaries.
6850When everything goes well, and assuming the GNU tool chain supports the
6851target platform, this can be as simple as running a command like this
6852one:
6853
6854@example
6855guix build --target=armv5tel-linux-gnueabi bootstrap-tarballs
6856@end example
6857
1c0c417d
LC
6858For this to work, the @code{glibc-dynamic-linker} procedure in
6859@code{(gnu packages bootstrap)} must be augmented to return the right
6860file name for libc's dynamic linker on that platform; likewise,
6861@code{system->linux-architecture} in @code{(gnu packages linux)} must be
6862taught about the new platform.
6863
cf4a9129 6864Once these are built, the @code{(gnu packages bootstrap)} module needs
1c0c417d
LC
6865to be updated to refer to these binaries on the target platform. That
6866is, the hashes and URLs of the bootstrap tarballs for the new platform
6867must be added alongside those of the currently supported platforms. The
6868bootstrap Guile tarball is treated specially: it is expected to be
6869available locally, and @file{gnu-system.am} has rules do download it for
6870the supported architectures; a rule for the new platform must be added
6871as well.
cf4a9129
LC
6872
6873In practice, there may be some complications. First, it may be that the
6874extended GNU triplet that specifies an ABI (like the @code{eabi} suffix
6875above) is not recognized by all the GNU tools. Typically, glibc
6876recognizes some of these, whereas GCC uses an extra @code{--with-abi}
6877configure flag (see @code{gcc.scm} for examples of how to handle this).
6878Second, some of the required packages could fail to build for that
6879platform. Lastly, the generated binaries could be broken for some
6880reason.
4af2447e 6881
9bf3c1a7 6882@c *********************************************************************
8c01b9d0 6883@include contributing.texi
c78bd12b 6884
568717fd
LC
6885@c *********************************************************************
6886@node Acknowledgments
6887@chapter Acknowledgments
6888
6889Guix is based on the Nix package manager, which was designed and
4c7ac9aa
LC
6890implemented by Eelco Dolstra, with contributions from other people (see
6891the @file{nix/AUTHORS} file in Guix.) Nix pioneered functional package
568717fd
LC
6892management, and promoted unprecedented features, such as transactional
6893package upgrades and rollbacks, per-user profiles, and referentially
6894transparent build processes. Without this work, Guix would not exist.
6895
6896The Nix-based software distributions, Nixpkgs and NixOS, have also been
6897an inspiration for Guix.
6898
4c7ac9aa
LC
6899GNU@tie{}Guix itself is a collective work with contributions from a
6900number of people. See the @file{AUTHORS} file in Guix for more
6901information on these fine people. The @file{THANKS} file lists people
6902who have helped by reporting bugs, taking care of the infrastructure,
6903providing artwork and themes, making suggestions, and more---thank you!
6904
6905
568717fd
LC
6906@c *********************************************************************
6907@node GNU Free Documentation License
6908@appendix GNU Free Documentation License
6909
6910@include fdl-1.3.texi
6911
6912@c *********************************************************************
6913@node Concept Index
6914@unnumbered Concept Index
6915@printindex cp
6916
a85b83d2
LC
6917@node Programming Index
6918@unnumbered Programming Index
6919@syncodeindex tp fn
6920@syncodeindex vr fn
568717fd
LC
6921@printindex fn
6922
6923@bye
6924
6925@c Local Variables:
6926@c ispell-local-dictionary: "american";
6927@c End: