build: Make sure tests/guix-package.sh doesn't leave anything behind it.
[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
425b0bfc 13Copyright @copyright{} 2012, 2013, 2014 Ludovic Courtès@*
af8a56b8 14Copyright @copyright{} 2013, 2014 Andreas Enge@*
7df7a74e
NK
15Copyright @copyright{} 2013 Nikita Karetnikov
16
17Permission is granted to copy, distribute and/or modify this document
18under the terms of the GNU Free Documentation License, Version 1.3 or
19any later version published by the Free Software Foundation; with no
20Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A
21copy of the license is included in the section entitled ``GNU Free
22Documentation License''.
23@end copying
568717fd 24
eeaf4427 25@dircategory Package management
568717fd
LC
26@direntry
27* guix: (guix). Guix, the functional package manager.
e49951eb 28* guix package: (guix)Invoking guix package
eeaf4427 29 Managing packages with Guix.
e49951eb 30* guix build: (guix)Invoking guix build
568717fd 31 Building packages with Guix.
054e8576
LC
32* guix system: (guix)Invoking guix system
33 Managing the operating system configuration.
568717fd 34@end direntry
568717fd
LC
35
36@titlepage
7730d112
LC
37@title GNU Guix Reference Manual
38@subtitle Using the GNU Guix Functional Package Manager
568717fd 39@author Ludovic Courtès
da7cabd4 40@author Andreas Enge
acc08466 41@author Nikita Karetnikov
568717fd
LC
42
43@page
44@vskip 0pt plus 1filll
45Edition @value{EDITION} @*
46@value{UPDATED} @*
47
7df7a74e 48@insertcopying
568717fd
LC
49@end titlepage
50
568717fd
LC
51@contents
52
53@c *********************************************************************
54@node Top
f8348b91 55@top GNU Guix
568717fd 56
f8348b91
LC
57This document describes GNU Guix version @value{VERSION}, a functional
58package management tool written for the GNU system.
568717fd
LC
59
60@menu
61* Introduction:: What is Guix about?
bd5e766b 62* Installation:: Installing Guix.
eeaf4427 63* Package Management:: Package installation, upgrade, etc.
568717fd
LC
64* Programming Interface:: Using Guix in Scheme.
65* Utilities:: Package management commands.
a1ba8475 66* GNU Distribution:: Software for your friendly GNU system.
9bf3c1a7 67* Contributing:: Your help needed!
568717fd
LC
68
69* Acknowledgments:: Thanks!
70* GNU Free Documentation License:: The license of this manual.
71* Concept Index:: Concepts.
a85b83d2 72* Programming Index:: Data types, functions, and variables.
568717fd
LC
73@end menu
74
75@c *********************************************************************
76@node Introduction
77@chapter Introduction
78
c80e7e55
LC
79GNU Guix@footnote{``Guix'' is pronounced like ``geeks'', or ``ɡiːks''
80using the international phonetic alphabet (IPA).} is a functional
81package management tool for the GNU system. Package management consists
4bfc4ea3
NK
82of all activities that relate to building packages from sources,
83honoring their build-time and run-time dependencies,
c80e7e55
LC
84installing packages in user environments, upgrading installed packages
85to new versions or rolling back to a previous set, removing unused
86software packages, etc.
568717fd
LC
87
88@cindex functional package management
89The term @dfn{functional} refers to a specific package management
90discipline. In Guix, the package build and installation process is seen
4bfc4ea3
NK
91as a function, in the mathematical sense. That function takes inputs,
92such as build scripts, a compiler, and libraries, and
93returns an installed package. As a pure function, its result depends
568717fd
LC
94solely on its inputs---for instance, it cannot refer to software or
95scripts that were not explicitly passed as inputs. A build function
4bfc4ea3
NK
96always produces the same result when passed a given set of inputs. It
97cannot alter the system's environment in
568717fd
LC
98any way; for instance, it cannot create, modify, or delete files outside
99of its build and installation directories. This is achieved by running
e900c503 100build processes in isolated environments (or @dfn{containers}), where only their
4bfc4ea3 101explicit inputs are visible.
568717fd 102
e531ac2a 103@cindex store
568717fd 104The result of package build functions is @dfn{cached} in the file
e531ac2a
LC
105system, in a special directory called @dfn{the store} (@pxref{The
106Store}). Each package is installed in a directory of its own, in the
834129e0 107store---by default under @file{/gnu/store}. The directory name contains
568717fd
LC
108a hash of all the inputs used to build that package; thus, changing an
109input yields a different directory name.
110
111This approach is the foundation of Guix's salient features: support for
4bfc4ea3 112transactional package upgrade and rollback, per-user installation, and
eeaf4427 113garbage collection of packages (@pxref{Features}).
568717fd 114
4bfc4ea3 115Guix has a command-line interface, which allows users to build, install,
568717fd 116upgrade, and remove packages, as well as a Scheme programming interface.
568717fd 117
a1ba8475
LC
118Last but not least, Guix is used to build a distribution of the GNU
119system, with many GNU and non-GNU free software packages. @xref{GNU
120Distribution}.
121
bd5e766b
LC
122@c *********************************************************************
123@node Installation
124@chapter Installation
125
48febeb8
LC
126GNU Guix is available for download from its website at
127@url{http://www.gnu.org/software/guix/}. This section describes the
128software requirements of Guix, as well as how to install it and get
129ready to use it.
bd5e766b 130
5af6de3e
LC
131Note that this section is concerned with the installation of the package
132manager, which can be done on top of a running GNU/Linux system. If,
133instead, you want to install the complete GNU operating system,
6621cdb6 134@pxref{System Installation}.
5af6de3e 135
b22a12fd 136The build procedure for Guix is the same as for other GNU software, and
1da983b9 137is not covered here. Please see the files @file{README} and
b22a12fd
LC
138@file{INSTALL} in the Guix source tree for additional details.
139
bd5e766b
LC
140@menu
141* Requirements:: Software needed to build and run Guix.
142* Setting Up the Daemon:: Preparing the build daemon's environment.
143* Invoking guix-daemon:: Running the build daemon.
144@end menu
145
146@node Requirements
147@section Requirements
148
149GNU Guix depends on the following packages:
150
151@itemize
4a328f73 152@item @url{http://gnu.org/software/guile/, GNU Guile}, version 2.0.5 or later;
288dca55
LC
153@item @url{http://gnupg.org/, GNU libgcrypt};
154@item
155optionally, installing
156@url{http://savannah.nongnu.org/projects/guile-json/, Guile-JSON} will
157allow you to use the @command{guix import pypi} command; it is of
158interest primarily for developers and not for casual users.
bd5e766b
LC
159@end itemize
160
161Unless @code{--disable-daemon} was passed to @command{configure}, the
162following packages are also needed:
163
164@itemize
165@item @url{http://sqlite.org, SQLite 3}
166@item @url{http://www.bzip.org, libbz2}
167@item @url{http://gcc.gnu.org, GCC's g++}
168@end itemize
169
4bfc4ea3
NK
170When a working installation of @url{http://nixos.org/nix/, the Nix package
171manager} is available, you
bd5e766b 172can instead configure Guix with @code{--disable-daemon}. In that case,
4bfc4ea3 173Nix replaces the three dependencies above.
bd5e766b 174
b22a12fd
LC
175Guix is compatible with Nix, so it is possible to share the same store
176between both. To do so, you must pass @command{configure} not only the
177same @code{--with-store-dir} value, but also the same
4bfc4ea3
NK
178@code{--localstatedir} value. The latter is essential because it
179specifies where the database that stores metadata about the store is
834129e0 180located, among other things. The default values for Nix are
b22a12fd 181@code{--with-store-dir=/nix/store} and @code{--localstatedir=/nix/var}.
4bfc4ea3
NK
182Note that @code{--disable-daemon} is not required if
183your goal is to share the store with Nix.
b22a12fd 184
bd5e766b
LC
185@node Setting Up the Daemon
186@section Setting Up the Daemon
187
188@cindex daemon
189Operations such as building a package or running the garbage collector
49e6291a 190are all performed by a specialized process, the @dfn{build daemon}, on
bd5e766b
LC
191behalf of clients. Only the daemon may access the store and its
192associated database. Thus, any operation that manipulates the store
193goes through the daemon. For instance, command-line tools such as
e49951eb 194@command{guix package} and @command{guix build} communicate with the
bd5e766b
LC
195daemon (@i{via} remote procedure calls) to instruct it what to do.
196
49e6291a
LC
197The following sections explain how to prepare the build daemon's
198environment.
199
200@menu
201* Build Environment Setup:: Preparing the isolated build environment.
202* Daemon Offload Setup:: Offloading builds to remote machines.
203@end menu
204
205@node Build Environment Setup
206@subsection Build Environment Setup
207
bd5e766b
LC
208In a standard multi-user setup, Guix and its daemon---the
209@command{guix-daemon} program---are installed by the system
834129e0 210administrator; @file{/gnu/store} is owned by @code{root} and
bd5e766b
LC
211@command{guix-daemon} runs as @code{root}. Unprivileged users may use
212Guix tools to build packages or otherwise access the store, and the
213daemon will do it on their behalf, ensuring that the store is kept in a
214consistent state, and allowing built packages to be shared among users.
215
216@cindex build users
217When @command{guix-daemon} runs as @code{root}, you may not want package
218build processes themselves to run as @code{root} too, for obvious
219security reasons. To avoid that, a special pool of @dfn{build users}
220should be created for use by build processes started by the daemon.
221These build users need not have a shell and a home directory: they will
222just be used when the daemon drops @code{root} privileges in build
223processes. Having several such users allows the daemon to launch
224distinct build processes under separate UIDs, which guarantees that they
225do not interfere with each other---an essential feature since builds are
226regarded as pure functions (@pxref{Introduction}).
227
228On a GNU/Linux system, a build user pool may be created like this (using
229Bash syntax and the @code{shadow} commands):
230
091196b3
LC
231@c See http://lists.gnu.org/archive/html/bug-guix/2013-01/msg00239.html
232@c for why `-G' is needed.
bd5e766b
LC
233@example
234# groupadd guix-builder
235# for i in `seq 1 10`;
236 do
091196b3
LC
237 useradd -g guix-builder -G guix-builder \
238 -d /var/empty -s `which nologin` \
4d1a2b50
LC
239 -c "Guix build user $i" --system \
240 guix-builder$i;
bd5e766b
LC
241 done
242@end example
243
244@noindent
245The @code{guix-daemon} program may then be run as @code{root} with:
246
247@example
248# guix-daemon --build-users-group=guix-builder
249@end example
250
e900c503 251@cindex chroot
b095792f
LC
252@noindent
253This way, the daemon starts build processes in a chroot, under one of
254the @code{guix-builder} users. On GNU/Linux, by default, the chroot
6dc99317
LC
255environment contains nothing but:
256
257@c Keep this list in sync with libstore/build.cc! -----------------------
258@itemize
259@item
4743a4da
LC
260a minimal @code{/dev} directory, created mostly independently from the
261host @code{/dev}@footnote{``Mostly'', because while the set of files
262that appear in the chroot's @code{/dev} is fixed, most of these files
263can only be created if the host has them.};
264
265@item
266the @code{/proc} directory; it only shows the container's processes
267since a separate PID name space is used;
6dc99317
LC
268
269@item
270@file{/etc/passwd} with an entry for the current user and an entry for
271user @file{nobody};
272
273@item
274@file{/etc/group} with an entry for the user's group;
275
276@item
277@file{/etc/hosts} with an entry that maps @code{localhost} to
278@code{127.0.0.1};
279
280@item
281a writable @file{/tmp} directory.
282@end itemize
b095792f 283
d43eb499 284If you are installing Guix as an unprivileged user, it is still
bd5e766b
LC
285possible to run @command{guix-daemon}. However, build processes will
286not be isolated from one another, and not from the rest of the system.
287Thus, build processes may interfere with each other, and may access
288programs, libraries, and other files available on the system---making it
289much harder to view them as @emph{pure} functions.
290
49e6291a
LC
291
292@node Daemon Offload Setup
293@subsection Using the Offload Facility
294
295@cindex offloading
4ec2e92d
LC
296@cindex build hook
297When desired, the build daemon can @dfn{offload}
298derivation builds to other machines
49e6291a
LC
299running Guix, using the @code{offload} @dfn{build hook}. When that
300feature is enabled, a list of user-specified build machines is read from
301@file{/etc/guix/machines.scm}; anytime a build is requested, for
302instance via @code{guix build}, the daemon attempts to offload it to one
303of the machines that satisfies the derivation's constraints, in
304particular its system type---e.g., @file{x86_64-linux}. Missing
305prerequisites for the build are copied over SSH to the target machine,
306which then proceeds with the build; upon success the output(s) of the
307build are copied back to the initial machine.
308
4ec2e92d 309The @file{/etc/guix/machines.scm} file typically looks like this:
49e6291a
LC
310
311@example
312(list (build-machine
313 (name "eightysix.example.org")
314 (system "x86_64-linux")
315 (user "bob")
316 (speed 2.)) ; incredibly fast!
317
318 (build-machine
319 (name "meeps.example.org")
320 (system "mips64el-linux")
321 (user "alice")
322 (private-key
323 (string-append (getenv "HOME")
324 "/.ssh/id-rsa-for-guix"))))
325@end example
326
327@noindent
328In the example above we specify a list of two build machines, one for
329the @code{x86_64} architecture and one for the @code{mips64el}
4ec2e92d
LC
330architecture.
331
332In fact, this file is---not surprisingly!---a Scheme file that is
333evaluated when the @code{offload} hook is started. Its return value
334must be a list of @code{build-machine} objects. While this example
335shows a fixed list of build machines, one could imagine, say, using
336DNS-SD to return a list of potential build machines discovered in the
337local network (@pxref{Introduction, Guile-Avahi,, guile-avahi, Using
c678a4ee
LC
338Avahi in Guile Scheme Programs}). The @code{build-machine} data type is
339detailed below.
4ec2e92d 340
c678a4ee
LC
341@deftp {Data Type} build-machine
342This data type represents build machines the daemon may offload builds
343to. The important fields are:
49e6291a
LC
344
345@table @code
346
347@item name
348The remote machine's host name.
349
350@item system
c678a4ee 351The remote machine's system type---e.g., @code{"x86_64-linux"}.
49e6291a
LC
352
353@item user
354The user account to use when connecting to the remote machine over SSH.
355Note that the SSH key pair must @emph{not} be passphrase-protected, to
356allow non-interactive logins.
357
358@end table
359
4ec2e92d 360A number of optional fields may be specified:
49e6291a
LC
361
362@table @code
363
cecd72d5
LC
364@item port
365Port number of the machine's SSH server (default: 22).
366
49e6291a
LC
367@item private-key
368The SSH private key file to use when connecting to the machine.
369
370@item parallel-builds
371The number of builds that may run in parallel on the machine (1 by
372default.)
373
374@item speed
375A ``relative speed factor''. The offload scheduler will tend to prefer
376machines with a higher speed factor.
377
378@item features
379A list of strings denoting specific features supported by the machine.
380An example is @code{"kvm"} for machines that have the KVM Linux modules
381and corresponding hardware support. Derivations can request features by
382name, and they will be scheduled on matching build machines.
383
384@end table
c678a4ee 385@end deftp
49e6291a
LC
386
387The @code{guix} command must be in the search path on the build
388machines, since offloading works by invoking the @code{guix archive} and
389@code{guix build} commands.
390
391There's one last thing to do once @file{machines.scm} is in place. As
392explained above, when offloading, files are transferred back and forth
393between the machine stores. For this to work, you need to generate a
394key pair to allow the daemon to export signed archives of files from the
395store (@pxref{Invoking guix archive}):
396
397@example
398# guix archive --generate-key
399@end example
400
401@noindent
402Thus, when receiving files, a machine's build daemon can make sure they
403are genuine, have not been tampered with, and that they are signed by an
404authorized key.
405
406
bd5e766b
LC
407@node Invoking guix-daemon
408@section Invoking @command{guix-daemon}
409
410The @command{guix-daemon} program implements all the functionality to
411access the store. This includes launching build processes, running the
412garbage collector, querying the availability of a build result, etc. It
413is normally run as @code{root} like this:
414
415@example
416# guix-daemon --build-users-group=guix-builder
417@end example
418
419@noindent
420For details on how to set it up, @ref{Setting Up the Daemon}.
421
e900c503
LC
422@cindex chroot
423@cindex container, build environment
424@cindex build environment
425@cindex reproducible builds
bd5e766b
LC
426By default, @command{guix-daemon} launches build processes under
427different UIDs, taken from the build group specified with
428@code{--build-users-group}. In addition, each build process is run in a
429chroot environment that only contains the subset of the store that the
430build process depends on, as specified by its derivation
431(@pxref{Programming Interface, derivation}), plus a set of specific
432system directories. By default, the latter contains @file{/dev} and
e900c503
LC
433@file{/dev/pts}. Furthermore, on GNU/Linux, the build environment is a
434@dfn{container}: in addition to having its own file system tree, it has
435a separate mount name space, its own PID name space, network name space,
436etc. This helps achieve reproducible builds (@pxref{Features}).
bd5e766b
LC
437
438The following command-line options are supported:
439
440@table @code
441@item --build-users-group=@var{group}
442Take users from @var{group} to run build processes (@pxref{Setting Up
443the Daemon, build users}).
444
6858f9d1 445@item --no-substitutes
b5385b52 446@cindex substitutes
6858f9d1 447Do not use substitutes for build products. That is, always build things
c4202d60
LC
448locally instead of allowing downloads of pre-built binaries
449(@pxref{Substitutes}).
6858f9d1 450
b5385b52
LC
451By default substitutes are used, unless the client---such as the
452@command{guix package} command---is explicitly invoked with
453@code{--no-substitutes}.
454
455When the daemon runs with @code{--no-substitutes}, clients can still
456explicitly enable substitution @i{via} the @code{set-build-options}
457remote procedure call (@pxref{The Store}).
458
9176607e
LC
459@item --substitute-urls=@var{urls}
460Consider @var{urls} the default whitespace-separated list of substitute
461source URLs. When this option is omitted, @code{http://hydra.gnu.org}
462is used.
463
464This means that substitutes may be downloaded from @var{urls}, as long
465as they are signed by a trusted signature (@pxref{Substitutes}).
466
4ec2e92d
LC
467@cindex build hook
468@item --no-build-hook
469Do not use the @dfn{build hook}.
470
471The build hook is a helper program that the daemon can start and to
472which it submits build requests. This mechanism is used to offload
473builds to other machines (@pxref{Daemon Offload Setup}).
474
bd5e766b
LC
475@item --cache-failures
476Cache build failures. By default, only successful builds are cached.
477
478@item --cores=@var{n}
479@itemx -c @var{n}
480Use @var{n} CPU cores to build each derivation; @code{0} means as many
481as available.
482
483The default value is @code{1}, but it may be overridden by clients, such
e49951eb
MW
484as the @code{--cores} option of @command{guix build} (@pxref{Invoking
485guix build}).
bd5e766b
LC
486
487The effect is to define the @code{NIX_BUILD_CORES} environment variable
488in the build process, which can then use it to exploit internal
489parallelism---for instance, by running @code{make -j$NIX_BUILD_CORES}.
490
491@item --max-jobs=@var{n}
492@itemx -M @var{n}
493Allow at most @var{n} build jobs in parallel. The default value is
494@code{1}.
495
496@item --debug
497Produce debugging output.
498
499This is useful to debug daemon start-up issues, but then it may be
500overridden by clients, for example the @code{--verbosity} option of
e49951eb 501@command{guix build} (@pxref{Invoking guix build}).
bd5e766b
LC
502
503@item --chroot-directory=@var{dir}
504Add @var{dir} to the build chroot.
505
506Doing this may change the result of build processes---for instance if
507they use optional dependencies found in @var{dir} when it is available,
508and not otherwise. For that reason, it is not recommended to do so.
509Instead, make sure that each derivation declares all the inputs that it
510needs.
511
512@item --disable-chroot
513Disable chroot builds.
514
515Using this option is not recommended since, again, it would allow build
516processes to gain access to undeclared dependencies.
517
518@item --disable-log-compression
519Disable compression of the build logs.
520
1da983b9
LC
521Unless @code{--lose-logs} is used, all the build logs are kept in the
522@var{localstatedir}. To save space, the daemon automatically compresses
523them with bzip2 by default. This option disables that.
524
ab3893d7
LC
525@item --disable-deduplication
526@cindex deduplication
bd5e766b
LC
527Disable automatic file ``deduplication'' in the store.
528
1da983b9 529By default, files added to the store are automatically ``deduplicated'':
ab3893d7
LC
530if a newly added file is identical to another one found in the store,
531the daemon makes the new file a hard link to the other file. This can
532noticeably reduce disk usage, at the expense of slightly increasde
533input/output load at the end of a build process. This option disables
534this optimization.
1da983b9 535
6e37066e
LC
536@item --gc-keep-outputs[=yes|no]
537Tell whether the garbage collector (GC) must keep outputs of live
538derivations.
539
540When set to ``yes'', the GC will keep the outputs of any live derivation
541available in the store---the @code{.drv} files. The default is ``no'',
542meaning that derivation outputs are kept only if they are GC roots.
543
544@item --gc-keep-derivations[=yes|no]
545Tell whether the garbage collector (GC) must keep derivations
546corresponding to live outputs.
547
548When set to ``yes'', as is the case by default, the GC keeps
549derivations---i.e., @code{.drv} files---as long as at least one of their
550outputs is live. This allows users to keep track of the origins of
551items in their store. Setting it to ``no'' saves a bit of disk space.
552
553Note that when both @code{--gc-keep-derivations} and
554@code{--gc-keep-outputs} are used, the effect is to keep all the build
555prerequisites (the sources, compiler, libraries, and other build-time
556tools) of live objects in the store, regardless of whether these
557prerequisites are live. This is convenient for developers since it
558saves rebuilds or downloads.
559
bd5e766b
LC
560@item --impersonate-linux-2.6
561On Linux-based systems, impersonate Linux 2.6. This means that the
562kernel's @code{uname} system call will report 2.6 as the release number.
563
564This might be helpful to build programs that (usually wrongfully) depend
565on the kernel version number.
566
567@item --lose-logs
568Do not keep build logs. By default they are kept under
ce33631f 569@code{@var{localstatedir}/guix/log}.
bd5e766b
LC
570
571@item --system=@var{system}
572Assume @var{system} as the current system type. By default it is the
573architecture/kernel pair found at configure time, such as
574@code{x86_64-linux}.
b8d2aa26
LC
575
576@item --listen=@var{socket}
577Listen for connections on @var{socket}, the file name of a Unix-domain
578socket. The default socket is
579@file{@var{localstatedir}/daemon-socket/socket}. This option is only
580useful in exceptional circumstances, such as if you need to run several
581daemons on the same machine.
bd5e766b
LC
582@end table
583
584
eeaf4427
LC
585@c *********************************************************************
586@node Package Management
587@chapter Package Management
588
f8348b91 589The purpose of GNU Guix is to allow users to easily install, upgrade, and
eeaf4427
LC
590remove software packages, without having to know about their build
591procedure or dependencies. Guix also goes beyond this obvious set of
592features.
593
594This chapter describes the main features of Guix, as well as the package
595management tools it provides.
596
597@menu
598* Features:: How Guix will make your life brighter.
e49951eb 599* Invoking guix package:: Package installation, removal, etc.
457f60fa 600* Emacs Interface:: Package management from Emacs.
c4202d60 601* Substitutes:: Downloading pre-built binaries.
760c60d6 602* Packages with Multiple Outputs:: Single source package, multiple outputs.
e49951eb 603* Invoking guix gc:: Running the garbage collector.
f651b477 604* Invoking guix pull:: Fetching the latest Guix and distribution.
760c60d6 605* Invoking guix archive:: Exporting and importing store files.
eeaf4427
LC
606@end menu
607
608@node Features
609@section Features
610
611When using Guix, each package ends up in the @dfn{package store}, in its
612own directory---something that resembles
834129e0 613@file{/gnu/store/xxx-package-1.2}, where @code{xxx} is a base32 string.
eeaf4427
LC
614
615Instead of referring to these directories, users have their own
616@dfn{profile}, which points to the packages that they actually want to
821b0015
LC
617use. These profiles are stored within each user's home directory, at
618@code{$HOME/.guix-profile}.
eeaf4427 619
821b0015 620For example, @code{alice} installs GCC 4.7.2. As a result,
eeaf4427 621@file{/home/alice/.guix-profile/bin/gcc} points to
834129e0 622@file{/gnu/store/@dots{}-gcc-4.7.2/bin/gcc}. Now, on the same machine,
821b0015
LC
623@code{bob} had already installed GCC 4.8.0. The profile of @code{bob}
624simply continues to point to
834129e0 625@file{/gnu/store/@dots{}-gcc-4.8.0/bin/gcc}---i.e., both versions of GCC
821b0015 626coexist on the same system without any interference.
eeaf4427 627
e49951eb
MW
628The @command{guix package} command is the central tool to manage
629packages (@pxref{Invoking guix package}). It operates on those per-user
821b0015 630profiles, and can be used @emph{with normal user privileges}.
eeaf4427
LC
631
632The command provides the obvious install, remove, and upgrade
633operations. Each invocation is actually a @emph{transaction}: either
ba55b1cb 634the specified operation succeeds, or nothing happens. Thus, if the
e49951eb 635@command{guix package} process is terminated during the transaction,
eeaf4427
LC
636or if a power outage occurs during the transaction, then the user's
637profile remains in its previous state, and remains usable.
638
639In addition, any package transaction may be @emph{rolled back}. So, if,
640for example, an upgrade installs a new version of a package that turns
641out to have a serious bug, users may roll back to the previous instance
4af2447e
LC
642of their profile, which was known to work well. Similarly, the global
643system configuration is subject to transactional upgrades and roll-back
644(@pxref{Using the Configuration System}).
eeaf4427
LC
645
646All those packages in the package store may be @emph{garbage-collected}.
647Guix can determine which packages are still referenced by the user
fe8ff028 648profiles, and remove those that are provably no longer referenced
e49951eb 649(@pxref{Invoking guix gc}). Users may also explicitly remove old
fe8ff028
LC
650generations of their profile so that the packages they refer to can be
651collected.
eeaf4427 652
e900c503
LC
653@cindex reproducibility
654@cindex reproducible builds
eeaf4427
LC
655Finally, Guix takes a @dfn{purely functional} approach to package
656management, as described in the introduction (@pxref{Introduction}).
834129e0 657Each @file{/gnu/store} package directory name contains a hash of all the
eeaf4427
LC
658inputs that were used to build that package---compiler, libraries, build
659scripts, etc. This direct correspondence allows users to make sure a
660given package installation matches the current state of their
e900c503
LC
661distribution. It also helps maximize @dfn{build reproducibility}:
662thanks to the isolated build environments that are used, a given build
663is likely to yield bit-identical files when performed on different
664machines (@pxref{Invoking guix-daemon, container}).
eeaf4427 665
c4202d60 666@cindex substitutes
eeaf4427 667This foundation allows Guix to support @dfn{transparent binary/source
c4202d60 668deployment}. When a pre-built binary for a @file{/gnu/store} item is
18f2887b 669available from an external source---a @dfn{substitute}, Guix just
c4202d60
LC
670downloads it and unpacks it;
671otherwise, it builds the package from source, locally
672(@pxref{Substitutes}).
eeaf4427 673
e49951eb
MW
674@node Invoking guix package
675@section Invoking @command{guix package}
eeaf4427 676
e49951eb 677The @command{guix package} command is the tool that allows users to
eeaf4427
LC
678install, upgrade, and remove packages, as well as rolling back to
679previous configurations. It operates only on the user's own profile,
680and works with normal user privileges (@pxref{Features}). Its syntax
681is:
682
683@example
e49951eb 684guix package @var{options}
eeaf4427
LC
685@end example
686
ba55b1cb 687Primarily, @var{options} specifies the operations to be performed during
eeaf4427
LC
688the transaction. Upon completion, a new profile is created, but
689previous generations of the profile remain available, should the user
690want to roll back.
691
6447738c
MW
692For example, to remove @code{lua} and install @code{guile} and
693@code{guile-cairo} in a single transaction:
694
695@example
696guix package -r lua -i guile guile-cairo
697@end example
698
b9e5c0a9 699For each user, a symlink to the user's default profile is automatically
0ec1af59 700created in @file{$HOME/.guix-profile}. This symlink always points to the
b9e5c0a9
LC
701current generation of the user's default profile. Thus, users can add
702@file{$HOME/.guix-profile/bin} to their @code{PATH} environment
703variable, and so on.
704
0ec1af59
LC
705In a multi-user setup, user profiles must be stored in a place
706registered as a @dfn{garbage-collector root}, which
e49951eb 707@file{$HOME/.guix-profile} points to (@pxref{Invoking guix gc}). That
0ec1af59
LC
708directory is normally
709@code{@var{localstatedir}/profiles/per-user/@var{user}}, where
710@var{localstatedir} is the value passed to @code{configure} as
711@code{--localstatedir}, and @var{user} is the user name. It must be
712created by @code{root}, with @var{user} as the owner. When it does not
70c43291
LC
713exist, or is not owned by @var{user}, @command{guix package} emits an
714error about it.
0ec1af59
LC
715
716The @var{options} can be among the following:
717
eeaf4427
LC
718@table @code
719
6447738c
MW
720@item --install=@var{package} @dots{}
721@itemx -i @var{package} @dots{}
722Install the specified @var{package}s.
eeaf4427 723
6447738c 724Each @var{package} may specify either a simple package name, such as
eeaf4427 725@code{guile}, or a package name followed by a hyphen and version number,
dc5669cd
MW
726such as @code{guile-1.8.8}. If no version number is specified, the
727newest available version will be selected. In addition, @var{package}
728may contain a colon, followed by the name of one of the outputs of the
6e721c4d 729package, as in @code{gcc:doc} or @code{binutils-2.22:lib}
e7f34eb0
LC
730(@pxref{Packages with Multiple Outputs}). Packages with a corresponding
731name (and optionally version) are searched for among the GNU
732distribution modules (@pxref{Package Modules}).
eeaf4427 733
461572cc
LC
734@cindex propagated inputs
735Sometimes packages have @dfn{propagated inputs}: these are dependencies
736that automatically get installed along with the required package.
737
738An example is the GNU MPC library: its C header files refer to those of
739the GNU MPFR library, which in turn refer to those of the GMP library.
740Thus, when installing MPC, the MPFR and GMP libraries also get installed
741in the profile; removing MPC also removes MPFR and GMP---unless they had
742also been explicitly installed independently.
743
ba7ea5ce 744Besides, packages sometimes rely on the definition of environment
5924080d 745variables for their search paths (see explanation of
ba7ea5ce 746@code{--search-paths} below). Any missing or possibly incorrect
5924080d
LC
747environment variable definitions are reported here.
748
ef010c0f 749@c XXX: keep me up-to-date
5924080d 750Finally, when installing a GNU package, the tool reports the
ef010c0f
LC
751availability of a newer upstream version. In the future, it may provide
752the option of installing directly from the upstream version, even if
753that version is not yet in the distribution.
754
5d4b411f
LC
755@item --install-from-expression=@var{exp}
756@itemx -e @var{exp}
757Install the package @var{exp} evaluates to.
758
759@var{exp} must be a Scheme expression that evaluates to a
760@code{<package>} object. This option is notably useful to disambiguate
761between same-named variants of a package, with expressions such as
762@code{(@@ (gnu packages base) guile-final)}.
763
764Note that this option installs the first output of the specified
765package, which may be insufficient when needing a specific output of a
766multiple-output package.
767
6447738c
MW
768@item --remove=@var{package} @dots{}
769@itemx -r @var{package} @dots{}
770Remove the specified @var{package}s.
eeaf4427 771
6447738c 772As for @code{--install}, each @var{package} may specify a version number
13ed095c
LC
773and/or output name in addition to the package name. For instance,
774@code{-r glibc:debug} would remove the @code{debug} output of
775@code{glibc}.
776
6447738c
MW
777@item --upgrade[=@var{regexp} @dots{}]
778@itemx -u [@var{regexp} @dots{}]
779Upgrade all the installed packages. If one or more @var{regexp}s are
780specified, upgrade only installed packages whose name matches a
781@var{regexp}.
eeaf4427 782
f651b477
LC
783Note that this upgrades package to the latest version of packages found
784in the distribution currently installed. To update your distribution,
785you should regularly run @command{guix pull} (@pxref{Invoking guix
786pull}).
787
24e262f0
LC
788@item --roll-back
789Roll back to the previous @dfn{generation} of the profile---i.e., undo
790the last transaction.
791
792When combined with options such as @code{--install}, roll back occurs
793before any other actions.
794
d9307267 795When rolling back from the first generation that actually contains
4b2bc804
NK
796installed packages, the profile is made to point to the @dfn{zeroth
797generation}, which contains no files apart from its own meta-data.
d9307267 798
82fe08ed
LC
799Installing, removing, or upgrading packages from a generation that has
800been rolled back to overwrites previous future generations. Thus, the
801history of a profile's generations is always linear.
802
5924080d
LC
803@item --search-paths
804@cindex search paths
805Report environment variable definitions, in Bash syntax, that may be
806needed in order to use the set of installed packages. These environment
807variables are used to specify @dfn{search paths} for files used by some
808of the installed packages.
809
810For example, GCC needs the @code{CPATH} and @code{LIBRARY_PATH}
811environment variables to be defined so it can look for headers and
812libraries in the user's profile (@pxref{Environment Variables,,, gcc,
813Using the GNU Compiler Collection (GCC)}). If GCC and, say, the C
814library are installed in the profile, then @code{--search-paths} will
815suggest setting these variables to @code{@var{profile}/include} and
816@code{@var{profile}/lib}, respectively.
817
eeaf4427
LC
818@item --profile=@var{profile}
819@itemx -p @var{profile}
820Use @var{profile} instead of the user's default profile.
821
70915c1a
LC
822@item --verbose
823Produce verbose output. In particular, emit the environment's build log
824on the standard error port.
825
eeaf4427
LC
826@item --bootstrap
827Use the bootstrap Guile to build the profile. This option is only
828useful to distribution developers.
829
830@end table
831
e49951eb 832In addition to these actions @command{guix package} supports the
733b4130
LC
833following options to query the current state of a profile, or the
834availability of packages:
eeaf4427 835
733b4130
LC
836@table @option
837
acc08466
NK
838@item --search=@var{regexp}
839@itemx -s @var{regexp}
840List the available packages whose synopsis or description matches
299112d3
LC
841@var{regexp}. Print all the meta-data of matching packages in
842@code{recutils} format (@pxref{Top, GNU recutils databases,, recutils,
843GNU recutils manual}).
acc08466 844
299112d3
LC
845This allows specific fields to be extracted using the @command{recsel}
846command, for instance:
847
848@example
e49951eb 849$ guix package -s malloc | recsel -p name,version
299112d3
LC
850name: glibc
851version: 2.17
852
853name: libgc
854version: 7.2alpha6
855@end example
acc08466 856
a12d92f5
LC
857Similarly, to show the name of all the packages available under the
858terms of the GNU@tie{}LGPL version 3:
859
860@example
861$ guix package -s "" | recsel -p name -e 'license ~ "LGPL 3"'
862name: elfutils
863
864name: gmp
865@dots{}
866@end example
867
2aa6efb0
CR
868@item --show=@var{package}
869Show details about @var{package}, taken from the list of available packages, in
870@code{recutils} format (@pxref{Top, GNU recutils databases,, recutils, GNU
871recutils manual}).
872
873@example
874$ guix package --show=python | recsel -p name,version
875name: python
876version: 2.7.6
877
878name: python
879version: 3.3.5
880@end example
881
882You may also specify the full name of a package to only get details about a
883specific version of it:
884@example
885$ guix package --show=python-3.3.5 | recsel -p name,version
886name: python
887version: 3.3.5
888@end example
889
890
891
733b4130
LC
892@item --list-installed[=@var{regexp}]
893@itemx -I [@var{regexp}]
bd9bde1c
LC
894List the currently installed packages in the specified profile, with the
895most recently installed packages shown last. When @var{regexp} is
896specified, list only installed packages whose name matches @var{regexp}.
733b4130
LC
897
898For each installed package, print the following items, separated by
899tabs: the package name, its version string, the part of the package that
900is installed (for instance, @code{out} for the default output,
901@code{include} for its headers, etc.), and the path of this package in
902the store.
903
64fc89b6
LC
904@item --list-available[=@var{regexp}]
905@itemx -A [@var{regexp}]
a1ba8475
LC
906List packages currently available in the software distribution
907(@pxref{GNU Distribution}). When @var{regexp} is specified, list only
908installed packages whose name matches @var{regexp}.
64fc89b6
LC
909
910For each package, print the following items separated by tabs: its name,
6e721c4d
LC
911its version string, the parts of the package (@pxref{Packages with
912Multiple Outputs}), and the source location of its definition.
64fc89b6 913
f566d765
LC
914@item --list-generations[=@var{pattern}]
915@itemx -l [@var{pattern}]
916Return a list of generations along with their creation dates; for each
917generation, show the installed packages, with the most recently
4b2bc804
NK
918installed packages shown last. Note that the zeroth generation is never
919shown.
f566d765
LC
920
921For each installed package, print the following items, separated by
922tabs: the name of a package, its version string, the part of the package
923that is installed (@pxref{Packages with Multiple Outputs}), and the
924location of this package in the store.
925
926When @var{pattern} is used, the command returns only matching
927generations. Valid patterns include:
928
929@itemize
930@item @emph{Integers and comma-separated integers}. Both patterns denote
931generation numbers. For instance, @code{--list-generations=1} returns
932the first one.
933
934And @code{--list-generations=1,8,2} outputs three generations in the
935specified order. Neither spaces nor trailing commas are allowed.
936
937@item @emph{Ranges}. @code{--list-generations=2..9} prints the
938specified generations and everything in between. Note that the start of
939a range must be lesser than its end.
940
941It is also possible to omit the endpoint. For example,
942@code{--list-generations=2..}, returns all generations starting from the
943second one.
944
945@item @emph{Durations}. You can also get the last @emph{N}@tie{}days, weeks,
946or months by passing an integer along with the first letter of the
d7ddb257
LC
947duration. For example, @code{--list-generations=20d} lists generations
948that are up to 20 days old.
f566d765
LC
949@end itemize
950
b7884ca3
NK
951@item --delete-generations[=@var{pattern}]
952@itemx -d [@var{pattern}]
d7ddb257
LC
953When @var{pattern} is omitted, delete all generations except the current
954one.
b7884ca3
NK
955
956This command accepts the same patterns as @option{--list-generations}.
d7ddb257
LC
957When @var{pattern} is specified, delete the matching generations. When
958@var{pattern} specifies a duration, generations @emph{older} than the
959specified duration match. For instance, @code{--delete-generations=1m}
960deletes generations that are more than one month old.
961
962If the current generation matches, it is deleted atomically---i.e., by
963switching to the previous available generation. Note that the zeroth
964generation is never deleted.
b7884ca3 965
1bb9900a
LC
966Note that deleting generations prevents roll-back to them.
967Consequently, this command must be used with care.
968
733b4130 969@end table
eeaf4427 970
70ee5642
LC
971Finally, since @command{guix package} may actually start build
972processes, it supports all the common build options that @command{guix
973build} supports (@pxref{Invoking guix build, common build options}).
974
457f60fa
AK
975@include emacs.texi
976
c4202d60
LC
977@node Substitutes
978@section Substitutes
979
980@cindex substitutes
981@cindex pre-built binaries
982Guix supports transparent source/binary deployment, which means that it
983can either build things locally, or download pre-built items from a
984server. We call these pre-built items @dfn{substitutes}---they are
985substitutes for local build results. In many cases, downloading a
986substitute is much faster than building things locally.
987
988Substitutes can be anything resulting from a derivation build
989(@pxref{Derivations}). Of course, in the common case, they are
990pre-built package binaries, but source tarballs, for instance, which
991also result from derivation builds, can be available as substitutes.
992
993The @code{hydra.gnu.org} server is a front-end to a build farm that
994builds packages from the GNU distribution continuously for some
9176607e
LC
995architectures, and makes them available as substitutes. This is the
996default source of substitutes; it can be overridden by passing
997@command{guix-daemon} the @code{--substitute-urls} option
998(@pxref{Invoking guix-daemon}).
c4202d60
LC
999
1000@cindex security
1001@cindex digital signatures
1002To allow Guix to download substitutes from @code{hydra.gnu.org}, you
1003must add its public key to the access control list (ACL) of archive
1004imports, using the @command{guix archive} command (@pxref{Invoking guix
1005archive}). Doing so implies that you trust @code{hydra.gnu.org} to not
1006be compromised and to serve genuine substitutes.
1007
1008This public key is installed along with Guix, in
1009@code{@var{prefix}/share/guix/hydra.gnu.org.pub}, where @var{prefix} is
1010the installation prefix of Guix. If you installed Guix from source,
1011make sure you checked the GPG signature of
1012@file{guix-@value{VERSION}.tar.gz}, which contains this public key file.
1013Then, you can run something like this:
1014
1015@example
1016# guix archive --authorize < hydra.gnu.org.pub
1017@end example
1018
1019Once this is in place, the output of a command like @code{guix build}
1020should change from something like:
1021
1022@example
1023$ guix build emacs --dry-run
1024The following derivations would be built:
1025 /gnu/store/yr7bnx8xwcayd6j95r2clmkdl1qh688w-emacs-24.3.drv
1026 /gnu/store/x8qsh1hlhgjx6cwsjyvybnfv2i37z23w-dbus-1.6.4.tar.gz.drv
1027 /gnu/store/1ixwp12fl950d15h2cj11c73733jay0z-alsa-lib-1.0.27.1.tar.bz2.drv
1028 /gnu/store/nlma1pw0p603fpfiqy7kn4zm105r5dmw-util-linux-2.21.drv
1029@dots{}
1030@end example
1031
1032@noindent
1033to something like:
1034
1035@example
1036$ guix build emacs --dry-run
1037The following files would be downloaded:
1038 /gnu/store/pk3n22lbq6ydamyymqkkz7i69wiwjiwi-emacs-24.3
1039 /gnu/store/2ygn4ncnhrpr61rssa6z0d9x22si0va3-libjpeg-8d
1040 /gnu/store/71yz6lgx4dazma9dwn2mcjxaah9w77jq-cairo-1.12.16
1041 /gnu/store/7zdhgp0n1518lvfn8mb96sxqfmvqrl7v-libxrender-0.9.7
1042@dots{}
1043@end example
1044
1045@noindent
1046This indicates that substitutes from @code{hydra.gnu.org} are usable and
1047will be downloaded, when possible, for future builds.
1048
1049Guix ignores substitutes that are not signed, or that are not signed by
ef27aa9c 1050one of the keys listed in the ACL. It also detects and raises an error
c4202d60
LC
1051when attempting to use a substitute that has been tampered with.
1052
1053The substitute mechanism can be disabled globally by running
1054@code{guix-daemon} with @code{--no-substitutes} (@pxref{Invoking
1055guix-daemon}). It can also be disabled temporarily by passing the
1056@code{--no-substitutes} option to @command{guix package}, @command{guix
1057build}, and other command-line tools.
1058
1059
1060Today, each individual's control over their own computing is at the
1061mercy of institutions, corporations, and groups with enough power and
1062determination to subvert the computing infrastructure and exploit its
1063weaknesses. While using @code{hydra.gnu.org} substitutes can be
1064convenient, we encourage users to also build on their own, or even run
1065their own build farm, such that @code{hydra.gnu.org} is less of an
1066interesting target.
1067
1068Guix has the foundations to maximize build reproducibility
1069(@pxref{Features}). In most cases, independent builds of a given
1070package or derivation should yield bit-identical results. Thus, through
1071a diverse set of independent package builds, we can strengthen the
1072integrity of our systems.
1073
1074In the future, we want Guix to have support to publish and retrieve
1075binaries to/from other users, in a peer-to-peer fashion. If you would
1076like to discuss this project, join us on @email{guix-devel@@gnu.org}.
1077
1078
6e721c4d
LC
1079@node Packages with Multiple Outputs
1080@section Packages with Multiple Outputs
1081
1082@cindex multiple-output packages
1083@cindex package outputs
1084
1085Often, packages defined in Guix have a single @dfn{output}---i.e., the
1086source package leads exactly one directory in the store. When running
1087@command{guix package -i glibc}, one installs the default output of the
1088GNU libc package; the default output is called @code{out}, but its name
1089can be omitted as shown in this command. In this particular case, the
1090default output of @code{glibc} contains all the C header files, shared
1091libraries, static libraries, Info documentation, and other supporting
1092files.
1093
1094Sometimes it is more appropriate to separate the various types of files
1095produced from a single source package into separate outputs. For
1096instance, the GLib C library (used by GTK+ and related packages)
1097installs more than 20 MiB of reference documentation as HTML pages.
1098To save space for users who do not need it, the documentation goes to a
1099separate output, called @code{doc}. To install the main GLib output,
1100which contains everything but the documentation, one would run:
1101
1102@example
1103guix package -i glib
1104@end example
1105
1106The command to install its documentation is:
1107
1108@example
1109guix package -i glib:doc
1110@end example
1111
1112Some packages install programs with different ``dependency footprints''.
1113For instance, the WordNet package install both command-line tools and
1114graphical user interfaces (GUIs). The former depend solely on the C
1115library, whereas the latter depend on Tcl/Tk and the underlying X
1116libraries. In this case, we leave the command-line tools in the default
1117output, whereas the GUIs are in a separate output. This allows users
1118who do not need the GUIs to save space.
1119
1120There are several such multiple-output packages in the GNU distribution.
91ef73d4
LC
1121Other conventional output names include @code{lib} for libraries and
1122possibly header files, @code{bin} for stand-alone programs, and
1123@code{debug} for debugging information (@pxref{Installing Debugging
1124Files}). The outputs of a packages are listed in the third column of
1125the output of @command{guix package --list-available} (@pxref{Invoking
1126guix package}).
6e721c4d 1127
eeaf4427 1128
e49951eb
MW
1129@node Invoking guix gc
1130@section Invoking @command{guix gc}
fe8ff028
LC
1131
1132@cindex garbage collector
1133Packages that are installed but not used may be @dfn{garbage-collected}.
e49951eb 1134The @command{guix gc} command allows users to explicitly run the garbage
834129e0 1135collector to reclaim space from the @file{/gnu/store} directory.
fe8ff028
LC
1136
1137The garbage collector has a set of known @dfn{roots}: any file under
834129e0 1138@file{/gnu/store} reachable from a root is considered @dfn{live} and
fe8ff028
LC
1139cannot be deleted; any other file is considered @dfn{dead} and may be
1140deleted. The set of garbage collector roots includes default user
e49951eb
MW
1141profiles, and may be augmented with @command{guix build --root}, for
1142example (@pxref{Invoking guix build}).
fe8ff028 1143
1bb9900a
LC
1144Prior to running @code{guix gc --collect-garbage} to make space, it is
1145often useful to remove old generations from user profiles; that way, old
1146package builds referenced by those generations can be reclaimed. This
1147is achieved by running @code{guix package --delete-generations}
1148(@pxref{Invoking guix package}).
1149
e49951eb 1150The @command{guix gc} command has three modes of operation: it can be
fe8ff028
LC
1151used to garbage-collect any dead files (the default), to delete specific
1152files (the @code{--delete} option), or to print garbage-collector
1153information. The available options are listed below:
1154
1155@table @code
1156@item --collect-garbage[=@var{min}]
1157@itemx -C [@var{min}]
834129e0 1158Collect garbage---i.e., unreachable @file{/gnu/store} files and
fe8ff028
LC
1159sub-directories. This is the default operation when no option is
1160specified.
1161
1162When @var{min} is given, stop once @var{min} bytes have been collected.
1163@var{min} may be a number of bytes, or it may include a unit as a
4a44d7bb
LC
1164suffix, such as @code{MiB} for mebibytes and @code{GB} for gigabytes
1165(@pxref{Block size, size specifications,, coreutils, GNU Coreutils}).
fe8ff028
LC
1166
1167When @var{min} is omitted, collect all the garbage.
1168
1169@item --delete
1170@itemx -d
1171Attempt to delete all the store files and directories specified as
1172arguments. This fails if some of the files are not in the store, or if
1173they are still live.
1174
1175@item --list-dead
1176Show the list of dead files and directories still present in the
1177store---i.e., files and directories no longer reachable from any root.
1178
1179@item --list-live
1180Show the list of live store files and directories.
ba8b732d
LC
1181
1182@end table
1183
1184In addition, the references among existing store files can be queried:
1185
1186@table @code
1187
1188@item --references
1189@itemx --referrers
1190List the references (respectively, the referrers) of store files given
1191as arguments.
1192
8e59fdd5
LC
1193@item --requisites
1194@itemx -R
1195List the requisites of the store files passed as arguments. Requisites
1196include the store files themselves, their references, and the references
1197of these, recursively. In other words, the returned list is the
1198@dfn{transitive closure} of the store files.
1199
fe8ff028
LC
1200@end table
1201
eeaf4427 1202
f651b477
LC
1203@node Invoking guix pull
1204@section Invoking @command{guix pull}
1205
1206Packages are installed or upgraded to the latest version available in
1207the distribution currently available on your local machine. To update
1208that distribution, along with the Guix tools, you must run @command{guix
1209pull}: the command downloads the latest Guix source code and package
1210descriptions, and deploys it.
1211
1212On completion, @command{guix package} will use packages and package
1213versions from this just-retrieved copy of Guix. Not only that, but all
1214the Guix commands and Scheme modules will also be taken from that latest
1215version. New @command{guix} sub-commands added by the update also
1216become available.
1217
1218The @command{guix pull} command is usually invoked with no arguments,
1219but it supports the following options:
1220
1221@table @code
1222@item --verbose
1223Produce verbose output, writing build logs to the standard error output.
1224
ab5d72ad
LC
1225@item --url=@var{url}
1226Download the source tarball of Guix from @var{url}.
1227
1228By default, the tarball is taken from its canonical address at
1229@code{gnu.org}, for the stable branch of Guix.
1230
f651b477
LC
1231@item --bootstrap
1232Use the bootstrap Guile to build the latest Guix. This option is only
1233useful to Guix developers.
1234@end table
1235
760c60d6
LC
1236
1237@node Invoking guix archive
1238@section Invoking @command{guix archive}
1239
1240The @command{guix archive} command allows users to @dfn{export} files
1241from the store into a single archive, and to later @dfn{import} them.
1242In particular, it allows store files to be transferred from one machine
1243to another machine's store. For example, to transfer the @code{emacs}
1244package to a machine connected over SSH, one would run:
1245
1246@example
1247guix archive --export emacs | ssh the-machine guix archive --import
1248@end example
1249
87236aed
LC
1250@noindent
1251However, note that, in this example, all of @code{emacs} and its
1252dependencies are transferred, regardless of what is already available in
1253the target machine's store. The @code{--missing} option can help figure
1254out which items are missing from the target's store.
1255
760c60d6 1256Archives are stored in the ``Nix archive'' or ``Nar'' format, which is
0dbd88db
LC
1257comparable in spirit to `tar', but with a few noteworthy differences
1258that make it more appropriate for our purposes. First, rather than
1259recording all Unix meta-data for each file, the Nar format only mentions
1260the file type (regular, directory, or symbolic link); Unix permissions
1261and owner/group are dismissed. Second, the order in which directory
1262entries are stored always follows the order of file names according to
1263the C locale collation order. This makes archive production fully
1264deterministic.
1265
1266When exporting, the daemon digitally signs the contents of the archive,
1267and that digital signature is appended. When importing, the daemon
1268verifies the signature and rejects the import in case of an invalid
1269signature or if the signing key is not authorized.
760c60d6
LC
1270@c FIXME: Add xref to daemon doc about signatures.
1271
1272The main options are:
1273
1274@table @code
1275@item --export
1276Export the specified store files or packages (see below.) Write the
1277resulting archive to the standard output.
1278
1279@item --import
1280Read an archive from the standard input, and import the files listed
1281therein into the store. Abort if the archive has an invalid digital
f82cc5fd
LC
1282signature, or if it is signed by a public key not among the authorized
1283keys (see @code{--authorize} below.)
554f26ec 1284
87236aed
LC
1285@item --missing
1286Read a list of store file names from the standard input, one per line,
1287and write on the standard output the subset of these files missing from
1288the store.
1289
554f26ec 1290@item --generate-key[=@var{parameters}]
f82cc5fd 1291@cindex signing, archives
554f26ec
LC
1292Generate a new key pair for the daemons. This is a prerequisite before
1293archives can be exported with @code{--export}. Note that this operation
1294usually takes time, because it needs to gather enough entropy to
1295generate the key pair.
1296
1297The generated key pair is typically stored under @file{/etc/guix}, in
1298@file{signing-key.pub} (public key) and @file{signing-key.sec} (private
1299key, which must be kept secret.) When @var{parameters} is omitted, it
1300is a 4096-bit RSA key. Alternately, @var{parameters} can specify
1301@code{genkey} parameters suitable for Libgcrypt (@pxref{General
1302public-key related Functions, @code{gcry_pk_genkey},, gcrypt, The
1303Libgcrypt Reference Manual}).
f82cc5fd
LC
1304
1305@item --authorize
1306@cindex authorizing, archives
1307Authorize imports signed by the public key passed on standard input.
1308The public key must be in ``s-expression advanced format''---i.e., the
1309same format as the @file{signing-key.pub} file.
1310
1311The list of authorized keys is kept in the human-editable file
1312@file{/etc/guix/acl}. The file contains
1313@url{http://people.csail.mit.edu/rivest/Sexp.txt, ``advanced-format
1314s-expressions''} and is structured as an access-control list in the
1315@url{http://theworld.com/~cme/spki.txt, Simple Public-Key Infrastructure
1316(SPKI)}.
760c60d6
LC
1317@end table
1318
1319To export store files as an archive to the standard output, run:
1320
1321@example
1322guix archive --export @var{options} @var{specifications}...
1323@end example
1324
1325@var{specifications} may be either store file names or package
1326specifications, as for @command{guix package} (@pxref{Invoking guix
1327package}). For instance, the following command creates an archive
1328containing the @code{gui} output of the @code{git} package and the main
1329output of @code{emacs}:
1330
1331@example
834129e0 1332guix archive --export git:gui /gnu/store/...-emacs-24.3 > great.nar
760c60d6
LC
1333@end example
1334
1335If the specified packages are not built yet, @command{guix archive}
1336automatically builds them. The build process may be controlled with the
1337same options that can be passed to the @command{guix build} command
70ee5642 1338(@pxref{Invoking guix build, common build options}).
760c60d6
LC
1339
1340
568717fd
LC
1341@c *********************************************************************
1342@node Programming Interface
1343@chapter Programming Interface
1344
3dc1970d
LC
1345GNU Guix provides several Scheme programming interfaces (APIs) to
1346define, build, and query packages. The first interface allows users to
1347write high-level package definitions. These definitions refer to
1348familiar packaging concepts, such as the name and version of a package,
1349its build system, and its dependencies. These definitions can then be
1350turned into concrete build actions.
1351
ba55b1cb 1352Build actions are performed by the Guix daemon, on behalf of users. In a
3dc1970d 1353standard setup, the daemon has write access to the store---the
834129e0 1354@file{/gnu/store} directory---whereas users do not. The recommended
3dc1970d
LC
1355setup also has the daemon perform builds in chroots, under a specific
1356build users, to minimize interference with the rest of the system.
1357
1358@cindex derivation
1359Lower-level APIs are available to interact with the daemon and the
1360store. To instruct the daemon to perform a build action, users actually
1361provide it with a @dfn{derivation}. A derivation is a low-level
1362representation of the build actions to be taken, and the environment in
1363which they should occur---derivations are to package definitions what
49ad317a
LC
1364assembly is to C programs. The term ``derivation'' comes from the fact
1365that build results @emph{derive} from them.
3dc1970d
LC
1366
1367This chapter describes all these APIs in turn, starting from high-level
1368package definitions.
1369
568717fd 1370@menu
b860f382 1371* Defining Packages:: Defining new packages.
7458bd0a 1372* Build Systems:: Specifying how packages are built.
b860f382
LC
1373* The Store:: Manipulating the package store.
1374* Derivations:: Low-level interface to package derivations.
1375* The Store Monad:: Purely functional interface to the store.
21b679f6 1376* G-Expressions:: Manipulating build expressions.
568717fd
LC
1377@end menu
1378
1379@node Defining Packages
1380@section Defining Packages
1381
3dc1970d
LC
1382The high-level interface to package definitions is implemented in the
1383@code{(guix packages)} and @code{(guix build-system)} modules. As an
1384example, the package definition, or @dfn{recipe}, for the GNU Hello
1385package looks like this:
1386
1387@example
e7f34eb0
LC
1388(define-module (gnu packages hello)
1389 #:use-module (guix packages)
1390 #:use-module (guix download)
1391 #:use-module (guix build-system gnu)
1392 #:use-module (guix licenses))
b22a12fd 1393
79f5dd59 1394(define-public hello
3dc1970d
LC
1395 (package
1396 (name "hello")
1397 (version "2.8")
1398 (source (origin
1399 (method url-fetch)
1400 (uri (string-append "mirror://gnu/hello/hello-" version
1401 ".tar.gz"))
1402 (sha256
1403 (base32 "0wqd8sjmxfskrflaxywc7gqw7sfawrfvdxd9skxawzfgyy0pzdz6"))))
1404 (build-system gnu-build-system)
7458bd0a 1405 (arguments `(#:configure-flags '("--enable-silent-rules")))
3dc1970d 1406 (inputs `(("gawk" ,gawk)))
7458bd0a
LC
1407 (synopsis "Hello, GNU world: An example GNU package")
1408 (description "Guess what GNU Hello prints!")
3dc1970d 1409 (home-page "http://www.gnu.org/software/hello/")
b22a12fd 1410 (license gpl3+)))
3dc1970d
LC
1411@end example
1412
1413@noindent
1414Without being a Scheme expert, the reader may have guessed the meaning
e7f34eb0 1415of the various fields here. This expression binds variable @code{hello}
3dc1970d
LC
1416to a @code{<package>} object, which is essentially a record
1417(@pxref{SRFI-9, Scheme records,, guile, GNU Guile Reference Manual}).
1418This package object can be inspected using procedures found in the
1419@code{(guix packages)} module; for instance, @code{(package-name hello)}
1420returns---surprise!---@code{"hello"}.
1421
e7f34eb0
LC
1422In the example above, @var{hello} is defined into a module of its own,
1423@code{(gnu packages hello)}. Technically, this is not strictly
1424necessary, but it is convenient to do so: all the packages defined in
1425modules under @code{(gnu packages @dots{})} are automatically known to
1426the command-line tools (@pxref{Package Modules}).
1427
3dc1970d
LC
1428There are a few points worth noting in the above package definition:
1429
1430@itemize
1431@item
1432The @code{source} field of the package is an @code{<origin>} object.
1433Here, the @code{url-fetch} method from @code{(guix download)} is used,
1434meaning that the source is a file to be downloaded over FTP or HTTP.
1435
1436The @code{mirror://gnu} prefix instructs @code{url-fetch} to use one of
1437the GNU mirrors defined in @code{(guix download)}.
1438
1439The @code{sha256} field specifies the expected SHA256 hash of the file
1440being downloaded. It is mandatory, and allows Guix to check the
1441integrity of the file. The @code{(base32 @dots{})} form introduces the
6c365eca 1442base32 representation of the hash. You can obtain this information with
210cc920
LC
1443@code{guix download} (@pxref{Invoking guix download}) and @code{guix
1444hash} (@pxref{Invoking guix hash}).
3dc1970d 1445
f9cc8971
LC
1446@cindex patches
1447When needed, the @code{origin} form can also have a @code{patches} field
1448listing patches to be applied, and a @code{snippet} field giving a
1449Scheme expression to modify the source code.
1450
3dc1970d
LC
1451@item
1452@cindex GNU Build System
7458bd0a
LC
1453The @code{build-system} field specifies the procedure to build the
1454package (@pxref{Build Systems}). Here, @var{gnu-build-system}
1455represents the familiar GNU Build System, where packages may be
1456configured, built, and installed with the usual @code{./configure &&
1457make && make check && make install} command sequence.
1458
1459@item
1460The @code{arguments} field specifies options for the build system
1461(@pxref{Build Systems}). Here it is interpreted by
1462@var{gnu-build-system} as a request run @file{configure} with the
1463@code{--enable-silent-rules} flag.
3dc1970d
LC
1464
1465@item
1466The @code{inputs} field specifies inputs to the build process---i.e.,
1467build-time or run-time dependencies of the package. Here, we define an
1468input called @code{"gawk"} whose value is that of the @var{gawk}
1469variable; @var{gawk} is itself bound to a @code{<package>} object.
1470
1471Note that GCC, Coreutils, Bash, and other essential tools do not need to
1472be specified as inputs here. Instead, @var{gnu-build-system} takes care
7458bd0a 1473of ensuring that they are present (@pxref{Build Systems}).
3dc1970d
LC
1474
1475However, any other dependencies need to be specified in the
1476@code{inputs} field. Any dependency not specified here will simply be
1477unavailable to the build process, possibly leading to a build failure.
1478@end itemize
1479
3dc1970d
LC
1480Once a package definition is in place@footnote{Simple package
1481definitions like the one above may be automatically converted from the
e49951eb
MW
1482Nixpkgs distribution using the @command{guix import} command.}, the
1483package may actually be built using the @code{guix build} command-line
7458bd0a 1484tool (@pxref{Invoking guix build}). @xref{Packaging Guidelines}, for
b4f5e0e8
CR
1485more information on how to test package definitions, and
1486@ref{Invoking guix lint}, for information on how to check a definition
1487for style conformance.
1488
7458bd0a
LC
1489
1490Eventually, updating the package definition to a new upstream version
1491can be partly automated by the @command{guix refresh} command
1492(@pxref{Invoking guix refresh}).
3dc1970d
LC
1493
1494Behind the scenes, a derivation corresponding to the @code{<package>}
1495object is first computed by the @code{package-derivation} procedure.
834129e0 1496That derivation is stored in a @code{.drv} file under @file{/gnu/store}.
ba55b1cb 1497The build actions it prescribes may then be realized by using the
3dc1970d
LC
1498@code{build-derivations} procedure (@pxref{The Store}).
1499
1500@deffn {Scheme Procedure} package-derivation @var{store} @var{package} [@var{system}]
59688fc4
LC
1501Return the @code{<derivation>} object of @var{package} for @var{system}
1502(@pxref{Derivations}).
3dc1970d
LC
1503
1504@var{package} must be a valid @code{<package>} object, and @var{system}
1505must be a string denoting the target system type---e.g.,
1506@code{"x86_64-linux"} for an x86_64 Linux-based GNU system. @var{store}
1507must be a connection to the daemon, which operates on the store
1508(@pxref{The Store}).
1509@end deffn
568717fd 1510
9c1edabd
LC
1511@noindent
1512@cindex cross-compilation
1513Similarly, it is possible to compute a derivation that cross-builds a
1514package for some other system:
1515
1516@deffn {Scheme Procedure} package-cross-derivation @var{store} @
1517 @var{package} @var{target} [@var{system}]
59688fc4
LC
1518Return the @code{<derivation>} object of @var{package} cross-built from
1519@var{system} to @var{target}.
9c1edabd
LC
1520
1521@var{target} must be a valid GNU triplet denoting the target hardware
1522and operating system, such as @code{"mips64el-linux-gnu"}
1523(@pxref{Configuration Names, GNU configuration triplets,, configure, GNU
1524Configure and Build System}).
1525@end deffn
1526
1527
7458bd0a
LC
1528@node Build Systems
1529@section Build Systems
1530
1531@cindex build system
1532Each package definition specifies a @dfn{build system} and arguments for
1533that build system (@pxref{Defining Packages}). This @code{build-system}
1534field represents the build procedure of the package, as well implicit
1535dependencies of that build procedure.
1536
1537Build systems are @code{<build-system>} objects. The interface to
1538create and manipulate them is provided by the @code{(guix build-system)}
1539module, and actual build systems are exported by specific modules.
1540
0d5a559f
LC
1541Under the hood, build systems first compile package objects to
1542@dfn{bags}. A @dfn{bag} is like a package, but with less
1543ornamentation---in other words, a bag is a lower-level representation of
1544a package, which includes all the inputs of that package, including some
1545that were implicitly added by the build system. This intermediate
1546representation is then compiled to a derivation (@pxref{Derivations}).
1547
7458bd0a
LC
1548Build systems accept an optional list of @dfn{arguments}. In package
1549definitions, these are passed @i{via} the @code{arguments} field
1550(@pxref{Defining Packages}). They are typically keyword arguments
1551(@pxref{Optional Arguments, keyword arguments in Guile,, guile, GNU
1552Guile Reference Manual}). The value of these arguments is usually
1553evaluated in the @dfn{build stratum}---i.e., by a Guile process launched
1554by the daemon (@pxref{Derivations}).
1555
1556The main build system is @var{gnu-build-system}, which implements the
1557standard build procedure for GNU packages and many other packages. It
1558is provided by the @code{(guix build-system gnu)} module.
1559
1560@defvr {Scheme Variable} gnu-build-system
1561@var{gnu-build-system} represents the GNU Build System, and variants
1562thereof (@pxref{Configuration, configuration and makefile conventions,,
1563standards, GNU Coding Standards}).
1564
1565@cindex build phases
1566In a nutshell, packages using it configured, built, and installed with
1567the usual @code{./configure && make && make check && make install}
1568command sequence. In practice, a few additional steps are often needed.
1569All these steps are split up in separate @dfn{phases},
1570notably@footnote{Please see the @code{(guix build gnu-build-system)}
1571modules for more details about the build phases.}:
1572
1573@table @code
1574@item unpack
1575Unpack the source tarball, and change the current directory to the
1576extracted source tree. If the source is actually a directory, copy it
1577to the build tree, and enter that directory.
1578
1579@item patch-source-shebangs
1580Patch shebangs encountered in source files so they refer to the right
1581store file names. For instance, this changes @code{#!/bin/sh} to
1582@code{#!/gnu/store/@dots{}-bash-4.3/bin/sh}.
1583
1584@item configure
1585Run the @file{configure} script with a number of default options, such
1586as @code{--prefix=/gnu/store/@dots{}}, as well as the options specified
1587by the @code{#:configure-flags} argument.
1588
1589@item build
1590Run @code{make} with the list of flags specified with
1591@code{#:make-flags}. If the @code{#:parallel-builds?} argument is true
1592(the default), build with @code{make -j}.
1593
1594@item check
1595Run @code{make check}, or some other target specified with
1596@code{#:test-target}, unless @code{#:tests? #f} is passed. If the
1597@code{#:parallel-tests?} argument is true (the default), run @code{make
1598check -j}.
1599
1600@item install
1601Run @code{make install} with the flags listed in @code{#:make-flags}.
1602
1603@item patch-shebangs
1604Patch shebangs on the installed executable files.
1605
1606@item strip
1607Strip debugging symbols from ELF files (unless @code{#:strip-binaries?}
1608is false), copying them to the @code{debug} output when available
1609(@pxref{Installing Debugging Files}).
1610@end table
1611
1612@vindex %standard-phases
1613The build-side module @code{(guix build gnu-build-system)} defines
1614@var{%standard-phases} as the default list of build phases.
1615@var{%standard-phases} is a list of symbol/procedure pairs, where the
1616procedure implements the actual phase.
1617
1618The list of phases used for a particular package can be changed with the
1619@code{#:phases} parameter. For instance, passing:
1620
1621@example
1622#:phases (alist-delete 'configure %standard-phases)
1623@end example
1624
9bf404e9 1625means that all the phases described above will be used, except the
7458bd0a
LC
1626@code{configure} phase.
1627
1628In addition, this build system ensures that the ``standard'' environment
1629for GNU packages is available. This includes tools such as GCC, libc,
1630Coreutils, Bash, Make, Diffutils, grep, and sed (see the @code{(guix
1631build-system gnu)} module for a complete list.) We call these the
1632@dfn{implicit inputs} of a package, because package definitions don't
1633have to mention them.
1634@end defvr
1635
1636Other @code{<build-system>} objects are defined to support other
1637conventions and tools used by free software packages. They inherit most
1638of @var{gnu-build-system}, and differ mainly in the set of inputs
1639implicitly added to the build process, and in the list of phases
1640executed. Some of these build systems are listed below.
1641
1642@defvr {Scheme Variable} cmake-build-system
1643This variable is exported by @code{(guix build-system cmake)}. It
1644implements the build procedure for packages using the
1645@url{http://www.cmake.org, CMake build tool}.
1646
1647It automatically adds the @code{cmake} package to the set of inputs.
1648Which package is used can be specified with the @code{#:cmake}
1649parameter.
9849cfc1
LC
1650
1651The @code{#:configure-flags} parameter is taken as a list of flags
1652passed to the @command{cmake} command. The @code{#:build-type}
1653parameter specifies in abstract terms the flags passed to the compiler;
1654it defaults to @code{"RelWithDebInfo"} (short for ``release mode with
1655debugging information''), which roughly means that code is compiled with
1656@code{-O2 -g}, as is the case for Autoconf-based packages by default.
7458bd0a
LC
1657@end defvr
1658
3afcf52b
FB
1659@defvr {Scheme Variable} glib-or-gtk-build-system
1660This variable is exported by @code{(guix build-system glib-or-gtk)}. It
1661is intended for use with packages making use of GLib or GTK+.
1662
1663This build system adds the following two phases to the ones defined by
1664@var{gnu-build-system}:
1665
1666@table @code
1667@item glib-or-gtk-wrap
1668The phase @code{glib-or-gtk-wrap} ensures that programs found under
1669@file{bin/} are able to find GLib's ``schemas'' and
1670@uref{https://developer.gnome.org/gtk3/stable/gtk-running.html, GTK+
1671modules}. This is achieved by wrapping the programs in launch scripts
1672that appropriately set the @code{XDG_DATA_DIRS} and @code{GTK_PATH}
1673environment variables.
1674
1675@item glib-or-gtk-compile-schemas
1676The phase @code{glib-or-gtk-compile-schemas} makes sure that all GLib's
1677@uref{https://developer.gnome.org/gio/stable/glib-compile-schemas.html,
1678GSettings schemas} are compiled. Compilation is performed by the
1679@command{glib-compile-schemas} program. It is provided by the package
1680@code{glib:bin} which is automatically imported by the build system.
1681The @code{glib} package providing @command{glib-compile-schemas} can be
1682specified with the @code{#:glib} parameter.
1683@end table
1684
1685Both phases are executed after the @code{install} phase.
1686@end defvr
1687
7458bd0a
LC
1688@defvr {Scheme Variable} python-build-system
1689This variable is exported by @code{(guix build-system python)}. It
1690implements the more or less standard build procedure used by Python
1691packages, which consists in running @code{python setup.py build} and
1692then @code{python setup.py install --prefix=/gnu/store/@dots{}}.
1693
1694For packages that install stand-alone Python programs under @code{bin/},
1695it takes care of wrapping these programs so their @code{PYTHONPATH}
1696environment variable points to all the Python libraries they depend on.
1697
1698Which Python package is used can be specified with the @code{#:python}
1699parameter.
1700@end defvr
1701
1702@defvr {Scheme Variable} perl-build-system
1703This variable is exported by @code{(guix build-system perl)}. It
1704implements the standard build procedure for Perl packages, which
1705consists in running @code{perl Makefile.PL PREFIX=/gnu/store/@dots{}},
1706followed by @code{make} and @code{make install}.
1707
1708The initial @code{perl Makefile.PL} invocation passes flags specified by
1709the @code{#:make-maker-flags} parameter.
1710
1711Which Perl package is used can be specified with @code{#:perl}.
1712@end defvr
1713
c08f9818
DT
1714@defvr {Scheme Variable} ruby-build-system
1715This variable is exported by @code{(guix build-system ruby)}. It
1716implements the RubyGems build procedure used by Ruby packages, which
1717involves running @code{gem build} followed by @code{gem install}.
1718
1719Which Ruby package is used can be specified with the @code{#:ruby}
1720parameter.
1721@end defvr
7458bd0a
LC
1722
1723Lastly, for packages that do not need anything as sophisticated, a
1724``trivial'' build system is provided. It is trivial in the sense that
1725it provides basically no support: it does not pull any implicit inputs,
1726and does not have a notion of build phases.
1727
1728@defvr {Scheme Variable} trivial-build-system
1729This variable is exported by @code{(guix build-system trivial)}.
1730
1731This build system requires a @code{#:builder} argument. This argument
1732must be a Scheme expression that builds the package's output(s)---as
1733with @code{build-expression->derivation} (@pxref{Derivations,
1734@code{build-expression->derivation}}).
1735@end defvr
1736
568717fd
LC
1737@node The Store
1738@section The Store
1739
e531ac2a
LC
1740@cindex store
1741@cindex store paths
1742
1743Conceptually, the @dfn{store} is where derivations that have been
834129e0 1744successfully built are stored---by default, under @file{/gnu/store}.
e531ac2a
LC
1745Sub-directories in the store are referred to as @dfn{store paths}. The
1746store has an associated database that contains information such has the
1747store paths referred to by each store path, and the list of @emph{valid}
1748store paths---paths that result from a successful build.
1749
1750The store is always accessed by the daemon on behalf of its clients
1751(@pxref{Invoking guix-daemon}). To manipulate the store, clients
1752connect to the daemon over a Unix-domain socket, send it requests, and
1753read the result---these are remote procedure calls, or RPCs.
1754
1755The @code{(guix store)} module provides procedures to connect to the
1756daemon, and to perform RPCs. These are described below.
1757
1758@deffn {Scheme Procedure} open-connection [@var{file}] [#:reserve-space? #t]
1759Connect to the daemon over the Unix-domain socket at @var{file}. When
1760@var{reserve-space?} is true, instruct it to reserve a little bit of
1761extra space on the file system so that the garbage collector can still
1762operate, should the disk become full. Return a server object.
1763
1764@var{file} defaults to @var{%default-socket-path}, which is the normal
1765location given the options that were passed to @command{configure}.
1766@end deffn
1767
1768@deffn {Scheme Procedure} close-connection @var{server}
1769Close the connection to @var{server}.
1770@end deffn
1771
1772@defvr {Scheme Variable} current-build-output-port
1773This variable is bound to a SRFI-39 parameter, which refers to the port
1774where build and error logs sent by the daemon should be written.
1775@end defvr
1776
1777Procedures that make RPCs all take a server object as their first
1778argument.
1779
1780@deffn {Scheme Procedure} valid-path? @var{server} @var{path}
1781Return @code{#t} when @var{path} is a valid store path.
1782@end deffn
1783
cfbf9160 1784@deffn {Scheme Procedure} add-text-to-store @var{server} @var{name} @var{text} [@var{references}]
e531ac2a
LC
1785Add @var{text} under file @var{name} in the store, and return its store
1786path. @var{references} is the list of store paths referred to by the
1787resulting store path.
1788@end deffn
1789
874e6874 1790@deffn {Scheme Procedure} build-derivations @var{server} @var{derivations}
59688fc4
LC
1791Build @var{derivations} (a list of @code{<derivation>} objects or
1792derivation paths), and return when the worker is done building them.
1793Return @code{#t} on success.
874e6874
LC
1794@end deffn
1795
b860f382
LC
1796Note that the @code{(guix monads)} module provides a monad as well as
1797monadic versions of the above procedures, with the goal of making it
1798more convenient to work with code that accesses the store (@pxref{The
1799Store Monad}).
1800
e531ac2a
LC
1801@c FIXME
1802@i{This section is currently incomplete.}
568717fd
LC
1803
1804@node Derivations
1805@section Derivations
1806
874e6874
LC
1807@cindex derivations
1808Low-level build actions and the environment in which they are performed
1809are represented by @dfn{derivations}. A derivation contain the
1810following pieces of information:
1811
1812@itemize
1813@item
1814The outputs of the derivation---derivations produce at least one file or
1815directory in the store, but may produce more.
1816
1817@item
1818The inputs of the derivations, which may be other derivations or plain
1819files in the store (patches, build scripts, etc.)
1820
1821@item
1822The system type targeted by the derivation---e.g., @code{x86_64-linux}.
1823
1824@item
1825The file name of a build script in the store, along with the arguments
1826to be passed.
1827
1828@item
1829A list of environment variables to be defined.
1830
1831@end itemize
1832
1833@cindex derivation path
1834Derivations allow clients of the daemon to communicate build actions to
1835the store. They exist in two forms: as an in-memory representation,
1836both on the client- and daemon-side, and as files in the store whose
1837name end in @code{.drv}---these files are referred to as @dfn{derivation
1838paths}. Derivations paths can be passed to the @code{build-derivations}
1839procedure to perform the build actions they prescribe (@pxref{The
1840Store}).
1841
1842The @code{(guix derivations)} module provides a representation of
1843derivations as Scheme objects, along with procedures to create and
1844otherwise manipulate derivations. The lowest-level primitive to create
1845a derivation is the @code{derivation} procedure:
1846
1909431c
LC
1847@deffn {Scheme Procedure} derivation @var{store} @var{name} @var{builder} @
1848 @var{args} [#:outputs '("out")] [#:hash #f] [#:hash-algo #f] @
2096ef47 1849 [#:recursive? #f] [#:inputs '()] [#:env-vars '()] @
1909431c 1850 [#:system (%current-system)] [#:references-graphs #f] @
b53be755 1851 [#:allowed-references #f] [#:local-build? #f]
59688fc4
LC
1852Build a derivation with the given arguments, and return the resulting
1853@code{<derivation>} object.
874e6874 1854
2096ef47 1855When @var{hash} and @var{hash-algo} are given, a
874e6874 1856@dfn{fixed-output derivation} is created---i.e., one whose result is
36bbbbd1
LC
1857known in advance, such as a file download. If, in addition,
1858@var{recursive?} is true, then that fixed output may be an executable
1859file or a directory and @var{hash} must be the hash of an archive
1860containing this output.
5b0c9d16 1861
858e9282 1862When @var{references-graphs} is true, it must be a list of file
5b0c9d16
LC
1863name/store path pairs. In that case, the reference graph of each store
1864path is exported in the build environment in the corresponding file, in
1865a simple text format.
1909431c 1866
b53be755
LC
1867When @var{allowed-references} is true, it must be a list of store items
1868or outputs that the derivation's output may refer to.
1869
1909431c
LC
1870When @var{local-build?} is true, declare that the derivation is not a
1871good candidate for offloading and should rather be built locally
1872(@pxref{Daemon Offload Setup}). This is the case for small derivations
1873where the costs of data transfers would outweigh the benefits.
874e6874
LC
1874@end deffn
1875
1876@noindent
1877Here's an example with a shell script as its builder, assuming
1878@var{store} is an open connection to the daemon, and @var{bash} points
1879to a Bash executable in the store:
1880
1881@lisp
1882(use-modules (guix utils)
1883 (guix store)
1884 (guix derivations))
1885
59688fc4
LC
1886(let ((builder ; add the Bash script to the store
1887 (add-text-to-store store "my-builder.sh"
1888 "echo hello world > $out\n" '())))
1889 (derivation store "foo"
1890 bash `("-e" ,builder)
21b679f6 1891 #:inputs `((,bash) (,builder))
59688fc4 1892 #:env-vars '(("HOME" . "/homeless"))))
834129e0 1893@result{} #<derivation /gnu/store/@dots{}-foo.drv => /gnu/store/@dots{}-foo>
874e6874
LC
1894@end lisp
1895
21b679f6
LC
1896As can be guessed, this primitive is cumbersome to use directly. A
1897better approach is to write build scripts in Scheme, of course! The
1898best course of action for that is to write the build code as a
1899``G-expression'', and to pass it to @code{gexp->derivation}. For more
6621cdb6 1900information, @pxref{G-Expressions}.
21b679f6
LC
1901
1902Once upon a time, @code{gexp->derivation} did not exist and constructing
1903derivations with build code written in Scheme was achieved with
1904@code{build-expression->derivation}, documented below. This procedure
1905is now deprecated in favor of the much nicer @code{gexp->derivation}.
874e6874 1906
dd1a5a15
LC
1907@deffn {Scheme Procedure} build-expression->derivation @var{store} @
1908 @var{name} @var{exp} @
1909 [#:system (%current-system)] [#:inputs '()] @
1910 [#:outputs '("out")] [#:hash #f] [#:hash-algo #f] @
36bbbbd1 1911 [#:recursive? #f] [#:env-vars '()] [#:modules '()] @
63a42824
LC
1912 [#:references-graphs #f] [#:allowed-references #f] @
1913 [#:local-build? #f] [#:guile-for-build #f]
874e6874
LC
1914Return a derivation that executes Scheme expression @var{exp} as a
1915builder for derivation @var{name}. @var{inputs} must be a list of
1916@code{(name drv-path sub-drv)} tuples; when @var{sub-drv} is omitted,
1917@code{"out"} is assumed. @var{modules} is a list of names of Guile
1918modules from the current search path to be copied in the store,
1919compiled, and made available in the load path during the execution of
1920@var{exp}---e.g., @code{((guix build utils) (guix build
1921gnu-build-system))}.
1922
1923@var{exp} is evaluated in an environment where @code{%outputs} is bound
1924to a list of output/path pairs, and where @code{%build-inputs} is bound
1925to a list of string/output-path pairs made from @var{inputs}.
1926Optionally, @var{env-vars} is a list of string pairs specifying the name
1927and value of environment variables visible to the builder. The builder
1928terminates by passing the result of @var{exp} to @code{exit}; thus, when
1929@var{exp} returns @code{#f}, the build is considered to have failed.
1930
1931@var{exp} is built using @var{guile-for-build} (a derivation). When
1932@var{guile-for-build} is omitted or is @code{#f}, the value of the
1933@code{%guile-for-build} fluid is used instead.
9c629a27 1934
63a42824
LC
1935See the @code{derivation} procedure for the meaning of
1936@var{references-graphs}, @var{allowed-references}, and @var{local-build?}.
874e6874
LC
1937@end deffn
1938
1939@noindent
1940Here's an example of a single-output derivation that creates a directory
1941containing one file:
1942
1943@lisp
1944(let ((builder '(let ((out (assoc-ref %outputs "out")))
834129e0 1945 (mkdir out) ; create /gnu/store/@dots{}-goo
874e6874
LC
1946 (call-with-output-file (string-append out "/test")
1947 (lambda (p)
1948 (display '(hello guix) p))))))
dd1a5a15 1949 (build-expression->derivation store "goo" builder))
874e6874 1950
834129e0 1951@result{} #<derivation /gnu/store/@dots{}-goo.drv => @dots{}>
874e6874
LC
1952@end lisp
1953
568717fd 1954
b860f382
LC
1955@node The Store Monad
1956@section The Store Monad
1957
1958@cindex monad
1959
1960The procedures that operate on the store described in the previous
1961sections all take an open connection to the build daemon as their first
1962argument. Although the underlying model is functional, they either have
1963side effects or depend on the current state of the store.
1964
1965The former is inconvenient: the connection to the build daemon has to be
1966carried around in all those functions, making it impossible to compose
1967functions that do not take that parameter with functions that do. The
1968latter can be problematic: since store operations have side effects
1969and/or depend on external state, they have to be properly sequenced.
1970
1971@cindex monadic values
1972@cindex monadic functions
1973This is where the @code{(guix monads)} module comes in. This module
1974provides a framework for working with @dfn{monads}, and a particularly
1975useful monad for our uses, the @dfn{store monad}. Monads are a
1976construct that allows two things: associating ``context'' with values
1977(in our case, the context is the store), and building sequences of
1978computations (here computations includes accesses to the store.) Values
1979in a monad---values that carry this additional context---are called
1980@dfn{monadic values}; procedures that return such values are called
1981@dfn{monadic procedures}.
1982
1983Consider this ``normal'' procedure:
1984
1985@example
45adbd62
LC
1986(define (sh-symlink store)
1987 ;; Return a derivation that symlinks the 'bash' executable.
1988 (let* ((drv (package-derivation store bash))
1989 (out (derivation->output-path drv))
1990 (sh (string-append out "/bin/bash")))
1991 (build-expression->derivation store "sh"
1992 `(symlink ,sh %output))))
b860f382
LC
1993@end example
1994
1995Using @code{(guix monads)}, it may be rewritten as a monadic function:
1996
ada3df03 1997@c FIXME: Find a better example, one that uses 'mlet'.
b860f382 1998@example
45adbd62 1999(define (sh-symlink)
b860f382 2000 ;; Same, but return a monadic value.
ada3df03
LC
2001 (gexp->derivation "sh"
2002 #~(symlink (string-append #$bash "/bin/bash") #$output)))
b860f382
LC
2003@end example
2004
2005There are two things to note in the second version: the @code{store}
2006parameter is now implicit, and the monadic value returned by
2007@code{package-file}---a wrapper around @code{package-derivation} and
2008@code{derivation->output-path}---is @dfn{bound} using @code{mlet}
2009instead of plain @code{let}.
2010
2011Calling the monadic @code{profile.sh} has no effect. To get the desired
2012effect, one must use @code{run-with-store}:
2013
2014@example
2015(run-with-store (open-connection) (profile.sh))
834129e0 2016@result{} /gnu/store/...-profile.sh
b860f382
LC
2017@end example
2018
b9b86078
LC
2019Note that the @code{(guix monad-repl)} module extends Guile's REPL with
2020new ``meta-commands'' to make it easier to deal with monadic procedures:
2021@code{run-in-store}, and @code{enter-store-monad}. The former, is used
2022to ``run'' a single monadic value through the store:
2023
2024@example
2025scheme@@(guile-user)> ,run-in-store (package->derivation hello)
2026$1 = #<derivation /gnu/store/@dots{}-hello-2.9.drv => @dots{}>
2027@end example
2028
2029The latter enters a recursive REPL, where all the return values are
2030automatically run through the store:
2031
2032@example
2033scheme@@(guile-user)> ,enter-store-monad
2034store-monad@@(guile-user) [1]> (package->derivation hello)
2035$2 = #<derivation /gnu/store/@dots{}-hello-2.9.drv => @dots{}>
2036store-monad@@(guile-user) [1]> (text-file "foo" "Hello!")
2037$3 = "/gnu/store/@dots{}-foo"
2038store-monad@@(guile-user) [1]> ,q
2039scheme@@(guile-user)>
2040@end example
2041
2042@noindent
2043Note that non-monadic values cannot be returned in the
2044@code{store-monad} REPL.
2045
b860f382
LC
2046The main syntactic forms to deal with monads in general are described
2047below.
2048
2049@deffn {Scheme Syntax} with-monad @var{monad} @var{body} ...
2050Evaluate any @code{>>=} or @code{return} forms in @var{body} as being
2051in @var{monad}.
2052@end deffn
2053
2054@deffn {Scheme Syntax} return @var{val}
2055Return a monadic value that encapsulates @var{val}.
2056@end deffn
2057
2058@deffn {Scheme Syntax} >>= @var{mval} @var{mproc}
2059@dfn{Bind} monadic value @var{mval}, passing its ``contents'' to monadic
2060procedure @var{mproc}@footnote{This operation is commonly referred to as
2061``bind'', but that name denotes an unrelated procedure in Guile. Thus
2062we use this somewhat cryptic symbol inherited from the Haskell
2063language.}.
2064@end deffn
2065
2066@deffn {Scheme Syntax} mlet @var{monad} ((@var{var} @var{mval}) ...) @
2067 @var{body} ...
2068@deffnx {Scheme Syntax} mlet* @var{monad} ((@var{var} @var{mval}) ...) @
2069 @var{body} ...
2070Bind the variables @var{var} to the monadic values @var{mval} in
2071@var{body}. The form (@var{var} -> @var{val}) binds @var{var} to the
2072``normal'' value @var{val}, as per @code{let}.
2073
2074@code{mlet*} is to @code{mlet} what @code{let*} is to @code{let}
2075(@pxref{Local Bindings,,, guile, GNU Guile Reference Manual}).
2076@end deffn
2077
405a9d4e
LC
2078@deffn {Scheme System} mbegin @var{monad} @var{mexp} ...
2079Bind @var{mexp} and the following monadic expressions in sequence,
2080returning the result of the last expression.
2081
2082This is akin to @code{mlet}, except that the return values of the
2083monadic expressions are ignored. In that sense, it is analogous to
2084@code{begin}, but applied to monadic expressions.
2085@end deffn
2086
b860f382
LC
2087The interface to the store monad provided by @code{(guix monads)} is as
2088follows.
2089
2090@defvr {Scheme Variable} %store-monad
2091The store monad. Values in the store monad encapsulate accesses to the
2092store. When its effect is needed, a value of the store monad must be
2093``evaluated'' by passing it to the @code{run-with-store} procedure (see
2094below.)
2095@end defvr
2096
2097@deffn {Scheme Procedure} run-with-store @var{store} @var{mval} [#:guile-for-build] [#:system (%current-system)]
2098Run @var{mval}, a monadic value in the store monad, in @var{store}, an
2099open store connection.
2100@end deffn
2101
2102@deffn {Monadic Procedure} text-file @var{name} @var{text}
2103Return as a monadic value the absolute file name in the store of the file
45adbd62
LC
2104containing @var{text}, a string.
2105@end deffn
2106
2107@deffn {Monadic Procedure} text-file* @var{name} @var{text} @dots{}
2108Return as a monadic value a derivation that builds a text file
2109containing all of @var{text}. @var{text} may list, in addition to
2110strings, packages, derivations, and store file names; the resulting
2111store file holds references to all these.
2112
2113This variant should be preferred over @code{text-file} anytime the file
2114to create will reference items from the store. This is typically the
2115case when building a configuration file that embeds store file names,
2116like this:
2117
2118@example
2119(define (profile.sh)
2120 ;; Return the name of a shell script in the store that
2121 ;; initializes the 'PATH' environment variable.
2122 (text-file* "profile.sh"
2123 "export PATH=" coreutils "/bin:"
2124 grep "/bin:" sed "/bin\n"))
2125@end example
2126
834129e0 2127In this example, the resulting @file{/gnu/store/@dots{}-profile.sh} file
45adbd62
LC
2128will references @var{coreutils}, @var{grep}, and @var{sed}, thereby
2129preventing them from being garbage-collected during its lifetime.
b860f382
LC
2130@end deffn
2131
0a90af15
LC
2132@deffn {Monadic Procedure} interned-file @var{file} [@var{name}] @
2133 [#:recursive? #t]
2134Return the name of @var{file} once interned in the store. Use
2135@var{name} as its store name, or the basename of @var{file} if
2136@var{name} is omitted.
2137
2138When @var{recursive?} is true, the contents of @var{file} are added
2139recursively; if @var{file} designates a flat file and @var{recursive?}
2140is true, its contents are added, and its permission bits are kept.
2141
2142The example below adds a file to the store, under two different names:
2143
2144@example
2145(run-with-store (open-connection)
2146 (mlet %store-monad ((a (interned-file "README"))
2147 (b (interned-file "README" "LEGU-MIN")))
2148 (return (list a b))))
2149
2150@result{} ("/gnu/store/rwm@dots{}-README" "/gnu/store/44i@dots{}-LEGU-MIN")
2151@end example
2152
2153@end deffn
2154
b860f382 2155@deffn {Monadic Procedure} package-file @var{package} [@var{file}] @
4231f05b
LC
2156 [#:system (%current-system)] [#:target #f] @
2157 [#:output "out"] Return as a monadic
b860f382
LC
2158value in the absolute file name of @var{file} within the @var{output}
2159directory of @var{package}. When @var{file} is omitted, return the name
4231f05b
LC
2160of the @var{output} directory of @var{package}. When @var{target} is
2161true, use it as a cross-compilation target triplet.
b860f382
LC
2162@end deffn
2163
b860f382 2164@deffn {Monadic Procedure} package->derivation @var{package} [@var{system}]
4231f05b
LC
2165@deffnx {Monadic Procedure} package->cross-derivation @var{package} @
2166 @var{target} [@var{system}]
2167Monadic version of @code{package-derivation} and
2168@code{package-cross-derivation} (@pxref{Defining Packages}).
b860f382
LC
2169@end deffn
2170
2171
21b679f6
LC
2172@node G-Expressions
2173@section G-Expressions
2174
2175@cindex G-expression
2176@cindex build code quoting
2177So we have ``derivations'', which represent a sequence of build actions
2178to be performed to produce an item in the store (@pxref{Derivations}).
2179Those build actions are performed when asking the daemon to actually
2180build the derivations; they are run by the daemon in a container
2181(@pxref{Invoking guix-daemon}).
2182
2183@cindex strata of code
2184It should come as no surprise that we like to write those build actions
2185in Scheme. When we do that, we end up with two @dfn{strata} of Scheme
2186code@footnote{The term @dfn{stratum} in this context was coined by
ef4ab0a4
LC
2187Manuel Serrano et al.@: in the context of their work on Hop. Oleg
2188Kiselyov, who has written insightful
2189@url{http://okmij.org/ftp/meta-programming/#meta-scheme, essays and code
2190on this topic}, refers to this kind of code generation as
2191@dfn{staging}.}: the ``host code''---code that defines packages, talks
2192to the daemon, etc.---and the ``build code''---code that actually
2193performs build actions, such as making directories, invoking
2194@command{make}, etc.
21b679f6
LC
2195
2196To describe a derivation and its build actions, one typically needs to
2197embed build code inside host code. It boils down to manipulating build
2198code as data, and Scheme's homoiconicity---code has a direct
2199representation as data---comes in handy for that. But we need more than
2200Scheme's normal @code{quasiquote} mechanism to construct build
2201expressions.
2202
2203The @code{(guix gexp)} module implements @dfn{G-expressions}, a form of
2204S-expressions adapted to build expressions. G-expressions, or
2205@dfn{gexps}, consist essentially in three syntactic forms: @code{gexp},
2206@code{ungexp}, and @code{ungexp-splicing} (or simply: @code{#~},
2207@code{#$}, and @code{#$@@}), which are comparable respectively to
2208@code{quasiquote}, @code{unquote}, and @code{unquote-splicing}
2209(@pxref{Expression Syntax, @code{quasiquote},, guile, GNU Guile
2210Reference Manual}). However, there are major differences:
2211
2212@itemize
2213@item
2214Gexps are meant to be written to a file and run or manipulated by other
2215processes.
2216
2217@item
2218When a package or derivation is unquoted inside a gexp, the result is as
2219if its output file name had been introduced.
2220
2221@item
2222Gexps carry information about the packages or derivations they refer to,
2223and these dependencies are automatically added as inputs to the build
2224processes that use them.
2225@end itemize
2226
2227To illustrate the idea, here is an example of a gexp:
2228
2229@example
2230(define build-exp
2231 #~(begin
2232 (mkdir #$output)
2233 (chdir #$output)
2234 (symlink (string-append #$coreutils "/bin/ls")
2235 "list-files")))
2236@end example
2237
2238This gexp can be passed to @code{gexp->derivation}; we obtain a
2239derivation that builds a directory containing exactly one symlink to
2240@file{/gnu/store/@dots{}-coreutils-8.22/bin/ls}:
2241
2242@example
2243(gexp->derivation "the-thing" build-exp)
2244@end example
2245
e20fd1bf 2246As one would expect, the @code{"/gnu/store/@dots{}-coreutils-8.22"} string is
21b679f6
LC
2247substituted to the reference to the @var{coreutils} package in the
2248actual build code, and @var{coreutils} is automatically made an input to
2249the derivation. Likewise, @code{#$output} (equivalent to @code{(ungexp
2250output)}) is replaced by a string containing the derivation's output
667b2508
LC
2251directory name.
2252
2253@cindex cross compilation
2254In a cross-compilation context, it is useful to distinguish between
2255references to the @emph{native} build of a package---that can run on the
2256host---versus references to cross builds of a package. To that end, the
2257@code{#+} plays the same role as @code{#$}, but is a reference to a
2258native package build:
2259
2260@example
2261(gexp->derivation "vi"
2262 #~(begin
2263 (mkdir #$output)
2264 (system* (string-append #+coreutils "/bin/ln")
2265 "-s"
2266 (string-append #$emacs "/bin/emacs")
2267 (string-append #$output "/bin/vi")))
2268 #:target "mips64el-linux")
2269@end example
2270
2271@noindent
2272In the example above, the native build of @var{coreutils} is used, so
2273that @command{ln} can actually run on the host; but then the
2274cross-compiled build of @var{emacs} is referenced.
2275
2276The syntactic form to construct gexps is summarized below.
21b679f6
LC
2277
2278@deffn {Scheme Syntax} #~@var{exp}
2279@deffnx {Scheme Syntax} (gexp @var{exp})
2280Return a G-expression containing @var{exp}. @var{exp} may contain one
2281or more of the following forms:
2282
2283@table @code
2284@item #$@var{obj}
2285@itemx (ungexp @var{obj})
2286Introduce a reference to @var{obj}. @var{obj} may be a package or a
2287derivation, in which case the @code{ungexp} form is replaced by its
2288output file name---e.g., @code{"/gnu/store/@dots{}-coreutils-8.22}.
2289
2290If @var{obj} is a list, it is traversed and any package or derivation
2291references are substituted similarly.
2292
2293If @var{obj} is another gexp, its contents are inserted and its
2294dependencies are added to those of the containing gexp.
2295
2296If @var{obj} is another kind of object, it is inserted as is.
2297
2298@item #$@var{package-or-derivation}:@var{output}
2299@itemx (ungexp @var{package-or-derivation} @var{output})
2300This is like the form above, but referring explicitly to the
2301@var{output} of @var{package-or-derivation}---this is useful when
2302@var{package-or-derivation} produces multiple outputs (@pxref{Packages
2303with Multiple Outputs}).
2304
667b2508
LC
2305@item #+@var{obj}
2306@itemx #+@var{obj}:output
2307@itemx (ungexp-native @var{obj})
2308@itemx (ungexp-native @var{obj} @var{output})
2309Same as @code{ungexp}, but produces a reference to the @emph{native}
2310build of @var{obj} when used in a cross compilation context.
2311
21b679f6
LC
2312@item #$output[:@var{output}]
2313@itemx (ungexp output [@var{output}])
2314Insert a reference to derivation output @var{output}, or to the main
2315output when @var{output} is omitted.
2316
2317This only makes sense for gexps passed to @code{gexp->derivation}.
2318
2319@item #$@@@var{lst}
2320@itemx (ungexp-splicing @var{lst})
2321Like the above, but splices the contents of @var{lst} inside the
2322containing list.
2323
667b2508
LC
2324@item #+@@@var{lst}
2325@itemx (ungexp-native-splicing @var{lst})
2326Like the above, but refers to native builds of the objects listed in
2327@var{lst}.
2328
21b679f6
LC
2329@end table
2330
2331G-expressions created by @code{gexp} or @code{#~} are run-time objects
2332of the @code{gexp?} type (see below.)
2333@end deffn
2334
2335@deffn {Scheme Procedure} gexp? @var{obj}
2336Return @code{#t} if @var{obj} is a G-expression.
2337@end deffn
2338
2339G-expressions are meant to be written to disk, either as code building
2340some derivation, or as plain files in the store. The monadic procedures
2341below allow you to do that (@pxref{The Store Monad}, for more
2342information about monads.)
2343
2344@deffn {Monadic Procedure} gexp->derivation @var{name} @var{exp} @
68a61e9f 2345 [#:system (%current-system)] [#:target #f] [#:inputs '()] @
21b679f6
LC
2346 [#:hash #f] [#:hash-algo #f] @
2347 [#:recursive? #f] [#:env-vars '()] [#:modules '()] @
2348 [#:references-graphs #f] [#:local-build? #f] @
2349 [#:guile-for-build #f]
2350Return a derivation @var{name} that runs @var{exp} (a gexp) with
68a61e9f
LC
2351@var{guile-for-build} (a derivation) on @var{system}. When @var{target}
2352is true, it is used as the cross-compilation target triplet for packages
2353referred to by @var{exp}.
21b679f6
LC
2354
2355Make @var{modules} available in the evaluation context of @var{EXP};
2356@var{MODULES} is a list of names of Guile modules from the current
2357search path to be copied in the store, compiled, and made available in
2358the load path during the execution of @var{exp}---e.g., @code{((guix
2359build utils) (guix build gnu-build-system))}.
2360
b53833b2
LC
2361When @var{references-graphs} is true, it must be a list of tuples of one of the
2362following forms:
2363
2364@example
2365(@var{file-name} @var{package})
2366(@var{file-name} @var{package} @var{output})
2367(@var{file-name} @var{derivation})
2368(@var{file-name} @var{derivation} @var{output})
2369(@var{file-name} @var{store-item})
2370@end example
2371
2372The right-hand-side of each element of @var{references-graphs} is automatically made
2373an input of the build process of @var{exp}. In the build environment, each
2374@var{file-name} contains the reference graph of the corresponding item, in a simple
2375text format.
2376
e20fd1bf 2377The other arguments are as for @code{derivation} (@pxref{Derivations}).
21b679f6
LC
2378@end deffn
2379
2380@deffn {Monadic Procedure} gexp->script @var{name} @var{exp}
2381Return an executable script @var{name} that runs @var{exp} using
2382@var{guile} with @var{modules} in its search path.
2383
2384The example below builds a script that simply invokes the @command{ls}
2385command:
2386
2387@example
2388(use-modules (guix gexp) (gnu packages base))
2389
2390(gexp->script "list-files"
2391 #~(execl (string-append #$coreutils "/bin/ls")
2392 "ls"))
2393@end example
2394
2395When ``running'' it through the store (@pxref{The Store Monad,
e20fd1bf 2396@code{run-with-store}}), we obtain a derivation that produces an
21b679f6
LC
2397executable file @file{/gnu/store/@dots{}-list-files} along these lines:
2398
2399@example
2400#!/gnu/store/@dots{}-guile-2.0.11/bin/guile -ds
2401!#
2402(execl (string-append "/gnu/store/@dots{}-coreutils-8.22"/bin/ls")
2403 "ls")
2404@end example
2405@end deffn
2406
2407@deffn {Monadic Procedure} gexp->file @var{name} @var{exp}
2408Return a derivation that builds a file @var{name} containing @var{exp}.
2409
2410The resulting file holds references to all the dependencies of @var{exp}
2411or a subset thereof.
2412@end deffn
2413
2414Of course, in addition to gexps embedded in ``host'' code, there are
2415also modules containing build tools. To make it clear that they are
2416meant to be used in the build stratum, these modules are kept in the
2417@code{(guix build @dots{})} name space.
2418
2419
568717fd
LC
2420@c *********************************************************************
2421@node Utilities
2422@chapter Utilities
2423
210cc920
LC
2424This section describes tools primarily targeted at developers and users
2425who write new package definitions. They complement the Scheme
2426programming interface of Guix in a convenient way.
2427
568717fd 2428@menu
37166310 2429* Invoking guix build:: Building packages from the command line.
210cc920 2430* Invoking guix download:: Downloading a file and printing its hash.
37166310
LC
2431* Invoking guix hash:: Computing the cryptographic hash of a file.
2432* Invoking guix refresh:: Updating package definitions.
b4f5e0e8 2433* Invoking guix lint:: Finding errors in package definitions.
568717fd
LC
2434@end menu
2435
e49951eb
MW
2436@node Invoking guix build
2437@section Invoking @command{guix build}
568717fd 2438
e49951eb 2439The @command{guix build} command builds packages or derivations and
6798a8e4
LC
2440their dependencies, and prints the resulting store paths. Note that it
2441does not modify the user's profile---this is the job of the
e49951eb 2442@command{guix package} command (@pxref{Invoking guix package}). Thus,
6798a8e4
LC
2443it is mainly useful for distribution developers.
2444
2445The general syntax is:
c78bd12b
LC
2446
2447@example
e49951eb 2448guix build @var{options} @var{package-or-derivation}@dots{}
c78bd12b
LC
2449@end example
2450
2451@var{package-or-derivation} may be either the name of a package found in
5401dd75
LC
2452the software distribution such as @code{coreutils} or
2453@code{coreutils-8.20}, or a derivation such as
834129e0 2454@file{/gnu/store/@dots{}-coreutils-8.19.drv}. In the former case, a
e7f34eb0
LC
2455package with the corresponding name (and optionally version) is searched
2456for among the GNU distribution modules (@pxref{Package Modules}).
2457
2458Alternatively, the @code{--expression} option may be used to specify a
2459Scheme expression that evaluates to a package; this is useful when
2460disambiguation among several same-named packages or package variants is
2461needed.
c78bd12b
LC
2462
2463The @var{options} may be zero or more of the following:
2464
2465@table @code
2466
2467@item --expression=@var{expr}
2468@itemx -e @var{expr}
ac5de156 2469Build the package or derivation @var{expr} evaluates to.
c78bd12b 2470
5401dd75 2471For example, @var{expr} may be @code{(@@ (gnu packages guile)
c78bd12b
LC
2472guile-1.8)}, which unambiguously designates this specific variant of
2473version 1.8 of Guile.
2474
56b82106
LC
2475Alternately, @var{expr} may be a G-expression, in which case it is used
2476as a build program passed to @code{gexp->derivation}
2477(@pxref{G-Expressions}).
2478
2479Lastly, @var{expr} may refer to a zero-argument monadic procedure
ac5de156
LC
2480(@pxref{The Store Monad}). The procedure must return a derivation as a
2481monadic value, which is then passed through @code{run-with-store}.
2482
c78bd12b
LC
2483@item --source
2484@itemx -S
2485Build the packages' source derivations, rather than the packages
2486themselves.
2487
e49951eb 2488For instance, @code{guix build -S gcc} returns something like
834129e0 2489@file{/gnu/store/@dots{}-gcc-4.7.2.tar.bz2}, which is GCC's source tarball.
c78bd12b 2490
f9cc8971
LC
2491The returned source tarball is the result of applying any patches and
2492code snippets specified in the package's @code{origin} (@pxref{Defining
2493Packages}).
2494
c78bd12b
LC
2495@item --system=@var{system}
2496@itemx -s @var{system}
2497Attempt to build for @var{system}---e.g., @code{i686-linux}---instead of
2498the host's system type.
2499
2500An example use of this is on Linux-based systems, which can emulate
2501different personalities. For instance, passing
2502@code{--system=i686-linux} on an @code{x86_64-linux} system allows users
2503to build packages in a complete 32-bit environment.
2504
e55ec43d
LC
2505@item --target=@var{triplet}
2506@cindex cross-compilation
2507Cross-build for @var{triplet}, which must be a valid GNU triplet, such
2508as @code{"mips64el-linux-gnu"} (@pxref{Configuration Names, GNU
2509configuration triplets,, configure, GNU Configure and Build System}).
2510
7f3673f2
LC
2511@item --with-source=@var{source}
2512Use @var{source} as the source of the corresponding package.
2513@var{source} must be a file name or a URL, as for @command{guix
2514download} (@pxref{Invoking guix download}).
2515
2516The ``corresponding package'' is taken to be one specified on the
2517command line whose name matches the base of @var{source}---e.g., if
2518@var{source} is @code{/src/guile-2.0.10.tar.gz}, the corresponding
2519package is @code{guile}. Likewise, the version string is inferred from
2520@var{source}; in the previous example, it's @code{2.0.10}.
2521
2522This option allows users to try out versions of packages other than the
2523one provided by the distribution. The example below downloads
2524@file{ed-1.7.tar.gz} from a GNU mirror and uses that as the source for
2525the @code{ed} package:
2526
2527@example
2528guix build ed --with-source=mirror://gnu/ed/ed-1.7.tar.gz
2529@end example
2530
2531As a developer, @code{--with-source} makes it easy to test release
2532candidates:
2533
2534@example
2535guix build guile --with-source=../guile-2.0.9.219-e1bb7.tar.xz
2536@end example
2537
2538
c78bd12b
LC
2539@item --derivations
2540@itemx -d
2541Return the derivation paths, not the output paths, of the given
2542packages.
2543
70ee5642
LC
2544@item --root=@var{file}
2545@itemx -r @var{file}
2546Make @var{file} a symlink to the result, and register it as a garbage
2547collector root.
2548
2549@item --log-file
2550Return the build log file names for the given
2551@var{package-or-derivation}s, or raise an error if build logs are
2552missing.
2553
2554This works regardless of how packages or derivations are specified. For
2555instance, the following invocations are equivalent:
2556
2557@example
2558guix build --log-file `guix build -d guile`
2559guix build --log-file `guix build guile`
2560guix build --log-file guile
2561guix build --log-file -e '(@@ (gnu packages guile) guile-2.0)'
2562@end example
2563
2564
2565@end table
2566
2567@cindex common build options
2568In addition, a number of options that control the build process are
2569common to @command{guix build} and other commands that can spawn builds,
2570such as @command{guix package} or @command{guix archive}. These are the
2571following:
2572
2573@table @code
2574
300868ba
LC
2575@item --load-path=@var{directory}
2576@itemx -L @var{directory}
2577Add @var{directory} to the front of the package module search path
2578(@pxref{Package Modules}).
2579
2580This allows users to define their own packages and make them visible to
2581the command-line tools.
2582
c78bd12b
LC
2583@item --keep-failed
2584@itemx -K
2585Keep the build tree of failed builds. Thus, if a build fail, its build
2586tree is kept under @file{/tmp}, in a directory whose name is shown at
2587the end of the build log. This is useful when debugging build issues.
2588
2589@item --dry-run
2590@itemx -n
2591Do not build the derivations.
2592
56b1f4b7
LC
2593@item --fallback
2594When substituting a pre-built binary fails, fall back to building
2595packages locally.
2596
c78bd12b 2597@item --no-substitutes
b5385b52 2598Do not use substitutes for build products. That is, always build things
c4202d60
LC
2599locally instead of allowing downloads of pre-built binaries
2600(@pxref{Substitutes}).
c78bd12b 2601
425b0bfc 2602@item --no-build-hook
4ec2e92d
LC
2603Do not attempt to offload builds @i{via} the daemon's ``build hook''
2604(@pxref{Daemon Offload Setup}). That is, always build things locally
2605instead of offloading builds to remote machines.
425b0bfc 2606
969e678e
LC
2607@item --max-silent-time=@var{seconds}
2608When the build or substitution process remains silent for more than
2609@var{seconds}, terminate it and report a build failure.
2610
002622b6
LC
2611@item --timeout=@var{seconds}
2612Likewise, when the build or substitution process lasts for more than
2613@var{seconds}, terminate it and report a build failure.
2614
2615By default there is no timeout. This behavior can be restored with
2616@code{--timeout=0}.
2617
07ab4bf1
LC
2618@item --verbosity=@var{level}
2619Use the given verbosity level. @var{level} must be an integer between 0
2620and 5; higher means more verbose output. Setting a level of 4 or more
2621may be helpful when debugging setup issues with the build daemon.
2622
70ee5642
LC
2623@item --cores=@var{n}
2624@itemx -c @var{n}
2625Allow the use of up to @var{n} CPU cores for the build. The special
2626value @code{0} means to use as many CPU cores as available.
bf421152 2627
c78bd12b
LC
2628@end table
2629
e49951eb 2630Behind the scenes, @command{guix build} is essentially an interface to
c78bd12b
LC
2631the @code{package-derivation} procedure of the @code{(guix packages)}
2632module, and to the @code{build-derivations} procedure of the @code{(guix
2633store)} module.
2634
210cc920
LC
2635@node Invoking guix download
2636@section Invoking @command{guix download}
2637
2638When writing a package definition, developers typically need to download
2639the package's source tarball, compute its SHA256 hash, and write that
2640hash in the package definition (@pxref{Defining Packages}). The
2641@command{guix download} tool helps with this task: it downloads a file
2642from the given URI, adds it to the store, and prints both its file name
2643in the store and its SHA256 hash.
2644
2645The fact that the downloaded file is added to the store saves bandwidth:
2646when the developer eventually tries to build the newly defined package
2647with @command{guix build}, the source tarball will not have to be
2648downloaded again because it is already in the store. It is also a
2649convenient way to temporarily stash files, which may be deleted
2650eventually (@pxref{Invoking guix gc}).
2651
2652The @command{guix download} command supports the same URIs as used in
2653package definitions. In particular, it supports @code{mirror://} URIs.
2654@code{https} URIs (HTTP over TLS) are supported @emph{provided} the
2655Guile bindings for GnuTLS are available in the user's environment; when
2656they are not available, an error is raised.
2657
2658The following option is available:
2659
2660@table @code
2661@item --format=@var{fmt}
2662@itemx -f @var{fmt}
2663Write the hash in the format specified by @var{fmt}. For more
2664information on the valid values for @var{fmt}, @ref{Invoking guix hash}.
2665@end table
2666
6c365eca
NK
2667@node Invoking guix hash
2668@section Invoking @command{guix hash}
2669
210cc920 2670The @command{guix hash} command computes the SHA256 hash of a file.
6c365eca
NK
2671It is primarily a convenience tool for anyone contributing to the
2672distribution: it computes the cryptographic hash of a file, which can be
2673used in the definition of a package (@pxref{Defining Packages}).
2674
2675The general syntax is:
2676
2677@example
2678guix hash @var{option} @var{file}
2679@end example
2680
2681@command{guix hash} has the following option:
2682
2683@table @code
2684
2685@item --format=@var{fmt}
2686@itemx -f @var{fmt}
210cc920 2687Write the hash in the format specified by @var{fmt}.
6c365eca
NK
2688
2689Supported formats: @code{nix-base32}, @code{base32}, @code{base16}
2690(@code{hex} and @code{hexadecimal} can be used as well).
2691
2692If the @option{--format} option is not specified, @command{guix hash}
2693will output the hash in @code{nix-base32}. This representation is used
2694in the definitions of packages.
2695
3140f2df
LC
2696@item --recursive
2697@itemx -r
2698Compute the hash on @var{file} recursively.
2699
2700In this case, the hash is computed on an archive containing @var{file},
2701including its children if it is a directory. Some of @var{file}'s
2702meta-data is part of the archive; for instance, when @var{file} is a
2703regular file, the hash is different depending on whether @var{file} is
2704executable or not. Meta-data such as time stamps has no impact on the
2705hash (@pxref{Invoking guix archive}).
2706@c FIXME: Replace xref above with xref to an ``Archive'' section when
2707@c it exists.
2708
6c365eca
NK
2709@end table
2710
37166310
LC
2711@node Invoking guix refresh
2712@section Invoking @command{guix refresh}
2713
2714The primary audience of the @command{guix refresh} command is developers
2715of the GNU software distribution. By default, it reports any packages
2716provided by the distribution that are outdated compared to the latest
2717upstream version, like this:
2718
2719@example
2720$ guix refresh
2721gnu/packages/gettext.scm:29:13: gettext would be upgraded from 0.18.1.1 to 0.18.2.1
2722gnu/packages/glib.scm:77:12: glib would be upgraded from 2.34.3 to 2.37.0
2723@end example
2724
2725It does so by browsing each package's FTP directory and determining the
2726highest version number of the source tarballs
2727therein@footnote{Currently, this only works for GNU packages.}.
2728
2729When passed @code{--update}, it modifies distribution source files to
2730update the version numbers and source tarball hashes of those packages'
2731recipes (@pxref{Defining Packages}). This is achieved by downloading
2732each package's latest source tarball and its associated OpenPGP
2733signature, authenticating the downloaded tarball against its signature
2734using @command{gpg}, and finally computing its hash. When the public
2735key used to sign the tarball is missing from the user's keyring, an
2736attempt is made to automatically retrieve it from a public key server;
2737when it's successful, the key is added to the user's keyring; otherwise,
2738@command{guix refresh} reports an error.
2739
2740The following options are supported:
2741
2742@table @code
2743
2744@item --update
2745@itemx -u
2746Update distribution source files (package recipes) in place.
2747@ref{Defining Packages}, for more information on package definitions.
2748
2749@item --select=[@var{subset}]
2750@itemx -s @var{subset}
2751Select all the packages in @var{subset}, one of @code{core} or
2752@code{non-core}.
2753
2754The @code{core} subset refers to all the packages at the core of the
2755distribution---i.e., packages that are used to build ``everything
2756else''. This includes GCC, libc, Binutils, Bash, etc. Usually,
2757changing one of these packages in the distribution entails a rebuild of
2758all the others. Thus, such updates are an inconvenience to users in
2759terms of build time or bandwidth used to achieve the upgrade.
2760
2761The @code{non-core} subset refers to the remaining packages. It is
2762typically useful in cases where an update of the core packages would be
2763inconvenient.
2764
2765@end table
2766
2767In addition, @command{guix refresh} can be passed one or more package
2768names, as in this example:
2769
2770@example
2771guix refresh -u emacs idutils
2772@end example
2773
2774@noindent
2775The command above specifically updates the @code{emacs} and
2776@code{idutils} packages. The @code{--select} option would have no
2777effect in this case.
2778
7d193ec3
EB
2779When considering whether to upgrade a package, it is sometimes
2780convenient to know which packages would be affected by the upgrade and
2781should be checked for compatibility. For this the following option may
2782be used when passing @command{guix refresh} one or more package names:
2783
2784@table @code
2785
2786@item --list-dependent
2787@itemx -l
2788List top-level dependent packages that would need to be rebuilt as a
2789result of upgrading one or more packages.
2790
2791@end table
2792
2793Be aware that the @code{--list-dependent} option only
2794@emph{approximates} the rebuilds that would be required as a result of
2795an upgrade. More rebuilds might be required under some circumstances.
2796
2797@example
7779ab61
LC
2798$ guix refresh --list-dependent flex
2799Building the following 120 packages would ensure 213 dependent packages are rebuilt:
2800hop-2.4.0 geiser-0.4 notmuch-0.18 mu-0.9.9.5 cflow-1.4 idutils-4.6 @dots{}
7d193ec3
EB
2801@end example
2802
2803The command above lists a set of packages that could be built to check
2804for compatibility with an upgraded @code{flex} package.
2805
f9230085
LC
2806The following options can be used to customize GnuPG operation:
2807
2808@table @code
2809
2810@item --key-server=@var{host}
2811Use @var{host} as the OpenPGP key server when importing a public key.
2812
2813@item --gpg=@var{command}
2814Use @var{command} as the GnuPG 2.x command. @var{command} is searched
2815for in @code{$PATH}.
2816
2817@end table
2818
b4f5e0e8
CR
2819@node Invoking guix lint
2820@section Invoking @command{guix lint}
2821The @command{guix lint} is meant to help package developers avoid common
2822errors and use a consistent style. It runs a few checks on a given set of
2823packages in order to find common mistakes in their definitions.
2824
2825The general syntax is:
2826
2827@example
2828guix lint @var{options} @var{package}@dots{}
2829@end example
2830
2831If no package is given on the command line, then all packages are checked.
2832The @var{options} may be zero or more of the following:
2833
2834@table @code
2835
2836@item --list-checkers
2837@itemx -l
2838List and describe all the available checkers that will be run on packages
2839and exit.
2840
2841@end table
37166310 2842
a1ba8475
LC
2843@c *********************************************************************
2844@node GNU Distribution
2845@chapter GNU Distribution
2846
2847Guix comes with a distribution of free software@footnote{The term
2848``free'' here refers to the
2849@url{http://www.gnu.org/philosophy/free-sw.html,freedom provided to
c320011d 2850users of that software}.} that forms the basis of the GNU system. This
a1ba8475
LC
2851includes core GNU packages such as GNU libc, GCC, and Binutils, as well
2852as many GNU and non-GNU applications. The complete list of available
d03bb653
LC
2853packages can be browsed
2854@url{http://www.gnu.org/software/guix/package-list.html,on-line} or by
2855running @command{guix package} (@pxref{Invoking guix package}):
a1ba8475
LC
2856
2857@example
e49951eb 2858guix package --list-available
a1ba8475
LC
2859@end example
2860
401c53c4
LC
2861Our goal is to build a practical 100% free software distribution of
2862Linux-based and other variants of GNU, with a focus on the promotion and
2863tight integration of GNU components, and an emphasis on programs and
2864tools that help users exert that freedom.
2865
c320011d
LC
2866The GNU distribution is currently available on the following platforms:
2867
2868@table @code
2869
2870@item x86_64-linux
2871Intel/AMD @code{x86_64} architecture, Linux-Libre kernel;
2872
2873@item i686-linux
2874Intel 32-bit architecture (IA32), Linux-Libre kernel;
2875
2876@item mips64el-linux
2877little-endian 64-bit MIPS processors, specifically the Loongson series,
2878n32 application binary interface (ABI), and Linux-Libre kernel.
2879
2880@end table
2881
2882@noindent
2883For information on porting to other architectures or kernels,
2884@xref{Porting}.
2885
401c53c4 2886@menu
5af6de3e 2887* System Installation:: Installing the whole operating system.
cf4a9129 2888* System Configuration:: Configuring a GNU system.
91ef73d4 2889* Installing Debugging Files:: Feeding the debugger.
401c53c4 2890* Package Modules:: Packages from the programmer's viewpoint.
da7cabd4 2891* Packaging Guidelines:: Growing the distribution.
401c53c4 2892* Bootstrapping:: GNU/Linux built from scratch.
8b315a6d 2893* Porting:: Targeting another platform or kernel.
401c53c4
LC
2894@end menu
2895
2896Building this distribution is a cooperative effort, and you are invited
2897to join! @ref{Contributing}, for information about how you can help.
2898
5af6de3e
LC
2899@node System Installation
2900@section System Installation
2901
2902This section explains how to install the complete GNU operating system
2903on a machine. The Guix package manager can also be installed on top of
6621cdb6 2904a running GNU/Linux system, @pxref{Installation}.
5af6de3e
LC
2905
2906@ifinfo
2907@c This paragraph is for people reading this from tty2 of the
2908@c installation image.
2909You're reading this documentation with an Info reader. For details on
2910how to use it, hit the @key{RET} key (``return'' or ``enter'') on the
6621cdb6 2911link that follows: @pxref{Help,,, info, Info: An Introduction}. Hit
5af6de3e
LC
2912@kbd{l} afterwards to come back here.
2913@end ifinfo
2914
8aaaae38
LC
2915@subsection Limitations
2916
2917As of version @value{VERSION}, GNU@tie{}Guix and the GNU system
2918distribution are alpha software. It may contain bugs and lack important
2919features. Thus, if you are looking for a stable production system that
2920respects your freedom as a computer user, a good solution at this point
2921is to consider @url{http://www.gnu.org/distros/free-distros.html, one of
2922more established GNU/Linux distributions}. We hope you can soon switch
2923to the GNU system without fear, of course. In the meantime, you can
2924also keep using your distribution and try out the package manager on top
2925of it (@pxref{Installation}).
2926
2927Before you proceed with the installation, be aware of the following
2928noteworthy limitations applicable to version @value{VERSION}:
2929
2930@itemize
2931@item
2932The installation process does not include a graphical user interface and
2933requires familiarity with GNU/Linux (see the following subsections to
2934get a feel of what that means.)
2935
2936@item
2937The system does not yet provide graphical desktop environments such as
2938GNOME and KDE.
2939
2940@item
dbcb0ab1 2941Support for the Logical Volume Manager (LVM) is missing.
8aaaae38
LC
2942
2943@item
2944Few system services are currently supported out-of-the-box
2945(@pxref{Services}).
2946
2947@item
2948On the order of 1,000 packages are available, which means that you may
2949occasionally find that a useful package is missing.
2950@end itemize
2951
2952You've been warned. But more than a disclaimer, this is an invitation
2953to report issues (and success stories!), and join us in improving it.
2954@xref{Contributing}, for more info.
5af6de3e
LC
2955
2956@subsection USB Stick Installation
2957
2958An installation image for USB sticks can be downloaded from
2959@url{ftp://alpha.gnu.org/gnu/guix/gnu-usb-install-@value{VERSION}.@var{system}.xz},
2960where @var{system} is one of:
2961
2962@table @code
2963@item x86_64-linux
2964for a GNU/Linux system on Intel/AMD-compatible 64-bit CPUs;
2965
2966@item i686-linux
2967for a 32-bit GNU/Linux system on Intel-compatible CPUs.
2968@end table
2969
2970This image contains a single partition with the tools necessary for an
2971installation. It is meant to be copied @emph{as is} to a large-enough
2972USB stick.
2973
2974To copy the image to a USB stick, follow these steps:
2975
2976@enumerate
2977@item
2978Decompress the image using the @command{xz} command:
2979
2980@example
2981xz -d gnu-usb-install-@value{VERSION}.@var{system}.xz
2982@end example
2983
2984@item
2985Insert a USB stick of 1@tie{}GiB or more in your machine, and determine
2986its device name. Assuming that USB stick is known as @file{/dev/sdX},
2987copy the image with:
2988
2989@example
445d6529 2990dd if=gnu-usb-install-@value{VERSION}.x86_64 of=/dev/sdX
5af6de3e
LC
2991@end example
2992
2993Access to @file{/dev/sdX} usually requires root privileges.
2994@end enumerate
2995
2996Once this is done, you should be able to reboot the system and boot from
2997the USB stick. The latter usually requires you to get in the BIOS' boot
2998menu, where you can choose to boot from the USB stick.
2999
3000@subsection Preparing for Installation
3001
3002Once you have successfully booted the image on the USB stick, you should
3003end up with a root prompt. Several console TTYs are configured and can
3004be used to run commands as root. TTY2 shows this documentation,
3005browsable using the Info reader commands (@pxref{Help,,, info, Info: An
3006Introduction}).
3007
3008To install the system, you would:
3009
3010@enumerate
3011
3012@item
3013Configure the network, by running @command{dhclient eth0} (to get an
3014automatically assigned IP address from the wired network interface
3015controller), or using the @command{ifconfig} command.
3016
3017The system automatically loads drivers for your network interface
3018controllers.
3019
3020Setting up network access is almost always a requirement because the
3021image does not contain all the software and tools that may be needed.
3022
3023@item
3024Unless this has already been done, you must partition and format the
3025target partitions.
3026
7ab44369
LC
3027Preferably, assign partitions a label so that you can easily and
3028reliably refer to them in @code{file-system} declarations (@pxref{File
3029Systems}). This is typically done using the @code{-L} option of
3030@command{mkfs.ext4} and related commands.
3031
5af6de3e
LC
3032The installation image includes Parted (@pxref{Overview,,, parted, GNU
3033Parted User Manual}), @command{fdisk}, and e2fsprogs, the suite of tools
3034to manipulate ext2/ext3/ext4 file systems.
3035
83a17b62
LC
3036@item
3037Once that is done, mount the target root partition under @file{/mnt}.
3038
3039@item
3040Lastly, run @code{deco start cow-store /mnt}.
3041
3042This will make @file{/gnu/store} copy-on-write, such that packages added
3043to it during the installation phase will be written to the target disk
3044rather than kept in memory.
3045
5af6de3e
LC
3046@end enumerate
3047
5af6de3e
LC
3048
3049@subsection Proceeding with the Installation
3050
3051With the target partitions ready, you now have to edit a file and
3052provide the declaration of the operating system to be installed. To
3053that end, the installation system comes with two text editors: GNU nano
3054(@pxref{Top,,, nano, GNU nano Manual}), and GNU Zile, an Emacs clone.
3055It is better to store that file on the target root file system, say, as
3056@file{/mnt/etc/config.scm}.
3057
3058A minimal operating system configuration, with just the bare minimum and
1dac8566
LC
3059only a root account would look like this (on the installation system,
3060this example is available as @file{/etc/configuration-template.scm}):
5af6de3e
LC
3061
3062@example
931c132a 3063@include os-config.texi
5af6de3e
LC
3064@end example
3065
3066@noindent
3067For more information on @code{operating-system} declarations,
6621cdb6 3068@pxref{Using the Configuration System}.
5af6de3e
LC
3069
3070Once that is done, the new system must be initialized (remember that the
3071target root file system is mounted under @file{/mnt}):
3072
3073@example
3074guix system init /mnt/etc/config.scm /mnt
3075@end example
3076
3077@noindent
3078This will copy all the necessary files, and install GRUB on
3079@file{/dev/sdX}, unless you pass the @option{--no-grub} option. For
6621cdb6 3080more information, @pxref{Invoking guix system}. This command may trigger
5af6de3e
LC
3081downloads or builds of missing packages, which can take some time.
3082
3083Once that command has completed---and hopefully succeeded!---you can
ad14d9e7 3084run @command{reboot} and boot into the new system. Cross fingers, and
5af6de3e
LC
3085join us on @code{#guix} on the Freenode IRC network or on
3086@file{guix-devel@@gnu.org} to share your experience---good or not so
3087good.
3088
3089@subsection Building the Installation Image
3090
3091The installation image described above was built using the @command{guix
3092system} command, specifically:
3093
3094@example
3095guix system disk-image --image-size=800MiB gnu/system/install.scm
3096@end example
3097
3098@xref{Invoking guix system}, for more information. See
3099@file{gnu/system/install.scm} in the source tree for more information
3100about the installation image.
3101
cf4a9129
LC
3102@node System Configuration
3103@section System Configuration
b208a005 3104
cf4a9129
LC
3105@cindex system configuration
3106The GNU system supports a consistent whole-system configuration
3107mechanism. By that we mean that all aspects of the global system
3108configuration---such as the available system services, timezone and
3109locale settings, user accounts---are declared in a single place. Such
3110a @dfn{system configuration} can be @dfn{instantiated}---i.e., effected.
91ef73d4 3111
cf4a9129
LC
3112One of the advantages of putting all the system configuration under the
3113control of Guix is that it supports transactional system upgrades, and
3114makes it possible to roll-back to a previous system instantiation,
3115should something go wrong with the new one (@pxref{Features}). Another
3116one is that it makes it easy to replicate the exact same configuration
3117across different machines, or at different points in time, without
3118having to resort to additional administration tools layered on top of
3119the system's own tools.
3120@c Yes, we're talking of Puppet, Chef, & co. here. ↑
91ef73d4 3121
cf4a9129
LC
3122This section describes this mechanism. First we focus on the system
3123administrator's viewpoint---explaining how the system is configured and
3124instantiated. Then we show how this mechanism can be extended, for
3125instance to support new system services.
91ef73d4 3126
cf4a9129
LC
3127@menu
3128* Using the Configuration System:: Customizing your GNU system.
7313a52e 3129* operating-system Reference:: Detail of operating-system declarations.
cf4a9129 3130* File Systems:: Configuring file system mounts.
510f9d86 3131* Mapped Devices:: Block device extra processing.
cf4a9129
LC
3132* User Accounts:: Specifying user accounts.
3133* Services:: Specifying system services.
0ae8c15a 3134* Setuid Programs:: Programs running with root privileges.
fd1b1fa2 3135* Initial RAM Disk:: Linux-Libre bootstrapping.
cf4a9129
LC
3136* Invoking guix system:: Instantiating a system configuration.
3137* Defining Services:: Adding new service definitions.
3138@end menu
91ef73d4 3139
cf4a9129
LC
3140@node Using the Configuration System
3141@subsection Using the Configuration System
64d76fa6 3142
cf4a9129
LC
3143The operating system is configured by providing an
3144@code{operating-system} declaration in a file that can then be passed to
3145the @command{guix system} command (@pxref{Invoking guix system}). A
3146simple setup, with the default system services, the default Linux-Libre
3147kernel, initial RAM disk, and boot loader looks like this:
91ef73d4 3148
cf4a9129
LC
3149@findex operating-system
3150@lisp
3151(use-modules (gnu) ; for 'user-account', '%base-services', etc.
3152 (gnu packages emacs) ; for 'emacs'
3153 (gnu services ssh)) ; for 'lsh-service'
91ef73d4 3154
cf4a9129
LC
3155(operating-system
3156 (host-name "komputilo")
3157 (timezone "Europe/Paris")
3158 (locale "fr_FR.UTF-8")
3159 (bootloader (grub-configuration
3160 (device "/dev/sda")))
a69576ea 3161 (file-systems (cons (file-system
cf4a9129
LC
3162 (device "/dev/sda1") ; or partition label
3163 (mount-point "/")
a69576ea
LC
3164 (type "ext3"))
3165 %base-file-systems))
cf4a9129
LC
3166 (users (list (user-account
3167 (name "alice")
3168 (password "")
1c00f836 3169 (uid 1000) (group 100)
cf4a9129
LC
3170 (comment "Bob's sister")
3171 (home-directory "/home/alice"))))
3172 (packages (cons emacs %base-packages))
3173 (services (cons (lsh-service #:port 2222 #:allow-root-login? #t)
3174 %base-services)))
3175@end lisp
401c53c4 3176
cf4a9129
LC
3177This example should be self-describing. Some of the fields defined
3178above, such as @code{host-name} and @code{bootloader}, are mandatory.
3179Others, such as @code{packages} and @code{services}, can be omitted, in
3180which case they get a default value.
e7f34eb0 3181
cf4a9129
LC
3182@vindex %base-packages
3183The @code{packages} field lists
3184packages that will be globally visible on the system, for all user
3185accounts---i.e., in every user's @code{PATH} environment variable---in
3186addition to the per-user profiles (@pxref{Invoking guix package}). The
3187@var{%base-packages} variable provides all the tools one would expect
3188for basic user and administrator tasks---including the GNU Core
3189Utilities, the GNU Networking Utilities, the GNU Zile lightweight text
3190editor, @command{find}, @command{grep}, etc. The example above adds
3191Emacs to those, taken from the @code{(gnu packages emacs)} module
3192(@pxref{Package Modules}).
e7f34eb0 3193
cf4a9129
LC
3194@vindex %base-services
3195The @code{services} field lists @dfn{system services} to be made
3196available when the system starts (@pxref{Services}).
3197The @code{operating-system} declaration above specifies that, in
3198addition to the basic services, we want the @command{lshd} secure shell
3199daemon listening on port 2222, and allowing remote @code{root} logins
3200(@pxref{Invoking lshd,,, lsh, GNU lsh Manual}). Under the hood,
3201@code{lsh-service} arranges so that @code{lshd} is started with the
3202right command-line options, possibly with supporting configuration files
7313a52e
LC
3203generated as needed (@pxref{Defining Services}). @xref{operating-system
3204Reference}, for details about the available @code{operating-system}
3205fields.
a1ba8475 3206
cf4a9129
LC
3207Assuming the above snippet is stored in the @file{my-system-config.scm}
3208file, the @command{guix system reconfigure my-system-config.scm} command
3209instantiates that configuration, and makes it the default GRUB boot
3210entry (@pxref{Invoking guix system}). The normal way to change the
3211system's configuration is by updating this file and re-running the
3212@command{guix system} command.
b81e1947 3213
cf4a9129
LC
3214At the Scheme level, the bulk of an @code{operating-system} declaration
3215is instantiated with the following monadic procedure (@pxref{The Store
3216Monad}):
b81e1947 3217
cf4a9129
LC
3218@deffn {Monadic Procedure} operating-system-derivation os
3219Return a derivation that builds @var{os}, an @code{operating-system}
3220object (@pxref{Derivations}).
b81e1947 3221
cf4a9129
LC
3222The output of the derivation is a single directory that refers to all
3223the packages, configuration files, and other supporting files needed to
3224instantiate @var{os}.
3225@end deffn
b81e1947 3226
7313a52e
LC
3227@node operating-system Reference
3228@subsection @code{operating-system} Reference
3229
3230This section summarizes all the options available in
3231@code{operating-system} declarations (@pxref{Using the Configuration
3232System}).
3233
3234@deftp {Data Type} operating-system
3235This is the data type representing an operating system configuration.
3236By that, we mean all the global system configuration, not per-user
3237configuration (@pxref{Using the Configuration System}).
3238
3239@table @asis
3240@item @code{kernel} (default: @var{linux-libre})
3241The package object of the operating system to use@footnote{Currently
3242only the Linux-libre kernel is supported. In the future, it will be
3243possible to use the GNU@tie{}Hurd.}.
3244
3245@item @code{bootloader}
3246The system bootloader configuration object.
3247@c FIXME: Add xref to bootloader section.
3248
3249@item @code{initrd} (default: @code{base-initrd})
3250A two-argument monadic procedure that returns an initial RAM disk for
3251the Linux kernel. @xref{Initial RAM Disk}.
3252
3253@item @code{host-name}
3254The host name.
3255
3256@item @code{hosts-file}
3257@cindex hosts file
3258A zero-argument monadic procedure that returns a text file for use as
3259@file{/etc/hosts} (@pxref{Host Names,,, libc, The GNU C Library
3260Reference Manual}). The default is to produce a file with entries for
3261@code{localhost} and @var{host-name}.
3262
3263@item @code{mapped-devices} (default: @code{'()})
3264A list of mapped devices. @xref{Mapped Devices}.
3265
3266@item @code{file-systems}
3267A list of file systems. @xref{File Systems}.
3268
3269@item @code{swap-devices} (default: @code{'()})
3270@cindex swap devices
3271A list of strings identifying devices to be used for ``swap space''
3272(@pxref{Memory Concepts,,, libc, The GNU C Library Reference Manual}).
3273For example, @code{'("/dev/sda3")}.
3274
3275@item @code{users} (default: @code{'()})
3276@itemx @code{groups} (default: @var{%base-groups})
3277List of user accounts and groups. @xref{User Accounts}.
3278
3279@item @code{skeletons} (default: @code{(default-skeletons)})
3280A monadic list of pairs of target file name and files. These are the
3281files that will be used as skeletons as new accounts are created.
3282
3283For instance, a valid value may look like this:
3284
3285@example
3286(mlet %store-monad ((bashrc (text-file "bashrc" "\
3287 export PATH=$HOME/.guix-profile/bin")))
3288 (return `((".bashrc" ,bashrc))))
3289@end example
3290
3291@item @code{issue} (default: @var{%default-issue})
3292A string denoting the contents of the @file{/etc/issue} file, which is
3293what displayed when users log in on a text console.
3294
3295@item @code{packages} (default: @var{%base-packages})
3296The set of packages installed in the global profile, which is accessible
3297at @file{/run/current-system/profile}.
3298
3299The default set includes core utilities, but it is good practice to
3300install non-core utilities in user profiles (@pxref{Invoking guix
3301package}).
3302
3303@item @code{timezone}
3304A timezone identifying string---e.g., @code{"Europe/Paris"}.
3305
3306@item @code{locale} (default: @code{"en_US.UTF-8"})
3307The name of the default locale (@pxref{Locales,,, libc, The GNU C
3308Library Reference Manual}).
3309
3310@item @code{services} (default: @var{%base-services})
3311A list of monadic values denoting system services. @xref{Services}.
3312
3313@item @code{pam-services} (default: @code{(base-pam-services)})
3314@cindex PAM
3315@cindex pluggable authentication modules
3316Linux @dfn{pluggable authentication module} (PAM) services.
3317@c FIXME: Add xref to PAM services section.
3318
3319@item @code{setuid-programs} (default: @var{%setuid-programs})
3320List of string-valued G-expressions denoting setuid programs.
3321@xref{Setuid Programs}.
3322
3323@item @code{sudoers} (default: @var{%sudoers-specification})
3324@cindex sudoers
3325The contents of the @file{/etc/sudoers} file as a string.
3326
3327This file specifies which users can use the @command{sudo} command, what
3328they are allowed to do, and what privileges they may gain. The default
3329is that only @code{root} and members of the @code{wheel} group may use
3330@code{sudo}.
3331
3332@end table
3333@end deftp
3334
cf4a9129
LC
3335@node File Systems
3336@subsection File Systems
b81e1947 3337
cf4a9129
LC
3338The list of file systems to be mounted is specified in the
3339@code{file-systems} field of the operating system's declaration
3340(@pxref{Using the Configuration System}). Each file system is declared
3341using the @code{file-system} form, like this:
b81e1947
LC
3342
3343@example
cf4a9129
LC
3344(file-system
3345 (mount-point "/home")
3346 (device "/dev/sda3")
3347 (type "ext4"))
b81e1947
LC
3348@end example
3349
cf4a9129
LC
3350As usual, some of the fields are mandatory---those shown in the example
3351above---while others can be omitted. These are described below.
b81e1947 3352
cf4a9129
LC
3353@deftp {Data Type} file-system
3354Objects of this type represent file systems to be mounted. They
3355contain the following members:
5ff3c4b8 3356
cf4a9129
LC
3357@table @asis
3358@item @code{type}
3359This is a string specifying the type of the file system---e.g.,
3360@code{"ext4"}.
5ff3c4b8 3361
cf4a9129
LC
3362@item @code{mount-point}
3363This designates the place where the file system is to be mounted.
b81e1947 3364
cf4a9129
LC
3365@item @code{device}
3366This names the ``source'' of the file system. By default it is the name
3367of a node under @file{/dev}, but its meaning depends on the @code{title}
3368field described below.
401c53c4 3369
cf4a9129
LC
3370@item @code{title} (default: @code{'device})
3371This is a symbol that specifies how the @code{device} field is to be
3372interpreted.
401c53c4 3373
cf4a9129
LC
3374When it is the symbol @code{device}, then the @code{device} field is
3375interpreted as a file name; when it is @code{label}, then @code{device}
3376is interpreted as a partition label name; when it is @code{uuid},
3377@code{device} is interpreted as a partition unique identifier (UUID).
da7cabd4 3378
cf4a9129
LC
3379The @code{label} and @code{uuid} options offer a way to refer to disk
3380partitions without having to hard-code their actual device name.
da7cabd4 3381
cf4a9129
LC
3382@item @code{flags} (default: @code{'()})
3383This is a list of symbols denoting mount flags. Recognized flags
2c071ce9
LC
3384include @code{read-only}, @code{bind-mount}, @code{no-dev} (disallow
3385access to special files), @code{no-suid} (ignore setuid and setgid
3386bits), and @code{no-exec} (disallow program execution.)
da7cabd4 3387
cf4a9129
LC
3388@item @code{options} (default: @code{#f})
3389This is either @code{#f}, or a string denoting mount options.
da7cabd4 3390
cf4a9129
LC
3391@item @code{needed-for-boot?} (default: @code{#f})
3392This Boolean value indicates whether the file system is needed when
3393booting. If that is true, then the file system is mounted when the
3394initial RAM disk (initrd) is loaded. This is always the case, for
3395instance, for the root file system.
da7cabd4 3396
cf4a9129
LC
3397@item @code{check?} (default: @code{#t})
3398This Boolean indicates whether the file system needs to be checked for
3399errors before being mounted.
f9cc8971 3400
4e469051
LC
3401@item @code{create-mount-point?} (default: @code{#f})
3402When true, the mount point is created if it does not exist yet.
3403
cf4a9129
LC
3404@end table
3405@end deftp
da7cabd4 3406
a69576ea
LC
3407The @code{(gnu system file-systems)} exports the following useful
3408variables.
3409
3410@defvr {Scheme Variable} %base-file-systems
3411These are essential file systems that are required on normal systems,
3412such as @var{%devtmpfs-file-system} (see below.) Operating system
3413declarations should always contain at least these.
3414@end defvr
3415
3416@defvr {Scheme Variable} %devtmpfs-file-system
3417The @code{devtmpfs} file system to be mounted on @file{/dev}. This is a
3418requirement for udev (@pxref{Base Services, @code{udev-service}}).
3419@end defvr
3420
7f239fd3
LC
3421@defvr {Scheme Variable} %pseudo-terminal-file-system
3422This is the file system to be mounted as @file{/dev/pts}. It supports
3423@dfn{pseudo-terminals} created @i{via} @code{openpty} and similar
3424functions (@pxref{Pseudo-Terminals,,, libc, The GNU C Library Reference
3425Manual}). Pseudo-terminals are used by terminal emulators such as
3426@command{xterm}.
3427@end defvr
3428
db17ae5c
LC
3429@defvr {Scheme Variable} %shared-memory-file-system
3430This file system is mounted as @file{/dev/shm} and is used to support
3431memory sharing across processes (@pxref{Memory-mapped I/O,
3432@code{shm_open},, libc, The GNU C Library Reference Manual}).
3433@end defvr
3434
a69576ea
LC
3435@defvr {Scheme Variable} %binary-format-file-system
3436The @code{binfmt_misc} file system, which allows handling of arbitrary
3437executable file types to be delegated to user space. This requires the
3438@code{binfmt.ko} kernel module to be loaded.
3439@end defvr
3440
3441@defvr {Scheme Variable} %fuse-control-file-system
3442The @code{fusectl} file system, which allows unprivileged users to mount
3443and unmount user-space FUSE file systems. This requires the
3444@code{fuse.ko} kernel module to be loaded.
3445@end defvr
3446
510f9d86
LC
3447@node Mapped Devices
3448@subsection Mapped Devices
3449
3450@cindex device mapping
3451@cindex mapped devices
3452The Linux kernel has a notion of @dfn{device mapping}: a block device,
3453such as a hard disk partition, can be @dfn{mapped} into another device,
3454with additional processing over the data that flows through
3455it@footnote{Note that the GNU@tie{}Hurd makes no difference between the
3456concept of a ``mapped device'' and that of a file system: both boil down
3457to @emph{translating} input/output operations made on a file to
3458operations on its backing store. Thus, the Hurd implements mapped
3459devices, like file systems, using the generic @dfn{translator} mechanism
3460(@pxref{Translators,,, hurd, The GNU Hurd Reference Manual}).}. A
3461typical example is encryption device mapping: all writes to the mapped
3462device are encrypted, and all reads are deciphered, transparently.
3463
3464Mapped devices are declared using the @code{mapped-device} form:
3465
3466@example
3467(mapped-device
3468 (source "/dev/sda3")
3469 (target "home")
3470 (type luks-device-mapping))
3471@end example
3472
3473@noindent
3474@cindex disk encryption
3475@cindex LUKS
3476This example specifies a mapping from @file{/dev/sda3} to
3477@file{/dev/mapper/home} using LUKS---the
3478@url{http://code.google.com/p/cryptsetup,Linux Unified Key Setup}, a
3479standard mechanism for disk encryption. The @file{/dev/mapper/home}
3480device can then be used as the @code{device} of a @code{file-system}
3481declaration (@pxref{File Systems}). The @code{mapped-device} form is
3482detailed below.
3483
3484@deftp {Data Type} mapped-device
3485Objects of this type represent device mappings that will be made when
3486the system boots up.
3487
3488@table @code
3489@item source
3490This string specifies the name of the block device to be mapped, such as
3491@code{"/dev/sda3"}.
3492
3493@item target
3494This string specifies the name of the mapping to be established. For
3495example, specifying @code{"my-partition"} will lead to the creation of
3496the @code{"/dev/mapper/my-partition"} device.
3497
3498@item type
3499This must be a @code{mapped-device-kind} object, which specifies how
3500@var{source} is mapped to @var{target}.
3501@end table
3502@end deftp
3503
3504@defvr {Scheme Variable} luks-device-mapping
3505This defines LUKS block device encryption using the @command{cryptsetup}
3506command, from the same-named package. This relies on the
3507@code{dm-crypt} Linux kernel module.
3508@end defvr
3509
cf4a9129
LC
3510@node User Accounts
3511@subsection User Accounts
ee85f3db 3512
cf4a9129 3513User accounts are specified with the @code{user-account} form:
ee85f3db 3514
cf4a9129
LC
3515@example
3516(user-account
3517 (name "alice")
3518 (group "users")
24e752c0
LC
3519 (supplementary-groups '("wheel" ;allow use of sudo, etc.
3520 "audio" ;sound card
3521 "video" ;video devices such as webcams
3522 "cdrom")) ;the good ol' CD-ROM
cf4a9129
LC
3523 (comment "Bob's sister")
3524 (home-directory "/home/alice"))
3525@end example
25083588 3526
cf4a9129
LC
3527@deftp {Data Type} user-account
3528Objects of this type represent user accounts. The following members may
3529be specified:
ee85f3db 3530
cf4a9129
LC
3531@table @asis
3532@item @code{name}
3533The name of the user account.
ee85f3db 3534
cf4a9129
LC
3535@item @code{group}
3536This is the name (a string) or identifier (a number) of the user group
3537this account belongs to.
ee85f3db 3538
cf4a9129
LC
3539@item @code{supplementary-groups} (default: @code{'()})
3540Optionally, this can be defined as a list of group names that this
3541account belongs to.
ee85f3db 3542
cf4a9129
LC
3543@item @code{uid} (default: @code{#f})
3544This is the user ID for this account (a number), or @code{#f}. In the
3545latter case, a number is automatically chosen by the system when the
3546account is created.
ee85f3db 3547
cf4a9129
LC
3548@item @code{comment} (default: @code{""})
3549A comment about the account, such as the account's owner full name.
c8c871d1 3550
cf4a9129
LC
3551@item @code{home-directory}
3552This is the name of the home directory for the account.
ee85f3db 3553
cf4a9129
LC
3554@item @code{shell} (default: Bash)
3555This is a G-expression denoting the file name of a program to be used as
3556the shell (@pxref{G-Expressions}).
ee85f3db 3557
cf4a9129
LC
3558@item @code{system?} (default: @code{#f})
3559This Boolean value indicates whether the account is a ``system''
3560account. System accounts are sometimes treated specially; for instance,
3561graphical login managers do not list them.
ee85f3db 3562
cf4a9129
LC
3563@item @code{password} (default: @code{#f})
3564Unless @code{#f}, this is the password to be used for the account.
c8c871d1 3565
cf4a9129
LC
3566@end table
3567@end deftp
ee85f3db 3568
cf4a9129 3569User group declarations are even simpler:
ee85f3db 3570
cf4a9129
LC
3571@example
3572(user-group (name "students"))
3573@end example
ee85f3db 3574
cf4a9129
LC
3575@deftp {Data Type} user-group
3576This type is for, well, user groups. There are just a few fields:
af8a56b8 3577
cf4a9129
LC
3578@table @asis
3579@item @code{name}
3580The group's name.
ee85f3db 3581
cf4a9129
LC
3582@item @code{id} (default: @code{#f})
3583The group identifier (a number). If @code{#f}, a new number is
3584automatically allocated when the group is created.
ee85f3db 3585
c8fa3426
LC
3586@item @code{system?} (default: @code{#f})
3587This Boolean value indicates whether the group is a ``system'' group.
3588System groups have low numerical IDs.
3589
cf4a9129
LC
3590@item @code{password} (default: @code{#f})
3591What, user groups can have a password? Well, apparently yes. Unless
3592@code{#f}, this field specifies the group's password.
ee85f3db 3593
cf4a9129
LC
3594@end table
3595@end deftp
401c53c4 3596
cf4a9129
LC
3597For convenience, a variable lists all the basic user groups one may
3598expect:
401c53c4 3599
cf4a9129
LC
3600@defvr {Scheme Variable} %base-groups
3601This is the list of basic user groups that users and/or packages expect
3602to be present on the system. This includes groups such as ``root'',
3603``wheel'', and ``users'', as well as groups used to control access to
3604specific devices such as ``audio'', ``disk'', and ``cdrom''.
3605@end defvr
401c53c4 3606
401c53c4 3607
cf4a9129
LC
3608@node Services
3609@subsection Services
401c53c4 3610
cf4a9129
LC
3611@cindex system services
3612An important part of preparing an @code{operating-system} declaration is
3613listing @dfn{system services} and their configuration (@pxref{Using the
3614Configuration System}). System services are typically daemons launched
3615when the system boots, or other actions needed at that time---e.g.,
3616configuring network access. They are managed by GNU@tie{}dmd
3617(@pxref{Introduction,,, dmd, GNU dmd Manual}).
401c53c4 3618
cf4a9129
LC
3619The following sections document the available services, starting with
3620the core services.
401c53c4 3621
cf4a9129
LC
3622@menu
3623* Base Services:: Essential system services.
3624* Networking Services:: Network setup, SSH daemon, etc.
3625* X Window:: Graphical display.
3626@end menu
401c53c4 3627
cf4a9129
LC
3628@node Base Services
3629@subsubsection Base Services
a1ba8475 3630
cf4a9129
LC
3631The @code{(gnu services base)} module provides definitions for the basic
3632services that one expects from the system. The services exported by
3633this module are listed below.
401c53c4 3634
cf4a9129
LC
3635@defvr {Scheme Variable} %base-services
3636This variable contains a list of basic services@footnote{Technically,
3637this is a list of monadic services. @xref{The Store Monad}.} one would
3638expect from the system: a login service (mingetty) on each tty, syslogd,
3639libc's name service cache daemon (nscd), the udev device manager, and
3640more.
401c53c4 3641
cf4a9129
LC
3642This is the default value of the @code{services} field of
3643@code{operating-system} declarations. Usually, when customizing a
3644system, you will want to append services to @var{%base-services}, like
3645this:
401c53c4 3646
cf4a9129
LC
3647@example
3648(cons* (avahi-service) (lshd-service) %base-services)
3649@end example
3650@end defvr
401c53c4 3651
cf4a9129
LC
3652@deffn {Monadic Procedure} host-name-service @var{name}
3653Return a service that sets the host name to @var{name}.
3654@end deffn
401c53c4 3655
cf4a9129
LC
3656@deffn {Monadic Procedure} mingetty-service @var{tty} [#:motd] @
3657 [#:auto-login #f] [#:login-program] [#:login-pause? #f] @
3658 [#:allow-empty-passwords? #f]
3659Return a service to run mingetty on @var{tty}.
401c53c4 3660
cf4a9129
LC
3661When @var{allow-empty-passwords?} is true, allow empty log-in password. When
3662@var{auto-login} is true, it must be a user name under which to log-in
3663automatically. @var{login-pause?} can be set to @code{#t} in conjunction with
3664@var{auto-login}, in which case the user will have to press a key before the
3665login shell is launched.
401c53c4 3666
cf4a9129
LC
3667When true, @var{login-program} is a gexp or a monadic gexp denoting the name
3668of the log-in program (the default is the @code{login} program from the Shadow
3669tool suite.)
401c53c4 3670
cf4a9129
LC
3671@var{motd} is a monadic value containing a text file to use as
3672the ``message of the day''.
3673@end deffn
401c53c4 3674
cf4a9129
LC
3675@deffn {Monadic Procedure} nscd-service [#:glibc glibc]
3676Return a service that runs libc's name service cache daemon (nscd).
3677@end deffn
401c53c4 3678
cf4a9129
LC
3679@deffn {Monadic Procedure} syslog-service
3680Return a service that runs @code{syslogd} with reasonable default
3681settings.
3682@end deffn
401c53c4 3683
cf4a9129
LC
3684@deffn {Monadic Procedure} guix-service [#:guix guix] @
3685 [#:builder-group "guixbuild"] [#:build-accounts 10] @
3686 [#:authorize-hydra-key? #f] [#:use-substitutes? #t] @
3687 [#:extra-options '()]
3688Return a service that runs the build daemon from @var{guix}, and has
3689@var{build-accounts} user accounts available under @var{builder-group}.
401c53c4 3690
cf4a9129
LC
3691When @var{authorize-hydra-key?} is true, the @code{hydra.gnu.org} public key
3692provided by @var{guix} is authorized upon activation, meaning that substitutes
3693from @code{hydra.gnu.org} are used by default.
401c53c4 3694
cf4a9129
LC
3695If @var{use-substitutes?} is false, the daemon is run with
3696@option{--no-substitutes} (@pxref{Invoking guix-daemon,
3697@option{--no-substitutes}}).
401c53c4 3698
cf4a9129
LC
3699Finally, @var{extra-options} is a list of additional command-line options
3700passed to @command{guix-daemon}.
3701@end deffn
a1ba8475 3702
cf4a9129
LC
3703@deffn {Monadic Procedure} udev-service [#:udev udev]
3704Run @var{udev}, which populates the @file{/dev} directory dynamically.
3705@end deffn
401c53c4 3706
a69576ea 3707
cf4a9129
LC
3708@node Networking Services
3709@subsubsection Networking Services
401c53c4 3710
cf4a9129
LC
3711The @code{(gnu system networking)} module provides services to configure
3712the network interface.
a1ba8475 3713
a023cca8
LC
3714@cindex DHCP, networking service
3715@deffn {Monadic Procedure} dhcp-client-service [#:dhcp @var{isc-dhcp}]
3716Return a service that runs @var{dhcp}, a Dynamic Host Configuration
3717Protocol (DHCP) client, on all the non-loopback network interfaces.
3718@end deffn
3719
cf4a9129
LC
3720@deffn {Monadic Procedure} static-networking-service @var{interface} @var{ip} @
3721 [#:gateway #f] [#:name-services @code{'()}]
3722Return a service that starts @var{interface} with address @var{ip}. If
3723@var{gateway} is true, it must be a string specifying the default network
3724gateway.
3725@end deffn
8b315a6d 3726
cf4a9129
LC
3727@deffn {Monadic Procedure} tor-service [#:tor tor]
3728Return a service to run the @uref{https://torproject.org,Tor} daemon.
8b315a6d 3729
cf4a9129
LC
3730The daemon runs with the default settings (in particular the default exit
3731policy) as the @code{tor} unprivileged user.
3732@end deffn
8b315a6d 3733
4627a464
LC
3734@deffn {Monadic Procedure} bitlbee-service [#:bitlbee bitlbee] @
3735 [#:interface "127.0.0.1"] [#:port 6667] @
3736 [#:extra-settings ""]
3737Return a service that runs @url{http://bitlbee.org,BitlBee}, a daemon that
3738acts as a gateway between IRC and chat networks.
3739
3740The daemon will listen to the interface corresponding to the IP address
3741specified in @var{interface}, on @var{port}. @code{127.0.0.1} means that only
3742local clients can connect, whereas @code{0.0.0.0} means that connections can
3743come from any networking interface.
3744
3745In addition, @var{extra-settings} specifies a string to append to the
3746configuration file.
3747@end deffn
3748
3749Furthermore, @code{(gnu system ssh)} provides the following service.
8b315a6d 3750
cf4a9129
LC
3751@deffn {Monadic Procedure} lsh-service [#:host-key "/etc/lsh/host-key"] @
3752 [#:interfaces '()] [#:port-number 22] @
3753 [#:allow-empty-passwords? #f] [#:root-login? #f] @
3754 [#:syslog-output? #t] [#:x11-forwarding? #t] @
3755 [#:tcp/ip-forwarding? #t] [#:password-authentication? #t] @
3756 [public-key-authentication? #t] [#:initialize? #f]
3757Run the @command{lshd} program from @var{lsh} to listen on port @var{port-number}.
3758@var{host-key} must designate a file containing the host key, and readable
3759only by root.
72e25e35 3760
cf4a9129
LC
3761When @var{initialize?} is true, automatically create the seed and host key
3762upon service activation if they do not exist yet. This may take long and
3763require interaction.
8b315a6d 3764
cf4a9129
LC
3765When @var{interfaces} is empty, lshd listens for connections on all the
3766network interfaces; otherwise, @var{interfaces} must be a list of host names
3767or addresses.
9bf3c1a7 3768
cf4a9129
LC
3769@var{allow-empty-passwords?} specifies whether to accepts log-ins with empty
3770passwords, and @var{root-login?} specifies whether to accepts log-ins as
3771root.
4af2447e 3772
cf4a9129
LC
3773The other options should be self-descriptive.
3774@end deffn
4af2447e 3775
fa0c1d61
LC
3776@defvr {Scheme Variable} %facebook-host-aliases
3777This variable contains a string for use in @file{/etc/hosts}
3778(@pxref{Host Names,,, libc, The GNU C Library Reference Manual}). Each
3779line contains a entry that maps a known server name of the Facebook
3780on-line service---e.g., @code{www.facebook.com}---to the local
3781host---@code{127.0.0.1} or its IPv6 equivalent, @code{::1}.
3782
3783This variable is typically used in the @code{hosts-file} field of an
7313a52e
LC
3784@code{operating-system} declaration (@pxref{operating-system Reference,
3785@file{/etc/hosts}}):
fa0c1d61
LC
3786
3787@example
3788(use-modules (gnu) (guix))
3789
3790(operating-system
3791 (host-name "mymachine")
3792 ;; ...
3793 (hosts-file
3794 ;; Create a /etc/hosts file with aliases for "localhost"
3795 ;; and "mymachine", as well as for Facebook servers.
3796 (text-file "hosts"
3797 (string-append (local-host-aliases host-name)
3798 %facebook-host-aliases))))
3799@end example
3800
3801This mechanism can prevent programs running locally, such as Web
3802browsers, from accessing Facebook.
3803@end defvr
3804
cf4a9129
LC
3805@node X Window
3806@subsubsection X Window
68ad877c 3807
cf4a9129
LC
3808Support for the X Window graphical display system---specifically
3809Xorg---is provided by the @code{(gnu services xorg)} module. Note that
3810there is no @code{xorg-service} procedure. Instead, the X server is
3811started by the @dfn{login manager}, currently SLiM.
4af2447e 3812
cf4a9129
LC
3813@deffn {Monadic Procedure} slim-service [#:allow-empty-passwords? #f] @
3814 [#:auto-login? #f] [#:default-user ""] [#:startx]
3815Return a service that spawns the SLiM graphical login manager, which in
3816turn starts the X display server with @var{startx}, a command as returned by
3817@code{xorg-start-command}.
4af2447e 3818
cf4a9129
LC
3819When @var{allow-empty-passwords?} is true, allow logins with an empty
3820password. When @var{auto-login?} is true, log in automatically as
3821@var{default-user}.
3822@end deffn
4af2447e 3823
4af2447e 3824
0ae8c15a
LC
3825@node Setuid Programs
3826@subsection Setuid Programs
3827
3828@cindex setuid programs
3829Some programs need to run with ``root'' privileges, even when they are
3830launched by unprivileged users. A notorious example is the
3831@command{passwd} programs, which can users can run to change their
3832password, and which requires write access to the @file{/etc/passwd} and
3833@file{/etc/shadow} files---something normally restricted to root, for
3834obvious security reasons. To address that, these executables are
3835@dfn{setuid-root}, meaning that they always run with root privileges
3836(@pxref{How Change Persona,,, libc, The GNU C Library Reference Manual},
3837for more info about the setuid mechanisms.)
3838
3839The store itself @emph{cannot} contain setuid programs: that would be a
3840security issue since any user on the system can write derivations that
3841populate the store (@pxref{The Store}). Thus, a different mechanism is
3842used: instead of changing the setuid bit directly on files that are in
3843the store, we let the system administrator @emph{declare} which programs
3844should be setuid root.
3845
3846The @code{setuid-programs} field of an @code{operating-system}
3847declaration contains a list of G-expressions denoting the names of
3848programs to be setuid-root (@pxref{Using the Configuration System}).
3849For instance, the @command{passwd} program, which is part of the Shadow
3850package, can be designated by this G-expression (@pxref{G-Expressions}):
3851
3852@example
3853#~(string-append #$shadow "/bin/passwd")
3854@end example
3855
3856A default set of setuid programs is defined by the
3857@code{%setuid-programs} variable of the @code{(gnu system)} module.
3858
3859@defvr {Scheme Variable} %setuid-programs
3860A list of G-expressions denoting common programs that are setuid-root.
3861
3862The list includes commands such as @command{passwd}, @command{ping},
3863@command{su}, and @command{sudo}.
3864@end defvr
3865
3866Under the hood, the actual setuid programs are created in the
3867@file{/run/setuid-programs} directory at system activation time. The
3868files in this directory refer to the ``real'' binaries, which are in the
3869store.
3870
3871
fd1b1fa2
LC
3872@node Initial RAM Disk
3873@subsection Initial RAM Disk
3874
3875@cindex initial RAM disk (initrd)
3876@cindex initrd (initial RAM disk)
3877For bootstrapping purposes, the Linux-Libre kernel is passed an
3878@dfn{initial RAM disk}, or @dfn{initrd}. An initrd contains a temporary
3879root file system, as well as an initialization script. The latter is
3880responsible for mounting the real root file system, and for loading any
3881kernel modules that may be needed to achieve that.
3882
3883The @code{initrd} field of an @code{operating-system} declaration allows
3884you to specify which initrd you would like to use. The @code{(gnu
3885system linux-initrd)} module provides two ways to build an initrd: the
3886high-level @code{base-initrd} procedure, and the low-level
3887@code{expression->initrd} procedure.
3888
3889The @code{base-initrd} procedure is intended to cover most common uses.
3890For example, if you want to add a bunch of kernel modules to be loaded
3891at boot time, you can define the @code{initrd} field of the operating
3892system declaration like this:
3893
3894@example
52ac153e
LC
3895(initrd (lambda (file-systems . rest)
3896 (apply base-initrd file-systems
3897 #:extra-modules '("my.ko" "modules.ko")
3898 rest)))
fd1b1fa2
LC
3899@end example
3900
52ac153e
LC
3901The @code{base-initrd} procedure also handles common use cases that
3902involves using the system as a QEMU guest, or as a ``live'' system whose
3903root file system is volatile.
fd1b1fa2
LC
3904
3905@deffn {Monadic Procedure} base-initrd @var{file-systems} @
3906 [#:qemu-networking? #f] [#:virtio? #f] [#:volatile-root? #f] @
52ac153e 3907 [#:extra-modules '()] [#:mapped-devices '()]
fd1b1fa2
LC
3908Return a monadic derivation that builds a generic initrd. @var{file-systems} is
3909a list of file-systems to be mounted by the initrd, possibly in addition to
3910the root file system specified on the kernel command line via @code{--root}.
52ac153e
LC
3911@var{mapped-devices} is a list of device mappings to realize before
3912@var{file-systems} are mounted (@pxref{Mapped Devices}).
fd1b1fa2
LC
3913
3914When @var{qemu-networking?} is true, set up networking with the standard QEMU
3915parameters. When @var{virtio?} is true, load additional modules so the initrd can
3916be used as a QEMU guest with para-virtualized I/O drivers.
3917
3918When @var{volatile-root?} is true, the root file system is writable but any changes
3919to it are lost.
3920
3921The initrd is automatically populated with all the kernel modules necessary
3922for @var{file-systems} and for the given options. However, additional kernel
3923modules can be listed in @var{extra-modules}. They will be added to the initrd, and
3924loaded at boot time in the order in which they appear.
3925@end deffn
3926
3927Needless to say, the initrds we produce and use embed a
3928statically-linked Guile, and the initialization program is a Guile
3929program. That gives a lot of flexibility. The
3930@code{expression->initrd} procedure builds such an initrd, given the
3931program to run in that initrd.
3932
3933@deffn {Monadic Procedure} expression->initrd @var{exp} @
3934 [#:guile %guile-static-stripped] [#:name "guile-initrd"] @
42d10464 3935 [#:modules '()]
fd1b1fa2
LC
3936Return a derivation that builds a Linux initrd (a gzipped cpio archive)
3937containing @var{guile} and that evaluates @var{exp}, a G-expression,
df650fa8
LC
3938upon booting. All the derivations referenced by @var{exp} are
3939automatically copied to the initrd.
fd1b1fa2 3940
42d10464
LC
3941@var{modules} is a list of Guile module names to be embedded in the
3942initrd.
fd1b1fa2
LC
3943@end deffn
3944
cf4a9129
LC
3945@node Invoking guix system
3946@subsection Invoking @code{guix system}
0918e64a 3947
cf4a9129
LC
3948Once you have written an operating system declaration, as seen in the
3949previous section, it can be @dfn{instantiated} using the @command{guix
3950system} command. The synopsis is:
4af2447e 3951
cf4a9129
LC
3952@example
3953guix system @var{options}@dots{} @var{action} @var{file}
3954@end example
4af2447e 3955
cf4a9129
LC
3956@var{file} must be the name of a file containing an
3957@code{operating-system} declaration. @var{action} specifies how the
3958operating system is instantiate. Currently the following values are
3959supported:
4af2447e 3960
cf4a9129
LC
3961@table @code
3962@item reconfigure
3963Build the operating system described in @var{file}, activate it, and
3964switch to it@footnote{This action is usable only on systems already
3965running GNU.}.
4af2447e 3966
cf4a9129
LC
3967This effects all the configuration specified in @var{file}: user
3968accounts, system services, global package list, setuid programs, etc.
4af2447e 3969
cf4a9129
LC
3970It also adds a GRUB menu entry for the new OS configuration, and moves
3971entries for older configurations to a submenu---unless
3972@option{--no-grub} is passed.
4af2447e 3973
cf4a9129
LC
3974@item build
3975Build the operating system's derivation, which includes all the
3976configuration files and programs needed to boot and run the system.
3977This action does not actually install anything.
113daf62 3978
cf4a9129
LC
3979@item init
3980Populate the given directory with all the files necessary to run the
3981operating system specified in @var{file}. This is useful for first-time
3982installations of the GNU system. For instance:
113daf62
LC
3983
3984@example
cf4a9129 3985guix system init my-os-config.scm /mnt
113daf62
LC
3986@end example
3987
cf4a9129
LC
3988copies to @file{/mnt} all the store items required by the configuration
3989specified in @file{my-os-config.scm}. This includes configuration
3990files, packages, and so on. It also creates other essential files
3991needed for the system to operate correctly---e.g., the @file{/etc},
3992@file{/var}, and @file{/run} directories, and the @file{/bin/sh} file.
113daf62 3993
cf4a9129
LC
3994This command also installs GRUB on the device specified in
3995@file{my-os-config}, unless the @option{--no-grub} option was passed.
113daf62 3996
cf4a9129
LC
3997@item vm
3998@cindex virtual machine
3999Build a virtual machine that contain the operating system declared in
4000@var{file}, and return a script to run that virtual machine (VM).
113daf62 4001
cf4a9129 4002The VM shares its store with the host system.
113daf62 4003
cf4a9129
LC
4004@item vm-image
4005@itemx disk-image
4006Return a virtual machine or disk image of the operating system declared
4007in @var{file} that stands alone. Use the @option{--image-size} option
4008to specify the size of the image.
113daf62 4009
cf4a9129
LC
4010When using @code{vm-image}, the returned image is in qcow2 format, which
4011the QEMU emulator can efficiently use.
113daf62 4012
cf4a9129
LC
4013When using @code{disk-image}, a raw disk image is produced; it can be
4014copied as is to a USB stick, for instance. Assuming @code{/dev/sdc} is
4015the device corresponding to a USB stick, one can copy the image on it
4016using the following command:
113daf62 4017
cf4a9129
LC
4018@example
4019# dd if=$(guix system disk-image my-os.scm) of=/dev/sdc
4020@end example
113daf62 4021
cf4a9129 4022@end table
113daf62 4023
cf4a9129
LC
4024@var{options} can contain any of the common build options provided by
4025@command{guix build} (@pxref{Invoking guix build}). In addition,
4026@var{options} can contain one of the following:
113daf62 4027
cf4a9129
LC
4028@table @option
4029@item --system=@var{system}
4030@itemx -s @var{system}
4031Attempt to build for @var{system} instead of the host's system type.
4032This works as per @command{guix build} (@pxref{Invoking guix build}).
113daf62 4033
cf4a9129
LC
4034@item --image-size=@var{size}
4035For the @code{vm-image} and @code{disk-image} actions, create an image
4036of the given @var{size}. @var{size} may be a number of bytes, or it may
4a44d7bb
LC
4037include a unit as a suffix (@pxref{Block size, size specifications,,
4038coreutils, GNU Coreutils}).
113daf62 4039@end table
113daf62 4040
cf4a9129
LC
4041Note that all the actions above, except @code{build} and @code{init},
4042rely on KVM support in the Linux-Libre kernel. Specifically, the
4043machine should have hardware virtualization support, the corresponding
4044KVM kernel module should be loaded, and the @file{/dev/kvm} device node
4045must exist and be readable and writable by the user and by the daemon's
4046build users.
8451a568 4047
cf4a9129
LC
4048@node Defining Services
4049@subsection Defining Services
8451a568 4050
cf4a9129
LC
4051The @code{(gnu services @dots{})} modules define several procedures that allow
4052users to declare the operating system's services (@pxref{Using the
4053Configuration System}). These procedures are @emph{monadic
4054procedures}---i.e., procedures that return a monadic value in the store
4055monad (@pxref{The Store Monad}). For examples of such procedures,
4056@xref{Services}.
8451a568 4057
cf4a9129
LC
4058@cindex service definition
4059The monadic value returned by those procedures is a @dfn{service
4060definition}---a structure as returned by the @code{service} form.
4061Service definitions specifies the inputs the service depends on, and an
4062expression to start and stop the service. Behind the scenes, service
4063definitions are ``translated'' into the form suitable for the
4064configuration file of dmd, the init system (@pxref{Services,,, dmd, GNU
4065dmd Manual}).
8451a568 4066
cf4a9129
LC
4067As an example, here is what the @code{nscd-service} procedure looks
4068like:
8451a568 4069
cf4a9129
LC
4070@lisp
4071(define (nscd-service)
4072 (with-monad %store-monad
4073 (return (service
4074 (documentation "Run libc's name service cache daemon.")
4075 (provision '(nscd))
4076 (activate #~(begin
4077 (use-modules (guix build utils))
4078 (mkdir-p "/var/run/nscd")))
4079 (start #~(make-forkexec-constructor
4080 (string-append #$glibc "/sbin/nscd")
4081 "-f" "/dev/null" "--foreground"))
4082 (stop #~(make-kill-destructor))
4083 (respawn? #f)))))
4084@end lisp
8451a568 4085
cf4a9129
LC
4086@noindent
4087The @code{activate}, @code{start}, and @code{stop} fields are G-expressions
4088(@pxref{G-Expressions}). The @code{activate} field contains a script to
4089run at ``activation'' time; it makes sure that the @file{/var/run/nscd}
4090directory exists before @command{nscd} is started.
8451a568 4091
cf4a9129
LC
4092The @code{start} and @code{stop} fields refer to dmd's facilities to
4093start and stop processes (@pxref{Service De- and Constructors,,, dmd,
4094GNU dmd Manual}). The @code{provision} field specifies the name under
4095which this service is known to dmd, and @code{documentation} specifies
4096on-line documentation. Thus, the commands @command{deco start ncsd},
4097@command{deco stop nscd}, and @command{deco doc nscd} will do what you
4098would expect (@pxref{Invoking deco,,, dmd, GNU dmd Manual}).
8451a568 4099
8451a568 4100
cf4a9129
LC
4101@node Installing Debugging Files
4102@section Installing Debugging Files
8451a568 4103
cf4a9129
LC
4104@cindex debugging files
4105Program binaries, as produced by the GCC compilers for instance, are
4106typically written in the ELF format, with a section containing
4107@dfn{debugging information}. Debugging information is what allows the
4108debugger, GDB, to map binary code to source code; it is required to
4109debug a compiled program in good conditions.
8451a568 4110
cf4a9129
LC
4111The problem with debugging information is that is takes up a fair amount
4112of disk space. For example, debugging information for the GNU C Library
4113weighs in at more than 60 MiB. Thus, as a user, keeping all the
4114debugging info of all the installed programs is usually not an option.
4115Yet, space savings should not come at the cost of an impediment to
4116debugging---especially in the GNU system, which should make it easier
4117for users to exert their computing freedom (@pxref{GNU Distribution}).
8451a568 4118
cf4a9129
LC
4119Thankfully, the GNU Binary Utilities (Binutils) and GDB provide a
4120mechanism that allows users to get the best of both worlds: debugging
4121information can be stripped from the binaries and stored in separate
4122files. GDB is then able to load debugging information from those files,
4123when they are available (@pxref{Separate Debug Files,,, gdb, Debugging
4124with GDB}).
8451a568 4125
cf4a9129
LC
4126The GNU distribution takes advantage of this by storing debugging
4127information in the @code{lib/debug} sub-directory of a separate package
4128output unimaginatively called @code{debug} (@pxref{Packages with
4129Multiple Outputs}). Users can choose to install the @code{debug} output
4130of a package when they need it. For instance, the following command
4131installs the debugging information for the GNU C Library and for GNU
4132Guile:
8451a568
LC
4133
4134@example
cf4a9129 4135guix package -i glibc:debug guile:debug
8451a568
LC
4136@end example
4137
cf4a9129
LC
4138GDB must then be told to look for debug files in the user's profile, by
4139setting the @code{debug-file-directory} variable (consider setting it
4140from the @file{~/.gdbinit} file, @pxref{Startup,,, gdb, Debugging with
4141GDB}):
8451a568 4142
cf4a9129
LC
4143@example
4144(gdb) set debug-file-directory ~/.guix-profile/lib/debug
4145@end example
8451a568 4146
cf4a9129
LC
4147From there on, GDB will pick up debugging information from the
4148@code{.debug} files under @file{~/.guix-profile/lib/debug}.
8451a568 4149
cf4a9129
LC
4150In addition, you will most likely want GDB to be able to show the source
4151code being debugged. To do that, you will have to unpack the source
4152code of the package of interest (obtained with @code{guix build
4153--source}, @pxref{Invoking guix build}), and to point GDB to that source
4154directory using the @code{directory} command (@pxref{Source Path,
4155@code{directory},, gdb, Debugging with GDB}).
8451a568 4156
cf4a9129
LC
4157@c XXX: keep me up-to-date
4158The @code{debug} output mechanism in Guix is implemented by the
4159@code{gnu-build-system} (@pxref{Build Systems}). Currently, it is
4160opt-in---debugging information is available only for those packages
4161whose definition explicitly declares a @code{debug} output. This may be
4162changed to opt-out in the future, if our build farm servers can handle
4163the load. To check whether a package has a @code{debug} output, use
4164@command{guix package --list-available} (@pxref{Invoking guix package}).
8451a568 4165
8451a568 4166
cf4a9129
LC
4167@node Package Modules
4168@section Package Modules
8451a568 4169
cf4a9129
LC
4170From a programming viewpoint, the package definitions of the
4171GNU distribution are provided by Guile modules in the @code{(gnu packages
4172@dots{})} name space@footnote{Note that packages under the @code{(gnu
4173packages @dots{})} module name space are not necessarily ``GNU
4174packages''. This module naming scheme follows the usual Guile module
4175naming convention: @code{gnu} means that these modules are distributed
4176as part of the GNU system, and @code{packages} identifies modules that
4177define packages.} (@pxref{Modules, Guile modules,, guile, GNU Guile
4178Reference Manual}). For instance, the @code{(gnu packages emacs)}
4179module exports a variable named @code{emacs}, which is bound to a
4180@code{<package>} object (@pxref{Defining Packages}).
113daf62 4181
300868ba 4182The @code{(gnu packages @dots{})} module name space is
cf4a9129
LC
4183automatically scanned for packages by the command-line tools. For
4184instance, when running @code{guix package -i emacs}, all the @code{(gnu
4185packages @dots{})} modules are scanned until one that exports a package
4186object whose name is @code{emacs} is found. This package search
4187facility is implemented in the @code{(gnu packages)} module.
113daf62 4188
300868ba 4189@cindex customization, of packages
8689901f 4190@cindex package module search path
cf4a9129 4191Users can store package definitions in modules with different
300868ba
LC
4192names---e.g., @code{(my-packages emacs)}. These package definitions
4193will not be visible by default. Thus, users can invoke commands such as
4194@command{guix package} and @command{guix build} have to be used with the
4195@code{-e} option so that they know where to find the package, or use the
4196@code{-L} option of these commands to make those modules visible
8689901f
LC
4197(@pxref{Invoking guix build, @code{--load-path}}), or define the
4198@code{GUIX_PACKAGE_PATH} environment variable. This environment
4199variable makes it easy to extend or customize the distribution and is
4200honored by all the user interfaces.
4201
4202@defvr {Environment Variable} GUIX_PACKAGE_PATH
4203This is a colon-separated list of directories to search for package
4204modules. Directories listed in this variable take precedence over the
4205distribution's own modules.
4206@end defvr
ef5dd60a 4207
cf4a9129
LC
4208The distribution is fully @dfn{bootstrapped} and @dfn{self-contained}:
4209each package is built based solely on other packages in the
4210distribution. The root of this dependency graph is a small set of
4211@dfn{bootstrap binaries}, provided by the @code{(gnu packages
4212bootstrap)} module. For more information on bootstrapping,
4213@ref{Bootstrapping}.
ef5dd60a 4214
cf4a9129
LC
4215@node Packaging Guidelines
4216@section Packaging Guidelines
ef5dd60a 4217
cf4a9129
LC
4218The GNU distribution is nascent and may well lack some of your favorite
4219packages. This section describes how you can help make the distribution
4220grow. @xref{Contributing}, for additional information on how you can
4221help.
ef5dd60a 4222
cf4a9129
LC
4223Free software packages are usually distributed in the form of
4224@dfn{source code tarballs}---typically @file{tar.gz} files that contain
4225all the source files. Adding a package to the distribution means
4226essentially two things: adding a @dfn{recipe} that describes how to
4227build the package, including a list of other packages required to build
4228it, and adding @dfn{package meta-data} along with that recipe, such as a
4229description and licensing information.
ef5dd60a 4230
cf4a9129
LC
4231In Guix all this information is embodied in @dfn{package definitions}.
4232Package definitions provide a high-level view of the package. They are
4233written using the syntax of the Scheme programming language; in fact,
4234for each package we define a variable bound to the package definition,
4235and export that variable from a module (@pxref{Package Modules}).
4236However, in-depth Scheme knowledge is @emph{not} a prerequisite for
4237creating packages. For more information on package definitions,
4238@ref{Defining Packages}.
ef5dd60a 4239
cf4a9129
LC
4240Once a package definition is in place, stored in a file in the Guix
4241source tree, it can be tested using the @command{guix build} command
4242(@pxref{Invoking guix build}). For example, assuming the new package is
4243called @code{gnew}, you may run this command from the Guix build tree:
ef5dd60a
LC
4244
4245@example
cf4a9129 4246./pre-inst-env guix build gnew --keep-failed
ef5dd60a 4247@end example
ef5dd60a 4248
cf4a9129
LC
4249Using @code{--keep-failed} makes it easier to debug build failures since
4250it provides access to the failed build tree. Another useful
4251command-line option when debugging is @code{--log-file}, to access the
4252build log.
ef5dd60a 4253
cf4a9129
LC
4254If the package is unknown to the @command{guix} command, it may be that
4255the source file contains a syntax error, or lacks a @code{define-public}
4256clause to export the package variable. To figure it out, you may load
4257the module from Guile to get more information about the actual error:
ef5dd60a 4258
cf4a9129
LC
4259@example
4260./pre-inst-env guile -c '(use-modules (gnu packages gnew))'
4261@end example
ef5dd60a 4262
cf4a9129
LC
4263Once your package builds correctly, please send us a patch
4264(@pxref{Contributing}). Well, if you need help, we will be happy to
4265help you too. Once the patch is committed in the Guix repository, the
4266new package automatically gets built on the supported platforms by
4267@url{http://hydra.gnu.org/gnu/master, our continuous integration
4268system}.
ef5dd60a 4269
cf4a9129
LC
4270@cindex substituter
4271Users can obtain the new package definition simply by running
4272@command{guix pull} (@pxref{Invoking guix pull}). When
4273@code{hydra.gnu.org} is done building the package, installing the
4274package automatically downloads binaries from there
4275(@pxref{Substitutes}). The only place where human intervention is
4276needed is to review and apply the patch.
ef5dd60a 4277
ef5dd60a 4278
cf4a9129
LC
4279@menu
4280* Software Freedom:: What may go into the distribution.
4281* Package Naming:: What's in a name?
4282* Version Numbers:: When the name is not enough.
4283* Python Modules:: Taming the snake.
4284* Perl Modules:: Little pearls.
4285@end menu
ef5dd60a 4286
cf4a9129
LC
4287@node Software Freedom
4288@subsection Software Freedom
ef5dd60a 4289
cf4a9129 4290@c Adapted from http://www.gnu.org/philosophy/philosophy.html.
c11a6eb1 4291
cf4a9129
LC
4292The GNU operating system has been developed so that users can have
4293freedom in their computing. GNU is @dfn{free software}, meaning that
4294users have the @url{http://www.gnu.org/philosophy/free-sw.html,four
4295essential freedoms}: to run the program, to study and change the program
4296in source code form, to redistribute exact copies, and to distribute
4297modified versions. Packages found in the GNU distribution provide only
4298software that conveys these four freedoms.
c11a6eb1 4299
cf4a9129
LC
4300In addition, the GNU distribution follow the
4301@url{http://www.gnu.org/distros/free-system-distribution-guidelines.html,free
4302software distribution guidelines}. Among other things, these guidelines
4303reject non-free firmware, recommendations of non-free software, and
4304discuss ways to deal with trademarks and patents.
ef5dd60a 4305
cf4a9129
LC
4306Some packages contain a small and optional subset that violates the
4307above guidelines, for instance because this subset is itself non-free
4308code. When that happens, the offending items are removed with
4309appropriate patches or code snippets in the package definition's
4310@code{origin} form (@pxref{Defining Packages}). That way, @code{guix
4311build --source} returns the ``freed'' source rather than the unmodified
4312upstream source.
ef5dd60a 4313
ef5dd60a 4314
cf4a9129
LC
4315@node Package Naming
4316@subsection Package Naming
ef5dd60a 4317
cf4a9129
LC
4318A package has actually two names associated with it:
4319First, there is the name of the @emph{Scheme variable}, the one following
4320@code{define-public}. By this name, the package can be made known in the
4321Scheme code, for instance as input to another package. Second, there is
4322the string in the @code{name} field of a package definition. This name
4323is used by package management commands such as
4324@command{guix package} and @command{guix build}.
ef5dd60a 4325
cf4a9129
LC
4326Both are usually the same and correspond to the lowercase conversion of
4327the project name chosen upstream, with underscores replaced with
4328hyphens. For instance, GNUnet is available as @code{gnunet}, and
4329SDL_net as @code{sdl-net}.
927097ef 4330
cf4a9129
LC
4331We do not add @code{lib} prefixes for library packages, unless these are
4332already part of the official project name. But see @pxref{Python
4333Modules} and @ref{Perl Modules} for special rules concerning modules for
4334the Python and Perl languages.
927097ef 4335
ef5dd60a 4336
cf4a9129
LC
4337@node Version Numbers
4338@subsection Version Numbers
ef5dd60a 4339
cf4a9129
LC
4340We usually package only the latest version of a given free software
4341project. But sometimes, for instance for incompatible library versions,
4342two (or more) versions of the same package are needed. These require
4343different Scheme variable names. We use the name as defined
4344in @ref{Package Naming}
4345for the most recent version; previous versions use the same name, suffixed
4346by @code{-} and the smallest prefix of the version number that may
4347distinguish the two versions.
ef5dd60a 4348
cf4a9129
LC
4349The name inside the package definition is the same for all versions of a
4350package and does not contain any version number.
ef5dd60a 4351
cf4a9129 4352For instance, the versions 2.24.20 and 3.9.12 of GTK+ may be packaged as follows:
ef5dd60a 4353
cf4a9129
LC
4354@example
4355(define-public gtk+
4356 (package
4357 (name "gtk+")
4358 (version "3.9.12")
4359 ...))
4360(define-public gtk+-2
4361 (package
4362 (name "gtk+")
4363 (version "2.24.20")
4364 ...))
4365@end example
4366If we also wanted GTK+ 3.8.2, this would be packaged as
4367@example
4368(define-public gtk+-3.8
4369 (package
4370 (name "gtk+")
4371 (version "3.8.2")
4372 ...))
4373@end example
ef5dd60a 4374
ef5dd60a 4375
cf4a9129
LC
4376@node Python Modules
4377@subsection Python Modules
ef5dd60a 4378
cf4a9129
LC
4379We currently package Python 2 and Python 3, under the Scheme variable names
4380@code{python-2} and @code{python} as explained in @ref{Version Numbers}.
4381To avoid confusion and naming clashes with other programming languages, it
4382seems desirable that the name of a package for a Python module contains
4383the word @code{python}.
ef5dd60a 4384
cf4a9129
LC
4385Some modules are compatible with only one version of Python, others with both.
4386If the package Foo compiles only with Python 3, we name it
4387@code{python-foo}; if it compiles only with Python 2, we name it
4388@code{python2-foo}. If it is compatible with both versions, we create two
4389packages with the corresponding names.
ef5dd60a 4390
cf4a9129
LC
4391If a project already contains the word @code{python}, we drop this;
4392for instance, the module python-dateutil is packaged under the names
4393@code{python-dateutil} and @code{python2-dateutil}.
113daf62 4394
523e4896 4395
cf4a9129
LC
4396@node Perl Modules
4397@subsection Perl Modules
523e4896 4398
cf4a9129
LC
4399Perl programs standing for themselves are named as any other package,
4400using the lowercase upstream name.
4401For Perl packages containing a single class, we use the lowercase class name,
4402replace all occurrences of @code{::} by dashes and prepend the prefix
4403@code{perl-}.
4404So the class @code{XML::Parser} becomes @code{perl-xml-parser}.
4405Modules containing several classes keep their lowercase upstream name and
4406are also prepended by @code{perl-}. Such modules tend to have the word
4407@code{perl} somewhere in their name, which gets dropped in favor of the
4408prefix. For instance, @code{libwww-perl} becomes @code{perl-libwww}.
523e4896 4409
523e4896 4410
b25937e3 4411
cf4a9129
LC
4412@node Bootstrapping
4413@section Bootstrapping
b25937e3 4414
cf4a9129 4415@c Adapted from the ELS 2013 paper.
b25937e3 4416
cf4a9129 4417@cindex bootstrapping
7889394e 4418
cf4a9129
LC
4419Bootstrapping in our context refers to how the distribution gets built
4420``from nothing''. Remember that the build environment of a derivation
4421contains nothing but its declared inputs (@pxref{Introduction}). So
4422there's an obvious chicken-and-egg problem: how does the first package
4423get built? How does the first compiler get compiled? Note that this is
4424a question of interest only to the curious hacker, not to the regular
4425user, so you can shamelessly skip this section if you consider yourself
4426a ``regular user''.
72b9d60d 4427
cf4a9129
LC
4428@cindex bootstrap binaries
4429The GNU system is primarily made of C code, with libc at its core. The
4430GNU build system itself assumes the availability of a Bourne shell and
4431command-line tools provided by GNU Coreutils, Awk, Findutils, `sed', and
4432`grep'. Furthermore, build programs---programs that run
4433@code{./configure}, @code{make}, etc.---are written in Guile Scheme
4434(@pxref{Derivations}). Consequently, to be able to build anything at
4435all, from scratch, Guix relies on pre-built binaries of Guile, GCC,
4436Binutils, libc, and the other packages mentioned above---the
4437@dfn{bootstrap binaries}.
72b9d60d 4438
cf4a9129
LC
4439These bootstrap binaries are ``taken for granted'', though we can also
4440re-create them if needed (more on that later).
72b9d60d 4441
cf4a9129 4442@unnumberedsubsec Preparing to Use the Bootstrap Binaries
c79d54fe 4443
cf4a9129
LC
4444@c As of Emacs 24.3, Info-mode displays the image, but since it's a
4445@c large image, it's hard to scroll. Oh well.
4446@image{images/bootstrap-graph,6in,,Dependency graph of the early bootstrap derivations}
523e4896 4447
cf4a9129
LC
4448The figure above shows the very beginning of the dependency graph of the
4449distribution, corresponding to the package definitions of the @code{(gnu
4450packages bootstrap)} module. At this level of detail, things are
4451slightly complex. First, Guile itself consists of an ELF executable,
4452along with many source and compiled Scheme files that are dynamically
4453loaded when it runs. This gets stored in the @file{guile-2.0.7.tar.xz}
4454tarball shown in this graph. This tarball is part of Guix's ``source''
4455distribution, and gets inserted into the store with @code{add-to-store}
4456(@pxref{The Store}).
2e7b5cea 4457
cf4a9129
LC
4458But how do we write a derivation that unpacks this tarball and adds it
4459to the store? To solve this problem, the @code{guile-bootstrap-2.0.drv}
4460derivation---the first one that gets built---uses @code{bash} as its
4461builder, which runs @code{build-bootstrap-guile.sh}, which in turn calls
4462@code{tar} to unpack the tarball. Thus, @file{bash}, @file{tar},
4463@file{xz}, and @file{mkdir} are statically-linked binaries, also part of
4464the Guix source distribution, whose sole purpose is to allow the Guile
4465tarball to be unpacked.
fb729425 4466
cf4a9129
LC
4467Once @code{guile-bootstrap-2.0.drv} is built, we have a functioning
4468Guile that can be used to run subsequent build programs. Its first task
4469is to download tarballs containing the other pre-built binaries---this
4470is what the @code{.tar.xz.drv} derivations do. Guix modules such as
4471@code{ftp-client.scm} are used for this purpose. The
4472@code{module-import.drv} derivations import those modules in a directory
4473in the store, using the original layout. The
4474@code{module-import-compiled.drv} derivations compile those modules, and
4475write them in an output directory with the right layout. This
4476corresponds to the @code{#:modules} argument of
4477@code{build-expression->derivation} (@pxref{Derivations}).
fb729425 4478
cf4a9129
LC
4479Finally, the various tarballs are unpacked by the
4480derivations @code{gcc-bootstrap-0.drv}, @code{glibc-bootstrap-0.drv},
4481etc., at which point we have a working C tool chain.
fb729425 4482
fb729425 4483
cf4a9129 4484@unnumberedsubsec Building the Build Tools
523e4896 4485
cf4a9129
LC
4486@c TODO: Add a package-level dependency graph generated from (gnu
4487@c packages base).
df2ce343 4488
cf4a9129
LC
4489Bootstrapping is complete when we have a full tool chain that does not
4490depend on the pre-built bootstrap tools discussed above. This
4491no-dependency requirement is verified by checking whether the files of
4492the final tool chain contain references to the @file{/gnu/store}
4493directories of the bootstrap inputs. The process that leads to this
4494``final'' tool chain is described by the package definitions found in
4495the @code{(gnu packages base)} module.
df2ce343 4496
cf4a9129
LC
4497@c See <http://lists.gnu.org/archive/html/gnu-system-discuss/2012-10/msg00000.html>.
4498The first tool that gets built with the bootstrap binaries is
4499GNU Make, which is a prerequisite for all the following packages.
4500From there Findutils and Diffutils get built.
523e4896 4501
cf4a9129
LC
4502Then come the first-stage Binutils and GCC, built as pseudo cross
4503tools---i.e., with @code{--target} equal to @code{--host}. They are
4504used to build libc. Thanks to this cross-build trick, this libc is
4505guaranteed not to hold any reference to the initial tool chain.
4af2447e 4506
cf4a9129
LC
4507From there the final Binutils and GCC are built. GCC uses @code{ld}
4508from the final Binutils, and links programs against the just-built libc.
4509This tool chain is used to build the other packages used by Guix and by
4510the GNU Build System: Guile, Bash, Coreutils, etc.
4af2447e 4511
cf4a9129
LC
4512And voilà! At this point we have the complete set of build tools that
4513the GNU Build System expects. These are in the @code{%final-inputs}
dd164244
MW
4514variable of the @code{(gnu packages commencement)} module, and are
4515implicitly used by any package that uses @code{gnu-build-system}
4516(@pxref{Defining Packages}).
4af2447e 4517
4af2447e 4518
cf4a9129 4519@unnumberedsubsec Building the Bootstrap Binaries
4af2447e 4520
cf4a9129
LC
4521Because the final tool chain does not depend on the bootstrap binaries,
4522those rarely need to be updated. Nevertheless, it is useful to have an
4523automated way to produce them, should an update occur, and this is what
4524the @code{(gnu packages make-bootstrap)} module provides.
4af2447e 4525
cf4a9129
LC
4526The following command builds the tarballs containing the bootstrap
4527binaries (Guile, Binutils, GCC, libc, and a tarball containing a mixture
4528of Coreutils and other basic command-line tools):
4b2615e1 4529
cf4a9129
LC
4530@example
4531guix build bootstrap-tarballs
4532@end example
4533
4534The generated tarballs are those that should be referred to in the
4535@code{(gnu packages bootstrap)} module mentioned at the beginning of
4536this section.
4537
4538Still here? Then perhaps by now you've started to wonder: when do we
4539reach a fixed point? That is an interesting question! The answer is
4540unknown, but if you would like to investigate further (and have
4541significant computational and storage resources to do so), then let us
4542know.
4543
4544@node Porting
4545@section Porting to a New Platform
4546
4547As discussed above, the GNU distribution is self-contained, and
4548self-containment is achieved by relying on pre-built ``bootstrap
4549binaries'' (@pxref{Bootstrapping}). These binaries are specific to an
4550operating system kernel, CPU architecture, and application binary
4551interface (ABI). Thus, to port the distribution to a platform that is
4552not yet supported, one must build those bootstrap binaries, and update
4553the @code{(gnu packages bootstrap)} module to use them on that platform.
4554
4555Fortunately, Guix can @emph{cross compile} those bootstrap binaries.
4556When everything goes well, and assuming the GNU tool chain supports the
4557target platform, this can be as simple as running a command like this
4558one:
4559
4560@example
4561guix build --target=armv5tel-linux-gnueabi bootstrap-tarballs
4562@end example
4563
4564Once these are built, the @code{(gnu packages bootstrap)} module needs
4565to be updated to refer to these binaries on the target platform. In
4566addition, the @code{glibc-dynamic-linker} procedure in that module must
4567be augmented to return the right file name for libc's dynamic linker on
4568that platform; likewise, @code{system->linux-architecture} in @code{(gnu
4569packages linux)} must be taught about the new platform.
4570
4571In practice, there may be some complications. First, it may be that the
4572extended GNU triplet that specifies an ABI (like the @code{eabi} suffix
4573above) is not recognized by all the GNU tools. Typically, glibc
4574recognizes some of these, whereas GCC uses an extra @code{--with-abi}
4575configure flag (see @code{gcc.scm} for examples of how to handle this).
4576Second, some of the required packages could fail to build for that
4577platform. Lastly, the generated binaries could be broken for some
4578reason.
4af2447e
LC
4579
4580
9bf3c1a7
LC
4581@c *********************************************************************
4582@node Contributing
4583@chapter Contributing
4584
4585This project is a cooperative effort, and we need your help to make it
5ff3c4b8
PAR
4586grow! Please get in touch with us on @email{guix-devel@@gnu.org} and
4587@code{#guix} on the Freenode IRC network. We welcome ideas, bug
4588reports, patches, and anything that may be helpful to the project. We
4589particularly welcome help on packaging (@pxref{Packaging Guidelines}).
a1ba8475 4590
9bf3c1a7
LC
4591Please see the
4592@url{http://git.savannah.gnu.org/cgit/guix.git/tree/HACKING,
4593@file{HACKING} file} that comes with the Guix source code for practical
4594details about contributions.
4595
c78bd12b 4596
568717fd
LC
4597@c *********************************************************************
4598@node Acknowledgments
4599@chapter Acknowledgments
4600
4601Guix is based on the Nix package manager, which was designed and
4602implemented by Eelco Dolstra. Nix pioneered functional package
4603management, and promoted unprecedented features, such as transactional
4604package upgrades and rollbacks, per-user profiles, and referentially
4605transparent build processes. Without this work, Guix would not exist.
4606
4607The Nix-based software distributions, Nixpkgs and NixOS, have also been
4608an inspiration for Guix.
4609
4610@c *********************************************************************
4611@node GNU Free Documentation License
4612@appendix GNU Free Documentation License
4613
4614@include fdl-1.3.texi
4615
4616@c *********************************************************************
4617@node Concept Index
4618@unnumbered Concept Index
4619@printindex cp
4620
a85b83d2
LC
4621@node Programming Index
4622@unnumbered Programming Index
4623@syncodeindex tp fn
4624@syncodeindex vr fn
568717fd
LC
4625@printindex fn
4626
4627@bye
4628
4629@c Local Variables:
4630@c ispell-local-dictionary: "american";
4631@c End: