gnu: Sync synopses with the Womb.
[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
58db733e 11@set YEARS 2012, 2013
568717fd 12
eeaf4427 13@dircategory Package management
568717fd
LC
14@direntry
15* guix: (guix). Guix, the functional package manager.
e49951eb 16* guix package: (guix)Invoking guix package
eeaf4427 17 Managing packages with Guix.
e49951eb 18* guix build: (guix)Invoking guix build
568717fd
LC
19 Building packages with Guix.
20@end direntry
568717fd
LC
21
22@titlepage
7730d112
LC
23@title GNU Guix Reference Manual
24@subtitle Using the GNU Guix Functional Package Manager
568717fd 25@author Ludovic Courtès
acc08466 26@author Nikita Karetnikov
568717fd
LC
27
28@page
29@vskip 0pt plus 1filll
30Edition @value{EDITION} @*
31@value{UPDATED} @*
32
58db733e 33Copyright @copyright{} @value{YEARS} Ludovic Court@`es
568717fd
LC
34
35@quotation
36Permission is granted to copy, distribute and/or modify this document
37under the terms of the GNU Free Documentation License, Version 1.3 or
38any later version published by the Free Software Foundation; with no
39Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A
40copy of the license is included in the section entitled ``GNU Free
41Documentation License''.
42@end quotation
43@end titlepage
44
45@copying
f8348b91 46This manual documents GNU Guix version @value{VERSION}.
568717fd 47
58db733e 48Copyright @copyright{} @value{YEARS} Ludovic Courtès
568717fd
LC
49
50Permission is granted to copy, distribute and/or modify this document
51under the terms of the GNU Free Documentation License, Version 1.3 or
52any later version published by the Free Software Foundation; with no
53Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A
54copy of the license is included in the section entitled ``GNU Free
55Documentation License.''
56@end copying
57
58@contents
59
60@c *********************************************************************
61@node Top
f8348b91 62@top GNU Guix
568717fd 63
f8348b91
LC
64This document describes GNU Guix version @value{VERSION}, a functional
65package management tool written for the GNU system.
568717fd 66
58db733e
LC
67@quotation
68Copyright @copyright{} @value{YEARS} Ludovic Courtès
69
70Permission is granted to copy, distribute and/or modify this document
71under the terms of the GNU Free Documentation License, Version 1.3 or
72any later version published by the Free Software Foundation; with no
73Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A
74copy of the license is included in the section entitled ``GNU Free
75Documentation License.''
76@end quotation
77
568717fd
LC
78@menu
79* Introduction:: What is Guix about?
bd5e766b 80* Installation:: Installing Guix.
eeaf4427 81* Package Management:: Package installation, upgrade, etc.
568717fd
LC
82* Programming Interface:: Using Guix in Scheme.
83* Utilities:: Package management commands.
a1ba8475 84* GNU Distribution:: Software for your friendly GNU system.
568717fd
LC
85
86* Acknowledgments:: Thanks!
87* GNU Free Documentation License:: The license of this manual.
88* Concept Index:: Concepts.
89* Function Index:: Functions.
90@end menu
91
92@c *********************************************************************
93@node Introduction
94@chapter Introduction
95
c80e7e55
LC
96GNU Guix@footnote{``Guix'' is pronounced like ``geeks'', or ``ɡiːks''
97using the international phonetic alphabet (IPA).} is a functional
98package management tool for the GNU system. Package management consists
99in all the activities that relate to building packages from source,
100honoring the build-time and run-time dependencies on packages,
101installing packages in user environments, upgrading installed packages
102to new versions or rolling back to a previous set, removing unused
103software packages, etc.
568717fd
LC
104
105@cindex functional package management
106The term @dfn{functional} refers to a specific package management
107discipline. In Guix, the package build and installation process is seen
108as a function, in the mathematical sense: that function takes inputs,
109such as build scripts, a compiler, and libraries depended on, and
110returns the installed package. As a pure function, its result depends
111solely on its inputs---for instance, it cannot refer to software or
112scripts that were not explicitly passed as inputs. A build function
113always produces the same result when passed a given set of inputs. Last
114but not least, a build function cannot alter the system's environment in
115any way; for instance, it cannot create, modify, or delete files outside
116of its build and installation directories. This is achieved by running
117build processes in dedicated ``chroots'', where only their explicit
118inputs are visible.
119
e531ac2a 120@cindex store
568717fd 121The result of package build functions is @dfn{cached} in the file
e531ac2a
LC
122system, in a special directory called @dfn{the store} (@pxref{The
123Store}). Each package is installed in a directory of its own, in the
568717fd
LC
124store---by default under @file{/nix/store}. The directory name contains
125a hash of all the inputs used to build that package; thus, changing an
126input yields a different directory name.
127
128This approach is the foundation of Guix's salient features: support for
129transactional package upgrades and rollback, per-user installation, and
eeaf4427 130garbage collection of packages (@pxref{Features}).
568717fd
LC
131
132Guix has a command-line interface allowing users to build, install,
133upgrade, and remove packages, as well as a Scheme programming interface.
134The remainder of this manual describes them.
135
a1ba8475
LC
136Last but not least, Guix is used to build a distribution of the GNU
137system, with many GNU and non-GNU free software packages. @xref{GNU
138Distribution}.
139
bd5e766b
LC
140@c *********************************************************************
141@node Installation
142@chapter Installation
143
48febeb8
LC
144GNU Guix is available for download from its website at
145@url{http://www.gnu.org/software/guix/}. This section describes the
146software requirements of Guix, as well as how to install it and get
147ready to use it.
bd5e766b 148
b22a12fd 149The build procedure for Guix is the same as for other GNU software, and
1da983b9 150is not covered here. Please see the files @file{README} and
b22a12fd
LC
151@file{INSTALL} in the Guix source tree for additional details.
152
bd5e766b
LC
153@menu
154* Requirements:: Software needed to build and run Guix.
155* Setting Up the Daemon:: Preparing the build daemon's environment.
156* Invoking guix-daemon:: Running the build daemon.
157@end menu
158
159@node Requirements
160@section Requirements
161
162GNU Guix depends on the following packages:
163
164@itemize
165@item @url{http://gnu.org/software/guile/, GNU Guile 2.0.x};
166@item @url{http://gnupg.org/, GNU libgcrypt}
167@end itemize
168
169Unless @code{--disable-daemon} was passed to @command{configure}, the
170following packages are also needed:
171
172@itemize
173@item @url{http://sqlite.org, SQLite 3}
174@item @url{http://www.bzip.org, libbz2}
175@item @url{http://gcc.gnu.org, GCC's g++}
176@end itemize
177
178When a working installation of the Nix package manager is available, you
179can instead configure Guix with @code{--disable-daemon}. In that case,
180@url{http://nixos.org/nix/, Nix} replaces the three dependencies above.
181
b22a12fd
LC
182Guix is compatible with Nix, so it is possible to share the same store
183between both. To do so, you must pass @command{configure} not only the
184same @code{--with-store-dir} value, but also the same
185@code{--localstatedir} value (the latter is essential because it
186specifies where the database that store meta-data about the store is
187located, among other things.) The default values are
188@code{--with-store-dir=/nix/store} and @code{--localstatedir=/nix/var}.
189Note that @code{--disable-daemon} is orthogonal and is not required if
190your goal is to share the same store as Nix.
191
bd5e766b
LC
192@node Setting Up the Daemon
193@section Setting Up the Daemon
194
195@cindex daemon
196Operations such as building a package or running the garbage collector
197are all performed by a specialized process, the @dfn{Guix daemon}, on
198behalf of clients. Only the daemon may access the store and its
199associated database. Thus, any operation that manipulates the store
200goes through the daemon. For instance, command-line tools such as
e49951eb 201@command{guix package} and @command{guix build} communicate with the
bd5e766b
LC
202daemon (@i{via} remote procedure calls) to instruct it what to do.
203
204In a standard multi-user setup, Guix and its daemon---the
205@command{guix-daemon} program---are installed by the system
206administrator; @file{/nix/store} is owned by @code{root} and
207@command{guix-daemon} runs as @code{root}. Unprivileged users may use
208Guix tools to build packages or otherwise access the store, and the
209daemon will do it on their behalf, ensuring that the store is kept in a
210consistent state, and allowing built packages to be shared among users.
211
212@cindex build users
213When @command{guix-daemon} runs as @code{root}, you may not want package
214build processes themselves to run as @code{root} too, for obvious
215security reasons. To avoid that, a special pool of @dfn{build users}
216should be created for use by build processes started by the daemon.
217These build users need not have a shell and a home directory: they will
218just be used when the daemon drops @code{root} privileges in build
219processes. Having several such users allows the daemon to launch
220distinct build processes under separate UIDs, which guarantees that they
221do not interfere with each other---an essential feature since builds are
222regarded as pure functions (@pxref{Introduction}).
223
224On a GNU/Linux system, a build user pool may be created like this (using
225Bash syntax and the @code{shadow} commands):
226
091196b3
LC
227@c See http://lists.gnu.org/archive/html/bug-guix/2013-01/msg00239.html
228@c for why `-G' is needed.
bd5e766b
LC
229@example
230# groupadd guix-builder
231# for i in `seq 1 10`;
232 do
091196b3
LC
233 useradd -g guix-builder -G guix-builder \
234 -d /var/empty -s `which nologin` \
80ba8cc0 235 -c "Guix build user $i" guix-builder$i;
bd5e766b
LC
236 done
237@end example
238
239@noindent
240The @code{guix-daemon} program may then be run as @code{root} with:
241
242@example
243# guix-daemon --build-users-group=guix-builder
244@end example
245
246Guix may also be used in a single-user setup, with @command{guix-daemon}
1da983b9 247running as an unprivileged user. However, to maximize non-interference
bd5e766b
LC
248of build processes, the daemon still needs to perform certain operations
249that are restricted to @code{root} on GNU/Linux: it should be able to
250run build processes in a chroot, and to run them under different UIDs.
251To that end, the @command{nix-setuid-helper} program is provided; it is
252a small C program (less than 300 lines) that, if it is made setuid
253@code{root}, can be executed by the daemon to perform these operations
254on its behalf. The @code{root}-owned @file{/etc/nix-setuid.conf} file
255is read by @command{nix-setuid-helper}; it should contain exactly two
256words: the user name under which the authorized @command{guix-daemon}
257runs, and the name of the build users group.
258
259If you are installing Guix as an unprivileged user and do not have the
260ability to make @file{nix-setuid-helper} setuid-@code{root}, it is still
261possible to run @command{guix-daemon}. However, build processes will
262not be isolated from one another, and not from the rest of the system.
263Thus, build processes may interfere with each other, and may access
264programs, libraries, and other files available on the system---making it
265much harder to view them as @emph{pure} functions.
266
267@node Invoking guix-daemon
268@section Invoking @command{guix-daemon}
269
270The @command{guix-daemon} program implements all the functionality to
271access the store. This includes launching build processes, running the
272garbage collector, querying the availability of a build result, etc. It
273is normally run as @code{root} like this:
274
275@example
276# guix-daemon --build-users-group=guix-builder
277@end example
278
279@noindent
280For details on how to set it up, @ref{Setting Up the Daemon}.
281
282By default, @command{guix-daemon} launches build processes under
283different UIDs, taken from the build group specified with
284@code{--build-users-group}. In addition, each build process is run in a
285chroot environment that only contains the subset of the store that the
286build process depends on, as specified by its derivation
287(@pxref{Programming Interface, derivation}), plus a set of specific
288system directories. By default, the latter contains @file{/dev} and
289@file{/dev/pts}.
290
291The following command-line options are supported:
292
293@table @code
294@item --build-users-group=@var{group}
295Take users from @var{group} to run build processes (@pxref{Setting Up
296the Daemon, build users}).
297
6858f9d1
LC
298@item --no-substitutes
299Do not use substitutes for build products. That is, always build things
300locally instead of allowing downloads of pre-built binaries.
301
bd5e766b
LC
302@item --cache-failures
303Cache build failures. By default, only successful builds are cached.
304
305@item --cores=@var{n}
306@itemx -c @var{n}
307Use @var{n} CPU cores to build each derivation; @code{0} means as many
308as available.
309
310The default value is @code{1}, but it may be overridden by clients, such
e49951eb
MW
311as the @code{--cores} option of @command{guix build} (@pxref{Invoking
312guix build}).
bd5e766b
LC
313
314The effect is to define the @code{NIX_BUILD_CORES} environment variable
315in the build process, which can then use it to exploit internal
316parallelism---for instance, by running @code{make -j$NIX_BUILD_CORES}.
317
318@item --max-jobs=@var{n}
319@itemx -M @var{n}
320Allow at most @var{n} build jobs in parallel. The default value is
321@code{1}.
322
323@item --debug
324Produce debugging output.
325
326This is useful to debug daemon start-up issues, but then it may be
327overridden by clients, for example the @code{--verbosity} option of
e49951eb 328@command{guix build} (@pxref{Invoking guix build}).
bd5e766b
LC
329
330@item --chroot-directory=@var{dir}
331Add @var{dir} to the build chroot.
332
333Doing this may change the result of build processes---for instance if
334they use optional dependencies found in @var{dir} when it is available,
335and not otherwise. For that reason, it is not recommended to do so.
336Instead, make sure that each derivation declares all the inputs that it
337needs.
338
339@item --disable-chroot
340Disable chroot builds.
341
342Using this option is not recommended since, again, it would allow build
343processes to gain access to undeclared dependencies.
344
345@item --disable-log-compression
346Disable compression of the build logs.
347
1da983b9
LC
348Unless @code{--lose-logs} is used, all the build logs are kept in the
349@var{localstatedir}. To save space, the daemon automatically compresses
350them with bzip2 by default. This option disables that.
351
bd5e766b
LC
352@item --disable-store-optimization
353Disable automatic file ``deduplication'' in the store.
354
1da983b9
LC
355By default, files added to the store are automatically ``deduplicated'':
356if a newly added file is identical as another one found in the store,
357the daemon makes the new file a hard link to the other file. This
358slightly increases the input/output load at the end of a build process.
359This option disables this.
360
bd5e766b
LC
361@item --impersonate-linux-2.6
362On Linux-based systems, impersonate Linux 2.6. This means that the
363kernel's @code{uname} system call will report 2.6 as the release number.
364
365This might be helpful to build programs that (usually wrongfully) depend
366on the kernel version number.
367
368@item --lose-logs
369Do not keep build logs. By default they are kept under
370@code{@var{localstatedir}/nix/log}.
371
372@item --system=@var{system}
373Assume @var{system} as the current system type. By default it is the
374architecture/kernel pair found at configure time, such as
375@code{x86_64-linux}.
b8d2aa26
LC
376
377@item --listen=@var{socket}
378Listen for connections on @var{socket}, the file name of a Unix-domain
379socket. The default socket is
380@file{@var{localstatedir}/daemon-socket/socket}. This option is only
381useful in exceptional circumstances, such as if you need to run several
382daemons on the same machine.
bd5e766b
LC
383@end table
384
385
eeaf4427
LC
386@c *********************************************************************
387@node Package Management
388@chapter Package Management
389
f8348b91 390The purpose of GNU Guix is to allow users to easily install, upgrade, and
eeaf4427
LC
391remove software packages, without having to know about their build
392procedure or dependencies. Guix also goes beyond this obvious set of
393features.
394
395This chapter describes the main features of Guix, as well as the package
396management tools it provides.
397
398@menu
399* Features:: How Guix will make your life brighter.
e49951eb
MW
400* Invoking guix package:: Package installation, removal, etc.
401* Invoking guix gc:: Running the garbage collector.
f651b477 402* Invoking guix pull:: Fetching the latest Guix and distribution.
eeaf4427
LC
403@end menu
404
405@node Features
406@section Features
407
408When using Guix, each package ends up in the @dfn{package store}, in its
409own directory---something that resembles
410@file{/nix/store/xxx-package-1.2}, where @code{xxx} is a base32 string.
411
412Instead of referring to these directories, users have their own
413@dfn{profile}, which points to the packages that they actually want to
821b0015
LC
414use. These profiles are stored within each user's home directory, at
415@code{$HOME/.guix-profile}.
eeaf4427 416
821b0015 417For example, @code{alice} installs GCC 4.7.2. As a result,
eeaf4427 418@file{/home/alice/.guix-profile/bin/gcc} points to
821b0015
LC
419@file{/nix/store/@dots{}-gcc-4.7.2/bin/gcc}. Now, on the same machine,
420@code{bob} had already installed GCC 4.8.0. The profile of @code{bob}
421simply continues to point to
422@file{/nix/store/@dots{}-gcc-4.8.0/bin/gcc}---i.e., both versions of GCC
423coexist on the same system without any interference.
eeaf4427 424
e49951eb
MW
425The @command{guix package} command is the central tool to manage
426packages (@pxref{Invoking guix package}). It operates on those per-user
821b0015 427profiles, and can be used @emph{with normal user privileges}.
eeaf4427
LC
428
429The command provides the obvious install, remove, and upgrade
430operations. Each invocation is actually a @emph{transaction}: either
ba55b1cb 431the specified operation succeeds, or nothing happens. Thus, if the
e49951eb 432@command{guix package} process is terminated during the transaction,
eeaf4427
LC
433or if a power outage occurs during the transaction, then the user's
434profile remains in its previous state, and remains usable.
435
436In addition, any package transaction may be @emph{rolled back}. So, if,
437for example, an upgrade installs a new version of a package that turns
438out to have a serious bug, users may roll back to the previous instance
439of their profile, which was known to work well.
440
441All those packages in the package store may be @emph{garbage-collected}.
442Guix can determine which packages are still referenced by the user
fe8ff028 443profiles, and remove those that are provably no longer referenced
e49951eb 444(@pxref{Invoking guix gc}). Users may also explicitly remove old
fe8ff028
LC
445generations of their profile so that the packages they refer to can be
446collected.
eeaf4427
LC
447
448Finally, Guix takes a @dfn{purely functional} approach to package
449management, as described in the introduction (@pxref{Introduction}).
450Each @file{/nix/store} package directory name contains a hash of all the
451inputs that were used to build that package---compiler, libraries, build
452scripts, etc. This direct correspondence allows users to make sure a
453given package installation matches the current state of their
a1ba8475 454distribution, and helps maximize @dfn{reproducibility}.
eeaf4427
LC
455
456This foundation allows Guix to support @dfn{transparent binary/source
3b78d1ea 457deployment}. When a pre-built binary for a @file{/nix/store} path is
eeaf4427
LC
458available from an external source, Guix just downloads it; otherwise, it
459builds the package from source, locally.
460
e49951eb
MW
461@node Invoking guix package
462@section Invoking @command{guix package}
eeaf4427 463
e49951eb 464The @command{guix package} command is the tool that allows users to
eeaf4427
LC
465install, upgrade, and remove packages, as well as rolling back to
466previous configurations. It operates only on the user's own profile,
467and works with normal user privileges (@pxref{Features}). Its syntax
468is:
469
470@example
e49951eb 471guix package @var{options}
eeaf4427
LC
472@end example
473
ba55b1cb 474Primarily, @var{options} specifies the operations to be performed during
eeaf4427
LC
475the transaction. Upon completion, a new profile is created, but
476previous generations of the profile remain available, should the user
477want to roll back.
478
b9e5c0a9 479For each user, a symlink to the user's default profile is automatically
0ec1af59 480created in @file{$HOME/.guix-profile}. This symlink always points to the
b9e5c0a9
LC
481current generation of the user's default profile. Thus, users can add
482@file{$HOME/.guix-profile/bin} to their @code{PATH} environment
483variable, and so on.
484
0ec1af59
LC
485In a multi-user setup, user profiles must be stored in a place
486registered as a @dfn{garbage-collector root}, which
e49951eb 487@file{$HOME/.guix-profile} points to (@pxref{Invoking guix gc}). That
0ec1af59
LC
488directory is normally
489@code{@var{localstatedir}/profiles/per-user/@var{user}}, where
490@var{localstatedir} is the value passed to @code{configure} as
491@code{--localstatedir}, and @var{user} is the user name. It must be
492created by @code{root}, with @var{user} as the owner. When it does not
e49951eb 493exist, @command{guix package} emits an error about it.
0ec1af59
LC
494
495The @var{options} can be among the following:
496
eeaf4427
LC
497@table @code
498
499@item --install=@var{package}
51c8d790 500@itemx -i @var{package}
eeaf4427
LC
501Install @var{package}.
502
503@var{package} may specify either a simple package name, such as
504@code{guile}, or a package name followed by a hyphen and version number,
dc5669cd
MW
505such as @code{guile-1.8.8}. If no version number is specified, the
506newest available version will be selected. In addition, @var{package}
507may contain a colon, followed by the name of one of the outputs of the
508package, as in @code{gcc:doc} or @code{binutils-2.22:lib}.
eeaf4427 509
461572cc
LC
510@cindex propagated inputs
511Sometimes packages have @dfn{propagated inputs}: these are dependencies
512that automatically get installed along with the required package.
513
514An example is the GNU MPC library: its C header files refer to those of
515the GNU MPFR library, which in turn refer to those of the GMP library.
516Thus, when installing MPC, the MPFR and GMP libraries also get installed
517in the profile; removing MPC also removes MPFR and GMP---unless they had
518also been explicitly installed independently.
519
5924080d
LC
520Besides, packages sometime rely on the definition of environment
521variables for their search paths (see explanation of
522@code{--search-paths} below.) Any missing or possibly incorrect
523environment variable definitions are reported here.
524
ef010c0f 525@c XXX: keep me up-to-date
5924080d 526Finally, when installing a GNU package, the tool reports the
ef010c0f
LC
527availability of a newer upstream version. In the future, it may provide
528the option of installing directly from the upstream version, even if
529that version is not yet in the distribution.
530
5d4b411f
LC
531@item --install-from-expression=@var{exp}
532@itemx -e @var{exp}
533Install the package @var{exp} evaluates to.
534
535@var{exp} must be a Scheme expression that evaluates to a
536@code{<package>} object. This option is notably useful to disambiguate
537between same-named variants of a package, with expressions such as
538@code{(@@ (gnu packages base) guile-final)}.
539
540Note that this option installs the first output of the specified
541package, which may be insufficient when needing a specific output of a
542multiple-output package.
543
eeaf4427
LC
544@item --remove=@var{package}
545@itemx -r @var{package}
546Remove @var{package}.
547
acb6ba25
CR
548@item --upgrade[=@var{regexp}]
549@itemx -u [@var{regexp}]
550Upgrade all the installed packages. When @var{regexp} is specified, upgrade
551only installed packages whose name matches @var{regexp}.
eeaf4427 552
f651b477
LC
553Note that this upgrades package to the latest version of packages found
554in the distribution currently installed. To update your distribution,
555you should regularly run @command{guix pull} (@pxref{Invoking guix
556pull}).
557
24e262f0
LC
558@item --roll-back
559Roll back to the previous @dfn{generation} of the profile---i.e., undo
560the last transaction.
561
562When combined with options such as @code{--install}, roll back occurs
563before any other actions.
564
d9307267
LC
565When rolling back from the first generation that actually contains
566installed packages, the profile is made to point to the @dfn{empty
567profile}, also known as @dfn{profile zero}---i.e., it contains no files
568apart from its own meta-data.
569
82fe08ed
LC
570Installing, removing, or upgrading packages from a generation that has
571been rolled back to overwrites previous future generations. Thus, the
572history of a profile's generations is always linear.
573
5924080d
LC
574@item --search-paths
575@cindex search paths
576Report environment variable definitions, in Bash syntax, that may be
577needed in order to use the set of installed packages. These environment
578variables are used to specify @dfn{search paths} for files used by some
579of the installed packages.
580
581For example, GCC needs the @code{CPATH} and @code{LIBRARY_PATH}
582environment variables to be defined so it can look for headers and
583libraries in the user's profile (@pxref{Environment Variables,,, gcc,
584Using the GNU Compiler Collection (GCC)}). If GCC and, say, the C
585library are installed in the profile, then @code{--search-paths} will
586suggest setting these variables to @code{@var{profile}/include} and
587@code{@var{profile}/lib}, respectively.
588
eeaf4427
LC
589@item --profile=@var{profile}
590@itemx -p @var{profile}
591Use @var{profile} instead of the user's default profile.
592
593@item --dry-run
594@itemx -n
595Show what would be done without actually doing it.
596
3b824605
LC
597@item --no-substitutes
598Build instead of resorting to pre-built substitutes.
599
70915c1a
LC
600@item --verbose
601Produce verbose output. In particular, emit the environment's build log
602on the standard error port.
603
eeaf4427
LC
604@item --bootstrap
605Use the bootstrap Guile to build the profile. This option is only
606useful to distribution developers.
607
608@end table
609
e49951eb 610In addition to these actions @command{guix package} supports the
733b4130
LC
611following options to query the current state of a profile, or the
612availability of packages:
eeaf4427 613
733b4130
LC
614@table @option
615
acc08466
NK
616@item --search=@var{regexp}
617@itemx -s @var{regexp}
618List the available packages whose synopsis or description matches
299112d3
LC
619@var{regexp}. Print all the meta-data of matching packages in
620@code{recutils} format (@pxref{Top, GNU recutils databases,, recutils,
621GNU recutils manual}).
acc08466 622
299112d3
LC
623This allows specific fields to be extracted using the @command{recsel}
624command, for instance:
625
626@example
e49951eb 627$ guix package -s malloc | recsel -p name,version
299112d3
LC
628name: glibc
629version: 2.17
630
631name: libgc
632version: 7.2alpha6
633@end example
acc08466 634
733b4130
LC
635@item --list-installed[=@var{regexp}]
636@itemx -I [@var{regexp}]
637List currently installed packages in the specified profile. When
638@var{regexp} is specified, list only installed packages whose name
639matches @var{regexp}.
640
641For each installed package, print the following items, separated by
642tabs: the package name, its version string, the part of the package that
643is installed (for instance, @code{out} for the default output,
644@code{include} for its headers, etc.), and the path of this package in
645the store.
646
64fc89b6
LC
647@item --list-available[=@var{regexp}]
648@itemx -A [@var{regexp}]
a1ba8475
LC
649List packages currently available in the software distribution
650(@pxref{GNU Distribution}). When @var{regexp} is specified, list only
651installed packages whose name matches @var{regexp}.
64fc89b6
LC
652
653For each package, print the following items separated by tabs: its name,
44b6be77
LC
654its version string, the parts of the package (@code{out} for the main
655files, @code{lib} for libraries and possibly headers, etc.), and the
656source location of its definition.
64fc89b6 657
733b4130 658@end table
eeaf4427
LC
659
660
e49951eb
MW
661@node Invoking guix gc
662@section Invoking @command{guix gc}
fe8ff028
LC
663
664@cindex garbage collector
665Packages that are installed but not used may be @dfn{garbage-collected}.
e49951eb 666The @command{guix gc} command allows users to explicitly run the garbage
fe8ff028
LC
667collector to reclaim space from the @file{/nix/store} directory.
668
669The garbage collector has a set of known @dfn{roots}: any file under
670@file{/nix/store} reachable from a root is considered @dfn{live} and
671cannot be deleted; any other file is considered @dfn{dead} and may be
672deleted. The set of garbage collector roots includes default user
e49951eb
MW
673profiles, and may be augmented with @command{guix build --root}, for
674example (@pxref{Invoking guix build}).
fe8ff028 675
e49951eb 676The @command{guix gc} command has three modes of operation: it can be
fe8ff028
LC
677used to garbage-collect any dead files (the default), to delete specific
678files (the @code{--delete} option), or to print garbage-collector
679information. The available options are listed below:
680
681@table @code
682@item --collect-garbage[=@var{min}]
683@itemx -C [@var{min}]
684Collect garbage---i.e., unreachable @file{/nix/store} files and
685sub-directories. This is the default operation when no option is
686specified.
687
688When @var{min} is given, stop once @var{min} bytes have been collected.
689@var{min} may be a number of bytes, or it may include a unit as a
690suffix, such as @code{MiB} for mebibytes and @code{GB} for gigabytes.
691
692When @var{min} is omitted, collect all the garbage.
693
694@item --delete
695@itemx -d
696Attempt to delete all the store files and directories specified as
697arguments. This fails if some of the files are not in the store, or if
698they are still live.
699
700@item --list-dead
701Show the list of dead files and directories still present in the
702store---i.e., files and directories no longer reachable from any root.
703
704@item --list-live
705Show the list of live store files and directories.
ba8b732d
LC
706
707@end table
708
709In addition, the references among existing store files can be queried:
710
711@table @code
712
713@item --references
714@itemx --referrers
715List the references (respectively, the referrers) of store files given
716as arguments.
717
fe8ff028
LC
718@end table
719
eeaf4427 720
f651b477
LC
721@node Invoking guix pull
722@section Invoking @command{guix pull}
723
724Packages are installed or upgraded to the latest version available in
725the distribution currently available on your local machine. To update
726that distribution, along with the Guix tools, you must run @command{guix
727pull}: the command downloads the latest Guix source code and package
728descriptions, and deploys it.
729
730On completion, @command{guix package} will use packages and package
731versions from this just-retrieved copy of Guix. Not only that, but all
732the Guix commands and Scheme modules will also be taken from that latest
733version. New @command{guix} sub-commands added by the update also
734become available.
735
736The @command{guix pull} command is usually invoked with no arguments,
737but it supports the following options:
738
739@table @code
740@item --verbose
741Produce verbose output, writing build logs to the standard error output.
742
743@item --bootstrap
744Use the bootstrap Guile to build the latest Guix. This option is only
745useful to Guix developers.
746@end table
747
568717fd
LC
748@c *********************************************************************
749@node Programming Interface
750@chapter Programming Interface
751
3dc1970d
LC
752GNU Guix provides several Scheme programming interfaces (APIs) to
753define, build, and query packages. The first interface allows users to
754write high-level package definitions. These definitions refer to
755familiar packaging concepts, such as the name and version of a package,
756its build system, and its dependencies. These definitions can then be
757turned into concrete build actions.
758
ba55b1cb 759Build actions are performed by the Guix daemon, on behalf of users. In a
3dc1970d
LC
760standard setup, the daemon has write access to the store---the
761@file{/nix/store} directory---whereas users do not. The recommended
762setup also has the daemon perform builds in chroots, under a specific
763build users, to minimize interference with the rest of the system.
764
765@cindex derivation
766Lower-level APIs are available to interact with the daemon and the
767store. To instruct the daemon to perform a build action, users actually
768provide it with a @dfn{derivation}. A derivation is a low-level
769representation of the build actions to be taken, and the environment in
770which they should occur---derivations are to package definitions what
771assembly is to C programs.
772
773This chapter describes all these APIs in turn, starting from high-level
774package definitions.
775
568717fd
LC
776@menu
777* Defining Packages:: Defining new packages.
778* The Store:: Manipulating the package store.
779* Derivations:: Low-level interface to package derivations.
780@end menu
781
782@node Defining Packages
783@section Defining Packages
784
3dc1970d
LC
785The high-level interface to package definitions is implemented in the
786@code{(guix packages)} and @code{(guix build-system)} modules. As an
787example, the package definition, or @dfn{recipe}, for the GNU Hello
788package looks like this:
789
790@example
b22a12fd
LC
791(use-modules (guix packages)
792 (guix download)
793 (guix build-system gnu)
794 (guix licenses))
795
3dc1970d
LC
796(define hello
797 (package
798 (name "hello")
799 (version "2.8")
800 (source (origin
801 (method url-fetch)
802 (uri (string-append "mirror://gnu/hello/hello-" version
803 ".tar.gz"))
804 (sha256
805 (base32 "0wqd8sjmxfskrflaxywc7gqw7sfawrfvdxd9skxawzfgyy0pzdz6"))))
806 (build-system gnu-build-system)
807 (inputs `(("gawk" ,gawk)))
808 (synopsis "GNU Hello")
809 (description "Yeah...")
810 (home-page "http://www.gnu.org/software/hello/")
b22a12fd 811 (license gpl3+)))
3dc1970d
LC
812@end example
813
814@noindent
815Without being a Scheme expert, the reader may have guessed the meaning
816of the various fields here. This expression binds variable @var{hello}
817to a @code{<package>} object, which is essentially a record
818(@pxref{SRFI-9, Scheme records,, guile, GNU Guile Reference Manual}).
819This package object can be inspected using procedures found in the
820@code{(guix packages)} module; for instance, @code{(package-name hello)}
821returns---surprise!---@code{"hello"}.
822
823There are a few points worth noting in the above package definition:
824
825@itemize
826@item
827The @code{source} field of the package is an @code{<origin>} object.
828Here, the @code{url-fetch} method from @code{(guix download)} is used,
829meaning that the source is a file to be downloaded over FTP or HTTP.
830
831The @code{mirror://gnu} prefix instructs @code{url-fetch} to use one of
832the GNU mirrors defined in @code{(guix download)}.
833
834The @code{sha256} field specifies the expected SHA256 hash of the file
835being downloaded. It is mandatory, and allows Guix to check the
836integrity of the file. The @code{(base32 @dots{})} form introduces the
6c365eca
NK
837base32 representation of the hash. You can obtain this information with
838the @code{guix hash} (@pxref{Invoking guix hash}) and @code{guix
839download} tools.
3dc1970d
LC
840
841@item
842@cindex GNU Build System
843The @code{build-system} field is set to @var{gnu-build-system}. The
844@var{gnu-build-system} variable is defined in the @code{(guix
845build-system gnu)} module, and is bound to a @code{<build-system>}
846object.
847
848Naturally, @var{gnu-build-system} represents the familiar GNU Build
849System, and variants thereof (@pxref{Configuration, configuration and
850makefile conventions,, standards, GNU Coding Standards}). In a
ba55b1cb 851nutshell, packages using the GNU Build System may be configured, built,
3dc1970d
LC
852and installed with the usual @code{./configure && make && make check &&
853make install} command sequence. This is what @var{gnu-build-system}
854does.
855
856In addition, @var{gnu-build-system} ensures that the ``standard''
857environment for GNU packages is available. This includes tools such as
858GCC, Coreutils, Bash, Make, Diffutils, and Patch.
859
860@item
861The @code{inputs} field specifies inputs to the build process---i.e.,
862build-time or run-time dependencies of the package. Here, we define an
863input called @code{"gawk"} whose value is that of the @var{gawk}
864variable; @var{gawk} is itself bound to a @code{<package>} object.
865
866Note that GCC, Coreutils, Bash, and other essential tools do not need to
867be specified as inputs here. Instead, @var{gnu-build-system} takes care
868of ensuring that they are present.
869
870However, any other dependencies need to be specified in the
871@code{inputs} field. Any dependency not specified here will simply be
872unavailable to the build process, possibly leading to a build failure.
873@end itemize
874
875There are other fields that package definitions may provide. Of
876particular interest is the @code{arguments} field. When specified, it
877must be bound to a list of additional arguments to be passed to the
878build system. For instance, the above definition could be augmented
879with the following field initializer:
880
881@example
882 (arguments `(#:tests? #f
883 #:configure-flags '("--enable-silent-rules")))
884@end example
885
886@noindent
887These are keyword arguments (@pxref{Optional Arguments, keyword
888arguments in Guile,, guile, GNU Guile Reference Manual}). They are
889passed to @var{gnu-build-system}, which interprets them as meaning ``do
890not run @code{make check}'', and ``run @file{configure} with the
874e6874
LC
891@code{--enable-silent-rules} flag''. The value of these keyword
892parameters is actually evaluated in the @dfn{build stratum}---i.e., by a
893Guile process launched by the daemon (@pxref{Derivations}).
3dc1970d
LC
894
895Once a package definition is in place@footnote{Simple package
896definitions like the one above may be automatically converted from the
e49951eb
MW
897Nixpkgs distribution using the @command{guix import} command.}, the
898package may actually be built using the @code{guix build} command-line
37166310
LC
899tool (@pxref{Invoking guix build}). Eventually, updating the package
900definition to a new upstream version can be partly automated by the
901@command{guix refresh} command (@pxref{Invoking guix refresh}).
3dc1970d
LC
902
903Behind the scenes, a derivation corresponding to the @code{<package>}
904object is first computed by the @code{package-derivation} procedure.
905That derivation is stored in a @code{.drv} file under @file{/nix/store}.
ba55b1cb 906The build actions it prescribes may then be realized by using the
3dc1970d
LC
907@code{build-derivations} procedure (@pxref{The Store}).
908
909@deffn {Scheme Procedure} package-derivation @var{store} @var{package} [@var{system}]
e509d152
LC
910Return the derivation path and corresponding @code{<derivation>} object
911of @var{package} for @var{system} (@pxref{Derivations}).
3dc1970d
LC
912
913@var{package} must be a valid @code{<package>} object, and @var{system}
914must be a string denoting the target system type---e.g.,
915@code{"x86_64-linux"} for an x86_64 Linux-based GNU system. @var{store}
916must be a connection to the daemon, which operates on the store
917(@pxref{The Store}).
918@end deffn
568717fd
LC
919
920@node The Store
921@section The Store
922
e531ac2a
LC
923@cindex store
924@cindex store paths
925
926Conceptually, the @dfn{store} is where derivations that have been
927successfully built are stored---by default, under @file{/nix/store}.
928Sub-directories in the store are referred to as @dfn{store paths}. The
929store has an associated database that contains information such has the
930store paths referred to by each store path, and the list of @emph{valid}
931store paths---paths that result from a successful build.
932
933The store is always accessed by the daemon on behalf of its clients
934(@pxref{Invoking guix-daemon}). To manipulate the store, clients
935connect to the daemon over a Unix-domain socket, send it requests, and
936read the result---these are remote procedure calls, or RPCs.
937
938The @code{(guix store)} module provides procedures to connect to the
939daemon, and to perform RPCs. These are described below.
940
941@deffn {Scheme Procedure} open-connection [@var{file}] [#:reserve-space? #t]
942Connect to the daemon over the Unix-domain socket at @var{file}. When
943@var{reserve-space?} is true, instruct it to reserve a little bit of
944extra space on the file system so that the garbage collector can still
945operate, should the disk become full. Return a server object.
946
947@var{file} defaults to @var{%default-socket-path}, which is the normal
948location given the options that were passed to @command{configure}.
949@end deffn
950
951@deffn {Scheme Procedure} close-connection @var{server}
952Close the connection to @var{server}.
953@end deffn
954
955@defvr {Scheme Variable} current-build-output-port
956This variable is bound to a SRFI-39 parameter, which refers to the port
957where build and error logs sent by the daemon should be written.
958@end defvr
959
960Procedures that make RPCs all take a server object as their first
961argument.
962
963@deffn {Scheme Procedure} valid-path? @var{server} @var{path}
964Return @code{#t} when @var{path} is a valid store path.
965@end deffn
966
967@deffn {Scheme Procedure} add-text-to-store @var{server} @var{name} @var{text} @var{references}
968Add @var{text} under file @var{name} in the store, and return its store
969path. @var{references} is the list of store paths referred to by the
970resulting store path.
971@end deffn
972
874e6874
LC
973@deffn {Scheme Procedure} build-derivations @var{server} @var{derivations}
974Build @var{derivations} (a list of derivation paths), and return when
975the worker is done building them. Return @code{#t} on success.
976@end deffn
977
e531ac2a
LC
978@c FIXME
979@i{This section is currently incomplete.}
568717fd
LC
980
981@node Derivations
982@section Derivations
983
874e6874
LC
984@cindex derivations
985Low-level build actions and the environment in which they are performed
986are represented by @dfn{derivations}. A derivation contain the
987following pieces of information:
988
989@itemize
990@item
991The outputs of the derivation---derivations produce at least one file or
992directory in the store, but may produce more.
993
994@item
995The inputs of the derivations, which may be other derivations or plain
996files in the store (patches, build scripts, etc.)
997
998@item
999The system type targeted by the derivation---e.g., @code{x86_64-linux}.
1000
1001@item
1002The file name of a build script in the store, along with the arguments
1003to be passed.
1004
1005@item
1006A list of environment variables to be defined.
1007
1008@end itemize
1009
1010@cindex derivation path
1011Derivations allow clients of the daemon to communicate build actions to
1012the store. They exist in two forms: as an in-memory representation,
1013both on the client- and daemon-side, and as files in the store whose
1014name end in @code{.drv}---these files are referred to as @dfn{derivation
1015paths}. Derivations paths can be passed to the @code{build-derivations}
1016procedure to perform the build actions they prescribe (@pxref{The
1017Store}).
1018
1019The @code{(guix derivations)} module provides a representation of
1020derivations as Scheme objects, along with procedures to create and
1021otherwise manipulate derivations. The lowest-level primitive to create
1022a derivation is the @code{derivation} procedure:
1023
1024@deffn {Scheme Procedure} derivation @var{store} @var{name} @var{system} @var{builder} @var{args} @var{env-vars} @var{inputs} [#:outputs '("out")] [#:hash #f] [#:hash-algo #f] [#:hash-mode #f]
1025Build a derivation with the given arguments. Return the resulting store
1026path and @code{<derivation>} object.
1027
1028When @var{hash}, @var{hash-algo}, and @var{hash-mode} are given, a
1029@dfn{fixed-output derivation} is created---i.e., one whose result is
1030known in advance, such as a file download.
1031@end deffn
1032
1033@noindent
1034Here's an example with a shell script as its builder, assuming
1035@var{store} is an open connection to the daemon, and @var{bash} points
1036to a Bash executable in the store:
1037
1038@lisp
1039(use-modules (guix utils)
1040 (guix store)
1041 (guix derivations))
1042
1043(call-with-values
1044 (lambda ()
1045 (let ((builder ; add the Bash script to the store
1046 (add-text-to-store store "my-builder.sh"
1047 "echo hello world > $out\n" '())))
1048 (derivation store "foo" (%current-system)
1049 bash `("-e" ,builder)
1050 '(("HOME" . "/homeless")) '())))
1051 list)
1052@result{} ("/nix/store/@dots{}-foo.drv" #<<derivation> @dots{}>)
1053@end lisp
1054
1055As can be guessed, this primitive is cumbersome to use directly. An
1056improved variant is @code{build-expression->derivation}, which allows
1057the caller to directly pass a Guile expression as the build script:
1058
1059@deffn {Scheme Procedure} build-expression->derivation @var{store} @var{name} @var{system} @var{exp} @var{inputs} [#:outputs '("out")] [#:hash #f] [#:hash-algo #f] [#:env-vars '()] [#:modules '()] [#:guile-for-build #f]
1060Return a derivation that executes Scheme expression @var{exp} as a
1061builder for derivation @var{name}. @var{inputs} must be a list of
1062@code{(name drv-path sub-drv)} tuples; when @var{sub-drv} is omitted,
1063@code{"out"} is assumed. @var{modules} is a list of names of Guile
1064modules from the current search path to be copied in the store,
1065compiled, and made available in the load path during the execution of
1066@var{exp}---e.g., @code{((guix build utils) (guix build
1067gnu-build-system))}.
1068
1069@var{exp} is evaluated in an environment where @code{%outputs} is bound
1070to a list of output/path pairs, and where @code{%build-inputs} is bound
1071to a list of string/output-path pairs made from @var{inputs}.
1072Optionally, @var{env-vars} is a list of string pairs specifying the name
1073and value of environment variables visible to the builder. The builder
1074terminates by passing the result of @var{exp} to @code{exit}; thus, when
1075@var{exp} returns @code{#f}, the build is considered to have failed.
1076
1077@var{exp} is built using @var{guile-for-build} (a derivation). When
1078@var{guile-for-build} is omitted or is @code{#f}, the value of the
1079@code{%guile-for-build} fluid is used instead.
1080@end deffn
1081
1082@noindent
1083Here's an example of a single-output derivation that creates a directory
1084containing one file:
1085
1086@lisp
1087(let ((builder '(let ((out (assoc-ref %outputs "out")))
1088 (mkdir out) ; create /nix/store/@dots{}-goo
1089 (call-with-output-file (string-append out "/test")
1090 (lambda (p)
1091 (display '(hello guix) p))))))
1092 (build-expression->derivation store "goo" (%current-system)
1093 builder '()))
1094
1095@result{} "/nix/store/@dots{}-goo.drv"
1096@result{} #<<derivation> @dots{}>
1097@end lisp
1098
1099@cindex strata of code
1100Remember that the build expression passed to
1101@code{build-expression->derivation} is run by a separate Guile process
1102than the one that calls @code{build-expression->derivation}: it is run
1103by a Guile process launched by the daemon, typically in a chroot. So,
1104while there is a single language for both the @dfn{host} and the build
1105side, there are really two @dfn{strata} of code: the host-side, and the
1106build-side code@footnote{The term @dfn{stratum} in this context was
1107coined by Manuel Serrano et al. in the context of their work on Hop.}.
1108This distinction is important to keep in mind, notably when using
1109higher-level constructs such as @var{gnu-build-system} (@pxref{Defining
1110Packages}). For this reason, Guix modules that are meant to be used in
1111the build stratum are kept in the @code{(guix build @dots{})} name
1112space.
568717fd
LC
1113
1114@c *********************************************************************
1115@node Utilities
1116@chapter Utilities
1117
1118@menu
37166310
LC
1119* Invoking guix build:: Building packages from the command line.
1120* Invoking guix hash:: Computing the cryptographic hash of a file.
1121* Invoking guix refresh:: Updating package definitions.
568717fd
LC
1122@end menu
1123
e49951eb
MW
1124@node Invoking guix build
1125@section Invoking @command{guix build}
568717fd 1126
e49951eb 1127The @command{guix build} command builds packages or derivations and
6798a8e4
LC
1128their dependencies, and prints the resulting store paths. Note that it
1129does not modify the user's profile---this is the job of the
e49951eb 1130@command{guix package} command (@pxref{Invoking guix package}). Thus,
6798a8e4
LC
1131it is mainly useful for distribution developers.
1132
1133The general syntax is:
c78bd12b
LC
1134
1135@example
e49951eb 1136guix build @var{options} @var{package-or-derivation}@dots{}
c78bd12b
LC
1137@end example
1138
1139@var{package-or-derivation} may be either the name of a package found in
5401dd75
LC
1140the software distribution such as @code{coreutils} or
1141@code{coreutils-8.20}, or a derivation such as
1142@file{/nix/store/@dots{}-coreutils-8.19.drv}. Alternatively, the
c78bd12b
LC
1143@code{--expression} option may be used to specify a Scheme expression
1144that evaluates to a package; this is useful when disambiguation among
1145several same-named packages or package variants is needed.
1146
1147The @var{options} may be zero or more of the following:
1148
1149@table @code
1150
1151@item --expression=@var{expr}
1152@itemx -e @var{expr}
1153Build the package @var{expr} evaluates to.
1154
5401dd75 1155For example, @var{expr} may be @code{(@@ (gnu packages guile)
c78bd12b
LC
1156guile-1.8)}, which unambiguously designates this specific variant of
1157version 1.8 of Guile.
1158
1159@item --source
1160@itemx -S
1161Build the packages' source derivations, rather than the packages
1162themselves.
1163
e49951eb 1164For instance, @code{guix build -S gcc} returns something like
6798a8e4 1165@file{/nix/store/@dots{}-gcc-4.7.2.tar.bz2}, which is GCC's source tarball.
c78bd12b
LC
1166
1167@item --system=@var{system}
1168@itemx -s @var{system}
1169Attempt to build for @var{system}---e.g., @code{i686-linux}---instead of
1170the host's system type.
1171
1172An example use of this is on Linux-based systems, which can emulate
1173different personalities. For instance, passing
1174@code{--system=i686-linux} on an @code{x86_64-linux} system allows users
1175to build packages in a complete 32-bit environment.
1176
1177@item --derivations
1178@itemx -d
1179Return the derivation paths, not the output paths, of the given
1180packages.
1181
1182@item --keep-failed
1183@itemx -K
1184Keep the build tree of failed builds. Thus, if a build fail, its build
1185tree is kept under @file{/tmp}, in a directory whose name is shown at
1186the end of the build log. This is useful when debugging build issues.
1187
1188@item --dry-run
1189@itemx -n
1190Do not build the derivations.
1191
1192@item --no-substitutes
1193Build instead of resorting to pre-built substitutes.
1194
1195@item --cores=@var{n}
1196@itemx -c @var{n}
1197Allow the use of up to @var{n} CPU cores for the build. The special
1198value @code{0} means to use as many CPU cores as available.
1199
1200@item --root=@var{file}
1201@itemx -r @var{file}
1202Make @var{file} a symlink to the result, and register it as a garbage
1203collector root.
07ab4bf1
LC
1204
1205@item --verbosity=@var{level}
1206Use the given verbosity level. @var{level} must be an integer between 0
1207and 5; higher means more verbose output. Setting a level of 4 or more
1208may be helpful when debugging setup issues with the build daemon.
1209
c78bd12b
LC
1210@end table
1211
e49951eb 1212Behind the scenes, @command{guix build} is essentially an interface to
c78bd12b
LC
1213the @code{package-derivation} procedure of the @code{(guix packages)}
1214module, and to the @code{build-derivations} procedure of the @code{(guix
1215store)} module.
1216
6c365eca
NK
1217@node Invoking guix hash
1218@section Invoking @command{guix hash}
1219
1220The @command{guix hash} command allows to check the integrity of a file.
1221It is primarily a convenience tool for anyone contributing to the
1222distribution: it computes the cryptographic hash of a file, which can be
1223used in the definition of a package (@pxref{Defining Packages}).
1224
1225The general syntax is:
1226
1227@example
1228guix hash @var{option} @var{file}
1229@end example
1230
1231@command{guix hash} has the following option:
1232
1233@table @code
1234
1235@item --format=@var{fmt}
1236@itemx -f @var{fmt}
1237Write the hash in the given format.
1238
1239Supported formats: @code{nix-base32}, @code{base32}, @code{base16}
1240(@code{hex} and @code{hexadecimal} can be used as well).
1241
1242If the @option{--format} option is not specified, @command{guix hash}
1243will output the hash in @code{nix-base32}. This representation is used
1244in the definitions of packages.
1245
1246@end table
1247
37166310
LC
1248@node Invoking guix refresh
1249@section Invoking @command{guix refresh}
1250
1251The primary audience of the @command{guix refresh} command is developers
1252of the GNU software distribution. By default, it reports any packages
1253provided by the distribution that are outdated compared to the latest
1254upstream version, like this:
1255
1256@example
1257$ guix refresh
1258gnu/packages/gettext.scm:29:13: gettext would be upgraded from 0.18.1.1 to 0.18.2.1
1259gnu/packages/glib.scm:77:12: glib would be upgraded from 2.34.3 to 2.37.0
1260@end example
1261
1262It does so by browsing each package's FTP directory and determining the
1263highest version number of the source tarballs
1264therein@footnote{Currently, this only works for GNU packages.}.
1265
1266When passed @code{--update}, it modifies distribution source files to
1267update the version numbers and source tarball hashes of those packages'
1268recipes (@pxref{Defining Packages}). This is achieved by downloading
1269each package's latest source tarball and its associated OpenPGP
1270signature, authenticating the downloaded tarball against its signature
1271using @command{gpg}, and finally computing its hash. When the public
1272key used to sign the tarball is missing from the user's keyring, an
1273attempt is made to automatically retrieve it from a public key server;
1274when it's successful, the key is added to the user's keyring; otherwise,
1275@command{guix refresh} reports an error.
1276
1277The following options are supported:
1278
1279@table @code
1280
1281@item --update
1282@itemx -u
1283Update distribution source files (package recipes) in place.
1284@ref{Defining Packages}, for more information on package definitions.
1285
1286@item --select=[@var{subset}]
1287@itemx -s @var{subset}
1288Select all the packages in @var{subset}, one of @code{core} or
1289@code{non-core}.
1290
1291The @code{core} subset refers to all the packages at the core of the
1292distribution---i.e., packages that are used to build ``everything
1293else''. This includes GCC, libc, Binutils, Bash, etc. Usually,
1294changing one of these packages in the distribution entails a rebuild of
1295all the others. Thus, such updates are an inconvenience to users in
1296terms of build time or bandwidth used to achieve the upgrade.
1297
1298The @code{non-core} subset refers to the remaining packages. It is
1299typically useful in cases where an update of the core packages would be
1300inconvenient.
1301
1302@end table
1303
1304In addition, @command{guix refresh} can be passed one or more package
1305names, as in this example:
1306
1307@example
1308guix refresh -u emacs idutils
1309@end example
1310
1311@noindent
1312The command above specifically updates the @code{emacs} and
1313@code{idutils} packages. The @code{--select} option would have no
1314effect in this case.
1315
f9230085
LC
1316The following options can be used to customize GnuPG operation:
1317
1318@table @code
1319
1320@item --key-server=@var{host}
1321Use @var{host} as the OpenPGP key server when importing a public key.
1322
1323@item --gpg=@var{command}
1324Use @var{command} as the GnuPG 2.x command. @var{command} is searched
1325for in @code{$PATH}.
1326
1327@end table
1328
37166310 1329
a1ba8475
LC
1330@c *********************************************************************
1331@node GNU Distribution
1332@chapter GNU Distribution
1333
1334Guix comes with a distribution of free software@footnote{The term
1335``free'' here refers to the
1336@url{http://www.gnu.org/philosophy/free-sw.html,freedom provided to
1337users of that software}.} that form the basis of the GNU system. This
1338includes core GNU packages such as GNU libc, GCC, and Binutils, as well
1339as many GNU and non-GNU applications. The complete list of available
e49951eb
MW
1340packages can be seen by running @command{guix package} (@pxref{Invoking
1341guix package}):
a1ba8475
LC
1342
1343@example
e49951eb 1344guix package --list-available
a1ba8475
LC
1345@end example
1346
1347The package definitions of the distribution may are provided by Guile
1348modules in the @code{(gnu packages ...)} name space---for instance, the
1349@code{(gnu packages emacs)} module exports a variable named
1350@code{emacs}, which is bound to a @code{<package>} object
1351(@pxref{Defining Packages}). The @code{(gnu packages)} module provides
1352facilities for searching for packages.
1353
1354The distribution is fully @dfn{bootstrapped} and @dfn{self-contained}:
1355each package is built based solely on other packages in the
1356distribution. The root of this dependency graph is a small set of
1357@dfn{bootstrap binaries}, provided by the @code{(gnu packages
1358bootstrap)} module. These are statically-linked binaries of the core
1359tools without which building anything at all would be impossible.
1360
1361
1362Our goal is to build a practical 100% free software distribution of
1363Linux-based and other variants of GNU, with a focus on the promotion and
1364tight integration of GNU components, and an emphasis on programs and
1365tools that help users exert that freedom.
1366
1367Building this distribution is a cooperative effort, and you are invited
1368to join! Please get in touch with us on @email{bug-guix@@gnu.org}. We
1369welcome ideas, bug reports, patches, and anything that may be helpful to
1370the project.
1371
c78bd12b 1372
568717fd
LC
1373@c *********************************************************************
1374@node Acknowledgments
1375@chapter Acknowledgments
1376
1377Guix is based on the Nix package manager, which was designed and
1378implemented by Eelco Dolstra. Nix pioneered functional package
1379management, and promoted unprecedented features, such as transactional
1380package upgrades and rollbacks, per-user profiles, and referentially
1381transparent build processes. Without this work, Guix would not exist.
1382
1383The Nix-based software distributions, Nixpkgs and NixOS, have also been
1384an inspiration for Guix.
1385
1386@c *********************************************************************
1387@node GNU Free Documentation License
1388@appendix GNU Free Documentation License
1389
1390@include fdl-1.3.texi
1391
1392@c *********************************************************************
1393@node Concept Index
1394@unnumbered Concept Index
1395@printindex cp
1396
1397@node Function Index
1398@unnumbered Function Index
1399@printindex fn
1400
1401@bye
1402
1403@c Local Variables:
1404@c ispell-local-dictionary: "american";
1405@c End: