doc: Documentation installation and the daemon.
[jackhill/guix/guix.git] / doc / guix.texi
1 \input texinfo
2 @c -*-texinfo-*-
3
4 @c %**start of header
5 @setfilename guix.info
6 @documentencoding UTF-8
7 @settitle GNU Guix Reference Manual
8 @c %**end of header
9
10 @include version.texi
11
12 @dircategory Package management
13 @direntry
14 * guix: (guix). Guix, the functional package manager.
15 * guix-package: (guix)Invoking guix-package
16 Managing packages with Guix.
17 * guix-build: (guix)Invoking guix-build
18 Building packages with Guix.
19 @end direntry
20
21 @titlepage
22 @title{GNU Guix Reference Manual}
23 @subtitle{Using the GNU Guix Functional Package Manager}
24 @author Ludovic Courtès
25
26 @page
27 @vskip 0pt plus 1filll
28 Edition @value{EDITION} @*
29 @value{UPDATED} @*
30
31 Copyright @copyright{} 2012 Ludovic Court@`es
32
33 @quotation
34 Permission is granted to copy, distribute and/or modify this document
35 under the terms of the GNU Free Documentation License, Version 1.3 or
36 any later version published by the Free Software Foundation; with no
37 Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A
38 copy of the license is included in the section entitled ``GNU Free
39 Documentation License''.
40 @end quotation
41 @end titlepage
42
43 @copying
44 This manual documents GNU Guix version @value{VERSION}.
45
46 Copyright (C) 2012, 2013 Ludovic Courtès
47
48 Permission is granted to copy, distribute and/or modify this document
49 under the terms of the GNU Free Documentation License, Version 1.3 or
50 any later version published by the Free Software Foundation; with no
51 Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A
52 copy of the license is included in the section entitled ``GNU Free
53 Documentation License.''
54 @end copying
55
56 @contents
57
58 @c *********************************************************************
59 @node Top
60 @top GNU Guix
61
62 This document describes GNU Guix version @value{VERSION}, a functional
63 package management tool written for the GNU system.
64
65 @menu
66 * Introduction:: What is Guix about?
67 * Installation:: Installing Guix.
68 * Package Management:: Package installation, upgrade, etc.
69 * Programming Interface:: Using Guix in Scheme.
70 * Utilities:: Package management commands.
71
72 * Acknowledgments:: Thanks!
73 * GNU Free Documentation License:: The license of this manual.
74 * Concept Index:: Concepts.
75 * Function Index:: Functions.
76 @end menu
77
78 @c *********************************************************************
79 @node Introduction
80 @chapter Introduction
81
82 GNU Guix@footnote{``Guix'' is pronounced like ``geeks'', or ``ɡiːks''
83 using the international phonetic alphabet (IPA).} is a functional
84 package management tool for the GNU system. Package management consists
85 in all the activities that relate to building packages from source,
86 honoring the build-time and run-time dependencies on packages,
87 installing packages in user environments, upgrading installed packages
88 to new versions or rolling back to a previous set, removing unused
89 software packages, etc.
90
91 @cindex functional package management
92 The term @dfn{functional} refers to a specific package management
93 discipline. In Guix, the package build and installation process is seen
94 as a function, in the mathematical sense: that function takes inputs,
95 such as build scripts, a compiler, and libraries depended on, and
96 returns the installed package. As a pure function, its result depends
97 solely on its inputs---for instance, it cannot refer to software or
98 scripts that were not explicitly passed as inputs. A build function
99 always produces the same result when passed a given set of inputs. Last
100 but not least, a build function cannot alter the system's environment in
101 any way; for instance, it cannot create, modify, or delete files outside
102 of its build and installation directories. This is achieved by running
103 build processes in dedicated ``chroots'', where only their explicit
104 inputs are visible.
105
106 @cindex package store
107 The result of package build functions is @dfn{cached} in the file
108 system, in a special directory called the @dfn{package store}. In
109 practice, each package is installed in a directory of its own, in the
110 store---by default under @file{/nix/store}. The directory name contains
111 a hash of all the inputs used to build that package; thus, changing an
112 input yields a different directory name.
113
114 This approach is the foundation of Guix's salient features: support for
115 transactional package upgrades and rollback, per-user installation, and
116 garbage collection of packages (@pxref{Features}).
117
118 Guix has a command-line interface allowing users to build, install,
119 upgrade, and remove packages, as well as a Scheme programming interface.
120 The remainder of this manual describes them.
121
122 @c *********************************************************************
123 @node Installation
124 @chapter Installation
125
126 This section describes the software requirements of Guix, as well as how
127 to install it and get ready to use it.
128
129 @menu
130 * Requirements:: Software needed to build and run Guix.
131 * Setting Up the Daemon:: Preparing the build daemon's environment.
132 * Invoking guix-daemon:: Running the build daemon.
133 @end menu
134
135 @node Requirements
136 @section Requirements
137
138 GNU Guix depends on the following packages:
139
140 @itemize
141 @item @url{http://gnu.org/software/guile/, GNU Guile 2.0.x};
142 @item @url{http://gnupg.org/, GNU libgcrypt}
143 @end itemize
144
145 Unless @code{--disable-daemon} was passed to @command{configure}, the
146 following packages are also needed:
147
148 @itemize
149 @item @url{http://sqlite.org, SQLite 3}
150 @item @url{http://www.bzip.org, libbz2}
151 @item @url{http://gcc.gnu.org, GCC's g++}
152 @end itemize
153
154 When a working installation of the Nix package manager is available, you
155 can instead configure Guix with @code{--disable-daemon}. In that case,
156 @url{http://nixos.org/nix/, Nix} replaces the three dependencies above.
157
158 @node Setting Up the Daemon
159 @section Setting Up the Daemon
160
161 @cindex daemon
162 Operations such as building a package or running the garbage collector
163 are all performed by a specialized process, the @dfn{Guix daemon}, on
164 behalf of clients. Only the daemon may access the store and its
165 associated database. Thus, any operation that manipulates the store
166 goes through the daemon. For instance, command-line tools such as
167 @command{guix-package} and @command{guix-build} communicate with the
168 daemon (@i{via} remote procedure calls) to instruct it what to do.
169
170 In a standard multi-user setup, Guix and its daemon---the
171 @command{guix-daemon} program---are installed by the system
172 administrator; @file{/nix/store} is owned by @code{root} and
173 @command{guix-daemon} runs as @code{root}. Unprivileged users may use
174 Guix tools to build packages or otherwise access the store, and the
175 daemon will do it on their behalf, ensuring that the store is kept in a
176 consistent state, and allowing built packages to be shared among users.
177
178 @cindex build users
179 When @command{guix-daemon} runs as @code{root}, you may not want package
180 build processes themselves to run as @code{root} too, for obvious
181 security reasons. To avoid that, a special pool of @dfn{build users}
182 should be created for use by build processes started by the daemon.
183 These build users need not have a shell and a home directory: they will
184 just be used when the daemon drops @code{root} privileges in build
185 processes. Having several such users allows the daemon to launch
186 distinct build processes under separate UIDs, which guarantees that they
187 do not interfere with each other---an essential feature since builds are
188 regarded as pure functions (@pxref{Introduction}).
189
190 On a GNU/Linux system, a build user pool may be created like this (using
191 Bash syntax and the @code{shadow} commands):
192
193 @example
194 # groupadd guix-builder
195 # for i in `seq 1 10`;
196 do
197 useradd -g guix-builder -d /var/empty -s `which nologin` \
198 -m "Guix build user $i" guix-builder$i;
199 done
200 @end example
201
202 @noindent
203 The @code{guix-daemon} program may then be run as @code{root} with:
204
205 @example
206 # guix-daemon --build-users-group=guix-builder
207 @end example
208
209 Guix may also be used in a single-user setup, with @command{guix-daemon}
210 running as a unprivileged user. However, to maximize non-interference
211 of build processes, the daemon still needs to perform certain operations
212 that are restricted to @code{root} on GNU/Linux: it should be able to
213 run build processes in a chroot, and to run them under different UIDs.
214 To that end, the @command{nix-setuid-helper} program is provided; it is
215 a small C program (less than 300 lines) that, if it is made setuid
216 @code{root}, can be executed by the daemon to perform these operations
217 on its behalf. The @code{root}-owned @file{/etc/nix-setuid.conf} file
218 is read by @command{nix-setuid-helper}; it should contain exactly two
219 words: the user name under which the authorized @command{guix-daemon}
220 runs, and the name of the build users group.
221
222 If you are installing Guix as an unprivileged user and do not have the
223 ability to make @file{nix-setuid-helper} setuid-@code{root}, it is still
224 possible to run @command{guix-daemon}. However, build processes will
225 not be isolated from one another, and not from the rest of the system.
226 Thus, build processes may interfere with each other, and may access
227 programs, libraries, and other files available on the system---making it
228 much harder to view them as @emph{pure} functions.
229
230 @node Invoking guix-daemon
231 @section Invoking @command{guix-daemon}
232
233 The @command{guix-daemon} program implements all the functionality to
234 access the store. This includes launching build processes, running the
235 garbage collector, querying the availability of a build result, etc. It
236 is normally run as @code{root} like this:
237
238 @example
239 # guix-daemon --build-users-group=guix-builder
240 @end example
241
242 @noindent
243 For details on how to set it up, @ref{Setting Up the Daemon}.
244
245 By default, @command{guix-daemon} launches build processes under
246 different UIDs, taken from the build group specified with
247 @code{--build-users-group}. In addition, each build process is run in a
248 chroot environment that only contains the subset of the store that the
249 build process depends on, as specified by its derivation
250 (@pxref{Programming Interface, derivation}), plus a set of specific
251 system directories. By default, the latter contains @file{/dev} and
252 @file{/dev/pts}.
253
254 The following command-line options are supported:
255
256 @table @code
257 @item --build-users-group=@var{group}
258 Take users from @var{group} to run build processes (@pxref{Setting Up
259 the Daemon, build users}).
260
261 @item --cache-failures
262 Cache build failures. By default, only successful builds are cached.
263
264 @item --cores=@var{n}
265 @itemx -c @var{n}
266 Use @var{n} CPU cores to build each derivation; @code{0} means as many
267 as available.
268
269 The default value is @code{1}, but it may be overridden by clients, such
270 as the @code{--cores} option of @command{guix-build} (@pxref{Invoking
271 guix-build}).
272
273 The effect is to define the @code{NIX_BUILD_CORES} environment variable
274 in the build process, which can then use it to exploit internal
275 parallelism---for instance, by running @code{make -j$NIX_BUILD_CORES}.
276
277 @item --max-jobs=@var{n}
278 @itemx -M @var{n}
279 Allow at most @var{n} build jobs in parallel. The default value is
280 @code{1}.
281
282 @item --debug
283 Produce debugging output.
284
285 This is useful to debug daemon start-up issues, but then it may be
286 overridden by clients, for example the @code{--verbosity} option of
287 @command{guix-build} (@pxref{Invoking guix-build}).
288
289 @item --chroot-directory=@var{dir}
290 Add @var{dir} to the build chroot.
291
292 Doing this may change the result of build processes---for instance if
293 they use optional dependencies found in @var{dir} when it is available,
294 and not otherwise. For that reason, it is not recommended to do so.
295 Instead, make sure that each derivation declares all the inputs that it
296 needs.
297
298 @item --disable-chroot
299 Disable chroot builds.
300
301 Using this option is not recommended since, again, it would allow build
302 processes to gain access to undeclared dependencies.
303
304 @item --disable-log-compression
305 Disable compression of the build logs.
306
307 @item --disable-store-optimization
308 Disable automatic file ``deduplication'' in the store.
309
310 @item --impersonate-linux-2.6
311 On Linux-based systems, impersonate Linux 2.6. This means that the
312 kernel's @code{uname} system call will report 2.6 as the release number.
313
314 This might be helpful to build programs that (usually wrongfully) depend
315 on the kernel version number.
316
317 @item --lose-logs
318 Do not keep build logs. By default they are kept under
319 @code{@var{localstatedir}/nix/log}.
320
321 @item --system=@var{system}
322 Assume @var{system} as the current system type. By default it is the
323 architecture/kernel pair found at configure time, such as
324 @code{x86_64-linux}.
325 @end table
326
327
328 @c *********************************************************************
329 @node Package Management
330 @chapter Package Management
331
332 The purpose of GNU Guix is to allow users to easily install, upgrade, and
333 remove software packages, without having to know about their build
334 procedure or dependencies. Guix also goes beyond this obvious set of
335 features.
336
337 This chapter describes the main features of Guix, as well as the package
338 management tools it provides.
339
340 @menu
341 * Features:: How Guix will make your life brighter.
342 * Invoking guix-package:: Package installation, removal, etc.
343 * Invoking guix-gc:: Running the garbage collector.
344 @end menu
345
346 @node Features
347 @section Features
348
349 When using Guix, each package ends up in the @dfn{package store}, in its
350 own directory---something that resembles
351 @file{/nix/store/xxx-package-1.2}, where @code{xxx} is a base32 string.
352
353 Instead of referring to these directories, users have their own
354 @dfn{profile}, which points to the packages that they actually want to
355 use. That profile is normally stored in @code{$HOME/.guix-profile}, and
356 each user has its own profile.
357
358 For example, if @code{alice} installed GCC 4.7.2, then
359 @file{/home/alice/.guix-profile/bin/gcc} points to
360 @file{/nix/store/xxx-gcc-4.7.2/bin/gcc}; on the same machine, @code{bob}
361 may have installed GCC 4.8.0, in which case its profile refers to these
362 particular package installation. Both coexist, without any
363 interference.
364
365 The @command{guix-package} command is the central tool to manage
366 packages. It operates on those per-user profiles, and can be used
367 @emph{with normal user privileges}.
368
369 The command provides the obvious install, remove, and upgrade
370 operations. Each invocation is actually a @emph{transaction}: either
371 the specified operation succeeds, or nothing happens. Thus, if the
372 @command{guix-package} processed is terminated during the transaction,
373 or if a power outage occurs during the transaction, then the user's
374 profile remains in its previous state, and remains usable.
375
376 In addition, any package transaction may be @emph{rolled back}. So, if,
377 for example, an upgrade installs a new version of a package that turns
378 out to have a serious bug, users may roll back to the previous instance
379 of their profile, which was known to work well.
380
381 All those packages in the package store may be @emph{garbage-collected}.
382 Guix can determine which packages are still referenced by the user
383 profiles, and remove those that are provably no longer referenced
384 (@pxref{Invoking guix-gc}). Users may also explicitly remove old
385 generations of their profile so that the packages they refer to can be
386 collected.
387
388 Finally, Guix takes a @dfn{purely functional} approach to package
389 management, as described in the introduction (@pxref{Introduction}).
390 Each @file{/nix/store} package directory name contains a hash of all the
391 inputs that were used to build that package---compiler, libraries, build
392 scripts, etc. This direct correspondence allows users to make sure a
393 given package installation matches the current state of their
394 distribution.
395
396 This foundation allows Guix to support @dfn{transparent binary/source
397 deployment}. When a pre-built binary for a @file{/nix/store} path is
398 available from an external source, Guix just downloads it; otherwise, it
399 builds the package from source, locally.
400
401 @node Invoking guix-package
402 @section Invoking @command{guix-package}
403
404 The @command{guix-package} command is the tool that allows users to
405 install, upgrade, and remove packages, as well as rolling back to
406 previous configurations. It operates only on the user's own profile,
407 and works with normal user privileges (@pxref{Features}). Its syntax
408 is:
409
410 @example
411 guix-package @var{options}
412 @end example
413
414 Primarily, @var{options} specifies the operations to be performed during
415 the transaction. Upon completion, a new profile is created, but
416 previous generations of the profile remain available, should the user
417 want to roll back.
418
419 @table @code
420
421 @item --install=@var{package}
422 @itemx -i @var{package}
423 Install @var{package}.
424
425 @var{package} may specify either a simple package name, such as
426 @code{guile}, or a package name followed by a hyphen and version number,
427 such as @code{guile-1.8}. In addition, @var{package} may contain a
428 colon, followed by the name of one of the outputs of the package, as in
429 @code{gcc:doc} or @code{libsigsegv-2.10:lib}.
430
431 @item --remove=@var{package}
432 @itemx -r @var{package}
433 Remove @var{package}.
434
435 @item --upgrade=@var{regexp}
436 @itemx -u @var{regexp}
437 Upgrade all the installed packages matching @var{regexp}.
438
439 @item --profile=@var{profile}
440 @itemx -p @var{profile}
441 Use @var{profile} instead of the user's default profile.
442
443 @item --dry-run
444 @itemx -n
445 Show what would be done without actually doing it.
446
447 @item --verbose
448 Produce verbose output. In particular, emit the environment's build log
449 on the standard error port.
450
451 @item --bootstrap
452 Use the bootstrap Guile to build the profile. This option is only
453 useful to distribution developers.
454
455 @end table
456
457 In addition to these actions @command{guix-package} supports the
458 following options to query the current state of a profile, or the
459 availability of packages:
460
461 @table @option
462
463 @item --list-installed[=@var{regexp}]
464 @itemx -I [@var{regexp}]
465 List currently installed packages in the specified profile. When
466 @var{regexp} is specified, list only installed packages whose name
467 matches @var{regexp}.
468
469 For each installed package, print the following items, separated by
470 tabs: the package name, its version string, the part of the package that
471 is installed (for instance, @code{out} for the default output,
472 @code{include} for its headers, etc.), and the path of this package in
473 the store.
474
475 @item --list-available[=@var{regexp}]
476 @itemx -A [@var{regexp}]
477 List packages currently available in the software distribution. When
478 @var{regexp} is specified, list only installed packages whose name
479 matches @var{regexp}.
480
481 For each package, print the following items separated by tabs: its name,
482 its version string, and the source location of its definition.
483
484 @end table
485
486
487 @node Invoking guix-gc
488 @section Invoking @command{guix-gc}
489
490 @cindex garbage collector
491 Packages that are installed but not used may be @dfn{garbage-collected}.
492 The @command{guix-gc} command allows users to explicitly run the garbage
493 collector to reclaim space from the @file{/nix/store} directory.
494
495 The garbage collector has a set of known @dfn{roots}: any file under
496 @file{/nix/store} reachable from a root is considered @dfn{live} and
497 cannot be deleted; any other file is considered @dfn{dead} and may be
498 deleted. The set of garbage collector roots includes default user
499 profiles, and may be augmented with @command{guix-build --root}, for
500 example (@pxref{Invoking guix-build}).
501
502 The @command{guix-gc} command has three mode of operations: it can be
503 used to garbage-collect any dead files (the default), to delete specific
504 files (the @code{--delete} option), or to print garbage-collector
505 information. The available options are listed below:
506
507 @table @code
508 @item --collect-garbage[=@var{min}]
509 @itemx -C [@var{min}]
510 Collect garbage---i.e., unreachable @file{/nix/store} files and
511 sub-directories. This is the default operation when no option is
512 specified.
513
514 When @var{min} is given, stop once @var{min} bytes have been collected.
515 @var{min} may be a number of bytes, or it may include a unit as a
516 suffix, such as @code{MiB} for mebibytes and @code{GB} for gigabytes.
517
518 When @var{min} is omitted, collect all the garbage.
519
520 @item --delete
521 @itemx -d
522 Attempt to delete all the store files and directories specified as
523 arguments. This fails if some of the files are not in the store, or if
524 they are still live.
525
526 @item --list-dead
527 Show the list of dead files and directories still present in the
528 store---i.e., files and directories no longer reachable from any root.
529
530 @item --list-live
531 Show the list of live store files and directories.
532 @end table
533
534
535 @c *********************************************************************
536 @node Programming Interface
537 @chapter Programming Interface
538
539 GNU Guix provides several Scheme programming interfaces (APIs) to
540 define, build, and query packages. The first interface allows users to
541 write high-level package definitions. These definitions refer to
542 familiar packaging concepts, such as the name and version of a package,
543 its build system, and its dependencies. These definitions can then be
544 turned into concrete build actions.
545
546 Build actions are performed by the Guix daemon, on behalf of users. In a
547 standard setup, the daemon has write access to the store---the
548 @file{/nix/store} directory---whereas users do not. The recommended
549 setup also has the daemon perform builds in chroots, under a specific
550 build users, to minimize interference with the rest of the system.
551
552 @cindex derivation
553 Lower-level APIs are available to interact with the daemon and the
554 store. To instruct the daemon to perform a build action, users actually
555 provide it with a @dfn{derivation}. A derivation is a low-level
556 representation of the build actions to be taken, and the environment in
557 which they should occur---derivations are to package definitions what
558 assembly is to C programs.
559
560 This chapter describes all these APIs in turn, starting from high-level
561 package definitions.
562
563 @menu
564 * Defining Packages:: Defining new packages.
565 * The Store:: Manipulating the package store.
566 * Derivations:: Low-level interface to package derivations.
567 @end menu
568
569 @node Defining Packages
570 @section Defining Packages
571
572 The high-level interface to package definitions is implemented in the
573 @code{(guix packages)} and @code{(guix build-system)} modules. As an
574 example, the package definition, or @dfn{recipe}, for the GNU Hello
575 package looks like this:
576
577 @example
578 (define hello
579 (package
580 (name "hello")
581 (version "2.8")
582 (source (origin
583 (method url-fetch)
584 (uri (string-append "mirror://gnu/hello/hello-" version
585 ".tar.gz"))
586 (sha256
587 (base32 "0wqd8sjmxfskrflaxywc7gqw7sfawrfvdxd9skxawzfgyy0pzdz6"))))
588 (build-system gnu-build-system)
589 (inputs `(("gawk" ,gawk)))
590 (synopsis "GNU Hello")
591 (description "Yeah...")
592 (home-page "http://www.gnu.org/software/hello/")
593 (license "GPLv3+")))
594 @end example
595
596 @noindent
597 Without being a Scheme expert, the reader may have guessed the meaning
598 of the various fields here. This expression binds variable @var{hello}
599 to a @code{<package>} object, which is essentially a record
600 (@pxref{SRFI-9, Scheme records,, guile, GNU Guile Reference Manual}).
601 This package object can be inspected using procedures found in the
602 @code{(guix packages)} module; for instance, @code{(package-name hello)}
603 returns---surprise!---@code{"hello"}.
604
605 There are a few points worth noting in the above package definition:
606
607 @itemize
608 @item
609 The @code{source} field of the package is an @code{<origin>} object.
610 Here, the @code{url-fetch} method from @code{(guix download)} is used,
611 meaning that the source is a file to be downloaded over FTP or HTTP.
612
613 The @code{mirror://gnu} prefix instructs @code{url-fetch} to use one of
614 the GNU mirrors defined in @code{(guix download)}.
615
616 The @code{sha256} field specifies the expected SHA256 hash of the file
617 being downloaded. It is mandatory, and allows Guix to check the
618 integrity of the file. The @code{(base32 @dots{})} form introduces the
619 base32 representation of the hash. A convenient way to obtain this
620 information is with the @code{guix-download} tool.
621
622 @item
623 @cindex GNU Build System
624 The @code{build-system} field is set to @var{gnu-build-system}. The
625 @var{gnu-build-system} variable is defined in the @code{(guix
626 build-system gnu)} module, and is bound to a @code{<build-system>}
627 object.
628
629 Naturally, @var{gnu-build-system} represents the familiar GNU Build
630 System, and variants thereof (@pxref{Configuration, configuration and
631 makefile conventions,, standards, GNU Coding Standards}). In a
632 nutshell, packages using the GNU Build System may be configured, built,
633 and installed with the usual @code{./configure && make && make check &&
634 make install} command sequence. This is what @var{gnu-build-system}
635 does.
636
637 In addition, @var{gnu-build-system} ensures that the ``standard''
638 environment for GNU packages is available. This includes tools such as
639 GCC, Coreutils, Bash, Make, Diffutils, and Patch.
640
641 @item
642 The @code{inputs} field specifies inputs to the build process---i.e.,
643 build-time or run-time dependencies of the package. Here, we define an
644 input called @code{"gawk"} whose value is that of the @var{gawk}
645 variable; @var{gawk} is itself bound to a @code{<package>} object.
646
647 Note that GCC, Coreutils, Bash, and other essential tools do not need to
648 be specified as inputs here. Instead, @var{gnu-build-system} takes care
649 of ensuring that they are present.
650
651 However, any other dependencies need to be specified in the
652 @code{inputs} field. Any dependency not specified here will simply be
653 unavailable to the build process, possibly leading to a build failure.
654 @end itemize
655
656 There are other fields that package definitions may provide. Of
657 particular interest is the @code{arguments} field. When specified, it
658 must be bound to a list of additional arguments to be passed to the
659 build system. For instance, the above definition could be augmented
660 with the following field initializer:
661
662 @example
663 (arguments `(#:tests? #f
664 #:configure-flags '("--enable-silent-rules")))
665 @end example
666
667 @noindent
668 These are keyword arguments (@pxref{Optional Arguments, keyword
669 arguments in Guile,, guile, GNU Guile Reference Manual}). They are
670 passed to @var{gnu-build-system}, which interprets them as meaning ``do
671 not run @code{make check}'', and ``run @file{configure} with the
672 @code{--enable-silent-rules} flag''.
673
674 Once a package definition is in place@footnote{Simple package
675 definitions like the one above may be automatically converted from the
676 Nixpkgs distribution using the @command{guix-import} command.}, the
677 package may actually be built using the @code{guix-build} command-line
678 tool (@pxref{Invoking guix-build}).
679
680 Behind the scenes, a derivation corresponding to the @code{<package>}
681 object is first computed by the @code{package-derivation} procedure.
682 That derivation is stored in a @code{.drv} file under @file{/nix/store}.
683 The build actions it prescribes may then be realized by using the
684 @code{build-derivations} procedure (@pxref{The Store}).
685
686 @deffn {Scheme Procedure} package-derivation @var{store} @var{package} [@var{system}]
687 Return the derivation of @var{package} for @var{system}. The result is
688 the file name of the derivation---i.e., a @code{.drv} file under
689 @code{/nix/store}.
690
691 @var{package} must be a valid @code{<package>} object, and @var{system}
692 must be a string denoting the target system type---e.g.,
693 @code{"x86_64-linux"} for an x86_64 Linux-based GNU system. @var{store}
694 must be a connection to the daemon, which operates on the store
695 (@pxref{The Store}).
696 @end deffn
697
698 @node The Store
699 @section The Store
700
701 @code{(guix store)}
702
703 @node Derivations
704 @section Derivations
705
706 @code{(guix derivations)}
707
708 @c *********************************************************************
709 @node Utilities
710 @chapter Utilities
711
712 @menu
713 * Invoking guix-build:: Building packages from the command line.
714 @end menu
715
716 @node Invoking guix-build
717 @section Invoking @command{guix-build}
718
719 The @command{guix-build} command builds packages or derivations and
720 their dependencies, and prints the resulting store paths. It is mainly
721 useful for distribution developers. The general syntax is:
722
723 @example
724 guix-build @var{options} @var{package-or-derivation}@dots{}
725 @end example
726
727 @var{package-or-derivation} may be either the name of a package found in
728 the software distribution such as @code{coreutils}, or a derivation such
729 as @file{/nix/store/xxx-coreutils-8.19.drv}. Alternatively, the
730 @code{--expression} option may be used to specify a Scheme expression
731 that evaluates to a package; this is useful when disambiguation among
732 several same-named packages or package variants is needed.
733
734 The @var{options} may be zero or more of the following:
735
736 @table @code
737
738 @item --expression=@var{expr}
739 @itemx -e @var{expr}
740 Build the package @var{expr} evaluates to.
741
742 For example, @var{expr} may be @code{(@@ (distro packages guile)
743 guile-1.8)}, which unambiguously designates this specific variant of
744 version 1.8 of Guile.
745
746 @item --source
747 @itemx -S
748 Build the packages' source derivations, rather than the packages
749 themselves.
750
751 For instance, @code{guix-build -S gcc} returns something like
752 @file{/nix/store/xxx-gcc-4.7.2.tar.bz2}, which is GCC's source tarball.
753
754 @item --system=@var{system}
755 @itemx -s @var{system}
756 Attempt to build for @var{system}---e.g., @code{i686-linux}---instead of
757 the host's system type.
758
759 An example use of this is on Linux-based systems, which can emulate
760 different personalities. For instance, passing
761 @code{--system=i686-linux} on an @code{x86_64-linux} system allows users
762 to build packages in a complete 32-bit environment.
763
764 @item --derivations
765 @itemx -d
766 Return the derivation paths, not the output paths, of the given
767 packages.
768
769 @item --keep-failed
770 @itemx -K
771 Keep the build tree of failed builds. Thus, if a build fail, its build
772 tree is kept under @file{/tmp}, in a directory whose name is shown at
773 the end of the build log. This is useful when debugging build issues.
774
775 @item --dry-run
776 @itemx -n
777 Do not build the derivations.
778
779 @item --no-substitutes
780 Build instead of resorting to pre-built substitutes.
781
782 @item --cores=@var{n}
783 @itemx -c @var{n}
784 Allow the use of up to @var{n} CPU cores for the build. The special
785 value @code{0} means to use as many CPU cores as available.
786
787 @item --root=@var{file}
788 @itemx -r @var{file}
789 Make @var{file} a symlink to the result, and register it as a garbage
790 collector root.
791
792 @item --verbosity=@var{level}
793 Use the given verbosity level. @var{level} must be an integer between 0
794 and 5; higher means more verbose output. Setting a level of 4 or more
795 may be helpful when debugging setup issues with the build daemon.
796
797 @end table
798
799 Behind the scenes, @command{guix-build} is essentially an interface to
800 the @code{package-derivation} procedure of the @code{(guix packages)}
801 module, and to the @code{build-derivations} procedure of the @code{(guix
802 store)} module.
803
804
805 @c *********************************************************************
806 @node Acknowledgments
807 @chapter Acknowledgments
808
809 Guix is based on the Nix package manager, which was designed and
810 implemented by Eelco Dolstra. Nix pioneered functional package
811 management, and promoted unprecedented features, such as transactional
812 package upgrades and rollbacks, per-user profiles, and referentially
813 transparent build processes. Without this work, Guix would not exist.
814
815 The Nix-based software distributions, Nixpkgs and NixOS, have also been
816 an inspiration for Guix.
817
818 @c *********************************************************************
819 @node GNU Free Documentation License
820 @appendix GNU Free Documentation License
821
822 @include fdl-1.3.texi
823
824 @c *********************************************************************
825 @node Concept Index
826 @unnumbered Concept Index
827 @printindex cp
828
829 @node Function Index
830 @unnumbered Function Index
831 @printindex fn
832
833 @bye
834
835 @c Local Variables:
836 @c ispell-local-dictionary: "american";
837 @c End: