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 | |
399 | use. That profile is normally stored in @code{$HOME/.guix-profile}, and | |
400 | each user has its own profile. | |
401 | ||
402 | For example, if @code{alice} installed GCC 4.7.2, then | |
403 | @file{/home/alice/.guix-profile/bin/gcc} points to | |
404 | @file{/nix/store/xxx-gcc-4.7.2/bin/gcc}; on the same machine, @code{bob} | |
405 | may have installed GCC 4.8.0, in which case its profile refers to these | |
406 | particular package installation. Both coexist, without any | |
407 | interference. | |
408 | ||
409 | The @command{guix-package} command is the central tool to manage | |
410 | packages. It operates on those per-user profiles, and can be used | |
411 | @emph{with normal user privileges}. | |
412 | ||
413 | The command provides the obvious install, remove, and upgrade | |
414 | operations. Each invocation is actually a @emph{transaction}: either | |
ba55b1cb | 415 | the specified operation succeeds, or nothing happens. Thus, if the |
eeaf4427 LC |
416 | @command{guix-package} processed is terminated during the transaction, |
417 | or if a power outage occurs during the transaction, then the user's | |
418 | profile remains in its previous state, and remains usable. | |
419 | ||
420 | In addition, any package transaction may be @emph{rolled back}. So, if, | |
421 | for example, an upgrade installs a new version of a package that turns | |
422 | out to have a serious bug, users may roll back to the previous instance | |
423 | of their profile, which was known to work well. | |
424 | ||
425 | All those packages in the package store may be @emph{garbage-collected}. | |
426 | Guix can determine which packages are still referenced by the user | |
fe8ff028 LC |
427 | profiles, and remove those that are provably no longer referenced |
428 | (@pxref{Invoking guix-gc}). Users may also explicitly remove old | |
429 | generations of their profile so that the packages they refer to can be | |
430 | collected. | |
eeaf4427 LC |
431 | |
432 | Finally, Guix takes a @dfn{purely functional} approach to package | |
433 | management, as described in the introduction (@pxref{Introduction}). | |
434 | Each @file{/nix/store} package directory name contains a hash of all the | |
435 | inputs that were used to build that package---compiler, libraries, build | |
436 | scripts, etc. This direct correspondence allows users to make sure a | |
437 | given package installation matches the current state of their | |
a1ba8475 | 438 | distribution, and helps maximize @dfn{reproducibility}. |
eeaf4427 | 439 | |
75f1e8f7 | 440 | @c FIXME: Remove footnote when it's implemented. |
eeaf4427 | 441 | This foundation allows Guix to support @dfn{transparent binary/source |
75f1e8f7 LC |
442 | deployment}@footnote{This feature is not implemented as of version |
443 | @value{VERSION}. Please contact @email{bug-guix@@gnu.org} for more | |
444 | details.}. When a pre-built binary for a @file{/nix/store} path is | |
eeaf4427 LC |
445 | available from an external source, Guix just downloads it; otherwise, it |
446 | builds the package from source, locally. | |
447 | ||
448 | @node Invoking guix-package | |
449 | @section Invoking @command{guix-package} | |
450 | ||
ba55b1cb | 451 | The @command{guix-package} command is the tool that allows users to |
eeaf4427 LC |
452 | install, upgrade, and remove packages, as well as rolling back to |
453 | previous configurations. It operates only on the user's own profile, | |
454 | and works with normal user privileges (@pxref{Features}). Its syntax | |
455 | is: | |
456 | ||
457 | @example | |
458 | guix-package @var{options} | |
459 | @end example | |
460 | ||
ba55b1cb | 461 | Primarily, @var{options} specifies the operations to be performed during |
eeaf4427 LC |
462 | the transaction. Upon completion, a new profile is created, but |
463 | previous generations of the profile remain available, should the user | |
464 | want to roll back. | |
465 | ||
b9e5c0a9 | 466 | For each user, a symlink to the user's default profile is automatically |
0ec1af59 | 467 | created in @file{$HOME/.guix-profile}. This symlink always points to the |
b9e5c0a9 LC |
468 | current generation of the user's default profile. Thus, users can add |
469 | @file{$HOME/.guix-profile/bin} to their @code{PATH} environment | |
470 | variable, and so on. | |
471 | ||
0ec1af59 LC |
472 | In a multi-user setup, user profiles must be stored in a place |
473 | registered as a @dfn{garbage-collector root}, which | |
474 | @file{$HOME/.guix-profile} points to (@pxref{Invoking guix-gc}). That | |
475 | directory is normally | |
476 | @code{@var{localstatedir}/profiles/per-user/@var{user}}, where | |
477 | @var{localstatedir} is the value passed to @code{configure} as | |
478 | @code{--localstatedir}, and @var{user} is the user name. It must be | |
479 | created by @code{root}, with @var{user} as the owner. When it does not | |
480 | exist, @command{guix-package} emits an error about it. | |
481 | ||
482 | The @var{options} can be among the following: | |
483 | ||
eeaf4427 LC |
484 | @table @code |
485 | ||
486 | @item --install=@var{package} | |
51c8d790 | 487 | @itemx -i @var{package} |
eeaf4427 LC |
488 | Install @var{package}. |
489 | ||
490 | @var{package} may specify either a simple package name, such as | |
491 | @code{guile}, or a package name followed by a hyphen and version number, | |
bfe384cc | 492 | such as @code{guile-1.8.8}. In addition, @var{package} may contain a |
eeaf4427 | 493 | colon, followed by the name of one of the outputs of the package, as in |
f03e7115 | 494 | @code{gcc:doc} or @code{binutils-2.22:lib}. |
eeaf4427 LC |
495 | |
496 | @item --remove=@var{package} | |
497 | @itemx -r @var{package} | |
498 | Remove @var{package}. | |
499 | ||
ba55b1cb LC |
500 | @item --upgrade=@var{regexp} |
501 | @itemx -u @var{regexp} | |
eeaf4427 LC |
502 | Upgrade all the installed packages matching @var{regexp}. |
503 | ||
24e262f0 LC |
504 | @item --roll-back |
505 | Roll back to the previous @dfn{generation} of the profile---i.e., undo | |
506 | the last transaction. | |
507 | ||
508 | When combined with options such as @code{--install}, roll back occurs | |
509 | before any other actions. | |
510 | ||
eeaf4427 LC |
511 | @item --profile=@var{profile} |
512 | @itemx -p @var{profile} | |
513 | Use @var{profile} instead of the user's default profile. | |
514 | ||
515 | @item --dry-run | |
516 | @itemx -n | |
517 | Show what would be done without actually doing it. | |
518 | ||
70915c1a LC |
519 | @item --verbose |
520 | Produce verbose output. In particular, emit the environment's build log | |
521 | on the standard error port. | |
522 | ||
eeaf4427 LC |
523 | @item --bootstrap |
524 | Use the bootstrap Guile to build the profile. This option is only | |
525 | useful to distribution developers. | |
526 | ||
527 | @end table | |
528 | ||
733b4130 LC |
529 | In addition to these actions @command{guix-package} supports the |
530 | following options to query the current state of a profile, or the | |
531 | availability of packages: | |
eeaf4427 | 532 | |
733b4130 LC |
533 | @table @option |
534 | ||
535 | @item --list-installed[=@var{regexp}] | |
536 | @itemx -I [@var{regexp}] | |
537 | List currently installed packages in the specified profile. When | |
538 | @var{regexp} is specified, list only installed packages whose name | |
539 | matches @var{regexp}. | |
540 | ||
541 | For each installed package, print the following items, separated by | |
542 | tabs: the package name, its version string, the part of the package that | |
543 | is installed (for instance, @code{out} for the default output, | |
544 | @code{include} for its headers, etc.), and the path of this package in | |
545 | the store. | |
546 | ||
64fc89b6 LC |
547 | @item --list-available[=@var{regexp}] |
548 | @itemx -A [@var{regexp}] | |
a1ba8475 LC |
549 | List packages currently available in the software distribution |
550 | (@pxref{GNU Distribution}). When @var{regexp} is specified, list only | |
551 | installed packages whose name matches @var{regexp}. | |
64fc89b6 LC |
552 | |
553 | For each package, print the following items separated by tabs: its name, | |
44b6be77 LC |
554 | its version string, the parts of the package (@code{out} for the main |
555 | files, @code{lib} for libraries and possibly headers, etc.), and the | |
556 | source location of its definition. | |
64fc89b6 | 557 | |
733b4130 | 558 | @end table |
eeaf4427 LC |
559 | |
560 | ||
fe8ff028 LC |
561 | @node Invoking guix-gc |
562 | @section Invoking @command{guix-gc} | |
563 | ||
564 | @cindex garbage collector | |
565 | Packages that are installed but not used may be @dfn{garbage-collected}. | |
566 | The @command{guix-gc} command allows users to explicitly run the garbage | |
567 | collector to reclaim space from the @file{/nix/store} directory. | |
568 | ||
569 | The garbage collector has a set of known @dfn{roots}: any file under | |
570 | @file{/nix/store} reachable from a root is considered @dfn{live} and | |
571 | cannot be deleted; any other file is considered @dfn{dead} and may be | |
572 | deleted. The set of garbage collector roots includes default user | |
573 | profiles, and may be augmented with @command{guix-build --root}, for | |
574 | example (@pxref{Invoking guix-build}). | |
575 | ||
1da983b9 | 576 | The @command{guix-gc} command has three modes of operation: it can be |
fe8ff028 LC |
577 | used to garbage-collect any dead files (the default), to delete specific |
578 | files (the @code{--delete} option), or to print garbage-collector | |
579 | information. The available options are listed below: | |
580 | ||
581 | @table @code | |
582 | @item --collect-garbage[=@var{min}] | |
583 | @itemx -C [@var{min}] | |
584 | Collect garbage---i.e., unreachable @file{/nix/store} files and | |
585 | sub-directories. This is the default operation when no option is | |
586 | specified. | |
587 | ||
588 | When @var{min} is given, stop once @var{min} bytes have been collected. | |
589 | @var{min} may be a number of bytes, or it may include a unit as a | |
590 | suffix, such as @code{MiB} for mebibytes and @code{GB} for gigabytes. | |
591 | ||
592 | When @var{min} is omitted, collect all the garbage. | |
593 | ||
594 | @item --delete | |
595 | @itemx -d | |
596 | Attempt to delete all the store files and directories specified as | |
597 | arguments. This fails if some of the files are not in the store, or if | |
598 | they are still live. | |
599 | ||
600 | @item --list-dead | |
601 | Show the list of dead files and directories still present in the | |
602 | store---i.e., files and directories no longer reachable from any root. | |
603 | ||
604 | @item --list-live | |
605 | Show the list of live store files and directories. | |
606 | @end table | |
607 | ||
eeaf4427 | 608 | |
568717fd LC |
609 | @c ********************************************************************* |
610 | @node Programming Interface | |
611 | @chapter Programming Interface | |
612 | ||
3dc1970d LC |
613 | GNU Guix provides several Scheme programming interfaces (APIs) to |
614 | define, build, and query packages. The first interface allows users to | |
615 | write high-level package definitions. These definitions refer to | |
616 | familiar packaging concepts, such as the name and version of a package, | |
617 | its build system, and its dependencies. These definitions can then be | |
618 | turned into concrete build actions. | |
619 | ||
ba55b1cb | 620 | Build actions are performed by the Guix daemon, on behalf of users. In a |
3dc1970d LC |
621 | standard setup, the daemon has write access to the store---the |
622 | @file{/nix/store} directory---whereas users do not. The recommended | |
623 | setup also has the daemon perform builds in chroots, under a specific | |
624 | build users, to minimize interference with the rest of the system. | |
625 | ||
626 | @cindex derivation | |
627 | Lower-level APIs are available to interact with the daemon and the | |
628 | store. To instruct the daemon to perform a build action, users actually | |
629 | provide it with a @dfn{derivation}. A derivation is a low-level | |
630 | representation of the build actions to be taken, and the environment in | |
631 | which they should occur---derivations are to package definitions what | |
632 | assembly is to C programs. | |
633 | ||
634 | This chapter describes all these APIs in turn, starting from high-level | |
635 | package definitions. | |
636 | ||
568717fd LC |
637 | @menu |
638 | * Defining Packages:: Defining new packages. | |
639 | * The Store:: Manipulating the package store. | |
640 | * Derivations:: Low-level interface to package derivations. | |
641 | @end menu | |
642 | ||
643 | @node Defining Packages | |
644 | @section Defining Packages | |
645 | ||
3dc1970d LC |
646 | The high-level interface to package definitions is implemented in the |
647 | @code{(guix packages)} and @code{(guix build-system)} modules. As an | |
648 | example, the package definition, or @dfn{recipe}, for the GNU Hello | |
649 | package looks like this: | |
650 | ||
651 | @example | |
b22a12fd LC |
652 | (use-modules (guix packages) |
653 | (guix download) | |
654 | (guix build-system gnu) | |
655 | (guix licenses)) | |
656 | ||
3dc1970d LC |
657 | (define hello |
658 | (package | |
659 | (name "hello") | |
660 | (version "2.8") | |
661 | (source (origin | |
662 | (method url-fetch) | |
663 | (uri (string-append "mirror://gnu/hello/hello-" version | |
664 | ".tar.gz")) | |
665 | (sha256 | |
666 | (base32 "0wqd8sjmxfskrflaxywc7gqw7sfawrfvdxd9skxawzfgyy0pzdz6")))) | |
667 | (build-system gnu-build-system) | |
668 | (inputs `(("gawk" ,gawk))) | |
669 | (synopsis "GNU Hello") | |
670 | (description "Yeah...") | |
671 | (home-page "http://www.gnu.org/software/hello/") | |
b22a12fd | 672 | (license gpl3+))) |
3dc1970d LC |
673 | @end example |
674 | ||
675 | @noindent | |
676 | Without being a Scheme expert, the reader may have guessed the meaning | |
677 | of the various fields here. This expression binds variable @var{hello} | |
678 | to a @code{<package>} object, which is essentially a record | |
679 | (@pxref{SRFI-9, Scheme records,, guile, GNU Guile Reference Manual}). | |
680 | This package object can be inspected using procedures found in the | |
681 | @code{(guix packages)} module; for instance, @code{(package-name hello)} | |
682 | returns---surprise!---@code{"hello"}. | |
683 | ||
684 | There are a few points worth noting in the above package definition: | |
685 | ||
686 | @itemize | |
687 | @item | |
688 | The @code{source} field of the package is an @code{<origin>} object. | |
689 | Here, the @code{url-fetch} method from @code{(guix download)} is used, | |
690 | meaning that the source is a file to be downloaded over FTP or HTTP. | |
691 | ||
692 | The @code{mirror://gnu} prefix instructs @code{url-fetch} to use one of | |
693 | the GNU mirrors defined in @code{(guix download)}. | |
694 | ||
695 | The @code{sha256} field specifies the expected SHA256 hash of the file | |
696 | being downloaded. It is mandatory, and allows Guix to check the | |
697 | integrity of the file. The @code{(base32 @dots{})} form introduces the | |
698 | base32 representation of the hash. A convenient way to obtain this | |
699 | information is with the @code{guix-download} tool. | |
700 | ||
701 | @item | |
702 | @cindex GNU Build System | |
703 | The @code{build-system} field is set to @var{gnu-build-system}. The | |
704 | @var{gnu-build-system} variable is defined in the @code{(guix | |
705 | build-system gnu)} module, and is bound to a @code{<build-system>} | |
706 | object. | |
707 | ||
708 | Naturally, @var{gnu-build-system} represents the familiar GNU Build | |
709 | System, and variants thereof (@pxref{Configuration, configuration and | |
710 | makefile conventions,, standards, GNU Coding Standards}). In a | |
ba55b1cb | 711 | nutshell, packages using the GNU Build System may be configured, built, |
3dc1970d LC |
712 | and installed with the usual @code{./configure && make && make check && |
713 | make install} command sequence. This is what @var{gnu-build-system} | |
714 | does. | |
715 | ||
716 | In addition, @var{gnu-build-system} ensures that the ``standard'' | |
717 | environment for GNU packages is available. This includes tools such as | |
718 | GCC, Coreutils, Bash, Make, Diffutils, and Patch. | |
719 | ||
720 | @item | |
721 | The @code{inputs} field specifies inputs to the build process---i.e., | |
722 | build-time or run-time dependencies of the package. Here, we define an | |
723 | input called @code{"gawk"} whose value is that of the @var{gawk} | |
724 | variable; @var{gawk} is itself bound to a @code{<package>} object. | |
725 | ||
726 | Note that GCC, Coreutils, Bash, and other essential tools do not need to | |
727 | be specified as inputs here. Instead, @var{gnu-build-system} takes care | |
728 | of ensuring that they are present. | |
729 | ||
730 | However, any other dependencies need to be specified in the | |
731 | @code{inputs} field. Any dependency not specified here will simply be | |
732 | unavailable to the build process, possibly leading to a build failure. | |
733 | @end itemize | |
734 | ||
735 | There are other fields that package definitions may provide. Of | |
736 | particular interest is the @code{arguments} field. When specified, it | |
737 | must be bound to a list of additional arguments to be passed to the | |
738 | build system. For instance, the above definition could be augmented | |
739 | with the following field initializer: | |
740 | ||
741 | @example | |
742 | (arguments `(#:tests? #f | |
743 | #:configure-flags '("--enable-silent-rules"))) | |
744 | @end example | |
745 | ||
746 | @noindent | |
747 | These are keyword arguments (@pxref{Optional Arguments, keyword | |
748 | arguments in Guile,, guile, GNU Guile Reference Manual}). They are | |
749 | passed to @var{gnu-build-system}, which interprets them as meaning ``do | |
750 | not run @code{make check}'', and ``run @file{configure} with the | |
874e6874 LC |
751 | @code{--enable-silent-rules} flag''. The value of these keyword |
752 | parameters is actually evaluated in the @dfn{build stratum}---i.e., by a | |
753 | Guile process launched by the daemon (@pxref{Derivations}). | |
3dc1970d LC |
754 | |
755 | Once a package definition is in place@footnote{Simple package | |
756 | definitions like the one above may be automatically converted from the | |
757 | Nixpkgs distribution using the @command{guix-import} command.}, the | |
758 | package may actually be built using the @code{guix-build} command-line | |
759 | tool (@pxref{Invoking guix-build}). | |
760 | ||
761 | Behind the scenes, a derivation corresponding to the @code{<package>} | |
762 | object is first computed by the @code{package-derivation} procedure. | |
763 | That derivation is stored in a @code{.drv} file under @file{/nix/store}. | |
ba55b1cb | 764 | The build actions it prescribes may then be realized by using the |
3dc1970d LC |
765 | @code{build-derivations} procedure (@pxref{The Store}). |
766 | ||
767 | @deffn {Scheme Procedure} package-derivation @var{store} @var{package} [@var{system}] | |
e509d152 LC |
768 | Return the derivation path and corresponding @code{<derivation>} object |
769 | of @var{package} for @var{system} (@pxref{Derivations}). | |
3dc1970d LC |
770 | |
771 | @var{package} must be a valid @code{<package>} object, and @var{system} | |
772 | must be a string denoting the target system type---e.g., | |
773 | @code{"x86_64-linux"} for an x86_64 Linux-based GNU system. @var{store} | |
774 | must be a connection to the daemon, which operates on the store | |
775 | (@pxref{The Store}). | |
776 | @end deffn | |
568717fd LC |
777 | |
778 | @node The Store | |
779 | @section The Store | |
780 | ||
e531ac2a LC |
781 | @cindex store |
782 | @cindex store paths | |
783 | ||
784 | Conceptually, the @dfn{store} is where derivations that have been | |
785 | successfully built are stored---by default, under @file{/nix/store}. | |
786 | Sub-directories in the store are referred to as @dfn{store paths}. The | |
787 | store has an associated database that contains information such has the | |
788 | store paths referred to by each store path, and the list of @emph{valid} | |
789 | store paths---paths that result from a successful build. | |
790 | ||
791 | The store is always accessed by the daemon on behalf of its clients | |
792 | (@pxref{Invoking guix-daemon}). To manipulate the store, clients | |
793 | connect to the daemon over a Unix-domain socket, send it requests, and | |
794 | read the result---these are remote procedure calls, or RPCs. | |
795 | ||
796 | The @code{(guix store)} module provides procedures to connect to the | |
797 | daemon, and to perform RPCs. These are described below. | |
798 | ||
799 | @deffn {Scheme Procedure} open-connection [@var{file}] [#:reserve-space? #t] | |
800 | Connect to the daemon over the Unix-domain socket at @var{file}. When | |
801 | @var{reserve-space?} is true, instruct it to reserve a little bit of | |
802 | extra space on the file system so that the garbage collector can still | |
803 | operate, should the disk become full. Return a server object. | |
804 | ||
805 | @var{file} defaults to @var{%default-socket-path}, which is the normal | |
806 | location given the options that were passed to @command{configure}. | |
807 | @end deffn | |
808 | ||
809 | @deffn {Scheme Procedure} close-connection @var{server} | |
810 | Close the connection to @var{server}. | |
811 | @end deffn | |
812 | ||
813 | @defvr {Scheme Variable} current-build-output-port | |
814 | This variable is bound to a SRFI-39 parameter, which refers to the port | |
815 | where build and error logs sent by the daemon should be written. | |
816 | @end defvr | |
817 | ||
818 | Procedures that make RPCs all take a server object as their first | |
819 | argument. | |
820 | ||
821 | @deffn {Scheme Procedure} valid-path? @var{server} @var{path} | |
822 | Return @code{#t} when @var{path} is a valid store path. | |
823 | @end deffn | |
824 | ||
825 | @deffn {Scheme Procedure} add-text-to-store @var{server} @var{name} @var{text} @var{references} | |
826 | Add @var{text} under file @var{name} in the store, and return its store | |
827 | path. @var{references} is the list of store paths referred to by the | |
828 | resulting store path. | |
829 | @end deffn | |
830 | ||
874e6874 LC |
831 | @deffn {Scheme Procedure} build-derivations @var{server} @var{derivations} |
832 | Build @var{derivations} (a list of derivation paths), and return when | |
833 | the worker is done building them. Return @code{#t} on success. | |
834 | @end deffn | |
835 | ||
e531ac2a LC |
836 | @c FIXME |
837 | @i{This section is currently incomplete.} | |
568717fd LC |
838 | |
839 | @node Derivations | |
840 | @section Derivations | |
841 | ||
874e6874 LC |
842 | @cindex derivations |
843 | Low-level build actions and the environment in which they are performed | |
844 | are represented by @dfn{derivations}. A derivation contain the | |
845 | following pieces of information: | |
846 | ||
847 | @itemize | |
848 | @item | |
849 | The outputs of the derivation---derivations produce at least one file or | |
850 | directory in the store, but may produce more. | |
851 | ||
852 | @item | |
853 | The inputs of the derivations, which may be other derivations or plain | |
854 | files in the store (patches, build scripts, etc.) | |
855 | ||
856 | @item | |
857 | The system type targeted by the derivation---e.g., @code{x86_64-linux}. | |
858 | ||
859 | @item | |
860 | The file name of a build script in the store, along with the arguments | |
861 | to be passed. | |
862 | ||
863 | @item | |
864 | A list of environment variables to be defined. | |
865 | ||
866 | @end itemize | |
867 | ||
868 | @cindex derivation path | |
869 | Derivations allow clients of the daemon to communicate build actions to | |
870 | the store. They exist in two forms: as an in-memory representation, | |
871 | both on the client- and daemon-side, and as files in the store whose | |
872 | name end in @code{.drv}---these files are referred to as @dfn{derivation | |
873 | paths}. Derivations paths can be passed to the @code{build-derivations} | |
874 | procedure to perform the build actions they prescribe (@pxref{The | |
875 | Store}). | |
876 | ||
877 | The @code{(guix derivations)} module provides a representation of | |
878 | derivations as Scheme objects, along with procedures to create and | |
879 | otherwise manipulate derivations. The lowest-level primitive to create | |
880 | a derivation is the @code{derivation} procedure: | |
881 | ||
882 | @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] | |
883 | Build a derivation with the given arguments. Return the resulting store | |
884 | path and @code{<derivation>} object. | |
885 | ||
886 | When @var{hash}, @var{hash-algo}, and @var{hash-mode} are given, a | |
887 | @dfn{fixed-output derivation} is created---i.e., one whose result is | |
888 | known in advance, such as a file download. | |
889 | @end deffn | |
890 | ||
891 | @noindent | |
892 | Here's an example with a shell script as its builder, assuming | |
893 | @var{store} is an open connection to the daemon, and @var{bash} points | |
894 | to a Bash executable in the store: | |
895 | ||
896 | @lisp | |
897 | (use-modules (guix utils) | |
898 | (guix store) | |
899 | (guix derivations)) | |
900 | ||
901 | (call-with-values | |
902 | (lambda () | |
903 | (let ((builder ; add the Bash script to the store | |
904 | (add-text-to-store store "my-builder.sh" | |
905 | "echo hello world > $out\n" '()))) | |
906 | (derivation store "foo" (%current-system) | |
907 | bash `("-e" ,builder) | |
908 | '(("HOME" . "/homeless")) '()))) | |
909 | list) | |
910 | @result{} ("/nix/store/@dots{}-foo.drv" #<<derivation> @dots{}>) | |
911 | @end lisp | |
912 | ||
913 | As can be guessed, this primitive is cumbersome to use directly. An | |
914 | improved variant is @code{build-expression->derivation}, which allows | |
915 | the caller to directly pass a Guile expression as the build script: | |
916 | ||
917 | @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] | |
918 | Return a derivation that executes Scheme expression @var{exp} as a | |
919 | builder for derivation @var{name}. @var{inputs} must be a list of | |
920 | @code{(name drv-path sub-drv)} tuples; when @var{sub-drv} is omitted, | |
921 | @code{"out"} is assumed. @var{modules} is a list of names of Guile | |
922 | modules from the current search path to be copied in the store, | |
923 | compiled, and made available in the load path during the execution of | |
924 | @var{exp}---e.g., @code{((guix build utils) (guix build | |
925 | gnu-build-system))}. | |
926 | ||
927 | @var{exp} is evaluated in an environment where @code{%outputs} is bound | |
928 | to a list of output/path pairs, and where @code{%build-inputs} is bound | |
929 | to a list of string/output-path pairs made from @var{inputs}. | |
930 | Optionally, @var{env-vars} is a list of string pairs specifying the name | |
931 | and value of environment variables visible to the builder. The builder | |
932 | terminates by passing the result of @var{exp} to @code{exit}; thus, when | |
933 | @var{exp} returns @code{#f}, the build is considered to have failed. | |
934 | ||
935 | @var{exp} is built using @var{guile-for-build} (a derivation). When | |
936 | @var{guile-for-build} is omitted or is @code{#f}, the value of the | |
937 | @code{%guile-for-build} fluid is used instead. | |
938 | @end deffn | |
939 | ||
940 | @noindent | |
941 | Here's an example of a single-output derivation that creates a directory | |
942 | containing one file: | |
943 | ||
944 | @lisp | |
945 | (let ((builder '(let ((out (assoc-ref %outputs "out"))) | |
946 | (mkdir out) ; create /nix/store/@dots{}-goo | |
947 | (call-with-output-file (string-append out "/test") | |
948 | (lambda (p) | |
949 | (display '(hello guix) p)))))) | |
950 | (build-expression->derivation store "goo" (%current-system) | |
951 | builder '())) | |
952 | ||
953 | @result{} "/nix/store/@dots{}-goo.drv" | |
954 | @result{} #<<derivation> @dots{}> | |
955 | @end lisp | |
956 | ||
957 | @cindex strata of code | |
958 | Remember that the build expression passed to | |
959 | @code{build-expression->derivation} is run by a separate Guile process | |
960 | than the one that calls @code{build-expression->derivation}: it is run | |
961 | by a Guile process launched by the daemon, typically in a chroot. So, | |
962 | while there is a single language for both the @dfn{host} and the build | |
963 | side, there are really two @dfn{strata} of code: the host-side, and the | |
964 | build-side code@footnote{The term @dfn{stratum} in this context was | |
965 | coined by Manuel Serrano et al. in the context of their work on Hop.}. | |
966 | This distinction is important to keep in mind, notably when using | |
967 | higher-level constructs such as @var{gnu-build-system} (@pxref{Defining | |
968 | Packages}). For this reason, Guix modules that are meant to be used in | |
969 | the build stratum are kept in the @code{(guix build @dots{})} name | |
970 | space. | |
568717fd LC |
971 | |
972 | @c ********************************************************************* | |
973 | @node Utilities | |
974 | @chapter Utilities | |
975 | ||
976 | @menu | |
977 | * Invoking guix-build:: Building packages from the command line. | |
978 | @end menu | |
979 | ||
980 | @node Invoking guix-build | |
981 | @section Invoking @command{guix-build} | |
982 | ||
c78bd12b LC |
983 | The @command{guix-build} command builds packages or derivations and |
984 | their dependencies, and prints the resulting store paths. It is mainly | |
985 | useful for distribution developers. The general syntax is: | |
986 | ||
987 | @example | |
988 | guix-build @var{options} @var{package-or-derivation}@dots{} | |
989 | @end example | |
990 | ||
991 | @var{package-or-derivation} may be either the name of a package found in | |
5401dd75 LC |
992 | the software distribution such as @code{coreutils} or |
993 | @code{coreutils-8.20}, or a derivation such as | |
994 | @file{/nix/store/@dots{}-coreutils-8.19.drv}. Alternatively, the | |
c78bd12b LC |
995 | @code{--expression} option may be used to specify a Scheme expression |
996 | that evaluates to a package; this is useful when disambiguation among | |
997 | several same-named packages or package variants is needed. | |
998 | ||
999 | The @var{options} may be zero or more of the following: | |
1000 | ||
1001 | @table @code | |
1002 | ||
1003 | @item --expression=@var{expr} | |
1004 | @itemx -e @var{expr} | |
1005 | Build the package @var{expr} evaluates to. | |
1006 | ||
5401dd75 | 1007 | For example, @var{expr} may be @code{(@@ (gnu packages guile) |
c78bd12b LC |
1008 | guile-1.8)}, which unambiguously designates this specific variant of |
1009 | version 1.8 of Guile. | |
1010 | ||
1011 | @item --source | |
1012 | @itemx -S | |
1013 | Build the packages' source derivations, rather than the packages | |
1014 | themselves. | |
1015 | ||
1016 | For instance, @code{guix-build -S gcc} returns something like | |
1017 | @file{/nix/store/xxx-gcc-4.7.2.tar.bz2}, which is GCC's source tarball. | |
1018 | ||
1019 | @item --system=@var{system} | |
1020 | @itemx -s @var{system} | |
1021 | Attempt to build for @var{system}---e.g., @code{i686-linux}---instead of | |
1022 | the host's system type. | |
1023 | ||
1024 | An example use of this is on Linux-based systems, which can emulate | |
1025 | different personalities. For instance, passing | |
1026 | @code{--system=i686-linux} on an @code{x86_64-linux} system allows users | |
1027 | to build packages in a complete 32-bit environment. | |
1028 | ||
1029 | @item --derivations | |
1030 | @itemx -d | |
1031 | Return the derivation paths, not the output paths, of the given | |
1032 | packages. | |
1033 | ||
1034 | @item --keep-failed | |
1035 | @itemx -K | |
1036 | Keep the build tree of failed builds. Thus, if a build fail, its build | |
1037 | tree is kept under @file{/tmp}, in a directory whose name is shown at | |
1038 | the end of the build log. This is useful when debugging build issues. | |
1039 | ||
1040 | @item --dry-run | |
1041 | @itemx -n | |
1042 | Do not build the derivations. | |
1043 | ||
1044 | @item --no-substitutes | |
1045 | Build instead of resorting to pre-built substitutes. | |
1046 | ||
1047 | @item --cores=@var{n} | |
1048 | @itemx -c @var{n} | |
1049 | Allow the use of up to @var{n} CPU cores for the build. The special | |
1050 | value @code{0} means to use as many CPU cores as available. | |
1051 | ||
1052 | @item --root=@var{file} | |
1053 | @itemx -r @var{file} | |
1054 | Make @var{file} a symlink to the result, and register it as a garbage | |
1055 | collector root. | |
07ab4bf1 LC |
1056 | |
1057 | @item --verbosity=@var{level} | |
1058 | Use the given verbosity level. @var{level} must be an integer between 0 | |
1059 | and 5; higher means more verbose output. Setting a level of 4 or more | |
1060 | may be helpful when debugging setup issues with the build daemon. | |
1061 | ||
c78bd12b LC |
1062 | @end table |
1063 | ||
1064 | Behind the scenes, @command{guix-build} is essentially an interface to | |
1065 | the @code{package-derivation} procedure of the @code{(guix packages)} | |
1066 | module, and to the @code{build-derivations} procedure of the @code{(guix | |
1067 | store)} module. | |
1068 | ||
a1ba8475 LC |
1069 | @c ********************************************************************* |
1070 | @node GNU Distribution | |
1071 | @chapter GNU Distribution | |
1072 | ||
1073 | Guix comes with a distribution of free software@footnote{The term | |
1074 | ``free'' here refers to the | |
1075 | @url{http://www.gnu.org/philosophy/free-sw.html,freedom provided to | |
1076 | users of that software}.} that form the basis of the GNU system. This | |
1077 | includes core GNU packages such as GNU libc, GCC, and Binutils, as well | |
1078 | as many GNU and non-GNU applications. The complete list of available | |
1079 | packages can be seen by running @command{guix-package} (@pxref{Invoking | |
1080 | guix-package}): | |
1081 | ||
1082 | @example | |
1083 | guix-package --list-available | |
1084 | @end example | |
1085 | ||
1086 | The package definitions of the distribution may are provided by Guile | |
1087 | modules in the @code{(gnu packages ...)} name space---for instance, the | |
1088 | @code{(gnu packages emacs)} module exports a variable named | |
1089 | @code{emacs}, which is bound to a @code{<package>} object | |
1090 | (@pxref{Defining Packages}). The @code{(gnu packages)} module provides | |
1091 | facilities for searching for packages. | |
1092 | ||
1093 | The distribution is fully @dfn{bootstrapped} and @dfn{self-contained}: | |
1094 | each package is built based solely on other packages in the | |
1095 | distribution. The root of this dependency graph is a small set of | |
1096 | @dfn{bootstrap binaries}, provided by the @code{(gnu packages | |
1097 | bootstrap)} module. These are statically-linked binaries of the core | |
1098 | tools without which building anything at all would be impossible. | |
1099 | ||
1100 | ||
1101 | Our goal is to build a practical 100% free software distribution of | |
1102 | Linux-based and other variants of GNU, with a focus on the promotion and | |
1103 | tight integration of GNU components, and an emphasis on programs and | |
1104 | tools that help users exert that freedom. | |
1105 | ||
1106 | Building this distribution is a cooperative effort, and you are invited | |
1107 | to join! Please get in touch with us on @email{bug-guix@@gnu.org}. We | |
1108 | welcome ideas, bug reports, patches, and anything that may be helpful to | |
1109 | the project. | |
1110 | ||
c78bd12b | 1111 | |
568717fd LC |
1112 | @c ********************************************************************* |
1113 | @node Acknowledgments | |
1114 | @chapter Acknowledgments | |
1115 | ||
1116 | Guix is based on the Nix package manager, which was designed and | |
1117 | implemented by Eelco Dolstra. Nix pioneered functional package | |
1118 | management, and promoted unprecedented features, such as transactional | |
1119 | package upgrades and rollbacks, per-user profiles, and referentially | |
1120 | transparent build processes. Without this work, Guix would not exist. | |
1121 | ||
1122 | The Nix-based software distributions, Nixpkgs and NixOS, have also been | |
1123 | an inspiration for Guix. | |
1124 | ||
1125 | @c ********************************************************************* | |
1126 | @node GNU Free Documentation License | |
1127 | @appendix GNU Free Documentation License | |
1128 | ||
1129 | @include fdl-1.3.texi | |
1130 | ||
1131 | @c ********************************************************************* | |
1132 | @node Concept Index | |
1133 | @unnumbered Concept Index | |
1134 | @printindex cp | |
1135 | ||
1136 | @node Function Index | |
1137 | @unnumbered Function Index | |
1138 | @printindex fn | |
1139 | ||
1140 | @bye | |
1141 | ||
1142 | @c Local Variables: | |
1143 | @c ispell-local-dictionary: "american"; | |
1144 | @c End: |