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