gnu: qemu: Change multiple-SMB-share patch to /gnu/store.
[jackhill/guix/guix.git] / doc / guix.texi
CommitLineData
568717fd
LC
1\input texinfo
2@c -*-texinfo-*-
3
4@c %**start of header
5@setfilename guix.info
6@documentencoding UTF-8
f8348b91 7@settitle GNU Guix Reference Manual
568717fd
LC
8@c %**end of header
9
10@include version.texi
7df7a74e
NK
11
12@copying
425b0bfc 13Copyright @copyright{} 2012, 2013, 2014 Ludovic Courtès@*
7df7a74e
NK
14Copyright @copyright{} 2013 Andreas Enge@*
15Copyright @copyright{} 2013 Nikita Karetnikov
16
17Permission is granted to copy, distribute and/or modify this document
18under the terms of the GNU Free Documentation License, Version 1.3 or
19any later version published by the Free Software Foundation; with no
20Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A
21copy of the license is included in the section entitled ``GNU Free
22Documentation License''.
23@end copying
568717fd 24
eeaf4427 25@dircategory Package management
568717fd
LC
26@direntry
27* guix: (guix). Guix, the functional package manager.
e49951eb 28* guix package: (guix)Invoking guix package
eeaf4427 29 Managing packages with Guix.
e49951eb 30* guix build: (guix)Invoking guix build
568717fd
LC
31 Building packages with Guix.
32@end direntry
568717fd
LC
33
34@titlepage
7730d112
LC
35@title GNU Guix Reference Manual
36@subtitle Using the GNU Guix Functional Package Manager
568717fd 37@author Ludovic Courtès
da7cabd4 38@author Andreas Enge
acc08466 39@author Nikita Karetnikov
568717fd
LC
40
41@page
42@vskip 0pt plus 1filll
43Edition @value{EDITION} @*
44@value{UPDATED} @*
45
7df7a74e 46@insertcopying
568717fd
LC
47@end titlepage
48
568717fd
LC
49@contents
50
51@c *********************************************************************
52@node Top
f8348b91 53@top GNU Guix
568717fd 54
f8348b91
LC
55This document describes GNU Guix version @value{VERSION}, a functional
56package management tool written for the GNU system.
568717fd
LC
57
58@menu
59* Introduction:: What is Guix about?
bd5e766b 60* Installation:: Installing Guix.
eeaf4427 61* Package Management:: Package installation, upgrade, etc.
568717fd
LC
62* Programming Interface:: Using Guix in Scheme.
63* Utilities:: Package management commands.
a1ba8475 64* GNU Distribution:: Software for your friendly GNU system.
9bf3c1a7 65* Contributing:: Your help needed!
568717fd
LC
66
67* Acknowledgments:: Thanks!
68* GNU Free Documentation License:: The license of this manual.
69* Concept Index:: Concepts.
70* Function Index:: Functions.
71@end menu
72
73@c *********************************************************************
74@node Introduction
75@chapter Introduction
76
c80e7e55
LC
77GNU Guix@footnote{``Guix'' is pronounced like ``geeks'', or ``ɡiːks''
78using the international phonetic alphabet (IPA).} is a functional
79package management tool for the GNU system. Package management consists
4bfc4ea3
NK
80of all activities that relate to building packages from sources,
81honoring their build-time and run-time dependencies,
c80e7e55
LC
82installing packages in user environments, upgrading installed packages
83to new versions or rolling back to a previous set, removing unused
84software packages, etc.
568717fd
LC
85
86@cindex functional package management
87The term @dfn{functional} refers to a specific package management
88discipline. In Guix, the package build and installation process is seen
4bfc4ea3
NK
89as a function, in the mathematical sense. That function takes inputs,
90such as build scripts, a compiler, and libraries, and
91returns an installed package. As a pure function, its result depends
568717fd
LC
92solely on its inputs---for instance, it cannot refer to software or
93scripts that were not explicitly passed as inputs. A build function
4bfc4ea3
NK
94always produces the same result when passed a given set of inputs. It
95cannot alter the system's environment in
568717fd
LC
96any way; for instance, it cannot create, modify, or delete files outside
97of its build and installation directories. This is achieved by running
e900c503 98build processes in isolated environments (or @dfn{containers}), where only their
4bfc4ea3 99explicit inputs are visible.
568717fd 100
e531ac2a 101@cindex store
568717fd 102The result of package build functions is @dfn{cached} in the file
e531ac2a
LC
103system, in a special directory called @dfn{the store} (@pxref{The
104Store}). Each package is installed in a directory of its own, in the
834129e0 105store---by default under @file{/gnu/store}. The directory name contains
568717fd
LC
106a hash of all the inputs used to build that package; thus, changing an
107input yields a different directory name.
108
109This approach is the foundation of Guix's salient features: support for
4bfc4ea3 110transactional package upgrade and rollback, per-user installation, and
eeaf4427 111garbage collection of packages (@pxref{Features}).
568717fd 112
4bfc4ea3 113Guix has a command-line interface, which allows users to build, install,
568717fd 114upgrade, and remove packages, as well as a Scheme programming interface.
568717fd 115
a1ba8475
LC
116Last but not least, Guix is used to build a distribution of the GNU
117system, with many GNU and non-GNU free software packages. @xref{GNU
118Distribution}.
119
bd5e766b
LC
120@c *********************************************************************
121@node Installation
122@chapter Installation
123
48febeb8
LC
124GNU Guix is available for download from its website at
125@url{http://www.gnu.org/software/guix/}. This section describes the
126software requirements of Guix, as well as how to install it and get
127ready to use it.
bd5e766b 128
b22a12fd 129The build procedure for Guix is the same as for other GNU software, and
1da983b9 130is not covered here. Please see the files @file{README} and
b22a12fd
LC
131@file{INSTALL} in the Guix source tree for additional details.
132
bd5e766b
LC
133@menu
134* Requirements:: Software needed to build and run Guix.
135* Setting Up the Daemon:: Preparing the build daemon's environment.
136* Invoking guix-daemon:: Running the build daemon.
137@end menu
138
139@node Requirements
140@section Requirements
141
142GNU Guix depends on the following packages:
143
144@itemize
4a328f73 145@item @url{http://gnu.org/software/guile/, GNU Guile}, version 2.0.5 or later;
bd5e766b
LC
146@item @url{http://gnupg.org/, GNU libgcrypt}
147@end itemize
148
149Unless @code{--disable-daemon} was passed to @command{configure}, the
150following packages are also needed:
151
152@itemize
153@item @url{http://sqlite.org, SQLite 3}
154@item @url{http://www.bzip.org, libbz2}
155@item @url{http://gcc.gnu.org, GCC's g++}
156@end itemize
157
4bfc4ea3
NK
158When a working installation of @url{http://nixos.org/nix/, the Nix package
159manager} is available, you
bd5e766b 160can instead configure Guix with @code{--disable-daemon}. In that case,
4bfc4ea3 161Nix replaces the three dependencies above.
bd5e766b 162
b22a12fd
LC
163Guix is compatible with Nix, so it is possible to share the same store
164between both. To do so, you must pass @command{configure} not only the
165same @code{--with-store-dir} value, but also the same
4bfc4ea3
NK
166@code{--localstatedir} value. The latter is essential because it
167specifies where the database that stores metadata about the store is
834129e0 168located, among other things. The default values for Nix are
b22a12fd 169@code{--with-store-dir=/nix/store} and @code{--localstatedir=/nix/var}.
4bfc4ea3
NK
170Note that @code{--disable-daemon} is not required if
171your goal is to share the store with Nix.
b22a12fd 172
bd5e766b
LC
173@node Setting Up the Daemon
174@section Setting Up the Daemon
175
176@cindex daemon
177Operations such as building a package or running the garbage collector
49e6291a 178are all performed by a specialized process, the @dfn{build daemon}, on
bd5e766b
LC
179behalf of clients. Only the daemon may access the store and its
180associated database. Thus, any operation that manipulates the store
181goes through the daemon. For instance, command-line tools such as
e49951eb 182@command{guix package} and @command{guix build} communicate with the
bd5e766b
LC
183daemon (@i{via} remote procedure calls) to instruct it what to do.
184
49e6291a
LC
185The following sections explain how to prepare the build daemon's
186environment.
187
188@menu
189* Build Environment Setup:: Preparing the isolated build environment.
190* Daemon Offload Setup:: Offloading builds to remote machines.
191@end menu
192
193@node Build Environment Setup
194@subsection Build Environment Setup
195
bd5e766b
LC
196In a standard multi-user setup, Guix and its daemon---the
197@command{guix-daemon} program---are installed by the system
834129e0 198administrator; @file{/gnu/store} is owned by @code{root} and
bd5e766b
LC
199@command{guix-daemon} runs as @code{root}. Unprivileged users may use
200Guix tools to build packages or otherwise access the store, and the
201daemon will do it on their behalf, ensuring that the store is kept in a
202consistent state, and allowing built packages to be shared among users.
203
204@cindex build users
205When @command{guix-daemon} runs as @code{root}, you may not want package
206build processes themselves to run as @code{root} too, for obvious
207security reasons. To avoid that, a special pool of @dfn{build users}
208should be created for use by build processes started by the daemon.
209These build users need not have a shell and a home directory: they will
210just be used when the daemon drops @code{root} privileges in build
211processes. Having several such users allows the daemon to launch
212distinct build processes under separate UIDs, which guarantees that they
213do not interfere with each other---an essential feature since builds are
214regarded as pure functions (@pxref{Introduction}).
215
216On a GNU/Linux system, a build user pool may be created like this (using
217Bash syntax and the @code{shadow} commands):
218
091196b3
LC
219@c See http://lists.gnu.org/archive/html/bug-guix/2013-01/msg00239.html
220@c for why `-G' is needed.
bd5e766b
LC
221@example
222# groupadd guix-builder
223# for i in `seq 1 10`;
224 do
091196b3
LC
225 useradd -g guix-builder -G guix-builder \
226 -d /var/empty -s `which nologin` \
4d1a2b50
LC
227 -c "Guix build user $i" --system \
228 guix-builder$i;
bd5e766b
LC
229 done
230@end example
231
232@noindent
233The @code{guix-daemon} program may then be run as @code{root} with:
234
235@example
236# guix-daemon --build-users-group=guix-builder
237@end example
238
e900c503 239@cindex chroot
b095792f
LC
240@noindent
241This way, the daemon starts build processes in a chroot, under one of
242the @code{guix-builder} users. On GNU/Linux, by default, the chroot
6dc99317
LC
243environment contains nothing but:
244
245@c Keep this list in sync with libstore/build.cc! -----------------------
246@itemize
247@item
4743a4da
LC
248a minimal @code{/dev} directory, created mostly independently from the
249host @code{/dev}@footnote{``Mostly'', because while the set of files
250that appear in the chroot's @code{/dev} is fixed, most of these files
251can only be created if the host has them.};
252
253@item
254the @code{/proc} directory; it only shows the container's processes
255since a separate PID name space is used;
6dc99317
LC
256
257@item
258@file{/etc/passwd} with an entry for the current user and an entry for
259user @file{nobody};
260
261@item
262@file{/etc/group} with an entry for the user's group;
263
264@item
265@file{/etc/hosts} with an entry that maps @code{localhost} to
266@code{127.0.0.1};
267
268@item
269a writable @file{/tmp} directory.
270@end itemize
b095792f 271
d43eb499 272If you are installing Guix as an unprivileged user, it is still
bd5e766b
LC
273possible to run @command{guix-daemon}. However, build processes will
274not be isolated from one another, and not from the rest of the system.
275Thus, build processes may interfere with each other, and may access
276programs, libraries, and other files available on the system---making it
277much harder to view them as @emph{pure} functions.
278
49e6291a
LC
279
280@node Daemon Offload Setup
281@subsection Using the Offload Facility
282
283@cindex offloading
4ec2e92d
LC
284@cindex build hook
285When desired, the build daemon can @dfn{offload}
286derivation builds to other machines
49e6291a
LC
287running Guix, using the @code{offload} @dfn{build hook}. When that
288feature is enabled, a list of user-specified build machines is read from
289@file{/etc/guix/machines.scm}; anytime a build is requested, for
290instance via @code{guix build}, the daemon attempts to offload it to one
291of the machines that satisfies the derivation's constraints, in
292particular its system type---e.g., @file{x86_64-linux}. Missing
293prerequisites for the build are copied over SSH to the target machine,
294which then proceeds with the build; upon success the output(s) of the
295build are copied back to the initial machine.
296
4ec2e92d 297The @file{/etc/guix/machines.scm} file typically looks like this:
49e6291a
LC
298
299@example
300(list (build-machine
301 (name "eightysix.example.org")
302 (system "x86_64-linux")
303 (user "bob")
304 (speed 2.)) ; incredibly fast!
305
306 (build-machine
307 (name "meeps.example.org")
308 (system "mips64el-linux")
309 (user "alice")
310 (private-key
311 (string-append (getenv "HOME")
312 "/.ssh/id-rsa-for-guix"))))
313@end example
314
315@noindent
316In the example above we specify a list of two build machines, one for
317the @code{x86_64} architecture and one for the @code{mips64el}
4ec2e92d
LC
318architecture.
319
320In fact, this file is---not surprisingly!---a Scheme file that is
321evaluated when the @code{offload} hook is started. Its return value
322must be a list of @code{build-machine} objects. While this example
323shows a fixed list of build machines, one could imagine, say, using
324DNS-SD to return a list of potential build machines discovered in the
325local network (@pxref{Introduction, Guile-Avahi,, guile-avahi, Using
326Avahi in Guile Scheme Programs}).
327
328The compulsory fields for a @code{build-machine} declaration are:
49e6291a
LC
329
330@table @code
331
332@item name
333The remote machine's host name.
334
335@item system
336The remote machine's system type.
337
338@item user
339The user account to use when connecting to the remote machine over SSH.
340Note that the SSH key pair must @emph{not} be passphrase-protected, to
341allow non-interactive logins.
342
343@end table
344
345@noindent
4ec2e92d 346A number of optional fields may be specified:
49e6291a
LC
347
348@table @code
349
cecd72d5
LC
350@item port
351Port number of the machine's SSH server (default: 22).
352
49e6291a
LC
353@item private-key
354The SSH private key file to use when connecting to the machine.
355
356@item parallel-builds
357The number of builds that may run in parallel on the machine (1 by
358default.)
359
360@item speed
361A ``relative speed factor''. The offload scheduler will tend to prefer
362machines with a higher speed factor.
363
364@item features
365A list of strings denoting specific features supported by the machine.
366An example is @code{"kvm"} for machines that have the KVM Linux modules
367and corresponding hardware support. Derivations can request features by
368name, and they will be scheduled on matching build machines.
369
370@end table
371
372The @code{guix} command must be in the search path on the build
373machines, since offloading works by invoking the @code{guix archive} and
374@code{guix build} commands.
375
376There's one last thing to do once @file{machines.scm} is in place. As
377explained above, when offloading, files are transferred back and forth
378between the machine stores. For this to work, you need to generate a
379key pair to allow the daemon to export signed archives of files from the
380store (@pxref{Invoking guix archive}):
381
382@example
383# guix archive --generate-key
384@end example
385
386@noindent
387Thus, when receiving files, a machine's build daemon can make sure they
388are genuine, have not been tampered with, and that they are signed by an
389authorized key.
390
391
bd5e766b
LC
392@node Invoking guix-daemon
393@section Invoking @command{guix-daemon}
394
395The @command{guix-daemon} program implements all the functionality to
396access the store. This includes launching build processes, running the
397garbage collector, querying the availability of a build result, etc. It
398is normally run as @code{root} like this:
399
400@example
401# guix-daemon --build-users-group=guix-builder
402@end example
403
404@noindent
405For details on how to set it up, @ref{Setting Up the Daemon}.
406
e900c503
LC
407@cindex chroot
408@cindex container, build environment
409@cindex build environment
410@cindex reproducible builds
bd5e766b
LC
411By default, @command{guix-daemon} launches build processes under
412different UIDs, taken from the build group specified with
413@code{--build-users-group}. In addition, each build process is run in a
414chroot environment that only contains the subset of the store that the
415build process depends on, as specified by its derivation
416(@pxref{Programming Interface, derivation}), plus a set of specific
417system directories. By default, the latter contains @file{/dev} and
e900c503
LC
418@file{/dev/pts}. Furthermore, on GNU/Linux, the build environment is a
419@dfn{container}: in addition to having its own file system tree, it has
420a separate mount name space, its own PID name space, network name space,
421etc. This helps achieve reproducible builds (@pxref{Features}).
bd5e766b
LC
422
423The following command-line options are supported:
424
425@table @code
426@item --build-users-group=@var{group}
427Take users from @var{group} to run build processes (@pxref{Setting Up
428the Daemon, build users}).
429
6858f9d1 430@item --no-substitutes
b5385b52 431@cindex substitutes
6858f9d1 432Do not use substitutes for build products. That is, always build things
c4202d60
LC
433locally instead of allowing downloads of pre-built binaries
434(@pxref{Substitutes}).
6858f9d1 435
b5385b52
LC
436By default substitutes are used, unless the client---such as the
437@command{guix package} command---is explicitly invoked with
438@code{--no-substitutes}.
439
440When the daemon runs with @code{--no-substitutes}, clients can still
441explicitly enable substitution @i{via} the @code{set-build-options}
442remote procedure call (@pxref{The Store}).
443
4ec2e92d
LC
444@cindex build hook
445@item --no-build-hook
446Do not use the @dfn{build hook}.
447
448The build hook is a helper program that the daemon can start and to
449which it submits build requests. This mechanism is used to offload
450builds to other machines (@pxref{Daemon Offload Setup}).
451
bd5e766b
LC
452@item --cache-failures
453Cache build failures. By default, only successful builds are cached.
454
455@item --cores=@var{n}
456@itemx -c @var{n}
457Use @var{n} CPU cores to build each derivation; @code{0} means as many
458as available.
459
460The default value is @code{1}, but it may be overridden by clients, such
e49951eb
MW
461as the @code{--cores} option of @command{guix build} (@pxref{Invoking
462guix build}).
bd5e766b
LC
463
464The effect is to define the @code{NIX_BUILD_CORES} environment variable
465in the build process, which can then use it to exploit internal
466parallelism---for instance, by running @code{make -j$NIX_BUILD_CORES}.
467
468@item --max-jobs=@var{n}
469@itemx -M @var{n}
470Allow at most @var{n} build jobs in parallel. The default value is
471@code{1}.
472
473@item --debug
474Produce debugging output.
475
476This is useful to debug daemon start-up issues, but then it may be
477overridden by clients, for example the @code{--verbosity} option of
e49951eb 478@command{guix build} (@pxref{Invoking guix build}).
bd5e766b
LC
479
480@item --chroot-directory=@var{dir}
481Add @var{dir} to the build chroot.
482
483Doing this may change the result of build processes---for instance if
484they use optional dependencies found in @var{dir} when it is available,
485and not otherwise. For that reason, it is not recommended to do so.
486Instead, make sure that each derivation declares all the inputs that it
487needs.
488
489@item --disable-chroot
490Disable chroot builds.
491
492Using this option is not recommended since, again, it would allow build
493processes to gain access to undeclared dependencies.
494
495@item --disable-log-compression
496Disable compression of the build logs.
497
1da983b9
LC
498Unless @code{--lose-logs} is used, all the build logs are kept in the
499@var{localstatedir}. To save space, the daemon automatically compresses
500them with bzip2 by default. This option disables that.
501
bd5e766b
LC
502@item --disable-store-optimization
503Disable automatic file ``deduplication'' in the store.
504
1da983b9
LC
505By default, files added to the store are automatically ``deduplicated'':
506if a newly added file is identical as another one found in the store,
507the daemon makes the new file a hard link to the other file. This
508slightly increases the input/output load at the end of a build process.
509This option disables this.
510
6e37066e
LC
511@item --gc-keep-outputs[=yes|no]
512Tell whether the garbage collector (GC) must keep outputs of live
513derivations.
514
515When set to ``yes'', the GC will keep the outputs of any live derivation
516available in the store---the @code{.drv} files. The default is ``no'',
517meaning that derivation outputs are kept only if they are GC roots.
518
519@item --gc-keep-derivations[=yes|no]
520Tell whether the garbage collector (GC) must keep derivations
521corresponding to live outputs.
522
523When set to ``yes'', as is the case by default, the GC keeps
524derivations---i.e., @code{.drv} files---as long as at least one of their
525outputs is live. This allows users to keep track of the origins of
526items in their store. Setting it to ``no'' saves a bit of disk space.
527
528Note that when both @code{--gc-keep-derivations} and
529@code{--gc-keep-outputs} are used, the effect is to keep all the build
530prerequisites (the sources, compiler, libraries, and other build-time
531tools) of live objects in the store, regardless of whether these
532prerequisites are live. This is convenient for developers since it
533saves rebuilds or downloads.
534
bd5e766b
LC
535@item --impersonate-linux-2.6
536On Linux-based systems, impersonate Linux 2.6. This means that the
537kernel's @code{uname} system call will report 2.6 as the release number.
538
539This might be helpful to build programs that (usually wrongfully) depend
540on the kernel version number.
541
542@item --lose-logs
543Do not keep build logs. By default they are kept under
544@code{@var{localstatedir}/nix/log}.
545
546@item --system=@var{system}
547Assume @var{system} as the current system type. By default it is the
548architecture/kernel pair found at configure time, such as
549@code{x86_64-linux}.
b8d2aa26
LC
550
551@item --listen=@var{socket}
552Listen for connections on @var{socket}, the file name of a Unix-domain
553socket. The default socket is
554@file{@var{localstatedir}/daemon-socket/socket}. This option is only
555useful in exceptional circumstances, such as if you need to run several
556daemons on the same machine.
bd5e766b
LC
557@end table
558
559
eeaf4427
LC
560@c *********************************************************************
561@node Package Management
562@chapter Package Management
563
f8348b91 564The purpose of GNU Guix is to allow users to easily install, upgrade, and
eeaf4427
LC
565remove software packages, without having to know about their build
566procedure or dependencies. Guix also goes beyond this obvious set of
567features.
568
569This chapter describes the main features of Guix, as well as the package
570management tools it provides.
571
572@menu
573* Features:: How Guix will make your life brighter.
e49951eb 574* Invoking guix package:: Package installation, removal, etc.
c4202d60 575* Substitutes:: Downloading pre-built binaries.
760c60d6 576* Packages with Multiple Outputs:: Single source package, multiple outputs.
e49951eb 577* Invoking guix gc:: Running the garbage collector.
f651b477 578* Invoking guix pull:: Fetching the latest Guix and distribution.
760c60d6 579* Invoking guix archive:: Exporting and importing store files.
eeaf4427
LC
580@end menu
581
582@node Features
583@section Features
584
585When using Guix, each package ends up in the @dfn{package store}, in its
586own directory---something that resembles
834129e0 587@file{/gnu/store/xxx-package-1.2}, where @code{xxx} is a base32 string.
eeaf4427
LC
588
589Instead of referring to these directories, users have their own
590@dfn{profile}, which points to the packages that they actually want to
821b0015
LC
591use. These profiles are stored within each user's home directory, at
592@code{$HOME/.guix-profile}.
eeaf4427 593
821b0015 594For example, @code{alice} installs GCC 4.7.2. As a result,
eeaf4427 595@file{/home/alice/.guix-profile/bin/gcc} points to
834129e0 596@file{/gnu/store/@dots{}-gcc-4.7.2/bin/gcc}. Now, on the same machine,
821b0015
LC
597@code{bob} had already installed GCC 4.8.0. The profile of @code{bob}
598simply continues to point to
834129e0 599@file{/gnu/store/@dots{}-gcc-4.8.0/bin/gcc}---i.e., both versions of GCC
821b0015 600coexist on the same system without any interference.
eeaf4427 601
e49951eb
MW
602The @command{guix package} command is the central tool to manage
603packages (@pxref{Invoking guix package}). It operates on those per-user
821b0015 604profiles, and can be used @emph{with normal user privileges}.
eeaf4427
LC
605
606The command provides the obvious install, remove, and upgrade
607operations. Each invocation is actually a @emph{transaction}: either
ba55b1cb 608the specified operation succeeds, or nothing happens. Thus, if the
e49951eb 609@command{guix package} process is terminated during the transaction,
eeaf4427
LC
610or if a power outage occurs during the transaction, then the user's
611profile remains in its previous state, and remains usable.
612
613In addition, any package transaction may be @emph{rolled back}. So, if,
614for example, an upgrade installs a new version of a package that turns
615out to have a serious bug, users may roll back to the previous instance
4af2447e
LC
616of their profile, which was known to work well. Similarly, the global
617system configuration is subject to transactional upgrades and roll-back
618(@pxref{Using the Configuration System}).
eeaf4427
LC
619
620All those packages in the package store may be @emph{garbage-collected}.
621Guix can determine which packages are still referenced by the user
fe8ff028 622profiles, and remove those that are provably no longer referenced
e49951eb 623(@pxref{Invoking guix gc}). Users may also explicitly remove old
fe8ff028
LC
624generations of their profile so that the packages they refer to can be
625collected.
eeaf4427 626
e900c503
LC
627@cindex reproducibility
628@cindex reproducible builds
eeaf4427
LC
629Finally, Guix takes a @dfn{purely functional} approach to package
630management, as described in the introduction (@pxref{Introduction}).
834129e0 631Each @file{/gnu/store} package directory name contains a hash of all the
eeaf4427
LC
632inputs that were used to build that package---compiler, libraries, build
633scripts, etc. This direct correspondence allows users to make sure a
634given package installation matches the current state of their
e900c503
LC
635distribution. It also helps maximize @dfn{build reproducibility}:
636thanks to the isolated build environments that are used, a given build
637is likely to yield bit-identical files when performed on different
638machines (@pxref{Invoking guix-daemon, container}).
eeaf4427 639
c4202d60 640@cindex substitutes
eeaf4427 641This foundation allows Guix to support @dfn{transparent binary/source
c4202d60 642deployment}. When a pre-built binary for a @file{/gnu/store} item is
18f2887b 643available from an external source---a @dfn{substitute}, Guix just
c4202d60
LC
644downloads it and unpacks it;
645otherwise, it builds the package from source, locally
646(@pxref{Substitutes}).
eeaf4427 647
e49951eb
MW
648@node Invoking guix package
649@section Invoking @command{guix package}
eeaf4427 650
e49951eb 651The @command{guix package} command is the tool that allows users to
eeaf4427
LC
652install, upgrade, and remove packages, as well as rolling back to
653previous configurations. It operates only on the user's own profile,
654and works with normal user privileges (@pxref{Features}). Its syntax
655is:
656
657@example
e49951eb 658guix package @var{options}
eeaf4427
LC
659@end example
660
ba55b1cb 661Primarily, @var{options} specifies the operations to be performed during
eeaf4427
LC
662the transaction. Upon completion, a new profile is created, but
663previous generations of the profile remain available, should the user
664want to roll back.
665
6447738c
MW
666For example, to remove @code{lua} and install @code{guile} and
667@code{guile-cairo} in a single transaction:
668
669@example
670guix package -r lua -i guile guile-cairo
671@end example
672
b9e5c0a9 673For each user, a symlink to the user's default profile is automatically
0ec1af59 674created in @file{$HOME/.guix-profile}. This symlink always points to the
b9e5c0a9
LC
675current generation of the user's default profile. Thus, users can add
676@file{$HOME/.guix-profile/bin} to their @code{PATH} environment
677variable, and so on.
678
0ec1af59
LC
679In a multi-user setup, user profiles must be stored in a place
680registered as a @dfn{garbage-collector root}, which
e49951eb 681@file{$HOME/.guix-profile} points to (@pxref{Invoking guix gc}). That
0ec1af59
LC
682directory is normally
683@code{@var{localstatedir}/profiles/per-user/@var{user}}, where
684@var{localstatedir} is the value passed to @code{configure} as
685@code{--localstatedir}, and @var{user} is the user name. It must be
686created by @code{root}, with @var{user} as the owner. When it does not
70c43291
LC
687exist, or is not owned by @var{user}, @command{guix package} emits an
688error about it.
0ec1af59
LC
689
690The @var{options} can be among the following:
691
eeaf4427
LC
692@table @code
693
6447738c
MW
694@item --install=@var{package} @dots{}
695@itemx -i @var{package} @dots{}
696Install the specified @var{package}s.
eeaf4427 697
6447738c 698Each @var{package} may specify either a simple package name, such as
eeaf4427 699@code{guile}, or a package name followed by a hyphen and version number,
dc5669cd
MW
700such as @code{guile-1.8.8}. If no version number is specified, the
701newest available version will be selected. In addition, @var{package}
702may contain a colon, followed by the name of one of the outputs of the
6e721c4d 703package, as in @code{gcc:doc} or @code{binutils-2.22:lib}
e7f34eb0
LC
704(@pxref{Packages with Multiple Outputs}). Packages with a corresponding
705name (and optionally version) are searched for among the GNU
706distribution modules (@pxref{Package Modules}).
eeaf4427 707
461572cc
LC
708@cindex propagated inputs
709Sometimes packages have @dfn{propagated inputs}: these are dependencies
710that automatically get installed along with the required package.
711
712An example is the GNU MPC library: its C header files refer to those of
713the GNU MPFR library, which in turn refer to those of the GMP library.
714Thus, when installing MPC, the MPFR and GMP libraries also get installed
715in the profile; removing MPC also removes MPFR and GMP---unless they had
716also been explicitly installed independently.
717
ba7ea5ce 718Besides, packages sometimes rely on the definition of environment
5924080d 719variables for their search paths (see explanation of
ba7ea5ce 720@code{--search-paths} below). Any missing or possibly incorrect
5924080d
LC
721environment variable definitions are reported here.
722
ef010c0f 723@c XXX: keep me up-to-date
5924080d 724Finally, when installing a GNU package, the tool reports the
ef010c0f
LC
725availability of a newer upstream version. In the future, it may provide
726the option of installing directly from the upstream version, even if
727that version is not yet in the distribution.
728
5d4b411f
LC
729@item --install-from-expression=@var{exp}
730@itemx -e @var{exp}
731Install the package @var{exp} evaluates to.
732
733@var{exp} must be a Scheme expression that evaluates to a
734@code{<package>} object. This option is notably useful to disambiguate
735between same-named variants of a package, with expressions such as
736@code{(@@ (gnu packages base) guile-final)}.
737
738Note that this option installs the first output of the specified
739package, which may be insufficient when needing a specific output of a
740multiple-output package.
741
6447738c
MW
742@item --remove=@var{package} @dots{}
743@itemx -r @var{package} @dots{}
744Remove the specified @var{package}s.
eeaf4427 745
6447738c 746As for @code{--install}, each @var{package} may specify a version number
13ed095c
LC
747and/or output name in addition to the package name. For instance,
748@code{-r glibc:debug} would remove the @code{debug} output of
749@code{glibc}.
750
6447738c
MW
751@item --upgrade[=@var{regexp} @dots{}]
752@itemx -u [@var{regexp} @dots{}]
753Upgrade all the installed packages. If one or more @var{regexp}s are
754specified, upgrade only installed packages whose name matches a
755@var{regexp}.
eeaf4427 756
f651b477
LC
757Note that this upgrades package to the latest version of packages found
758in the distribution currently installed. To update your distribution,
759you should regularly run @command{guix pull} (@pxref{Invoking guix
760pull}).
761
24e262f0
LC
762@item --roll-back
763Roll back to the previous @dfn{generation} of the profile---i.e., undo
764the last transaction.
765
766When combined with options such as @code{--install}, roll back occurs
767before any other actions.
768
d9307267 769When rolling back from the first generation that actually contains
4b2bc804
NK
770installed packages, the profile is made to point to the @dfn{zeroth
771generation}, which contains no files apart from its own meta-data.
d9307267 772
82fe08ed
LC
773Installing, removing, or upgrading packages from a generation that has
774been rolled back to overwrites previous future generations. Thus, the
775history of a profile's generations is always linear.
776
5924080d
LC
777@item --search-paths
778@cindex search paths
779Report environment variable definitions, in Bash syntax, that may be
780needed in order to use the set of installed packages. These environment
781variables are used to specify @dfn{search paths} for files used by some
782of the installed packages.
783
784For example, GCC needs the @code{CPATH} and @code{LIBRARY_PATH}
785environment variables to be defined so it can look for headers and
786libraries in the user's profile (@pxref{Environment Variables,,, gcc,
787Using the GNU Compiler Collection (GCC)}). If GCC and, say, the C
788library are installed in the profile, then @code{--search-paths} will
789suggest setting these variables to @code{@var{profile}/include} and
790@code{@var{profile}/lib}, respectively.
791
eeaf4427
LC
792@item --profile=@var{profile}
793@itemx -p @var{profile}
794Use @var{profile} instead of the user's default profile.
795
70915c1a
LC
796@item --verbose
797Produce verbose output. In particular, emit the environment's build log
798on the standard error port.
799
eeaf4427
LC
800@item --bootstrap
801Use the bootstrap Guile to build the profile. This option is only
802useful to distribution developers.
803
804@end table
805
e49951eb 806In addition to these actions @command{guix package} supports the
733b4130
LC
807following options to query the current state of a profile, or the
808availability of packages:
eeaf4427 809
733b4130
LC
810@table @option
811
acc08466
NK
812@item --search=@var{regexp}
813@itemx -s @var{regexp}
814List the available packages whose synopsis or description matches
299112d3
LC
815@var{regexp}. Print all the meta-data of matching packages in
816@code{recutils} format (@pxref{Top, GNU recutils databases,, recutils,
817GNU recutils manual}).
acc08466 818
299112d3
LC
819This allows specific fields to be extracted using the @command{recsel}
820command, for instance:
821
822@example
e49951eb 823$ guix package -s malloc | recsel -p name,version
299112d3
LC
824name: glibc
825version: 2.17
826
827name: libgc
828version: 7.2alpha6
829@end example
acc08466 830
733b4130
LC
831@item --list-installed[=@var{regexp}]
832@itemx -I [@var{regexp}]
bd9bde1c
LC
833List the currently installed packages in the specified profile, with the
834most recently installed packages shown last. When @var{regexp} is
835specified, list only installed packages whose name matches @var{regexp}.
733b4130
LC
836
837For each installed package, print the following items, separated by
838tabs: the package name, its version string, the part of the package that
839is installed (for instance, @code{out} for the default output,
840@code{include} for its headers, etc.), and the path of this package in
841the store.
842
64fc89b6
LC
843@item --list-available[=@var{regexp}]
844@itemx -A [@var{regexp}]
a1ba8475
LC
845List packages currently available in the software distribution
846(@pxref{GNU Distribution}). When @var{regexp} is specified, list only
847installed packages whose name matches @var{regexp}.
64fc89b6
LC
848
849For each package, print the following items separated by tabs: its name,
6e721c4d
LC
850its version string, the parts of the package (@pxref{Packages with
851Multiple Outputs}), and the source location of its definition.
64fc89b6 852
f566d765
LC
853@item --list-generations[=@var{pattern}]
854@itemx -l [@var{pattern}]
855Return a list of generations along with their creation dates; for each
856generation, show the installed packages, with the most recently
4b2bc804
NK
857installed packages shown last. Note that the zeroth generation is never
858shown.
f566d765
LC
859
860For each installed package, print the following items, separated by
861tabs: the name of a package, its version string, the part of the package
862that is installed (@pxref{Packages with Multiple Outputs}), and the
863location of this package in the store.
864
865When @var{pattern} is used, the command returns only matching
866generations. Valid patterns include:
867
868@itemize
869@item @emph{Integers and comma-separated integers}. Both patterns denote
870generation numbers. For instance, @code{--list-generations=1} returns
871the first one.
872
873And @code{--list-generations=1,8,2} outputs three generations in the
874specified order. Neither spaces nor trailing commas are allowed.
875
876@item @emph{Ranges}. @code{--list-generations=2..9} prints the
877specified generations and everything in between. Note that the start of
878a range must be lesser than its end.
879
880It is also possible to omit the endpoint. For example,
881@code{--list-generations=2..}, returns all generations starting from the
882second one.
883
884@item @emph{Durations}. You can also get the last @emph{N}@tie{}days, weeks,
885or months by passing an integer along with the first letter of the
d7ddb257
LC
886duration. For example, @code{--list-generations=20d} lists generations
887that are up to 20 days old.
f566d765
LC
888@end itemize
889
b7884ca3
NK
890@item --delete-generations[=@var{pattern}]
891@itemx -d [@var{pattern}]
d7ddb257
LC
892When @var{pattern} is omitted, delete all generations except the current
893one.
b7884ca3
NK
894
895This command accepts the same patterns as @option{--list-generations}.
d7ddb257
LC
896When @var{pattern} is specified, delete the matching generations. When
897@var{pattern} specifies a duration, generations @emph{older} than the
898specified duration match. For instance, @code{--delete-generations=1m}
899deletes generations that are more than one month old.
900
901If the current generation matches, it is deleted atomically---i.e., by
902switching to the previous available generation. Note that the zeroth
903generation is never deleted.
b7884ca3 904
1bb9900a
LC
905Note that deleting generations prevents roll-back to them.
906Consequently, this command must be used with care.
907
733b4130 908@end table
eeaf4427 909
70ee5642
LC
910Finally, since @command{guix package} may actually start build
911processes, it supports all the common build options that @command{guix
912build} supports (@pxref{Invoking guix build, common build options}).
913
c4202d60
LC
914@node Substitutes
915@section Substitutes
916
917@cindex substitutes
918@cindex pre-built binaries
919Guix supports transparent source/binary deployment, which means that it
920can either build things locally, or download pre-built items from a
921server. We call these pre-built items @dfn{substitutes}---they are
922substitutes for local build results. In many cases, downloading a
923substitute is much faster than building things locally.
924
925Substitutes can be anything resulting from a derivation build
926(@pxref{Derivations}). Of course, in the common case, they are
927pre-built package binaries, but source tarballs, for instance, which
928also result from derivation builds, can be available as substitutes.
929
930The @code{hydra.gnu.org} server is a front-end to a build farm that
931builds packages from the GNU distribution continuously for some
932architectures, and makes them available as substitutes.
933
934@cindex security
935@cindex digital signatures
936To allow Guix to download substitutes from @code{hydra.gnu.org}, you
937must add its public key to the access control list (ACL) of archive
938imports, using the @command{guix archive} command (@pxref{Invoking guix
939archive}). Doing so implies that you trust @code{hydra.gnu.org} to not
940be compromised and to serve genuine substitutes.
941
942This public key is installed along with Guix, in
943@code{@var{prefix}/share/guix/hydra.gnu.org.pub}, where @var{prefix} is
944the installation prefix of Guix. If you installed Guix from source,
945make sure you checked the GPG signature of
946@file{guix-@value{VERSION}.tar.gz}, which contains this public key file.
947Then, you can run something like this:
948
949@example
950# guix archive --authorize < hydra.gnu.org.pub
951@end example
952
953Once this is in place, the output of a command like @code{guix build}
954should change from something like:
955
956@example
957$ guix build emacs --dry-run
958The following derivations would be built:
959 /gnu/store/yr7bnx8xwcayd6j95r2clmkdl1qh688w-emacs-24.3.drv
960 /gnu/store/x8qsh1hlhgjx6cwsjyvybnfv2i37z23w-dbus-1.6.4.tar.gz.drv
961 /gnu/store/1ixwp12fl950d15h2cj11c73733jay0z-alsa-lib-1.0.27.1.tar.bz2.drv
962 /gnu/store/nlma1pw0p603fpfiqy7kn4zm105r5dmw-util-linux-2.21.drv
963@dots{}
964@end example
965
966@noindent
967to something like:
968
969@example
970$ guix build emacs --dry-run
971The following files would be downloaded:
972 /gnu/store/pk3n22lbq6ydamyymqkkz7i69wiwjiwi-emacs-24.3
973 /gnu/store/2ygn4ncnhrpr61rssa6z0d9x22si0va3-libjpeg-8d
974 /gnu/store/71yz6lgx4dazma9dwn2mcjxaah9w77jq-cairo-1.12.16
975 /gnu/store/7zdhgp0n1518lvfn8mb96sxqfmvqrl7v-libxrender-0.9.7
976@dots{}
977@end example
978
979@noindent
980This indicates that substitutes from @code{hydra.gnu.org} are usable and
981will be downloaded, when possible, for future builds.
982
983Guix ignores substitutes that are not signed, or that are not signed by
ef27aa9c 984one of the keys listed in the ACL. It also detects and raises an error
c4202d60
LC
985when attempting to use a substitute that has been tampered with.
986
987The substitute mechanism can be disabled globally by running
988@code{guix-daemon} with @code{--no-substitutes} (@pxref{Invoking
989guix-daemon}). It can also be disabled temporarily by passing the
990@code{--no-substitutes} option to @command{guix package}, @command{guix
991build}, and other command-line tools.
992
993
994Today, each individual's control over their own computing is at the
995mercy of institutions, corporations, and groups with enough power and
996determination to subvert the computing infrastructure and exploit its
997weaknesses. While using @code{hydra.gnu.org} substitutes can be
998convenient, we encourage users to also build on their own, or even run
999their own build farm, such that @code{hydra.gnu.org} is less of an
1000interesting target.
1001
1002Guix has the foundations to maximize build reproducibility
1003(@pxref{Features}). In most cases, independent builds of a given
1004package or derivation should yield bit-identical results. Thus, through
1005a diverse set of independent package builds, we can strengthen the
1006integrity of our systems.
1007
1008In the future, we want Guix to have support to publish and retrieve
1009binaries to/from other users, in a peer-to-peer fashion. If you would
1010like to discuss this project, join us on @email{guix-devel@@gnu.org}.
1011
1012
6e721c4d
LC
1013@node Packages with Multiple Outputs
1014@section Packages with Multiple Outputs
1015
1016@cindex multiple-output packages
1017@cindex package outputs
1018
1019Often, packages defined in Guix have a single @dfn{output}---i.e., the
1020source package leads exactly one directory in the store. When running
1021@command{guix package -i glibc}, one installs the default output of the
1022GNU libc package; the default output is called @code{out}, but its name
1023can be omitted as shown in this command. In this particular case, the
1024default output of @code{glibc} contains all the C header files, shared
1025libraries, static libraries, Info documentation, and other supporting
1026files.
1027
1028Sometimes it is more appropriate to separate the various types of files
1029produced from a single source package into separate outputs. For
1030instance, the GLib C library (used by GTK+ and related packages)
1031installs more than 20 MiB of reference documentation as HTML pages.
1032To save space for users who do not need it, the documentation goes to a
1033separate output, called @code{doc}. To install the main GLib output,
1034which contains everything but the documentation, one would run:
1035
1036@example
1037guix package -i glib
1038@end example
1039
1040The command to install its documentation is:
1041
1042@example
1043guix package -i glib:doc
1044@end example
1045
1046Some packages install programs with different ``dependency footprints''.
1047For instance, the WordNet package install both command-line tools and
1048graphical user interfaces (GUIs). The former depend solely on the C
1049library, whereas the latter depend on Tcl/Tk and the underlying X
1050libraries. In this case, we leave the command-line tools in the default
1051output, whereas the GUIs are in a separate output. This allows users
1052who do not need the GUIs to save space.
1053
1054There are several such multiple-output packages in the GNU distribution.
91ef73d4
LC
1055Other conventional output names include @code{lib} for libraries and
1056possibly header files, @code{bin} for stand-alone programs, and
1057@code{debug} for debugging information (@pxref{Installing Debugging
1058Files}). The outputs of a packages are listed in the third column of
1059the output of @command{guix package --list-available} (@pxref{Invoking
1060guix package}).
6e721c4d 1061
eeaf4427 1062
e49951eb
MW
1063@node Invoking guix gc
1064@section Invoking @command{guix gc}
fe8ff028
LC
1065
1066@cindex garbage collector
1067Packages that are installed but not used may be @dfn{garbage-collected}.
e49951eb 1068The @command{guix gc} command allows users to explicitly run the garbage
834129e0 1069collector to reclaim space from the @file{/gnu/store} directory.
fe8ff028
LC
1070
1071The garbage collector has a set of known @dfn{roots}: any file under
834129e0 1072@file{/gnu/store} reachable from a root is considered @dfn{live} and
fe8ff028
LC
1073cannot be deleted; any other file is considered @dfn{dead} and may be
1074deleted. The set of garbage collector roots includes default user
e49951eb
MW
1075profiles, and may be augmented with @command{guix build --root}, for
1076example (@pxref{Invoking guix build}).
fe8ff028 1077
1bb9900a
LC
1078Prior to running @code{guix gc --collect-garbage} to make space, it is
1079often useful to remove old generations from user profiles; that way, old
1080package builds referenced by those generations can be reclaimed. This
1081is achieved by running @code{guix package --delete-generations}
1082(@pxref{Invoking guix package}).
1083
e49951eb 1084The @command{guix gc} command has three modes of operation: it can be
fe8ff028
LC
1085used to garbage-collect any dead files (the default), to delete specific
1086files (the @code{--delete} option), or to print garbage-collector
1087information. The available options are listed below:
1088
1089@table @code
1090@item --collect-garbage[=@var{min}]
1091@itemx -C [@var{min}]
834129e0 1092Collect garbage---i.e., unreachable @file{/gnu/store} files and
fe8ff028
LC
1093sub-directories. This is the default operation when no option is
1094specified.
1095
1096When @var{min} is given, stop once @var{min} bytes have been collected.
1097@var{min} may be a number of bytes, or it may include a unit as a
1098suffix, such as @code{MiB} for mebibytes and @code{GB} for gigabytes.
1099
1100When @var{min} is omitted, collect all the garbage.
1101
1102@item --delete
1103@itemx -d
1104Attempt to delete all the store files and directories specified as
1105arguments. This fails if some of the files are not in the store, or if
1106they are still live.
1107
1108@item --list-dead
1109Show the list of dead files and directories still present in the
1110store---i.e., files and directories no longer reachable from any root.
1111
1112@item --list-live
1113Show the list of live store files and directories.
ba8b732d
LC
1114
1115@end table
1116
1117In addition, the references among existing store files can be queried:
1118
1119@table @code
1120
1121@item --references
1122@itemx --referrers
1123List the references (respectively, the referrers) of store files given
1124as arguments.
1125
8e59fdd5
LC
1126@item --requisites
1127@itemx -R
1128List the requisites of the store files passed as arguments. Requisites
1129include the store files themselves, their references, and the references
1130of these, recursively. In other words, the returned list is the
1131@dfn{transitive closure} of the store files.
1132
fe8ff028
LC
1133@end table
1134
eeaf4427 1135
f651b477
LC
1136@node Invoking guix pull
1137@section Invoking @command{guix pull}
1138
1139Packages are installed or upgraded to the latest version available in
1140the distribution currently available on your local machine. To update
1141that distribution, along with the Guix tools, you must run @command{guix
1142pull}: the command downloads the latest Guix source code and package
1143descriptions, and deploys it.
1144
1145On completion, @command{guix package} will use packages and package
1146versions from this just-retrieved copy of Guix. Not only that, but all
1147the Guix commands and Scheme modules will also be taken from that latest
1148version. New @command{guix} sub-commands added by the update also
1149become available.
1150
1151The @command{guix pull} command is usually invoked with no arguments,
1152but it supports the following options:
1153
1154@table @code
1155@item --verbose
1156Produce verbose output, writing build logs to the standard error output.
1157
ab5d72ad
LC
1158@item --url=@var{url}
1159Download the source tarball of Guix from @var{url}.
1160
1161By default, the tarball is taken from its canonical address at
1162@code{gnu.org}, for the stable branch of Guix.
1163
f651b477
LC
1164@item --bootstrap
1165Use the bootstrap Guile to build the latest Guix. This option is only
1166useful to Guix developers.
1167@end table
1168
760c60d6
LC
1169
1170@node Invoking guix archive
1171@section Invoking @command{guix archive}
1172
1173The @command{guix archive} command allows users to @dfn{export} files
1174from the store into a single archive, and to later @dfn{import} them.
1175In particular, it allows store files to be transferred from one machine
1176to another machine's store. For example, to transfer the @code{emacs}
1177package to a machine connected over SSH, one would run:
1178
1179@example
1180guix archive --export emacs | ssh the-machine guix archive --import
1181@end example
1182
87236aed
LC
1183@noindent
1184However, note that, in this example, all of @code{emacs} and its
1185dependencies are transferred, regardless of what is already available in
1186the target machine's store. The @code{--missing} option can help figure
1187out which items are missing from the target's store.
1188
760c60d6 1189Archives are stored in the ``Nix archive'' or ``Nar'' format, which is
0dbd88db
LC
1190comparable in spirit to `tar', but with a few noteworthy differences
1191that make it more appropriate for our purposes. First, rather than
1192recording all Unix meta-data for each file, the Nar format only mentions
1193the file type (regular, directory, or symbolic link); Unix permissions
1194and owner/group are dismissed. Second, the order in which directory
1195entries are stored always follows the order of file names according to
1196the C locale collation order. This makes archive production fully
1197deterministic.
1198
1199When exporting, the daemon digitally signs the contents of the archive,
1200and that digital signature is appended. When importing, the daemon
1201verifies the signature and rejects the import in case of an invalid
1202signature or if the signing key is not authorized.
760c60d6
LC
1203@c FIXME: Add xref to daemon doc about signatures.
1204
1205The main options are:
1206
1207@table @code
1208@item --export
1209Export the specified store files or packages (see below.) Write the
1210resulting archive to the standard output.
1211
1212@item --import
1213Read an archive from the standard input, and import the files listed
1214therein into the store. Abort if the archive has an invalid digital
f82cc5fd
LC
1215signature, or if it is signed by a public key not among the authorized
1216keys (see @code{--authorize} below.)
554f26ec 1217
87236aed
LC
1218@item --missing
1219Read a list of store file names from the standard input, one per line,
1220and write on the standard output the subset of these files missing from
1221the store.
1222
554f26ec 1223@item --generate-key[=@var{parameters}]
f82cc5fd 1224@cindex signing, archives
554f26ec
LC
1225Generate a new key pair for the daemons. This is a prerequisite before
1226archives can be exported with @code{--export}. Note that this operation
1227usually takes time, because it needs to gather enough entropy to
1228generate the key pair.
1229
1230The generated key pair is typically stored under @file{/etc/guix}, in
1231@file{signing-key.pub} (public key) and @file{signing-key.sec} (private
1232key, which must be kept secret.) When @var{parameters} is omitted, it
1233is a 4096-bit RSA key. Alternately, @var{parameters} can specify
1234@code{genkey} parameters suitable for Libgcrypt (@pxref{General
1235public-key related Functions, @code{gcry_pk_genkey},, gcrypt, The
1236Libgcrypt Reference Manual}).
f82cc5fd
LC
1237
1238@item --authorize
1239@cindex authorizing, archives
1240Authorize imports signed by the public key passed on standard input.
1241The public key must be in ``s-expression advanced format''---i.e., the
1242same format as the @file{signing-key.pub} file.
1243
1244The list of authorized keys is kept in the human-editable file
1245@file{/etc/guix/acl}. The file contains
1246@url{http://people.csail.mit.edu/rivest/Sexp.txt, ``advanced-format
1247s-expressions''} and is structured as an access-control list in the
1248@url{http://theworld.com/~cme/spki.txt, Simple Public-Key Infrastructure
1249(SPKI)}.
760c60d6
LC
1250@end table
1251
1252To export store files as an archive to the standard output, run:
1253
1254@example
1255guix archive --export @var{options} @var{specifications}...
1256@end example
1257
1258@var{specifications} may be either store file names or package
1259specifications, as for @command{guix package} (@pxref{Invoking guix
1260package}). For instance, the following command creates an archive
1261containing the @code{gui} output of the @code{git} package and the main
1262output of @code{emacs}:
1263
1264@example
834129e0 1265guix archive --export git:gui /gnu/store/...-emacs-24.3 > great.nar
760c60d6
LC
1266@end example
1267
1268If the specified packages are not built yet, @command{guix archive}
1269automatically builds them. The build process may be controlled with the
1270same options that can be passed to the @command{guix build} command
70ee5642 1271(@pxref{Invoking guix build, common build options}).
760c60d6
LC
1272
1273
568717fd
LC
1274@c *********************************************************************
1275@node Programming Interface
1276@chapter Programming Interface
1277
3dc1970d
LC
1278GNU Guix provides several Scheme programming interfaces (APIs) to
1279define, build, and query packages. The first interface allows users to
1280write high-level package definitions. These definitions refer to
1281familiar packaging concepts, such as the name and version of a package,
1282its build system, and its dependencies. These definitions can then be
1283turned into concrete build actions.
1284
ba55b1cb 1285Build actions are performed by the Guix daemon, on behalf of users. In a
3dc1970d 1286standard setup, the daemon has write access to the store---the
834129e0 1287@file{/gnu/store} directory---whereas users do not. The recommended
3dc1970d
LC
1288setup also has the daemon perform builds in chroots, under a specific
1289build users, to minimize interference with the rest of the system.
1290
1291@cindex derivation
1292Lower-level APIs are available to interact with the daemon and the
1293store. To instruct the daemon to perform a build action, users actually
1294provide it with a @dfn{derivation}. A derivation is a low-level
1295representation of the build actions to be taken, and the environment in
1296which they should occur---derivations are to package definitions what
1297assembly is to C programs.
1298
1299This chapter describes all these APIs in turn, starting from high-level
1300package definitions.
1301
568717fd 1302@menu
b860f382
LC
1303* Defining Packages:: Defining new packages.
1304* The Store:: Manipulating the package store.
1305* Derivations:: Low-level interface to package derivations.
1306* The Store Monad:: Purely functional interface to the store.
568717fd
LC
1307@end menu
1308
1309@node Defining Packages
1310@section Defining Packages
1311
3dc1970d
LC
1312The high-level interface to package definitions is implemented in the
1313@code{(guix packages)} and @code{(guix build-system)} modules. As an
1314example, the package definition, or @dfn{recipe}, for the GNU Hello
1315package looks like this:
1316
1317@example
e7f34eb0
LC
1318(define-module (gnu packages hello)
1319 #:use-module (guix packages)
1320 #:use-module (guix download)
1321 #:use-module (guix build-system gnu)
1322 #:use-module (guix licenses))
b22a12fd 1323
3dc1970d
LC
1324(define hello
1325 (package
1326 (name "hello")
1327 (version "2.8")
1328 (source (origin
1329 (method url-fetch)
1330 (uri (string-append "mirror://gnu/hello/hello-" version
1331 ".tar.gz"))
1332 (sha256
1333 (base32 "0wqd8sjmxfskrflaxywc7gqw7sfawrfvdxd9skxawzfgyy0pzdz6"))))
1334 (build-system gnu-build-system)
1335 (inputs `(("gawk" ,gawk)))
1336 (synopsis "GNU Hello")
1337 (description "Yeah...")
1338 (home-page "http://www.gnu.org/software/hello/")
b22a12fd 1339 (license gpl3+)))
3dc1970d
LC
1340@end example
1341
1342@noindent
1343Without being a Scheme expert, the reader may have guessed the meaning
e7f34eb0 1344of the various fields here. This expression binds variable @code{hello}
3dc1970d
LC
1345to a @code{<package>} object, which is essentially a record
1346(@pxref{SRFI-9, Scheme records,, guile, GNU Guile Reference Manual}).
1347This package object can be inspected using procedures found in the
1348@code{(guix packages)} module; for instance, @code{(package-name hello)}
1349returns---surprise!---@code{"hello"}.
1350
e7f34eb0
LC
1351In the example above, @var{hello} is defined into a module of its own,
1352@code{(gnu packages hello)}. Technically, this is not strictly
1353necessary, but it is convenient to do so: all the packages defined in
1354modules under @code{(gnu packages @dots{})} are automatically known to
1355the command-line tools (@pxref{Package Modules}).
1356
3dc1970d
LC
1357There are a few points worth noting in the above package definition:
1358
1359@itemize
1360@item
1361The @code{source} field of the package is an @code{<origin>} object.
1362Here, the @code{url-fetch} method from @code{(guix download)} is used,
1363meaning that the source is a file to be downloaded over FTP or HTTP.
1364
1365The @code{mirror://gnu} prefix instructs @code{url-fetch} to use one of
1366the GNU mirrors defined in @code{(guix download)}.
1367
1368The @code{sha256} field specifies the expected SHA256 hash of the file
1369being downloaded. It is mandatory, and allows Guix to check the
1370integrity of the file. The @code{(base32 @dots{})} form introduces the
6c365eca 1371base32 representation of the hash. You can obtain this information with
210cc920
LC
1372@code{guix download} (@pxref{Invoking guix download}) and @code{guix
1373hash} (@pxref{Invoking guix hash}).
3dc1970d 1374
f9cc8971
LC
1375@cindex patches
1376When needed, the @code{origin} form can also have a @code{patches} field
1377listing patches to be applied, and a @code{snippet} field giving a
1378Scheme expression to modify the source code.
1379
3dc1970d
LC
1380@item
1381@cindex GNU Build System
1382The @code{build-system} field is set to @var{gnu-build-system}. The
1383@var{gnu-build-system} variable is defined in the @code{(guix
1384build-system gnu)} module, and is bound to a @code{<build-system>}
1385object.
1386
1387Naturally, @var{gnu-build-system} represents the familiar GNU Build
1388System, and variants thereof (@pxref{Configuration, configuration and
1389makefile conventions,, standards, GNU Coding Standards}). In a
ba55b1cb 1390nutshell, packages using the GNU Build System may be configured, built,
3dc1970d
LC
1391and installed with the usual @code{./configure && make && make check &&
1392make install} command sequence. This is what @var{gnu-build-system}
1393does.
1394
1395In addition, @var{gnu-build-system} ensures that the ``standard''
1396environment for GNU packages is available. This includes tools such as
1397GCC, Coreutils, Bash, Make, Diffutils, and Patch.
1398
1399@item
1400The @code{inputs} field specifies inputs to the build process---i.e.,
1401build-time or run-time dependencies of the package. Here, we define an
1402input called @code{"gawk"} whose value is that of the @var{gawk}
1403variable; @var{gawk} is itself bound to a @code{<package>} object.
1404
1405Note that GCC, Coreutils, Bash, and other essential tools do not need to
1406be specified as inputs here. Instead, @var{gnu-build-system} takes care
1407of ensuring that they are present.
1408
1409However, any other dependencies need to be specified in the
1410@code{inputs} field. Any dependency not specified here will simply be
1411unavailable to the build process, possibly leading to a build failure.
1412@end itemize
1413
1414There are other fields that package definitions may provide. Of
1415particular interest is the @code{arguments} field. When specified, it
1416must be bound to a list of additional arguments to be passed to the
1417build system. For instance, the above definition could be augmented
1418with the following field initializer:
1419
1420@example
1421 (arguments `(#:tests? #f
1422 #:configure-flags '("--enable-silent-rules")))
1423@end example
1424
1425@noindent
1426These are keyword arguments (@pxref{Optional Arguments, keyword
1427arguments in Guile,, guile, GNU Guile Reference Manual}). They are
1428passed to @var{gnu-build-system}, which interprets them as meaning ``do
1429not run @code{make check}'', and ``run @file{configure} with the
874e6874
LC
1430@code{--enable-silent-rules} flag''. The value of these keyword
1431parameters is actually evaluated in the @dfn{build stratum}---i.e., by a
1432Guile process launched by the daemon (@pxref{Derivations}).
3dc1970d
LC
1433
1434Once a package definition is in place@footnote{Simple package
1435definitions like the one above may be automatically converted from the
e49951eb
MW
1436Nixpkgs distribution using the @command{guix import} command.}, the
1437package may actually be built using the @code{guix build} command-line
37166310
LC
1438tool (@pxref{Invoking guix build}). Eventually, updating the package
1439definition to a new upstream version can be partly automated by the
1440@command{guix refresh} command (@pxref{Invoking guix refresh}).
3dc1970d
LC
1441
1442Behind the scenes, a derivation corresponding to the @code{<package>}
1443object is first computed by the @code{package-derivation} procedure.
834129e0 1444That derivation is stored in a @code{.drv} file under @file{/gnu/store}.
ba55b1cb 1445The build actions it prescribes may then be realized by using the
3dc1970d
LC
1446@code{build-derivations} procedure (@pxref{The Store}).
1447
1448@deffn {Scheme Procedure} package-derivation @var{store} @var{package} [@var{system}]
59688fc4
LC
1449Return the @code{<derivation>} object of @var{package} for @var{system}
1450(@pxref{Derivations}).
3dc1970d
LC
1451
1452@var{package} must be a valid @code{<package>} object, and @var{system}
1453must be a string denoting the target system type---e.g.,
1454@code{"x86_64-linux"} for an x86_64 Linux-based GNU system. @var{store}
1455must be a connection to the daemon, which operates on the store
1456(@pxref{The Store}).
1457@end deffn
568717fd 1458
9c1edabd
LC
1459@noindent
1460@cindex cross-compilation
1461Similarly, it is possible to compute a derivation that cross-builds a
1462package for some other system:
1463
1464@deffn {Scheme Procedure} package-cross-derivation @var{store} @
1465 @var{package} @var{target} [@var{system}]
59688fc4
LC
1466Return the @code{<derivation>} object of @var{package} cross-built from
1467@var{system} to @var{target}.
9c1edabd
LC
1468
1469@var{target} must be a valid GNU triplet denoting the target hardware
1470and operating system, such as @code{"mips64el-linux-gnu"}
1471(@pxref{Configuration Names, GNU configuration triplets,, configure, GNU
1472Configure and Build System}).
1473@end deffn
1474
1475
568717fd
LC
1476@node The Store
1477@section The Store
1478
e531ac2a
LC
1479@cindex store
1480@cindex store paths
1481
1482Conceptually, the @dfn{store} is where derivations that have been
834129e0 1483successfully built are stored---by default, under @file{/gnu/store}.
e531ac2a
LC
1484Sub-directories in the store are referred to as @dfn{store paths}. The
1485store has an associated database that contains information such has the
1486store paths referred to by each store path, and the list of @emph{valid}
1487store paths---paths that result from a successful build.
1488
1489The store is always accessed by the daemon on behalf of its clients
1490(@pxref{Invoking guix-daemon}). To manipulate the store, clients
1491connect to the daemon over a Unix-domain socket, send it requests, and
1492read the result---these are remote procedure calls, or RPCs.
1493
1494The @code{(guix store)} module provides procedures to connect to the
1495daemon, and to perform RPCs. These are described below.
1496
1497@deffn {Scheme Procedure} open-connection [@var{file}] [#:reserve-space? #t]
1498Connect to the daemon over the Unix-domain socket at @var{file}. When
1499@var{reserve-space?} is true, instruct it to reserve a little bit of
1500extra space on the file system so that the garbage collector can still
1501operate, should the disk become full. Return a server object.
1502
1503@var{file} defaults to @var{%default-socket-path}, which is the normal
1504location given the options that were passed to @command{configure}.
1505@end deffn
1506
1507@deffn {Scheme Procedure} close-connection @var{server}
1508Close the connection to @var{server}.
1509@end deffn
1510
1511@defvr {Scheme Variable} current-build-output-port
1512This variable is bound to a SRFI-39 parameter, which refers to the port
1513where build and error logs sent by the daemon should be written.
1514@end defvr
1515
1516Procedures that make RPCs all take a server object as their first
1517argument.
1518
1519@deffn {Scheme Procedure} valid-path? @var{server} @var{path}
1520Return @code{#t} when @var{path} is a valid store path.
1521@end deffn
1522
cfbf9160 1523@deffn {Scheme Procedure} add-text-to-store @var{server} @var{name} @var{text} [@var{references}]
e531ac2a
LC
1524Add @var{text} under file @var{name} in the store, and return its store
1525path. @var{references} is the list of store paths referred to by the
1526resulting store path.
1527@end deffn
1528
874e6874 1529@deffn {Scheme Procedure} build-derivations @var{server} @var{derivations}
59688fc4
LC
1530Build @var{derivations} (a list of @code{<derivation>} objects or
1531derivation paths), and return when the worker is done building them.
1532Return @code{#t} on success.
874e6874
LC
1533@end deffn
1534
b860f382
LC
1535Note that the @code{(guix monads)} module provides a monad as well as
1536monadic versions of the above procedures, with the goal of making it
1537more convenient to work with code that accesses the store (@pxref{The
1538Store Monad}).
1539
e531ac2a
LC
1540@c FIXME
1541@i{This section is currently incomplete.}
568717fd
LC
1542
1543@node Derivations
1544@section Derivations
1545
874e6874
LC
1546@cindex derivations
1547Low-level build actions and the environment in which they are performed
1548are represented by @dfn{derivations}. A derivation contain the
1549following pieces of information:
1550
1551@itemize
1552@item
1553The outputs of the derivation---derivations produce at least one file or
1554directory in the store, but may produce more.
1555
1556@item
1557The inputs of the derivations, which may be other derivations or plain
1558files in the store (patches, build scripts, etc.)
1559
1560@item
1561The system type targeted by the derivation---e.g., @code{x86_64-linux}.
1562
1563@item
1564The file name of a build script in the store, along with the arguments
1565to be passed.
1566
1567@item
1568A list of environment variables to be defined.
1569
1570@end itemize
1571
1572@cindex derivation path
1573Derivations allow clients of the daemon to communicate build actions to
1574the store. They exist in two forms: as an in-memory representation,
1575both on the client- and daemon-side, and as files in the store whose
1576name end in @code{.drv}---these files are referred to as @dfn{derivation
1577paths}. Derivations paths can be passed to the @code{build-derivations}
1578procedure to perform the build actions they prescribe (@pxref{The
1579Store}).
1580
1581The @code{(guix derivations)} module provides a representation of
1582derivations as Scheme objects, along with procedures to create and
1583otherwise manipulate derivations. The lowest-level primitive to create
1584a derivation is the @code{derivation} procedure:
1585
1909431c
LC
1586@deffn {Scheme Procedure} derivation @var{store} @var{name} @var{builder} @
1587 @var{args} [#:outputs '("out")] [#:hash #f] [#:hash-algo #f] @
2096ef47 1588 [#:recursive? #f] [#:inputs '()] [#:env-vars '()] @
1909431c
LC
1589 [#:system (%current-system)] [#:references-graphs #f] @
1590 [#:local-build? #f]
59688fc4
LC
1591Build a derivation with the given arguments, and return the resulting
1592@code{<derivation>} object.
874e6874 1593
2096ef47 1594When @var{hash} and @var{hash-algo} are given, a
874e6874 1595@dfn{fixed-output derivation} is created---i.e., one whose result is
36bbbbd1
LC
1596known in advance, such as a file download. If, in addition,
1597@var{recursive?} is true, then that fixed output may be an executable
1598file or a directory and @var{hash} must be the hash of an archive
1599containing this output.
5b0c9d16 1600
858e9282 1601When @var{references-graphs} is true, it must be a list of file
5b0c9d16
LC
1602name/store path pairs. In that case, the reference graph of each store
1603path is exported in the build environment in the corresponding file, in
1604a simple text format.
1909431c
LC
1605
1606When @var{local-build?} is true, declare that the derivation is not a
1607good candidate for offloading and should rather be built locally
1608(@pxref{Daemon Offload Setup}). This is the case for small derivations
1609where the costs of data transfers would outweigh the benefits.
874e6874
LC
1610@end deffn
1611
1612@noindent
1613Here's an example with a shell script as its builder, assuming
1614@var{store} is an open connection to the daemon, and @var{bash} points
1615to a Bash executable in the store:
1616
1617@lisp
1618(use-modules (guix utils)
1619 (guix store)
1620 (guix derivations))
1621
59688fc4
LC
1622(let ((builder ; add the Bash script to the store
1623 (add-text-to-store store "my-builder.sh"
1624 "echo hello world > $out\n" '())))
1625 (derivation store "foo"
1626 bash `("-e" ,builder)
1627 #:env-vars '(("HOME" . "/homeless"))))
834129e0 1628@result{} #<derivation /gnu/store/@dots{}-foo.drv => /gnu/store/@dots{}-foo>
874e6874
LC
1629@end lisp
1630
1631As can be guessed, this primitive is cumbersome to use directly. An
1632improved variant is @code{build-expression->derivation}, which allows
1633the caller to directly pass a Guile expression as the build script:
1634
dd1a5a15
LC
1635@deffn {Scheme Procedure} build-expression->derivation @var{store} @
1636 @var{name} @var{exp} @
1637 [#:system (%current-system)] [#:inputs '()] @
1638 [#:outputs '("out")] [#:hash #f] [#:hash-algo #f] @
36bbbbd1 1639 [#:recursive? #f] [#:env-vars '()] [#:modules '()] @
1909431c 1640 [#:references-graphs #f] [#:local-build? #f] [#:guile-for-build #f]
874e6874
LC
1641Return a derivation that executes Scheme expression @var{exp} as a
1642builder for derivation @var{name}. @var{inputs} must be a list of
1643@code{(name drv-path sub-drv)} tuples; when @var{sub-drv} is omitted,
1644@code{"out"} is assumed. @var{modules} is a list of names of Guile
1645modules from the current search path to be copied in the store,
1646compiled, and made available in the load path during the execution of
1647@var{exp}---e.g., @code{((guix build utils) (guix build
1648gnu-build-system))}.
1649
1650@var{exp} is evaluated in an environment where @code{%outputs} is bound
1651to a list of output/path pairs, and where @code{%build-inputs} is bound
1652to a list of string/output-path pairs made from @var{inputs}.
1653Optionally, @var{env-vars} is a list of string pairs specifying the name
1654and value of environment variables visible to the builder. The builder
1655terminates by passing the result of @var{exp} to @code{exit}; thus, when
1656@var{exp} returns @code{#f}, the build is considered to have failed.
1657
1658@var{exp} is built using @var{guile-for-build} (a derivation). When
1659@var{guile-for-build} is omitted or is @code{#f}, the value of the
1660@code{%guile-for-build} fluid is used instead.
9c629a27 1661
1909431c
LC
1662See the @code{derivation} procedure for the meaning of @var{references-graphs}
1663and @var{local-build?}.
874e6874
LC
1664@end deffn
1665
1666@noindent
1667Here's an example of a single-output derivation that creates a directory
1668containing one file:
1669
1670@lisp
1671(let ((builder '(let ((out (assoc-ref %outputs "out")))
834129e0 1672 (mkdir out) ; create /gnu/store/@dots{}-goo
874e6874
LC
1673 (call-with-output-file (string-append out "/test")
1674 (lambda (p)
1675 (display '(hello guix) p))))))
dd1a5a15 1676 (build-expression->derivation store "goo" builder))
874e6874 1677
834129e0 1678@result{} #<derivation /gnu/store/@dots{}-goo.drv => @dots{}>
874e6874
LC
1679@end lisp
1680
1681@cindex strata of code
1682Remember that the build expression passed to
1683@code{build-expression->derivation} is run by a separate Guile process
1684than the one that calls @code{build-expression->derivation}: it is run
1685by a Guile process launched by the daemon, typically in a chroot. So,
1686while there is a single language for both the @dfn{host} and the build
1687side, there are really two @dfn{strata} of code: the host-side, and the
1688build-side code@footnote{The term @dfn{stratum} in this context was
1689coined by Manuel Serrano et al. in the context of their work on Hop.}.
1690This distinction is important to keep in mind, notably when using
1691higher-level constructs such as @var{gnu-build-system} (@pxref{Defining
1692Packages}). For this reason, Guix modules that are meant to be used in
1693the build stratum are kept in the @code{(guix build @dots{})} name
1694space.
568717fd 1695
b860f382
LC
1696@node The Store Monad
1697@section The Store Monad
1698
1699@cindex monad
1700
1701The procedures that operate on the store described in the previous
1702sections all take an open connection to the build daemon as their first
1703argument. Although the underlying model is functional, they either have
1704side effects or depend on the current state of the store.
1705
1706The former is inconvenient: the connection to the build daemon has to be
1707carried around in all those functions, making it impossible to compose
1708functions that do not take that parameter with functions that do. The
1709latter can be problematic: since store operations have side effects
1710and/or depend on external state, they have to be properly sequenced.
1711
1712@cindex monadic values
1713@cindex monadic functions
1714This is where the @code{(guix monads)} module comes in. This module
1715provides a framework for working with @dfn{monads}, and a particularly
1716useful monad for our uses, the @dfn{store monad}. Monads are a
1717construct that allows two things: associating ``context'' with values
1718(in our case, the context is the store), and building sequences of
1719computations (here computations includes accesses to the store.) Values
1720in a monad---values that carry this additional context---are called
1721@dfn{monadic values}; procedures that return such values are called
1722@dfn{monadic procedures}.
1723
1724Consider this ``normal'' procedure:
1725
1726@example
45adbd62
LC
1727(define (sh-symlink store)
1728 ;; Return a derivation that symlinks the 'bash' executable.
1729 (let* ((drv (package-derivation store bash))
1730 (out (derivation->output-path drv))
1731 (sh (string-append out "/bin/bash")))
1732 (build-expression->derivation store "sh"
1733 `(symlink ,sh %output))))
b860f382
LC
1734@end example
1735
1736Using @code{(guix monads)}, it may be rewritten as a monadic function:
1737
1738@example
45adbd62 1739(define (sh-symlink)
b860f382 1740 ;; Same, but return a monadic value.
45adbd62
LC
1741 (mlet %store-monad ((sh (package-file bash "bin")))
1742 (derivation-expression "sh" `(symlink ,sh %output))))
b860f382
LC
1743@end example
1744
1745There are two things to note in the second version: the @code{store}
1746parameter is now implicit, and the monadic value returned by
1747@code{package-file}---a wrapper around @code{package-derivation} and
1748@code{derivation->output-path}---is @dfn{bound} using @code{mlet}
1749instead of plain @code{let}.
1750
1751Calling the monadic @code{profile.sh} has no effect. To get the desired
1752effect, one must use @code{run-with-store}:
1753
1754@example
1755(run-with-store (open-connection) (profile.sh))
834129e0 1756@result{} /gnu/store/...-profile.sh
b860f382
LC
1757@end example
1758
1759The main syntactic forms to deal with monads in general are described
1760below.
1761
1762@deffn {Scheme Syntax} with-monad @var{monad} @var{body} ...
1763Evaluate any @code{>>=} or @code{return} forms in @var{body} as being
1764in @var{monad}.
1765@end deffn
1766
1767@deffn {Scheme Syntax} return @var{val}
1768Return a monadic value that encapsulates @var{val}.
1769@end deffn
1770
1771@deffn {Scheme Syntax} >>= @var{mval} @var{mproc}
1772@dfn{Bind} monadic value @var{mval}, passing its ``contents'' to monadic
1773procedure @var{mproc}@footnote{This operation is commonly referred to as
1774``bind'', but that name denotes an unrelated procedure in Guile. Thus
1775we use this somewhat cryptic symbol inherited from the Haskell
1776language.}.
1777@end deffn
1778
1779@deffn {Scheme Syntax} mlet @var{monad} ((@var{var} @var{mval}) ...) @
1780 @var{body} ...
1781@deffnx {Scheme Syntax} mlet* @var{monad} ((@var{var} @var{mval}) ...) @
1782 @var{body} ...
1783Bind the variables @var{var} to the monadic values @var{mval} in
1784@var{body}. The form (@var{var} -> @var{val}) binds @var{var} to the
1785``normal'' value @var{val}, as per @code{let}.
1786
1787@code{mlet*} is to @code{mlet} what @code{let*} is to @code{let}
1788(@pxref{Local Bindings,,, guile, GNU Guile Reference Manual}).
1789@end deffn
1790
1791The interface to the store monad provided by @code{(guix monads)} is as
1792follows.
1793
1794@defvr {Scheme Variable} %store-monad
1795The store monad. Values in the store monad encapsulate accesses to the
1796store. When its effect is needed, a value of the store monad must be
1797``evaluated'' by passing it to the @code{run-with-store} procedure (see
1798below.)
1799@end defvr
1800
1801@deffn {Scheme Procedure} run-with-store @var{store} @var{mval} [#:guile-for-build] [#:system (%current-system)]
1802Run @var{mval}, a monadic value in the store monad, in @var{store}, an
1803open store connection.
1804@end deffn
1805
1806@deffn {Monadic Procedure} text-file @var{name} @var{text}
1807Return as a monadic value the absolute file name in the store of the file
45adbd62
LC
1808containing @var{text}, a string.
1809@end deffn
1810
1811@deffn {Monadic Procedure} text-file* @var{name} @var{text} @dots{}
1812Return as a monadic value a derivation that builds a text file
1813containing all of @var{text}. @var{text} may list, in addition to
1814strings, packages, derivations, and store file names; the resulting
1815store file holds references to all these.
1816
1817This variant should be preferred over @code{text-file} anytime the file
1818to create will reference items from the store. This is typically the
1819case when building a configuration file that embeds store file names,
1820like this:
1821
1822@example
1823(define (profile.sh)
1824 ;; Return the name of a shell script in the store that
1825 ;; initializes the 'PATH' environment variable.
1826 (text-file* "profile.sh"
1827 "export PATH=" coreutils "/bin:"
1828 grep "/bin:" sed "/bin\n"))
1829@end example
1830
834129e0 1831In this example, the resulting @file{/gnu/store/@dots{}-profile.sh} file
45adbd62
LC
1832will references @var{coreutils}, @var{grep}, and @var{sed}, thereby
1833preventing them from being garbage-collected during its lifetime.
b860f382
LC
1834@end deffn
1835
1836@deffn {Monadic Procedure} package-file @var{package} [@var{file}] @
1837 [#:system (%current-system)] [#:output "out"] Return as a monadic
1838value in the absolute file name of @var{file} within the @var{output}
1839directory of @var{package}. When @var{file} is omitted, return the name
1840of the @var{output} directory of @var{package}.
1841@end deffn
1842
dd1a5a15
LC
1843@deffn {Monadic Procedure} derivation-expression @var{name} @var{exp} @
1844 [#:system (%current-system)] [#:inputs '()] @
1845 [#:outputs '("out")] [#:hash #f] @
b860f382
LC
1846 [#:hash-algo #f] [#:env-vars '()] [#:modules '()] @
1847 [#:references-graphs #f] [#:guile-for-build #f]
1848Monadic version of @code{build-expression->derivation}
1849(@pxref{Derivations}).
1850@end deffn
1851
1852@deffn {Monadic Procedure} package->derivation @var{package} [@var{system}]
1853Monadic version of @code{package-derivation} (@pxref{Defining
1854Packages}).
1855@end deffn
1856
1857
568717fd
LC
1858@c *********************************************************************
1859@node Utilities
1860@chapter Utilities
1861
210cc920
LC
1862This section describes tools primarily targeted at developers and users
1863who write new package definitions. They complement the Scheme
1864programming interface of Guix in a convenient way.
1865
568717fd 1866@menu
37166310 1867* Invoking guix build:: Building packages from the command line.
210cc920 1868* Invoking guix download:: Downloading a file and printing its hash.
37166310
LC
1869* Invoking guix hash:: Computing the cryptographic hash of a file.
1870* Invoking guix refresh:: Updating package definitions.
568717fd
LC
1871@end menu
1872
e49951eb
MW
1873@node Invoking guix build
1874@section Invoking @command{guix build}
568717fd 1875
e49951eb 1876The @command{guix build} command builds packages or derivations and
6798a8e4
LC
1877their dependencies, and prints the resulting store paths. Note that it
1878does not modify the user's profile---this is the job of the
e49951eb 1879@command{guix package} command (@pxref{Invoking guix package}). Thus,
6798a8e4
LC
1880it is mainly useful for distribution developers.
1881
1882The general syntax is:
c78bd12b
LC
1883
1884@example
e49951eb 1885guix build @var{options} @var{package-or-derivation}@dots{}
c78bd12b
LC
1886@end example
1887
1888@var{package-or-derivation} may be either the name of a package found in
5401dd75
LC
1889the software distribution such as @code{coreutils} or
1890@code{coreutils-8.20}, or a derivation such as
834129e0 1891@file{/gnu/store/@dots{}-coreutils-8.19.drv}. In the former case, a
e7f34eb0
LC
1892package with the corresponding name (and optionally version) is searched
1893for among the GNU distribution modules (@pxref{Package Modules}).
1894
1895Alternatively, the @code{--expression} option may be used to specify a
1896Scheme expression that evaluates to a package; this is useful when
1897disambiguation among several same-named packages or package variants is
1898needed.
c78bd12b
LC
1899
1900The @var{options} may be zero or more of the following:
1901
1902@table @code
1903
1904@item --expression=@var{expr}
1905@itemx -e @var{expr}
ac5de156 1906Build the package or derivation @var{expr} evaluates to.
c78bd12b 1907
5401dd75 1908For example, @var{expr} may be @code{(@@ (gnu packages guile)
c78bd12b
LC
1909guile-1.8)}, which unambiguously designates this specific variant of
1910version 1.8 of Guile.
1911
ac5de156
LC
1912Alternately, @var{expr} may refer to a zero-argument monadic procedure
1913(@pxref{The Store Monad}). The procedure must return a derivation as a
1914monadic value, which is then passed through @code{run-with-store}.
1915
c78bd12b
LC
1916@item --source
1917@itemx -S
1918Build the packages' source derivations, rather than the packages
1919themselves.
1920
e49951eb 1921For instance, @code{guix build -S gcc} returns something like
834129e0 1922@file{/gnu/store/@dots{}-gcc-4.7.2.tar.bz2}, which is GCC's source tarball.
c78bd12b 1923
f9cc8971
LC
1924The returned source tarball is the result of applying any patches and
1925code snippets specified in the package's @code{origin} (@pxref{Defining
1926Packages}).
1927
c78bd12b
LC
1928@item --system=@var{system}
1929@itemx -s @var{system}
1930Attempt to build for @var{system}---e.g., @code{i686-linux}---instead of
1931the host's system type.
1932
1933An example use of this is on Linux-based systems, which can emulate
1934different personalities. For instance, passing
1935@code{--system=i686-linux} on an @code{x86_64-linux} system allows users
1936to build packages in a complete 32-bit environment.
1937
e55ec43d
LC
1938@item --target=@var{triplet}
1939@cindex cross-compilation
1940Cross-build for @var{triplet}, which must be a valid GNU triplet, such
1941as @code{"mips64el-linux-gnu"} (@pxref{Configuration Names, GNU
1942configuration triplets,, configure, GNU Configure and Build System}).
1943
7f3673f2
LC
1944@item --with-source=@var{source}
1945Use @var{source} as the source of the corresponding package.
1946@var{source} must be a file name or a URL, as for @command{guix
1947download} (@pxref{Invoking guix download}).
1948
1949The ``corresponding package'' is taken to be one specified on the
1950command line whose name matches the base of @var{source}---e.g., if
1951@var{source} is @code{/src/guile-2.0.10.tar.gz}, the corresponding
1952package is @code{guile}. Likewise, the version string is inferred from
1953@var{source}; in the previous example, it's @code{2.0.10}.
1954
1955This option allows users to try out versions of packages other than the
1956one provided by the distribution. The example below downloads
1957@file{ed-1.7.tar.gz} from a GNU mirror and uses that as the source for
1958the @code{ed} package:
1959
1960@example
1961guix build ed --with-source=mirror://gnu/ed/ed-1.7.tar.gz
1962@end example
1963
1964As a developer, @code{--with-source} makes it easy to test release
1965candidates:
1966
1967@example
1968guix build guile --with-source=../guile-2.0.9.219-e1bb7.tar.xz
1969@end example
1970
1971
c78bd12b
LC
1972@item --derivations
1973@itemx -d
1974Return the derivation paths, not the output paths, of the given
1975packages.
1976
70ee5642
LC
1977@item --root=@var{file}
1978@itemx -r @var{file}
1979Make @var{file} a symlink to the result, and register it as a garbage
1980collector root.
1981
1982@item --log-file
1983Return the build log file names for the given
1984@var{package-or-derivation}s, or raise an error if build logs are
1985missing.
1986
1987This works regardless of how packages or derivations are specified. For
1988instance, the following invocations are equivalent:
1989
1990@example
1991guix build --log-file `guix build -d guile`
1992guix build --log-file `guix build guile`
1993guix build --log-file guile
1994guix build --log-file -e '(@@ (gnu packages guile) guile-2.0)'
1995@end example
1996
1997
1998@end table
1999
2000@cindex common build options
2001In addition, a number of options that control the build process are
2002common to @command{guix build} and other commands that can spawn builds,
2003such as @command{guix package} or @command{guix archive}. These are the
2004following:
2005
2006@table @code
2007
c78bd12b
LC
2008@item --keep-failed
2009@itemx -K
2010Keep the build tree of failed builds. Thus, if a build fail, its build
2011tree is kept under @file{/tmp}, in a directory whose name is shown at
2012the end of the build log. This is useful when debugging build issues.
2013
2014@item --dry-run
2015@itemx -n
2016Do not build the derivations.
2017
56b1f4b7
LC
2018@item --fallback
2019When substituting a pre-built binary fails, fall back to building
2020packages locally.
2021
c78bd12b 2022@item --no-substitutes
b5385b52 2023Do not use substitutes for build products. That is, always build things
c4202d60
LC
2024locally instead of allowing downloads of pre-built binaries
2025(@pxref{Substitutes}).
c78bd12b 2026
425b0bfc 2027@item --no-build-hook
4ec2e92d
LC
2028Do not attempt to offload builds @i{via} the daemon's ``build hook''
2029(@pxref{Daemon Offload Setup}). That is, always build things locally
2030instead of offloading builds to remote machines.
425b0bfc 2031
969e678e
LC
2032@item --max-silent-time=@var{seconds}
2033When the build or substitution process remains silent for more than
2034@var{seconds}, terminate it and report a build failure.
2035
002622b6
LC
2036@item --timeout=@var{seconds}
2037Likewise, when the build or substitution process lasts for more than
2038@var{seconds}, terminate it and report a build failure.
2039
2040By default there is no timeout. This behavior can be restored with
2041@code{--timeout=0}.
2042
07ab4bf1
LC
2043@item --verbosity=@var{level}
2044Use the given verbosity level. @var{level} must be an integer between 0
2045and 5; higher means more verbose output. Setting a level of 4 or more
2046may be helpful when debugging setup issues with the build daemon.
2047
70ee5642
LC
2048@item --cores=@var{n}
2049@itemx -c @var{n}
2050Allow the use of up to @var{n} CPU cores for the build. The special
2051value @code{0} means to use as many CPU cores as available.
bf421152 2052
c78bd12b
LC
2053@end table
2054
e49951eb 2055Behind the scenes, @command{guix build} is essentially an interface to
c78bd12b
LC
2056the @code{package-derivation} procedure of the @code{(guix packages)}
2057module, and to the @code{build-derivations} procedure of the @code{(guix
2058store)} module.
2059
210cc920
LC
2060@node Invoking guix download
2061@section Invoking @command{guix download}
2062
2063When writing a package definition, developers typically need to download
2064the package's source tarball, compute its SHA256 hash, and write that
2065hash in the package definition (@pxref{Defining Packages}). The
2066@command{guix download} tool helps with this task: it downloads a file
2067from the given URI, adds it to the store, and prints both its file name
2068in the store and its SHA256 hash.
2069
2070The fact that the downloaded file is added to the store saves bandwidth:
2071when the developer eventually tries to build the newly defined package
2072with @command{guix build}, the source tarball will not have to be
2073downloaded again because it is already in the store. It is also a
2074convenient way to temporarily stash files, which may be deleted
2075eventually (@pxref{Invoking guix gc}).
2076
2077The @command{guix download} command supports the same URIs as used in
2078package definitions. In particular, it supports @code{mirror://} URIs.
2079@code{https} URIs (HTTP over TLS) are supported @emph{provided} the
2080Guile bindings for GnuTLS are available in the user's environment; when
2081they are not available, an error is raised.
2082
2083The following option is available:
2084
2085@table @code
2086@item --format=@var{fmt}
2087@itemx -f @var{fmt}
2088Write the hash in the format specified by @var{fmt}. For more
2089information on the valid values for @var{fmt}, @ref{Invoking guix hash}.
2090@end table
2091
6c365eca
NK
2092@node Invoking guix hash
2093@section Invoking @command{guix hash}
2094
210cc920 2095The @command{guix hash} command computes the SHA256 hash of a file.
6c365eca
NK
2096It is primarily a convenience tool for anyone contributing to the
2097distribution: it computes the cryptographic hash of a file, which can be
2098used in the definition of a package (@pxref{Defining Packages}).
2099
2100The general syntax is:
2101
2102@example
2103guix hash @var{option} @var{file}
2104@end example
2105
2106@command{guix hash} has the following option:
2107
2108@table @code
2109
2110@item --format=@var{fmt}
2111@itemx -f @var{fmt}
210cc920 2112Write the hash in the format specified by @var{fmt}.
6c365eca
NK
2113
2114Supported formats: @code{nix-base32}, @code{base32}, @code{base16}
2115(@code{hex} and @code{hexadecimal} can be used as well).
2116
2117If the @option{--format} option is not specified, @command{guix hash}
2118will output the hash in @code{nix-base32}. This representation is used
2119in the definitions of packages.
2120
3140f2df
LC
2121@item --recursive
2122@itemx -r
2123Compute the hash on @var{file} recursively.
2124
2125In this case, the hash is computed on an archive containing @var{file},
2126including its children if it is a directory. Some of @var{file}'s
2127meta-data is part of the archive; for instance, when @var{file} is a
2128regular file, the hash is different depending on whether @var{file} is
2129executable or not. Meta-data such as time stamps has no impact on the
2130hash (@pxref{Invoking guix archive}).
2131@c FIXME: Replace xref above with xref to an ``Archive'' section when
2132@c it exists.
2133
6c365eca
NK
2134@end table
2135
37166310
LC
2136@node Invoking guix refresh
2137@section Invoking @command{guix refresh}
2138
2139The primary audience of the @command{guix refresh} command is developers
2140of the GNU software distribution. By default, it reports any packages
2141provided by the distribution that are outdated compared to the latest
2142upstream version, like this:
2143
2144@example
2145$ guix refresh
2146gnu/packages/gettext.scm:29:13: gettext would be upgraded from 0.18.1.1 to 0.18.2.1
2147gnu/packages/glib.scm:77:12: glib would be upgraded from 2.34.3 to 2.37.0
2148@end example
2149
2150It does so by browsing each package's FTP directory and determining the
2151highest version number of the source tarballs
2152therein@footnote{Currently, this only works for GNU packages.}.
2153
2154When passed @code{--update}, it modifies distribution source files to
2155update the version numbers and source tarball hashes of those packages'
2156recipes (@pxref{Defining Packages}). This is achieved by downloading
2157each package's latest source tarball and its associated OpenPGP
2158signature, authenticating the downloaded tarball against its signature
2159using @command{gpg}, and finally computing its hash. When the public
2160key used to sign the tarball is missing from the user's keyring, an
2161attempt is made to automatically retrieve it from a public key server;
2162when it's successful, the key is added to the user's keyring; otherwise,
2163@command{guix refresh} reports an error.
2164
2165The following options are supported:
2166
2167@table @code
2168
2169@item --update
2170@itemx -u
2171Update distribution source files (package recipes) in place.
2172@ref{Defining Packages}, for more information on package definitions.
2173
2174@item --select=[@var{subset}]
2175@itemx -s @var{subset}
2176Select all the packages in @var{subset}, one of @code{core} or
2177@code{non-core}.
2178
2179The @code{core} subset refers to all the packages at the core of the
2180distribution---i.e., packages that are used to build ``everything
2181else''. This includes GCC, libc, Binutils, Bash, etc. Usually,
2182changing one of these packages in the distribution entails a rebuild of
2183all the others. Thus, such updates are an inconvenience to users in
2184terms of build time or bandwidth used to achieve the upgrade.
2185
2186The @code{non-core} subset refers to the remaining packages. It is
2187typically useful in cases where an update of the core packages would be
2188inconvenient.
2189
2190@end table
2191
2192In addition, @command{guix refresh} can be passed one or more package
2193names, as in this example:
2194
2195@example
2196guix refresh -u emacs idutils
2197@end example
2198
2199@noindent
2200The command above specifically updates the @code{emacs} and
2201@code{idutils} packages. The @code{--select} option would have no
2202effect in this case.
2203
f9230085
LC
2204The following options can be used to customize GnuPG operation:
2205
2206@table @code
2207
2208@item --key-server=@var{host}
2209Use @var{host} as the OpenPGP key server when importing a public key.
2210
2211@item --gpg=@var{command}
2212Use @var{command} as the GnuPG 2.x command. @var{command} is searched
2213for in @code{$PATH}.
2214
2215@end table
2216
37166310 2217
a1ba8475
LC
2218@c *********************************************************************
2219@node GNU Distribution
2220@chapter GNU Distribution
2221
2222Guix comes with a distribution of free software@footnote{The term
2223``free'' here refers to the
2224@url{http://www.gnu.org/philosophy/free-sw.html,freedom provided to
c320011d 2225users of that software}.} that forms the basis of the GNU system. This
a1ba8475
LC
2226includes core GNU packages such as GNU libc, GCC, and Binutils, as well
2227as many GNU and non-GNU applications. The complete list of available
d03bb653
LC
2228packages can be browsed
2229@url{http://www.gnu.org/software/guix/package-list.html,on-line} or by
2230running @command{guix package} (@pxref{Invoking guix package}):
a1ba8475
LC
2231
2232@example
e49951eb 2233guix package --list-available
a1ba8475
LC
2234@end example
2235
401c53c4
LC
2236Our goal is to build a practical 100% free software distribution of
2237Linux-based and other variants of GNU, with a focus on the promotion and
2238tight integration of GNU components, and an emphasis on programs and
2239tools that help users exert that freedom.
2240
c320011d
LC
2241The GNU distribution is currently available on the following platforms:
2242
2243@table @code
2244
2245@item x86_64-linux
2246Intel/AMD @code{x86_64} architecture, Linux-Libre kernel;
2247
2248@item i686-linux
2249Intel 32-bit architecture (IA32), Linux-Libre kernel;
2250
2251@item mips64el-linux
2252little-endian 64-bit MIPS processors, specifically the Loongson series,
2253n32 application binary interface (ABI), and Linux-Libre kernel.
2254
2255@end table
2256
2257@noindent
2258For information on porting to other architectures or kernels,
2259@xref{Porting}.
2260
401c53c4 2261@menu
91ef73d4 2262* Installing Debugging Files:: Feeding the debugger.
401c53c4 2263* Package Modules:: Packages from the programmer's viewpoint.
da7cabd4 2264* Packaging Guidelines:: Growing the distribution.
401c53c4 2265* Bootstrapping:: GNU/Linux built from scratch.
8b315a6d 2266* Porting:: Targeting another platform or kernel.
4af2447e 2267* System Configuration:: Configuring a GNU system.
401c53c4
LC
2268@end menu
2269
2270Building this distribution is a cooperative effort, and you are invited
2271to join! @ref{Contributing}, for information about how you can help.
2272
b208a005 2273
91ef73d4
LC
2274@node Installing Debugging Files
2275@section Installing Debugging Files
2276
2277Program binaries, as produced by the GCC compilers for instance, are
2278typically written in the ELF format, with a section containing
2279@dfn{debugging information}. Debugging information is what allows the
2280debugger, GDB, to map binary code to source code; it is required to
2281debug a compiled program in good conditions.
2282
2283The problem with debugging information is that is takes up a fair amount
2284of disk space. For example, debugging information for the GNU C Library
2285weighs in at more than 60 MiB. Thus, as a user, keeping all the
2286debugging info of all the installed programs is usually not an option.
2287Yet, space savings should not come at the cost of an impediment to
2288debugging---especially in the GNU system, which should make it easier
2289for users to exert their computing freedom (@pxref{GNU Distribution}).
2290
2291Thankfully, the GNU Binary Utilities (Binutils) and GDB provide a
2292mechanism that allows users to get the best of both worlds: debugging
2293information can be stripped from the binaries and stored in separate
2294files. GDB is then able to load debugging information from those files,
2295when they are available (@pxref{Separate Debug Files,,, gdb, Debugging
2296with GDB}).
2297
2298The GNU distribution takes advantage of this by storing debugging
2299information in the @code{lib/debug} sub-directory of a separate package
2300output unimaginatively called @code{debug} (@pxref{Packages with
2301Multiple Outputs}). Users can choose to install the @code{debug} output
2302of a package when they need it. For instance, the following command
2303installs the debugging information for the GNU C Library and for GNU
2304Guile:
2305
2306@example
2307guix package -i glibc:debug -i guile:debug
2308@end example
2309
2310GDB must then be told to look for debug files in the user's profile, by
2311setting the @code{debug-file-directory} variable (consider setting it
2312from the @file{~/.gdbinit} file, @pxref{Startup,,, gdb, Debugging with
2313GDB}):
2314
2315@example
2316(gdb) set debug-file-directory ~/.guix-profile/lib/debug
2317@end example
2318
2319From there on, GDB will pick up debugging information from the
2320@code{.debug} files under @file{~/.guix-profile/lib/debug}.
2321
2322@c XXX: keep me up-to-date
2323The @code{debug} output mechanism in Guix is implemented by the
2324@code{gnu-build-system} (@pxref{Defining Packages}). Currently, it is
2325opt-in---debugging information is available only for those packages
2326whose definition explicitly declares a @code{debug} output. This may be
2327changed to opt-out in the future, if our build farm servers can handle
2328the load. To check whether a package has a @code{debug} output, use
2329@command{guix package --list-available} (@pxref{Invoking guix package}).
2330
2331
401c53c4
LC
2332@node Package Modules
2333@section Package Modules
2334
2335From a programming viewpoint, the package definitions of the
e7f34eb0 2336GNU distribution are provided by Guile modules in the @code{(gnu packages
7e17f65d
LC
2337@dots{})} name space@footnote{Note that packages under the @code{(gnu
2338packages @dots{})} module name space are not necessarily ``GNU
2339packages''. This module naming scheme follows the usual Guile module
2340naming convention: @code{gnu} means that these modules are distributed
2341as part of the GNU system, and @code{packages} identifies modules that
2342define packages.} (@pxref{Modules, Guile modules,, guile, GNU Guile
b81e1947
LC
2343Reference Manual}). For instance, the @code{(gnu packages emacs)}
2344module exports a variable named @code{emacs}, which is bound to a
e7f34eb0
LC
2345@code{<package>} object (@pxref{Defining Packages}).
2346
2347The @code{(gnu packages @dots{})} module name space is special: it is
2348automatically scanned for packages by the command-line tools. For
2349instance, when running @code{guix package -i emacs}, all the @code{(gnu
2350packages @dots{})} modules are scanned until one that exports a package
2351object whose name is @code{emacs} is found. This package search
2352facility is implemented in the @code{(gnu packages)} module.
2353
2354Users can store package definitions in modules with different
2355names---e.g., @code{(my-packages emacs)}. In that case, commands such
2356as @command{guix package} and @command{guix build} have to be used with
2357the @code{-e} option so that they know where to find the package.
a1ba8475
LC
2358
2359The distribution is fully @dfn{bootstrapped} and @dfn{self-contained}:
2360each package is built based solely on other packages in the
2361distribution. The root of this dependency graph is a small set of
2362@dfn{bootstrap binaries}, provided by the @code{(gnu packages
b81e1947
LC
2363bootstrap)} module. For more information on bootstrapping,
2364@ref{Bootstrapping}.
2365
da7cabd4
AE
2366@node Packaging Guidelines
2367@section Packaging Guidelines
b81e1947
LC
2368
2369The GNU distribution is nascent and may well lack some of your favorite
2370packages. This section describes how you can help make the distribution
c8c871d1 2371grow. @xref{Contributing}, for additional information on how you can
b81e1947
LC
2372help.
2373
b81e1947
LC
2374Free software packages are usually distributed in the form of
2375@dfn{source code tarballs}---typically @file{tar.gz} files that contain
2376all the source files. Adding a package to the distribution means
2377essentially two things: adding a @dfn{recipe} that describes how to
2378build the package, including a list of other packages required to build
2379it, and adding @dfn{package meta-data} along with that recipe, such as a
2380description and licensing information.
2381
2382In Guix all this information is embodied in @dfn{package definitions}.
2383Package definitions provide a high-level view of the package. They are
2384written using the syntax of the Scheme programming language; in fact,
2385for each package we define a variable bound to the package definition,
2386and export that variable from a module (@pxref{Package Modules}).
2387However, in-depth Scheme knowledge is @emph{not} a prerequisite for
2388creating packages. For more information on package definitions,
2389@ref{Defining Packages}.
2390
2391Once a package definition is in place, stored in a file in the Guix
2392source tree, it can be tested using the @command{guix build} command
2393(@pxref{Invoking guix build}). For example, assuming the new package is
2394called @code{gnew}, you may run this command from the Guix build tree:
2395
2396@example
2397./pre-inst-env guix build gnew --keep-failed
2398@end example
2399
2400Using @code{--keep-failed} makes it easier to debug build failures since
2401it provides access to the failed build tree.
2402
5ff3c4b8
PAR
2403If the package is unknown to the @command{guix} command, it may be that
2404the source file contains a syntax error, or lacks a @code{define-public}
2405clause to export the package variable. To figure it out, you may load
2406the module from Guile to get more information about the actual error:
2407
2408@example
2409./pre-inst-env guile -c '(use-modules (gnu packages gnew))'
2410@end example
2411
b81e1947
LC
2412Once your package builds correctly, please send us a patch
2413(@pxref{Contributing}). Well, if you need help, we will be happy to
2414help you too. Once the patch is committed in the Guix repository, the
2415new package automatically gets built on the supported platforms by
2416@url{http://hydra.gnu.org/gnu/master, our continuous integration
2417system}.
2418
2419@cindex substituter
2420Users can obtain the new package definition simply by running
2421@command{guix pull} (@pxref{Invoking guix pull}). When
2422@code{hydra.gnu.org} is done building the package, installing the
c4202d60
LC
2423package automatically downloads binaries from there
2424(@pxref{Substitutes}). The only place where human intervention is
b81e1947 2425needed is to review and apply the patch.
401c53c4
LC
2426
2427
da7cabd4 2428@menu
ee85f3db
AE
2429* Software Freedom:: What may go into the distribution.
2430* Package Naming:: What's in a name?
2431* Version Numbers:: When the name is not enough.
2432* Python Modules:: Taming the snake.
da7cabd4
AE
2433@end menu
2434
2435@node Software Freedom
2436@subsection Software Freedom
2437
2438@c Adapted from http://www.gnu.org/philosophy/philosophy.html.
2439
2440The GNU operating system has been developed so that users can have
2441freedom in their computing. GNU is @dfn{free software}, meaning that
2442users have the @url{http://www.gnu.org/philosophy/free-sw.html,four
2443essential freedoms}: to run the program, to study and change the program
2444in source code form, to redistribute exact copies, and to distribute
2445modified versions. Packages found in the GNU distribution provide only
2446software that conveys these four freedoms.
2447
2448In addition, the GNU distribution follow the
2449@url{http://www.gnu.org/distros/free-system-distribution-guidelines.html,free
2450software distribution guidelines}. Among other things, these guidelines
2451reject non-free firmware, recommendations of non-free software, and
2452discuss ways to deal with trademarks and patents.
2453
f9cc8971
LC
2454Some packages contain a small and optional subset that violates the
2455above guidelines, for instance because this subset is itself non-free
2456code. When that happens, the offending items are removed with
2457appropriate patches or code snippets in the package definition's
2458@code{origin} form (@pxref{Defining Packages}). That way, @code{guix
2459build --source} returns the ``freed'' source rather than the unmodified
2460upstream source.
2461
da7cabd4 2462
ee85f3db
AE
2463@node Package Naming
2464@subsection Package Naming
2465
c8c871d1 2466A package has actually two names associated with it:
ee85f3db 2467First, there is the name of the @emph{Scheme variable}, the one following
c8c871d1
AE
2468@code{define-public}. By this name, the package can be made known in the
2469Scheme code, for instance as input to another package. Second, there is
2470the string in the @code{name} field of a package definition. This name
2471is used by package management commands such as
2472@command{guix package} and @command{guix build}.
ee85f3db
AE
2473
2474Both are usually the same and correspond to the lowercase conversion of the
c8c871d1
AE
2475project name chosen upstream. For instance, the GNUnet project is packaged
2476as @code{gnunet}. We do not add @code{lib} prefixes for library packages,
2477unless these are already part of the official project name. But see
2478@ref{Python Modules} for special rules concerning modules for
ee85f3db
AE
2479the Python language.
2480
2481
2482@node Version Numbers
2483@subsection Version Numbers
2484
2485We usually package only the latest version of a given free software
c8c871d1
AE
2486project. But sometimes, for instance for incompatible library versions,
2487two (or more) versions of the same package are needed. These require
2488different Scheme variable names. We use the name as defined
2489in @ref{Package Naming}
ee85f3db
AE
2490for the most recent version; previous versions use the same name, suffixed
2491by @code{-} and the smallest prefix of the version number that may
2492distinguish the two versions.
2493
2494The name inside the package definition is the same for all versions of a
2495package and does not contain any version number.
2496
2497For instance, the versions 2.24.20 and 3.9.12 of GTK+ may be packaged as follows:
c8c871d1 2498
ee85f3db
AE
2499@example
2500(define-public gtk+
2501 (package
2502 (name "gtk+")
2503 (version "3.9.12")
2504 ...))
2505(define-public gtk+-2
2506 (package
2507 (name "gtk+")
2508 (version "2.24.20")
2509 ...))
2510@end example
2511If we also wanted GTK+ 3.8.2, this would be packaged as
2512@example
2513(define-public gtk+-3.8
2514 (package
2515 (name "gtk+")
2516 (version "3.8.2")
2517 ...))
2518@end example
2519
2520
2521@node Python Modules
2522@subsection Python Modules
2523
2524We currently package Python 2 and Python 3, under the Scheme variable names
2525@code{python-2} and @code{python} as explained in @ref{Version Numbers}.
2526To avoid confusion and naming clashes with other programming languages, it
2527seems desirable that the name of a package for a Python module contains
2528the word @code{python}.
c8c871d1 2529
ee85f3db
AE
2530Some modules are compatible with only one version of Python, others with both.
2531If the package Foo compiles only with Python 3, we name it
2532@code{python-foo}; if it compiles only with Python 2, we name it
2533@code{python2-foo}. If it is compatible with both versions, we create two
2534packages with the corresponding names.
2535
2536If a project already contains the word @code{python}, we drop this;
2537for instance, the module python-dateutil is packaged under the names
2538@code{python-dateutil} and @code{python2-dateutil}.
2539
2540
2541
2542
2543
401c53c4
LC
2544@node Bootstrapping
2545@section Bootstrapping
2546
2547@c Adapted from the ELS 2013 paper.
2548
2549@cindex bootstrapping
2550
2551Bootstrapping in our context refers to how the distribution gets built
2552``from nothing''. Remember that the build environment of a derivation
2553contains nothing but its declared inputs (@pxref{Introduction}). So
2554there's an obvious chicken-and-egg problem: how does the first package
2555get built? How does the first compiler get compiled? Note that this is
2556a question of interest only to the curious hacker, not to the regular
2557user, so you can shamelessly skip this section if you consider yourself
2558a ``regular user''.
2559
2560@cindex bootstrap binaries
2561The GNU system is primarily made of C code, with libc at its core. The
2562GNU build system itself assumes the availability of a Bourne shell and
2563command-line tools provided by GNU Coreutils, Awk, Findutils, `sed', and
2564`grep'. Furthermore, build programs---programs that run
2565@code{./configure}, @code{make}, etc.---are written in Guile Scheme
2566(@pxref{Derivations}). Consequently, to be able to build anything at
2567all, from scratch, Guix relies on pre-built binaries of Guile, GCC,
2568Binutils, libc, and the other packages mentioned above---the
2569@dfn{bootstrap binaries}.
2570
2571These bootstrap binaries are ``taken for granted'', though we can also
ba7ea5ce 2572re-create them if needed (more on that later).
401c53c4
LC
2573
2574@unnumberedsubsec Preparing to Use the Bootstrap Binaries
2575
2576@c As of Emacs 24.3, Info-mode displays the image, but since it's a
2577@c large image, it's hard to scroll. Oh well.
29f66ddd 2578@image{images/bootstrap-graph,6in,,Dependency graph of the early bootstrap derivations}
401c53c4
LC
2579
2580The figure above shows the very beginning of the dependency graph of the
2581distribution, corresponding to the package definitions of the @code{(gnu
2582packages bootstrap)} module. At this level of detail, things are
2583slightly complex. First, Guile itself consists of an ELF executable,
2584along with many source and compiled Scheme files that are dynamically
2585loaded when it runs. This gets stored in the @file{guile-2.0.7.tar.xz}
2586tarball shown in this graph. This tarball is part of Guix's ``source''
2587distribution, and gets inserted into the store with @code{add-to-store}
2588(@pxref{The Store}).
a1ba8475 2589
401c53c4
LC
2590But how do we write a derivation that unpacks this tarball and adds it
2591to the store? To solve this problem, the @code{guile-bootstrap-2.0.drv}
2592derivation---the first one that gets built---uses @code{bash} as its
2593builder, which runs @code{build-bootstrap-guile.sh}, which in turn calls
2594@code{tar} to unpack the tarball. Thus, @file{bash}, @file{tar},
2595@file{xz}, and @file{mkdir} are statically-linked binaries, also part of
2596the Guix source distribution, whose sole purpose is to allow the Guile
2597tarball to be unpacked.
2598
2599Once @code{guile-bootstrap-2.0.drv} is built, we have a functioning
2600Guile that can be used to run subsequent build programs. Its first task
2601is to download tarballs containing the other pre-built binaries---this
2602is what the @code{.tar.xz.drv} derivations do. Guix modules such as
2603@code{ftp-client.scm} are used for this purpose. The
2604@code{module-import.drv} derivations import those modules in a directory
2605in the store, using the original layout. The
2606@code{module-import-compiled.drv} derivations compile those modules, and
2607write them in an output directory with the right layout. This
2608corresponds to the @code{#:modules} argument of
2609@code{build-expression->derivation} (@pxref{Derivations}).
2610
2611Finally, the various tarballs are unpacked by the
2612derivations @code{gcc-bootstrap-0.drv}, @code{glibc-bootstrap-0.drv},
2613etc., at which point we have a working C tool chain.
2614
2615
2616@unnumberedsubsec Building the Build Tools
2617
2618@c TODO: Add a package-level dependency graph generated from (gnu
2619@c packages base).
2620
2621Bootstrapping is complete when we have a full tool chain that does not
2622depend on the pre-built bootstrap tools discussed above. This
2623no-dependency requirement is verified by checking whether the files of
834129e0 2624the final tool chain contain references to the @file{/gnu/store}
401c53c4
LC
2625directories of the bootstrap inputs. The process that leads to this
2626``final'' tool chain is described by the package definitions found in
2627the @code{(gnu packages base)} module.
2628
2629@c See <http://lists.gnu.org/archive/html/gnu-system-discuss/2012-10/msg00000.html>.
2630The first tool that gets built with the bootstrap binaries is
2631GNU Make, which is a prerequisite for all the following packages.
2632From there Findutils and Diffutils get built.
2633
2634Then come the first-stage Binutils and GCC, built as pseudo cross
2635tools---i.e., with @code{--target} equal to @code{--host}. They are
2636used to build libc. Thanks to this cross-build trick, this libc is
2637guaranteed not to hold any reference to the initial tool chain.
2638
2639From there the final Binutils and GCC are built. GCC uses @code{ld}
2640from the final Binutils, and links programs against the just-built libc.
2641This tool chain is used to build the other packages used by Guix and by
2642the GNU Build System: Guile, Bash, Coreutils, etc.
2643
2644And voilà! At this point we have the complete set of build tools that
2645the GNU Build System expects. These are in the @code{%final-inputs}
2646variables of the @code{(gnu packages base)} module, and are implicitly
2647used by any package that uses @code{gnu-build-system} (@pxref{Defining
2648Packages}).
2649
2650
2651@unnumberedsubsec Building the Bootstrap Binaries
2652
2653Because the final tool chain does not depend on the bootstrap binaries,
2654those rarely need to be updated. Nevertheless, it is useful to have an
2655automated way to produce them, should an update occur, and this is what
2656the @code{(gnu packages make-bootstrap)} module provides.
2657
2658The following command builds the tarballs containing the bootstrap
2659binaries (Guile, Binutils, GCC, libc, and a tarball containing a mixture
2660of Coreutils and other basic command-line tools):
a1ba8475 2661
401c53c4
LC
2662@example
2663guix build bootstrap-tarballs
2664@end example
2665
2666The generated tarballs are those that should be referred to in the
2667@code{(gnu packages bootstrap)} module mentioned at the beginning of
2668this section.
2669
2670Still here? Then perhaps by now you've started to wonder: when do we
2671reach a fixed point? That is an interesting question! The answer is
2672unknown, but if you would like to investigate further (and have
2673significant computational and storage resources to do so), then let us
2674know.
a1ba8475 2675
8b315a6d
LC
2676@node Porting
2677@section Porting to a New Platform
2678
2679As discussed above, the GNU distribution is self-contained, and
2680self-containment is achieved by relying on pre-built ``bootstrap
2681binaries'' (@pxref{Bootstrapping}). These binaries are specific to an
2682operating system kernel, CPU architecture, and application binary
2683interface (ABI). Thus, to port the distribution to a platform that is
2684not yet supported, one must build those bootstrap binaries, and update
2685the @code{(gnu packages bootstrap)} module to use them on that platform.
2686
2687Fortunately, Guix can @emph{cross compile} those bootstrap binaries.
2688When everything goes well, and assuming the GNU tool chain supports the
2689target platform, this can be as simple as running a command like this
2690one:
2691
2692@example
2693guix build --target=armv5tel-linux-gnueabi bootstrap-tarballs
2694@end example
2695
72e25e35
LC
2696Once these are built, the @code{(gnu packages bootstrap)} module needs
2697to be updated to refer to these binaries on the target platform. In
2698addition, the @code{glibc-dynamic-linker} procedure in that module must
2699be augmented to return the right file name for libc's dynamic linker on
2700that platform; likewise, @code{system->linux-architecture} in @code{(gnu
2701packages linux)} must be taught about the new platform.
2702
8b315a6d
LC
2703In practice, there may be some complications. First, it may be that the
2704extended GNU triplet that specifies an ABI (like the @code{eabi} suffix
2705above) is not recognized by all the GNU tools. Typically, glibc
2706recognizes some of these, whereas GCC uses an extra @code{--with-abi}
ba7ea5ce 2707configure flag (see @code{gcc.scm} for examples of how to handle this).
8b315a6d
LC
2708Second, some of the required packages could fail to build for that
2709platform. Lastly, the generated binaries could be broken for some
2710reason.
2711
9bf3c1a7 2712
4af2447e
LC
2713@node System Configuration
2714@section System Configuration
2715
2716@emph{This section documents work-in-progress. As such it may be
2717incomplete, outdated, or open to discussions. Please discuss it on
2718@email{guix-devel@@gnu.org}.}
2719
2720@cindex system configuration
2721The GNU system supports a consistent whole-system configuration
2722mechanism. By that we mean that all aspects of the global system
2723configuration---such as the available system services, timezone and
68ad877c 2724locale settings, user accounts---are declared in a single place. Such
4af2447e
LC
2725a @dfn{system configuration} can be @dfn{instantiated}---i.e., effected.
2726
68ad877c
LC
2727One of the advantages of putting all the system configuration under the
2728control of Guix is that it supports transactional system upgrades, and
2729makes it possible to roll-back to a previous system instantiation,
2730should something go wrong with the new one (@pxref{Features}). Another
2731one is that it makes it easy to replicate the exact same configuration
2732across different machines, or at different points in time, without
2733having to resort to additional administration tools layered on top of
2734the system's own tools.
2735@c Yes, we're talking of Puppet, Chef, & co. here. ↑
2736
4af2447e
LC
2737This section describes this mechanism. First we focus on the system
2738administrator's viewpoint---explaining how the system is configured and
2739instantiated. Then we show how this mechanism can be extended, for
2740instance to support new system services.
2741
2742@menu
523e4896
LC
2743* Using the Configuration System:: Customizing your GNU system.
2744* Invoking guix system:: Instantiating a system configuration.
2745* Defining Services:: Adding new service definitions.
4af2447e
LC
2746@end menu
2747
2748@node Using the Configuration System
2749@subsection Using the Configuration System
2750
2751The operating system is configured by filling in an
2752@code{operating-system} structure, as defined by the @code{(gnu system)}
2753module. A simple setup, with the default system services, the default
2754Linux-Libre kernel, initial RAM disk, and boot loader looks like this:
2755
2756@findex operating-system
2757@lisp
8b198abe 2758(use-modules (gnu services base) ; for '%base-services'
db4fdc04 2759 (gnu services ssh) ; for 'lsh-service'
4af2447e 2760 (gnu system shadow) ; for 'user-account'
4af2447e
LC
2761 (gnu packages base) ; Coreutils, grep, etc.
2762 (gnu packages bash) ; Bash
4eaad71d 2763 (gnu packages admin) ; dmd, Inetutils
4af2447e
LC
2764 (gnu packages zile) ; Zile
2765 (gnu packages less) ; less
2766 (gnu packages guile) ; Guile
2767 (gnu packages linux)) ; procps, psmisc
2768
68ad877c 2769(define komputilo
4af2447e
LC
2770 (operating-system
2771 (host-name "komputilo")
2772 (timezone "Europe/Paris")
2773 (locale "fr_FR.UTF-8")
2774 (users (list (user-account
2775 (name "alice")
2776 (password "")
2777 (uid 1000) (gid 100)
2778 (comment "Bob's sister")
2779 (home-directory "/home/alice"))))
2780 (packages (list coreutils bash guile-2.0
2781 guix dmd
2782 inetutils
2783 findutils grep sed
2784 procps psmisc
2785 zile less))
2786 (services (cons (lsh-service #:port 2222 #:allow-root-login? #t)
8b198abe 2787 %base-services))))
4af2447e
LC
2788@end lisp
2789
2790This example should be self-describing. The @code{packages} field lists
68ad877c
LC
2791packages provided by the various @code{(gnu packages ...)} modules above
2792(@pxref{Package Modules}). These are the packages that will be globally
2793visible on the system, for all user accounts---i.e., in every user's
2794@code{PATH} environment variable---in addition to the per-user profiles
2795(@pxref{Invoking guix package}).
4af2447e 2796
8b198abe 2797@vindex %base-services
4af2447e 2798The @code{services} field lists @dfn{system services} to be made
8b198abe 2799available when the system starts. The @var{%base-services} list,
db4fdc04 2800from the @code{(gnu services base)} module, provides the basic services one
4af2447e
LC
2801would expect from a GNU system: a login service (mingetty) on each tty,
2802syslogd, libc's name service cache daemon (nscd), etc.
2803
2804The @code{operating-system} declaration above specifies that, in
2805addition to those services, we want the @command{lshd} secure shell
2806daemon listening on port 2222, and allowing remote @code{root} logins
2807(@pxref{Invoking lshd,,, lsh, GNU lsh Manual}). Under the hood,
2808@code{lsh-service} arranges so that @code{lshd} is started with the
2809right command-line options, possibly with supporting configuration files
2810generated as needed (@pxref{Defining Services}).
2811
4af2447e 2812Assuming the above snippet is stored in the @file{my-system-config.scm}
523e4896
LC
2813file, the @command{guix system boot my-system-config.scm} command
2814instantiates that configuration, and makes it the default GRUB boot
2815entry (@pxref{Invoking guix system}). The normal way to change the
2816system's configuration is by updating this file and re-running the
2817@command{guix system} command.
4af2447e
LC
2818
2819At the Scheme level, the bulk of an @code{operating-system} declaration
2820is instantiated with the following monadic procedure (@pxref{The Store
2821Monad}):
2822
2823@deffn {Monadic Procedure} operating-system-derivation os
2824Return a derivation that builds @var{os}, an @code{operating-system}
2825object (@pxref{Derivations}).
2826
2827The output of the derivation is a single directory that refers to all
2828the packages, configuration files, and other supporting files needed to
2829instantiate @var{os}.
2830@end deffn
2831
523e4896
LC
2832@node Invoking guix system
2833@subsection Invoking @code{guix system}
2834
2835Once you have written an operating system declaration, as seen in the
2836previous section, it can be @dfn{instantiated} using the @command{guix
2837system} command. The synopsis is:
2838
2839@example
2840guix system @var{options}@dots{} @var{action} @var{file}
2841@end example
2842
2843@var{file} must be the name of a file containing an
2844@code{operating-system} declaration. @var{action} specifies how the
2845operating system is instantiate. Currently only one value is supported:
2846
2847@table @code
2848@item vm
2849@cindex virtual machine
2850Build a virtual machine that contain the operating system declared in
2851@var{file}, and return a script to run that virtual machine (VM).
2852
2853The VM shares its store with the host system.
2854@end table
2855
2856@var{options} can contain any of the common build options provided by
2857@command{guix build} (@pxref{Invoking guix build}).
2858
4af2447e
LC
2859
2860@node Defining Services
2861@subsection Defining Services
2862
db4fdc04 2863The @code{(gnu services @dots{})} modules define several procedures that allow
4af2447e
LC
2864users to declare the operating system's services (@pxref{Using the
2865Configuration System}). These procedures are @emph{monadic
2866procedures}---i.e., procedures that return a monadic value in the store
2867monad (@pxref{The Store Monad}). Examples of such procedures include:
2868
2869@table @code
2870@item mingetty-service
2871return the definition of a service that runs @command{mingetty} to
2872offer a login service on the given console tty;
2873
2874@item nscd-service
2875return a definition for libc's name service cache daemon (nscd);
2876
2877@item guix-service
2878return a definition for a service that runs @command{guix-daemon}
2879(@pxref{Invoking guix-daemon}).
2880@end table
2881
2882@cindex service definition
2883The monadic value returned by those procedures is a @dfn{service
2884definition}---a structure as returned by the @code{service} form.
2885Service definitions specifies the inputs the service depends on, and an
2886expression to start and stop the service. Behind the scenes, service
2887definitions are ``translated'' into the form suitable for the
2888configuration file of dmd, the init system (@pxref{Services,,, dmd, GNU
2889dmd Manual}).
2890
2891As an example, here is what the @code{nscd-service} procedure looks
2892like:
2893
2894@lisp
2895(define (nscd-service)
2896 (mlet %store-monad ((nscd (package-file glibc "sbin/nscd")))
2897 (return (service
2898 (documentation "Run libc's name service cache daemon.")
2899 (provision '(nscd))
2900 (start `(make-forkexec-constructor ,nscd "-f" "/dev/null"
2901 "--foreground"))
2902 (stop `(make-kill-destructor))
2903
2904 (respawn? #f)
2905 (inputs `(("glibc" ,glibc)))))))
2906@end lisp
2907
2908@noindent
2909The @code{inputs} field specifies that this service depends on the
2910@var{glibc} package---the package that contains the @command{nscd}
2911program. The @code{start} and @code{stop} fields are expressions that
2912make use of dmd's facilities to start and stop processes (@pxref{Service
2913De- and Constructors,,, dmd, GNU dmd Manual}). The @code{provision}
2914field specifies the name under which this service is known to dmd, and
2915@code{documentation} specifies on-line documentation. Thus, the
2916commands @command{deco start ncsd}, @command{deco stop nscd}, and
2917@command{deco doc nscd} will do what you would expect (@pxref{Invoking
2918deco,,, dmd, GNU dmd Manual}).
2919
2920
9bf3c1a7
LC
2921@c *********************************************************************
2922@node Contributing
2923@chapter Contributing
2924
2925This project is a cooperative effort, and we need your help to make it
5ff3c4b8
PAR
2926grow! Please get in touch with us on @email{guix-devel@@gnu.org} and
2927@code{#guix} on the Freenode IRC network. We welcome ideas, bug
2928reports, patches, and anything that may be helpful to the project. We
2929particularly welcome help on packaging (@pxref{Packaging Guidelines}).
a1ba8475 2930
9bf3c1a7
LC
2931Please see the
2932@url{http://git.savannah.gnu.org/cgit/guix.git/tree/HACKING,
2933@file{HACKING} file} that comes with the Guix source code for practical
2934details about contributions.
2935
c78bd12b 2936
568717fd
LC
2937@c *********************************************************************
2938@node Acknowledgments
2939@chapter Acknowledgments
2940
2941Guix is based on the Nix package manager, which was designed and
2942implemented by Eelco Dolstra. Nix pioneered functional package
2943management, and promoted unprecedented features, such as transactional
2944package upgrades and rollbacks, per-user profiles, and referentially
2945transparent build processes. Without this work, Guix would not exist.
2946
2947The Nix-based software distributions, Nixpkgs and NixOS, have also been
2948an inspiration for Guix.
2949
2950@c *********************************************************************
2951@node GNU Free Documentation License
2952@appendix GNU Free Documentation License
2953
2954@include fdl-1.3.texi
2955
2956@c *********************************************************************
2957@node Concept Index
2958@unnumbered Concept Index
2959@printindex cp
2960
2961@node Function Index
2962@unnumbered Function Index
2963@printindex fn
2964
2965@bye
2966
2967@c Local Variables:
2968@c ispell-local-dictionary: "american";
2969@c End: