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