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 | |
7df7a74e NK |
11 | |
12 | @copying | |
425b0bfc | 13 | Copyright @copyright{} 2012, 2013, 2014 Ludovic Courtès@* |
af8a56b8 | 14 | Copyright @copyright{} 2013, 2014 Andreas Enge@* |
7df7a74e NK |
15 | Copyright @copyright{} 2013 Nikita Karetnikov |
16 | ||
17 | Permission is granted to copy, distribute and/or modify this document | |
18 | under the terms of the GNU Free Documentation License, Version 1.3 or | |
19 | any later version published by the Free Software Foundation; with no | |
20 | Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A | |
21 | copy of the license is included in the section entitled ``GNU Free | |
22 | Documentation License''. | |
23 | @end copying | |
568717fd | 24 | |
eeaf4427 | 25 | @dircategory Package management |
568717fd LC |
26 | @direntry |
27 | * guix: (guix). Guix, the functional package manager. | |
e49951eb | 28 | * guix package: (guix)Invoking guix package |
eeaf4427 | 29 | Managing packages with Guix. |
e49951eb | 30 | * guix build: (guix)Invoking guix build |
568717fd LC |
31 | Building packages with Guix. |
32 | @end direntry | |
568717fd LC |
33 | |
34 | @titlepage | |
7730d112 LC |
35 | @title GNU Guix Reference Manual |
36 | @subtitle Using the GNU Guix Functional Package Manager | |
568717fd | 37 | @author Ludovic Courtès |
da7cabd4 | 38 | @author Andreas Enge |
acc08466 | 39 | @author Nikita Karetnikov |
568717fd LC |
40 | |
41 | @page | |
42 | @vskip 0pt plus 1filll | |
43 | Edition @value{EDITION} @* | |
44 | @value{UPDATED} @* | |
45 | ||
7df7a74e | 46 | @insertcopying |
568717fd LC |
47 | @end titlepage |
48 | ||
568717fd LC |
49 | @contents |
50 | ||
51 | @c ********************************************************************* | |
52 | @node Top | |
f8348b91 | 53 | @top GNU Guix |
568717fd | 54 | |
f8348b91 LC |
55 | This document describes GNU Guix version @value{VERSION}, a functional |
56 | package management tool written for the GNU system. | |
568717fd LC |
57 | |
58 | @menu | |
59 | * Introduction:: What is Guix about? | |
bd5e766b | 60 | * Installation:: Installing Guix. |
eeaf4427 | 61 | * Package Management:: Package installation, upgrade, etc. |
568717fd LC |
62 | * Programming Interface:: Using Guix in Scheme. |
63 | * Utilities:: Package management commands. | |
a1ba8475 | 64 | * GNU Distribution:: Software for your friendly GNU system. |
9bf3c1a7 | 65 | * Contributing:: Your help needed! |
568717fd LC |
66 | |
67 | * Acknowledgments:: Thanks! | |
68 | * GNU Free Documentation License:: The license of this manual. | |
69 | * Concept Index:: Concepts. | |
70 | * Function Index:: Functions. | |
71 | @end menu | |
72 | ||
73 | @c ********************************************************************* | |
74 | @node Introduction | |
75 | @chapter Introduction | |
76 | ||
c80e7e55 LC |
77 | GNU Guix@footnote{``Guix'' is pronounced like ``geeks'', or ``ɡiːks'' |
78 | using the international phonetic alphabet (IPA).} is a functional | |
79 | package management tool for the GNU system. Package management consists | |
4bfc4ea3 NK |
80 | of all activities that relate to building packages from sources, |
81 | honoring their build-time and run-time dependencies, | |
c80e7e55 LC |
82 | installing packages in user environments, upgrading installed packages |
83 | to new versions or rolling back to a previous set, removing unused | |
84 | software packages, etc. | |
568717fd LC |
85 | |
86 | @cindex functional package management | |
87 | The term @dfn{functional} refers to a specific package management | |
88 | discipline. In Guix, the package build and installation process is seen | |
4bfc4ea3 NK |
89 | as a function, in the mathematical sense. That function takes inputs, |
90 | such as build scripts, a compiler, and libraries, and | |
91 | returns an installed package. As a pure function, its result depends | |
568717fd LC |
92 | solely on its inputs---for instance, it cannot refer to software or |
93 | scripts that were not explicitly passed as inputs. A build function | |
4bfc4ea3 NK |
94 | always produces the same result when passed a given set of inputs. It |
95 | cannot alter the system's environment in | |
568717fd LC |
96 | any way; for instance, it cannot create, modify, or delete files outside |
97 | of its build and installation directories. This is achieved by running | |
e900c503 | 98 | build processes in isolated environments (or @dfn{containers}), where only their |
4bfc4ea3 | 99 | explicit inputs are visible. |
568717fd | 100 | |
e531ac2a | 101 | @cindex store |
568717fd | 102 | The result of package build functions is @dfn{cached} in the file |
e531ac2a LC |
103 | system, in a special directory called @dfn{the store} (@pxref{The |
104 | Store}). Each package is installed in a directory of its own, in the | |
834129e0 | 105 | store---by default under @file{/gnu/store}. The directory name contains |
568717fd LC |
106 | a hash of all the inputs used to build that package; thus, changing an |
107 | input yields a different directory name. | |
108 | ||
109 | This approach is the foundation of Guix's salient features: support for | |
4bfc4ea3 | 110 | transactional package upgrade and rollback, per-user installation, and |
eeaf4427 | 111 | garbage collection of packages (@pxref{Features}). |
568717fd | 112 | |
4bfc4ea3 | 113 | Guix has a command-line interface, which allows users to build, install, |
568717fd | 114 | upgrade, and remove packages, as well as a Scheme programming interface. |
568717fd | 115 | |
a1ba8475 LC |
116 | Last but not least, Guix is used to build a distribution of the GNU |
117 | system, with many GNU and non-GNU free software packages. @xref{GNU | |
118 | Distribution}. | |
119 | ||
bd5e766b LC |
120 | @c ********************************************************************* |
121 | @node Installation | |
122 | @chapter Installation | |
123 | ||
48febeb8 LC |
124 | GNU Guix is available for download from its website at |
125 | @url{http://www.gnu.org/software/guix/}. This section describes the | |
126 | software requirements of Guix, as well as how to install it and get | |
127 | ready to use it. | |
bd5e766b | 128 | |
5af6de3e LC |
129 | Note that this section is concerned with the installation of the package |
130 | manager, which can be done on top of a running GNU/Linux system. If, | |
131 | instead, you want to install the complete GNU operating system, | |
132 | @ref{System Installation}. | |
133 | ||
b22a12fd | 134 | The build procedure for Guix is the same as for other GNU software, and |
1da983b9 | 135 | is not covered here. Please see the files @file{README} and |
b22a12fd LC |
136 | @file{INSTALL} in the Guix source tree for additional details. |
137 | ||
bd5e766b LC |
138 | @menu |
139 | * Requirements:: Software needed to build and run Guix. | |
140 | * Setting Up the Daemon:: Preparing the build daemon's environment. | |
141 | * Invoking guix-daemon:: Running the build daemon. | |
142 | @end menu | |
143 | ||
144 | @node Requirements | |
145 | @section Requirements | |
146 | ||
147 | GNU Guix depends on the following packages: | |
148 | ||
149 | @itemize | |
4a328f73 | 150 | @item @url{http://gnu.org/software/guile/, GNU Guile}, version 2.0.5 or later; |
bd5e766b LC |
151 | @item @url{http://gnupg.org/, GNU libgcrypt} |
152 | @end itemize | |
153 | ||
154 | Unless @code{--disable-daemon} was passed to @command{configure}, the | |
155 | following packages are also needed: | |
156 | ||
157 | @itemize | |
158 | @item @url{http://sqlite.org, SQLite 3} | |
159 | @item @url{http://www.bzip.org, libbz2} | |
160 | @item @url{http://gcc.gnu.org, GCC's g++} | |
161 | @end itemize | |
162 | ||
4bfc4ea3 NK |
163 | When a working installation of @url{http://nixos.org/nix/, the Nix package |
164 | manager} is available, you | |
bd5e766b | 165 | can instead configure Guix with @code{--disable-daemon}. In that case, |
4bfc4ea3 | 166 | Nix replaces the three dependencies above. |
bd5e766b | 167 | |
b22a12fd LC |
168 | Guix is compatible with Nix, so it is possible to share the same store |
169 | between both. To do so, you must pass @command{configure} not only the | |
170 | same @code{--with-store-dir} value, but also the same | |
4bfc4ea3 NK |
171 | @code{--localstatedir} value. The latter is essential because it |
172 | specifies where the database that stores metadata about the store is | |
834129e0 | 173 | located, among other things. The default values for Nix are |
b22a12fd | 174 | @code{--with-store-dir=/nix/store} and @code{--localstatedir=/nix/var}. |
4bfc4ea3 NK |
175 | Note that @code{--disable-daemon} is not required if |
176 | your goal is to share the store with Nix. | |
b22a12fd | 177 | |
bd5e766b LC |
178 | @node Setting Up the Daemon |
179 | @section Setting Up the Daemon | |
180 | ||
181 | @cindex daemon | |
182 | Operations such as building a package or running the garbage collector | |
49e6291a | 183 | are all performed by a specialized process, the @dfn{build daemon}, on |
bd5e766b LC |
184 | behalf of clients. Only the daemon may access the store and its |
185 | associated database. Thus, any operation that manipulates the store | |
186 | goes through the daemon. For instance, command-line tools such as | |
e49951eb | 187 | @command{guix package} and @command{guix build} communicate with the |
bd5e766b LC |
188 | daemon (@i{via} remote procedure calls) to instruct it what to do. |
189 | ||
49e6291a LC |
190 | The following sections explain how to prepare the build daemon's |
191 | environment. | |
192 | ||
193 | @menu | |
194 | * Build Environment Setup:: Preparing the isolated build environment. | |
195 | * Daemon Offload Setup:: Offloading builds to remote machines. | |
196 | @end menu | |
197 | ||
198 | @node Build Environment Setup | |
199 | @subsection Build Environment Setup | |
200 | ||
bd5e766b LC |
201 | In a standard multi-user setup, Guix and its daemon---the |
202 | @command{guix-daemon} program---are installed by the system | |
834129e0 | 203 | administrator; @file{/gnu/store} is owned by @code{root} and |
bd5e766b LC |
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` \ | |
4d1a2b50 LC |
232 | -c "Guix build user $i" --system \ |
233 | guix-builder$i; | |
bd5e766b LC |
234 | done |
235 | @end example | |
236 | ||
237 | @noindent | |
238 | The @code{guix-daemon} program may then be run as @code{root} with: | |
239 | ||
240 | @example | |
241 | # guix-daemon --build-users-group=guix-builder | |
242 | @end example | |
243 | ||
e900c503 | 244 | @cindex chroot |
b095792f LC |
245 | @noindent |
246 | This way, the daemon starts build processes in a chroot, under one of | |
247 | the @code{guix-builder} users. On GNU/Linux, by default, the chroot | |
6dc99317 LC |
248 | environment contains nothing but: |
249 | ||
250 | @c Keep this list in sync with libstore/build.cc! ----------------------- | |
251 | @itemize | |
252 | @item | |
4743a4da LC |
253 | a minimal @code{/dev} directory, created mostly independently from the |
254 | host @code{/dev}@footnote{``Mostly'', because while the set of files | |
255 | that appear in the chroot's @code{/dev} is fixed, most of these files | |
256 | can only be created if the host has them.}; | |
257 | ||
258 | @item | |
259 | the @code{/proc} directory; it only shows the container's processes | |
260 | since a separate PID name space is used; | |
6dc99317 LC |
261 | |
262 | @item | |
263 | @file{/etc/passwd} with an entry for the current user and an entry for | |
264 | user @file{nobody}; | |
265 | ||
266 | @item | |
267 | @file{/etc/group} with an entry for the user's group; | |
268 | ||
269 | @item | |
270 | @file{/etc/hosts} with an entry that maps @code{localhost} to | |
271 | @code{127.0.0.1}; | |
272 | ||
273 | @item | |
274 | a writable @file{/tmp} directory. | |
275 | @end itemize | |
b095792f | 276 | |
d43eb499 | 277 | If you are installing Guix as an unprivileged user, it is still |
bd5e766b LC |
278 | possible to run @command{guix-daemon}. However, build processes will |
279 | not be isolated from one another, and not from the rest of the system. | |
280 | Thus, build processes may interfere with each other, and may access | |
281 | programs, libraries, and other files available on the system---making it | |
282 | much harder to view them as @emph{pure} functions. | |
283 | ||
49e6291a LC |
284 | |
285 | @node Daemon Offload Setup | |
286 | @subsection Using the Offload Facility | |
287 | ||
288 | @cindex offloading | |
4ec2e92d LC |
289 | @cindex build hook |
290 | When desired, the build daemon can @dfn{offload} | |
291 | derivation builds to other machines | |
49e6291a LC |
292 | running Guix, using the @code{offload} @dfn{build hook}. When that |
293 | feature is enabled, a list of user-specified build machines is read from | |
294 | @file{/etc/guix/machines.scm}; anytime a build is requested, for | |
295 | instance via @code{guix build}, the daemon attempts to offload it to one | |
296 | of the machines that satisfies the derivation's constraints, in | |
297 | particular its system type---e.g., @file{x86_64-linux}. Missing | |
298 | prerequisites for the build are copied over SSH to the target machine, | |
299 | which then proceeds with the build; upon success the output(s) of the | |
300 | build are copied back to the initial machine. | |
301 | ||
4ec2e92d | 302 | The @file{/etc/guix/machines.scm} file typically looks like this: |
49e6291a LC |
303 | |
304 | @example | |
305 | (list (build-machine | |
306 | (name "eightysix.example.org") | |
307 | (system "x86_64-linux") | |
308 | (user "bob") | |
309 | (speed 2.)) ; incredibly fast! | |
310 | ||
311 | (build-machine | |
312 | (name "meeps.example.org") | |
313 | (system "mips64el-linux") | |
314 | (user "alice") | |
315 | (private-key | |
316 | (string-append (getenv "HOME") | |
317 | "/.ssh/id-rsa-for-guix")))) | |
318 | @end example | |
319 | ||
320 | @noindent | |
321 | In the example above we specify a list of two build machines, one for | |
322 | the @code{x86_64} architecture and one for the @code{mips64el} | |
4ec2e92d LC |
323 | architecture. |
324 | ||
325 | In fact, this file is---not surprisingly!---a Scheme file that is | |
326 | evaluated when the @code{offload} hook is started. Its return value | |
327 | must be a list of @code{build-machine} objects. While this example | |
328 | shows a fixed list of build machines, one could imagine, say, using | |
329 | DNS-SD to return a list of potential build machines discovered in the | |
330 | local network (@pxref{Introduction, Guile-Avahi,, guile-avahi, Using | |
331 | Avahi in Guile Scheme Programs}). | |
332 | ||
333 | The compulsory fields for a @code{build-machine} declaration are: | |
49e6291a LC |
334 | |
335 | @table @code | |
336 | ||
337 | @item name | |
338 | The remote machine's host name. | |
339 | ||
340 | @item system | |
341 | The remote machine's system type. | |
342 | ||
343 | @item user | |
344 | The user account to use when connecting to the remote machine over SSH. | |
345 | Note that the SSH key pair must @emph{not} be passphrase-protected, to | |
346 | allow non-interactive logins. | |
347 | ||
348 | @end table | |
349 | ||
350 | @noindent | |
4ec2e92d | 351 | A number of optional fields may be specified: |
49e6291a LC |
352 | |
353 | @table @code | |
354 | ||
cecd72d5 LC |
355 | @item port |
356 | Port number of the machine's SSH server (default: 22). | |
357 | ||
49e6291a LC |
358 | @item private-key |
359 | The SSH private key file to use when connecting to the machine. | |
360 | ||
361 | @item parallel-builds | |
362 | The number of builds that may run in parallel on the machine (1 by | |
363 | default.) | |
364 | ||
365 | @item speed | |
366 | A ``relative speed factor''. The offload scheduler will tend to prefer | |
367 | machines with a higher speed factor. | |
368 | ||
369 | @item features | |
370 | A list of strings denoting specific features supported by the machine. | |
371 | An example is @code{"kvm"} for machines that have the KVM Linux modules | |
372 | and corresponding hardware support. Derivations can request features by | |
373 | name, and they will be scheduled on matching build machines. | |
374 | ||
375 | @end table | |
376 | ||
377 | The @code{guix} command must be in the search path on the build | |
378 | machines, since offloading works by invoking the @code{guix archive} and | |
379 | @code{guix build} commands. | |
380 | ||
381 | There's one last thing to do once @file{machines.scm} is in place. As | |
382 | explained above, when offloading, files are transferred back and forth | |
383 | between the machine stores. For this to work, you need to generate a | |
384 | key pair to allow the daemon to export signed archives of files from the | |
385 | store (@pxref{Invoking guix archive}): | |
386 | ||
387 | @example | |
388 | # guix archive --generate-key | |
389 | @end example | |
390 | ||
391 | @noindent | |
392 | Thus, when receiving files, a machine's build daemon can make sure they | |
393 | are genuine, have not been tampered with, and that they are signed by an | |
394 | authorized key. | |
395 | ||
396 | ||
bd5e766b LC |
397 | @node Invoking guix-daemon |
398 | @section Invoking @command{guix-daemon} | |
399 | ||
400 | The @command{guix-daemon} program implements all the functionality to | |
401 | access the store. This includes launching build processes, running the | |
402 | garbage collector, querying the availability of a build result, etc. It | |
403 | is normally run as @code{root} like this: | |
404 | ||
405 | @example | |
406 | # guix-daemon --build-users-group=guix-builder | |
407 | @end example | |
408 | ||
409 | @noindent | |
410 | For details on how to set it up, @ref{Setting Up the Daemon}. | |
411 | ||
e900c503 LC |
412 | @cindex chroot |
413 | @cindex container, build environment | |
414 | @cindex build environment | |
415 | @cindex reproducible builds | |
bd5e766b LC |
416 | By default, @command{guix-daemon} launches build processes under |
417 | different UIDs, taken from the build group specified with | |
418 | @code{--build-users-group}. In addition, each build process is run in a | |
419 | chroot environment that only contains the subset of the store that the | |
420 | build process depends on, as specified by its derivation | |
421 | (@pxref{Programming Interface, derivation}), plus a set of specific | |
422 | system directories. By default, the latter contains @file{/dev} and | |
e900c503 LC |
423 | @file{/dev/pts}. Furthermore, on GNU/Linux, the build environment is a |
424 | @dfn{container}: in addition to having its own file system tree, it has | |
425 | a separate mount name space, its own PID name space, network name space, | |
426 | etc. This helps achieve reproducible builds (@pxref{Features}). | |
bd5e766b LC |
427 | |
428 | The following command-line options are supported: | |
429 | ||
430 | @table @code | |
431 | @item --build-users-group=@var{group} | |
432 | Take users from @var{group} to run build processes (@pxref{Setting Up | |
433 | the Daemon, build users}). | |
434 | ||
6858f9d1 | 435 | @item --no-substitutes |
b5385b52 | 436 | @cindex substitutes |
6858f9d1 | 437 | Do not use substitutes for build products. That is, always build things |
c4202d60 LC |
438 | locally instead of allowing downloads of pre-built binaries |
439 | (@pxref{Substitutes}). | |
6858f9d1 | 440 | |
b5385b52 LC |
441 | By default substitutes are used, unless the client---such as the |
442 | @command{guix package} command---is explicitly invoked with | |
443 | @code{--no-substitutes}. | |
444 | ||
445 | When the daemon runs with @code{--no-substitutes}, clients can still | |
446 | explicitly enable substitution @i{via} the @code{set-build-options} | |
447 | remote procedure call (@pxref{The Store}). | |
448 | ||
4ec2e92d LC |
449 | @cindex build hook |
450 | @item --no-build-hook | |
451 | Do not use the @dfn{build hook}. | |
452 | ||
453 | The build hook is a helper program that the daemon can start and to | |
454 | which it submits build requests. This mechanism is used to offload | |
455 | builds to other machines (@pxref{Daemon Offload Setup}). | |
456 | ||
bd5e766b LC |
457 | @item --cache-failures |
458 | Cache build failures. By default, only successful builds are cached. | |
459 | ||
460 | @item --cores=@var{n} | |
461 | @itemx -c @var{n} | |
462 | Use @var{n} CPU cores to build each derivation; @code{0} means as many | |
463 | as available. | |
464 | ||
465 | The default value is @code{1}, but it may be overridden by clients, such | |
e49951eb MW |
466 | as the @code{--cores} option of @command{guix build} (@pxref{Invoking |
467 | guix build}). | |
bd5e766b LC |
468 | |
469 | The effect is to define the @code{NIX_BUILD_CORES} environment variable | |
470 | in the build process, which can then use it to exploit internal | |
471 | parallelism---for instance, by running @code{make -j$NIX_BUILD_CORES}. | |
472 | ||
473 | @item --max-jobs=@var{n} | |
474 | @itemx -M @var{n} | |
475 | Allow at most @var{n} build jobs in parallel. The default value is | |
476 | @code{1}. | |
477 | ||
478 | @item --debug | |
479 | Produce debugging output. | |
480 | ||
481 | This is useful to debug daemon start-up issues, but then it may be | |
482 | overridden by clients, for example the @code{--verbosity} option of | |
e49951eb | 483 | @command{guix build} (@pxref{Invoking guix build}). |
bd5e766b LC |
484 | |
485 | @item --chroot-directory=@var{dir} | |
486 | Add @var{dir} to the build chroot. | |
487 | ||
488 | Doing this may change the result of build processes---for instance if | |
489 | they use optional dependencies found in @var{dir} when it is available, | |
490 | and not otherwise. For that reason, it is not recommended to do so. | |
491 | Instead, make sure that each derivation declares all the inputs that it | |
492 | needs. | |
493 | ||
494 | @item --disable-chroot | |
495 | Disable chroot builds. | |
496 | ||
497 | Using this option is not recommended since, again, it would allow build | |
498 | processes to gain access to undeclared dependencies. | |
499 | ||
500 | @item --disable-log-compression | |
501 | Disable compression of the build logs. | |
502 | ||
1da983b9 LC |
503 | Unless @code{--lose-logs} is used, all the build logs are kept in the |
504 | @var{localstatedir}. To save space, the daemon automatically compresses | |
505 | them with bzip2 by default. This option disables that. | |
506 | ||
bd5e766b LC |
507 | @item --disable-store-optimization |
508 | Disable automatic file ``deduplication'' in the store. | |
509 | ||
1da983b9 LC |
510 | By default, files added to the store are automatically ``deduplicated'': |
511 | if a newly added file is identical as another one found in the store, | |
512 | the daemon makes the new file a hard link to the other file. This | |
513 | slightly increases the input/output load at the end of a build process. | |
514 | This option disables this. | |
515 | ||
6e37066e LC |
516 | @item --gc-keep-outputs[=yes|no] |
517 | Tell whether the garbage collector (GC) must keep outputs of live | |
518 | derivations. | |
519 | ||
520 | When set to ``yes'', the GC will keep the outputs of any live derivation | |
521 | available in the store---the @code{.drv} files. The default is ``no'', | |
522 | meaning that derivation outputs are kept only if they are GC roots. | |
523 | ||
524 | @item --gc-keep-derivations[=yes|no] | |
525 | Tell whether the garbage collector (GC) must keep derivations | |
526 | corresponding to live outputs. | |
527 | ||
528 | When set to ``yes'', as is the case by default, the GC keeps | |
529 | derivations---i.e., @code{.drv} files---as long as at least one of their | |
530 | outputs is live. This allows users to keep track of the origins of | |
531 | items in their store. Setting it to ``no'' saves a bit of disk space. | |
532 | ||
533 | Note that when both @code{--gc-keep-derivations} and | |
534 | @code{--gc-keep-outputs} are used, the effect is to keep all the build | |
535 | prerequisites (the sources, compiler, libraries, and other build-time | |
536 | tools) of live objects in the store, regardless of whether these | |
537 | prerequisites are live. This is convenient for developers since it | |
538 | saves rebuilds or downloads. | |
539 | ||
bd5e766b LC |
540 | @item --impersonate-linux-2.6 |
541 | On Linux-based systems, impersonate Linux 2.6. This means that the | |
542 | kernel's @code{uname} system call will report 2.6 as the release number. | |
543 | ||
544 | This might be helpful to build programs that (usually wrongfully) depend | |
545 | on the kernel version number. | |
546 | ||
547 | @item --lose-logs | |
548 | Do not keep build logs. By default they are kept under | |
549 | @code{@var{localstatedir}/nix/log}. | |
550 | ||
551 | @item --system=@var{system} | |
552 | Assume @var{system} as the current system type. By default it is the | |
553 | architecture/kernel pair found at configure time, such as | |
554 | @code{x86_64-linux}. | |
b8d2aa26 LC |
555 | |
556 | @item --listen=@var{socket} | |
557 | Listen for connections on @var{socket}, the file name of a Unix-domain | |
558 | socket. The default socket is | |
559 | @file{@var{localstatedir}/daemon-socket/socket}. This option is only | |
560 | useful in exceptional circumstances, such as if you need to run several | |
561 | daemons on the same machine. | |
bd5e766b LC |
562 | @end table |
563 | ||
564 | ||
eeaf4427 LC |
565 | @c ********************************************************************* |
566 | @node Package Management | |
567 | @chapter Package Management | |
568 | ||
f8348b91 | 569 | The purpose of GNU Guix is to allow users to easily install, upgrade, and |
eeaf4427 LC |
570 | remove software packages, without having to know about their build |
571 | procedure or dependencies. Guix also goes beyond this obvious set of | |
572 | features. | |
573 | ||
574 | This chapter describes the main features of Guix, as well as the package | |
575 | management tools it provides. | |
576 | ||
577 | @menu | |
578 | * Features:: How Guix will make your life brighter. | |
e49951eb | 579 | * Invoking guix package:: Package installation, removal, etc. |
c4202d60 | 580 | * Substitutes:: Downloading pre-built binaries. |
760c60d6 | 581 | * Packages with Multiple Outputs:: Single source package, multiple outputs. |
e49951eb | 582 | * Invoking guix gc:: Running the garbage collector. |
f651b477 | 583 | * Invoking guix pull:: Fetching the latest Guix and distribution. |
760c60d6 | 584 | * Invoking guix archive:: Exporting and importing store files. |
eeaf4427 LC |
585 | @end menu |
586 | ||
587 | @node Features | |
588 | @section Features | |
589 | ||
590 | When using Guix, each package ends up in the @dfn{package store}, in its | |
591 | own directory---something that resembles | |
834129e0 | 592 | @file{/gnu/store/xxx-package-1.2}, where @code{xxx} is a base32 string. |
eeaf4427 LC |
593 | |
594 | Instead of referring to these directories, users have their own | |
595 | @dfn{profile}, which points to the packages that they actually want to | |
821b0015 LC |
596 | use. These profiles are stored within each user's home directory, at |
597 | @code{$HOME/.guix-profile}. | |
eeaf4427 | 598 | |
821b0015 | 599 | For example, @code{alice} installs GCC 4.7.2. As a result, |
eeaf4427 | 600 | @file{/home/alice/.guix-profile/bin/gcc} points to |
834129e0 | 601 | @file{/gnu/store/@dots{}-gcc-4.7.2/bin/gcc}. Now, on the same machine, |
821b0015 LC |
602 | @code{bob} had already installed GCC 4.8.0. The profile of @code{bob} |
603 | simply continues to point to | |
834129e0 | 604 | @file{/gnu/store/@dots{}-gcc-4.8.0/bin/gcc}---i.e., both versions of GCC |
821b0015 | 605 | coexist on the same system without any interference. |
eeaf4427 | 606 | |
e49951eb MW |
607 | The @command{guix package} command is the central tool to manage |
608 | packages (@pxref{Invoking guix package}). It operates on those per-user | |
821b0015 | 609 | profiles, and can be used @emph{with normal user privileges}. |
eeaf4427 LC |
610 | |
611 | The command provides the obvious install, remove, and upgrade | |
612 | operations. Each invocation is actually a @emph{transaction}: either | |
ba55b1cb | 613 | the specified operation succeeds, or nothing happens. Thus, if the |
e49951eb | 614 | @command{guix package} process is terminated during the transaction, |
eeaf4427 LC |
615 | or if a power outage occurs during the transaction, then the user's |
616 | profile remains in its previous state, and remains usable. | |
617 | ||
618 | In addition, any package transaction may be @emph{rolled back}. So, if, | |
619 | for example, an upgrade installs a new version of a package that turns | |
620 | out to have a serious bug, users may roll back to the previous instance | |
4af2447e LC |
621 | of their profile, which was known to work well. Similarly, the global |
622 | system configuration is subject to transactional upgrades and roll-back | |
623 | (@pxref{Using the Configuration System}). | |
eeaf4427 LC |
624 | |
625 | All those packages in the package store may be @emph{garbage-collected}. | |
626 | Guix can determine which packages are still referenced by the user | |
fe8ff028 | 627 | profiles, and remove those that are provably no longer referenced |
e49951eb | 628 | (@pxref{Invoking guix gc}). Users may also explicitly remove old |
fe8ff028 LC |
629 | generations of their profile so that the packages they refer to can be |
630 | collected. | |
eeaf4427 | 631 | |
e900c503 LC |
632 | @cindex reproducibility |
633 | @cindex reproducible builds | |
eeaf4427 LC |
634 | Finally, Guix takes a @dfn{purely functional} approach to package |
635 | management, as described in the introduction (@pxref{Introduction}). | |
834129e0 | 636 | Each @file{/gnu/store} package directory name contains a hash of all the |
eeaf4427 LC |
637 | inputs that were used to build that package---compiler, libraries, build |
638 | scripts, etc. This direct correspondence allows users to make sure a | |
639 | given package installation matches the current state of their | |
e900c503 LC |
640 | distribution. It also helps maximize @dfn{build reproducibility}: |
641 | thanks to the isolated build environments that are used, a given build | |
642 | is likely to yield bit-identical files when performed on different | |
643 | machines (@pxref{Invoking guix-daemon, container}). | |
eeaf4427 | 644 | |
c4202d60 | 645 | @cindex substitutes |
eeaf4427 | 646 | This foundation allows Guix to support @dfn{transparent binary/source |
c4202d60 | 647 | deployment}. When a pre-built binary for a @file{/gnu/store} item is |
18f2887b | 648 | available from an external source---a @dfn{substitute}, Guix just |
c4202d60 LC |
649 | downloads it and unpacks it; |
650 | otherwise, it builds the package from source, locally | |
651 | (@pxref{Substitutes}). | |
eeaf4427 | 652 | |
e49951eb MW |
653 | @node Invoking guix package |
654 | @section Invoking @command{guix package} | |
eeaf4427 | 655 | |
e49951eb | 656 | The @command{guix package} command is the tool that allows users to |
eeaf4427 LC |
657 | install, upgrade, and remove packages, as well as rolling back to |
658 | previous configurations. It operates only on the user's own profile, | |
659 | and works with normal user privileges (@pxref{Features}). Its syntax | |
660 | is: | |
661 | ||
662 | @example | |
e49951eb | 663 | guix package @var{options} |
eeaf4427 LC |
664 | @end example |
665 | ||
ba55b1cb | 666 | Primarily, @var{options} specifies the operations to be performed during |
eeaf4427 LC |
667 | the transaction. Upon completion, a new profile is created, but |
668 | previous generations of the profile remain available, should the user | |
669 | want to roll back. | |
670 | ||
6447738c MW |
671 | For example, to remove @code{lua} and install @code{guile} and |
672 | @code{guile-cairo} in a single transaction: | |
673 | ||
674 | @example | |
675 | guix package -r lua -i guile guile-cairo | |
676 | @end example | |
677 | ||
b9e5c0a9 | 678 | For each user, a symlink to the user's default profile is automatically |
0ec1af59 | 679 | created in @file{$HOME/.guix-profile}. This symlink always points to the |
b9e5c0a9 LC |
680 | current generation of the user's default profile. Thus, users can add |
681 | @file{$HOME/.guix-profile/bin} to their @code{PATH} environment | |
682 | variable, and so on. | |
683 | ||
0ec1af59 LC |
684 | In a multi-user setup, user profiles must be stored in a place |
685 | registered as a @dfn{garbage-collector root}, which | |
e49951eb | 686 | @file{$HOME/.guix-profile} points to (@pxref{Invoking guix gc}). That |
0ec1af59 LC |
687 | directory is normally |
688 | @code{@var{localstatedir}/profiles/per-user/@var{user}}, where | |
689 | @var{localstatedir} is the value passed to @code{configure} as | |
690 | @code{--localstatedir}, and @var{user} is the user name. It must be | |
691 | created by @code{root}, with @var{user} as the owner. When it does not | |
70c43291 LC |
692 | exist, or is not owned by @var{user}, @command{guix package} emits an |
693 | error about it. | |
0ec1af59 LC |
694 | |
695 | The @var{options} can be among the following: | |
696 | ||
eeaf4427 LC |
697 | @table @code |
698 | ||
6447738c MW |
699 | @item --install=@var{package} @dots{} |
700 | @itemx -i @var{package} @dots{} | |
701 | Install the specified @var{package}s. | |
eeaf4427 | 702 | |
6447738c | 703 | Each @var{package} may specify either a simple package name, such as |
eeaf4427 | 704 | @code{guile}, or a package name followed by a hyphen and version number, |
dc5669cd MW |
705 | such as @code{guile-1.8.8}. If no version number is specified, the |
706 | newest available version will be selected. In addition, @var{package} | |
707 | may contain a colon, followed by the name of one of the outputs of the | |
6e721c4d | 708 | package, as in @code{gcc:doc} or @code{binutils-2.22:lib} |
e7f34eb0 LC |
709 | (@pxref{Packages with Multiple Outputs}). Packages with a corresponding |
710 | name (and optionally version) are searched for among the GNU | |
711 | distribution modules (@pxref{Package Modules}). | |
eeaf4427 | 712 | |
461572cc LC |
713 | @cindex propagated inputs |
714 | Sometimes packages have @dfn{propagated inputs}: these are dependencies | |
715 | that automatically get installed along with the required package. | |
716 | ||
717 | An example is the GNU MPC library: its C header files refer to those of | |
718 | the GNU MPFR library, which in turn refer to those of the GMP library. | |
719 | Thus, when installing MPC, the MPFR and GMP libraries also get installed | |
720 | in the profile; removing MPC also removes MPFR and GMP---unless they had | |
721 | also been explicitly installed independently. | |
722 | ||
ba7ea5ce | 723 | Besides, packages sometimes rely on the definition of environment |
5924080d | 724 | variables for their search paths (see explanation of |
ba7ea5ce | 725 | @code{--search-paths} below). Any missing or possibly incorrect |
5924080d LC |
726 | environment variable definitions are reported here. |
727 | ||
ef010c0f | 728 | @c XXX: keep me up-to-date |
5924080d | 729 | Finally, when installing a GNU package, the tool reports the |
ef010c0f LC |
730 | availability of a newer upstream version. In the future, it may provide |
731 | the option of installing directly from the upstream version, even if | |
732 | that version is not yet in the distribution. | |
733 | ||
5d4b411f LC |
734 | @item --install-from-expression=@var{exp} |
735 | @itemx -e @var{exp} | |
736 | Install the package @var{exp} evaluates to. | |
737 | ||
738 | @var{exp} must be a Scheme expression that evaluates to a | |
739 | @code{<package>} object. This option is notably useful to disambiguate | |
740 | between same-named variants of a package, with expressions such as | |
741 | @code{(@@ (gnu packages base) guile-final)}. | |
742 | ||
743 | Note that this option installs the first output of the specified | |
744 | package, which may be insufficient when needing a specific output of a | |
745 | multiple-output package. | |
746 | ||
6447738c MW |
747 | @item --remove=@var{package} @dots{} |
748 | @itemx -r @var{package} @dots{} | |
749 | Remove the specified @var{package}s. | |
eeaf4427 | 750 | |
6447738c | 751 | As for @code{--install}, each @var{package} may specify a version number |
13ed095c LC |
752 | and/or output name in addition to the package name. For instance, |
753 | @code{-r glibc:debug} would remove the @code{debug} output of | |
754 | @code{glibc}. | |
755 | ||
6447738c MW |
756 | @item --upgrade[=@var{regexp} @dots{}] |
757 | @itemx -u [@var{regexp} @dots{}] | |
758 | Upgrade all the installed packages. If one or more @var{regexp}s are | |
759 | specified, upgrade only installed packages whose name matches a | |
760 | @var{regexp}. | |
eeaf4427 | 761 | |
f651b477 LC |
762 | Note that this upgrades package to the latest version of packages found |
763 | in the distribution currently installed. To update your distribution, | |
764 | you should regularly run @command{guix pull} (@pxref{Invoking guix | |
765 | pull}). | |
766 | ||
24e262f0 LC |
767 | @item --roll-back |
768 | Roll back to the previous @dfn{generation} of the profile---i.e., undo | |
769 | the last transaction. | |
770 | ||
771 | When combined with options such as @code{--install}, roll back occurs | |
772 | before any other actions. | |
773 | ||
d9307267 | 774 | When rolling back from the first generation that actually contains |
4b2bc804 NK |
775 | installed packages, the profile is made to point to the @dfn{zeroth |
776 | generation}, which contains no files apart from its own meta-data. | |
d9307267 | 777 | |
82fe08ed LC |
778 | Installing, removing, or upgrading packages from a generation that has |
779 | been rolled back to overwrites previous future generations. Thus, the | |
780 | history of a profile's generations is always linear. | |
781 | ||
5924080d LC |
782 | @item --search-paths |
783 | @cindex search paths | |
784 | Report environment variable definitions, in Bash syntax, that may be | |
785 | needed in order to use the set of installed packages. These environment | |
786 | variables are used to specify @dfn{search paths} for files used by some | |
787 | of the installed packages. | |
788 | ||
789 | For example, GCC needs the @code{CPATH} and @code{LIBRARY_PATH} | |
790 | environment variables to be defined so it can look for headers and | |
791 | libraries in the user's profile (@pxref{Environment Variables,,, gcc, | |
792 | Using the GNU Compiler Collection (GCC)}). If GCC and, say, the C | |
793 | library are installed in the profile, then @code{--search-paths} will | |
794 | suggest setting these variables to @code{@var{profile}/include} and | |
795 | @code{@var{profile}/lib}, respectively. | |
796 | ||
eeaf4427 LC |
797 | @item --profile=@var{profile} |
798 | @itemx -p @var{profile} | |
799 | Use @var{profile} instead of the user's default profile. | |
800 | ||
70915c1a LC |
801 | @item --verbose |
802 | Produce verbose output. In particular, emit the environment's build log | |
803 | on the standard error port. | |
804 | ||
eeaf4427 LC |
805 | @item --bootstrap |
806 | Use the bootstrap Guile to build the profile. This option is only | |
807 | useful to distribution developers. | |
808 | ||
809 | @end table | |
810 | ||
e49951eb | 811 | In addition to these actions @command{guix package} supports the |
733b4130 LC |
812 | following options to query the current state of a profile, or the |
813 | availability of packages: | |
eeaf4427 | 814 | |
733b4130 LC |
815 | @table @option |
816 | ||
acc08466 NK |
817 | @item --search=@var{regexp} |
818 | @itemx -s @var{regexp} | |
819 | List the available packages whose synopsis or description matches | |
299112d3 LC |
820 | @var{regexp}. Print all the meta-data of matching packages in |
821 | @code{recutils} format (@pxref{Top, GNU recutils databases,, recutils, | |
822 | GNU recutils manual}). | |
acc08466 | 823 | |
299112d3 LC |
824 | This allows specific fields to be extracted using the @command{recsel} |
825 | command, for instance: | |
826 | ||
827 | @example | |
e49951eb | 828 | $ guix package -s malloc | recsel -p name,version |
299112d3 LC |
829 | name: glibc |
830 | version: 2.17 | |
831 | ||
832 | name: libgc | |
833 | version: 7.2alpha6 | |
834 | @end example | |
acc08466 | 835 | |
a12d92f5 LC |
836 | Similarly, to show the name of all the packages available under the |
837 | terms of the GNU@tie{}LGPL version 3: | |
838 | ||
839 | @example | |
840 | $ guix package -s "" | recsel -p name -e 'license ~ "LGPL 3"' | |
841 | name: elfutils | |
842 | ||
843 | name: gmp | |
844 | @dots{} | |
845 | @end example | |
846 | ||
733b4130 LC |
847 | @item --list-installed[=@var{regexp}] |
848 | @itemx -I [@var{regexp}] | |
bd9bde1c LC |
849 | List the currently installed packages in the specified profile, with the |
850 | most recently installed packages shown last. When @var{regexp} is | |
851 | specified, list only installed packages whose name matches @var{regexp}. | |
733b4130 LC |
852 | |
853 | For each installed package, print the following items, separated by | |
854 | tabs: the package name, its version string, the part of the package that | |
855 | is installed (for instance, @code{out} for the default output, | |
856 | @code{include} for its headers, etc.), and the path of this package in | |
857 | the store. | |
858 | ||
64fc89b6 LC |
859 | @item --list-available[=@var{regexp}] |
860 | @itemx -A [@var{regexp}] | |
a1ba8475 LC |
861 | List packages currently available in the software distribution |
862 | (@pxref{GNU Distribution}). When @var{regexp} is specified, list only | |
863 | installed packages whose name matches @var{regexp}. | |
64fc89b6 LC |
864 | |
865 | For each package, print the following items separated by tabs: its name, | |
6e721c4d LC |
866 | its version string, the parts of the package (@pxref{Packages with |
867 | Multiple Outputs}), and the source location of its definition. | |
64fc89b6 | 868 | |
f566d765 LC |
869 | @item --list-generations[=@var{pattern}] |
870 | @itemx -l [@var{pattern}] | |
871 | Return a list of generations along with their creation dates; for each | |
872 | generation, show the installed packages, with the most recently | |
4b2bc804 NK |
873 | installed packages shown last. Note that the zeroth generation is never |
874 | shown. | |
f566d765 LC |
875 | |
876 | For each installed package, print the following items, separated by | |
877 | tabs: the name of a package, its version string, the part of the package | |
878 | that is installed (@pxref{Packages with Multiple Outputs}), and the | |
879 | location of this package in the store. | |
880 | ||
881 | When @var{pattern} is used, the command returns only matching | |
882 | generations. Valid patterns include: | |
883 | ||
884 | @itemize | |
885 | @item @emph{Integers and comma-separated integers}. Both patterns denote | |
886 | generation numbers. For instance, @code{--list-generations=1} returns | |
887 | the first one. | |
888 | ||
889 | And @code{--list-generations=1,8,2} outputs three generations in the | |
890 | specified order. Neither spaces nor trailing commas are allowed. | |
891 | ||
892 | @item @emph{Ranges}. @code{--list-generations=2..9} prints the | |
893 | specified generations and everything in between. Note that the start of | |
894 | a range must be lesser than its end. | |
895 | ||
896 | It is also possible to omit the endpoint. For example, | |
897 | @code{--list-generations=2..}, returns all generations starting from the | |
898 | second one. | |
899 | ||
900 | @item @emph{Durations}. You can also get the last @emph{N}@tie{}days, weeks, | |
901 | or months by passing an integer along with the first letter of the | |
d7ddb257 LC |
902 | duration. For example, @code{--list-generations=20d} lists generations |
903 | that are up to 20 days old. | |
f566d765 LC |
904 | @end itemize |
905 | ||
b7884ca3 NK |
906 | @item --delete-generations[=@var{pattern}] |
907 | @itemx -d [@var{pattern}] | |
d7ddb257 LC |
908 | When @var{pattern} is omitted, delete all generations except the current |
909 | one. | |
b7884ca3 NK |
910 | |
911 | This command accepts the same patterns as @option{--list-generations}. | |
d7ddb257 LC |
912 | When @var{pattern} is specified, delete the matching generations. When |
913 | @var{pattern} specifies a duration, generations @emph{older} than the | |
914 | specified duration match. For instance, @code{--delete-generations=1m} | |
915 | deletes generations that are more than one month old. | |
916 | ||
917 | If the current generation matches, it is deleted atomically---i.e., by | |
918 | switching to the previous available generation. Note that the zeroth | |
919 | generation is never deleted. | |
b7884ca3 | 920 | |
1bb9900a LC |
921 | Note that deleting generations prevents roll-back to them. |
922 | Consequently, this command must be used with care. | |
923 | ||
733b4130 | 924 | @end table |
eeaf4427 | 925 | |
70ee5642 LC |
926 | Finally, since @command{guix package} may actually start build |
927 | processes, it supports all the common build options that @command{guix | |
928 | build} supports (@pxref{Invoking guix build, common build options}). | |
929 | ||
c4202d60 LC |
930 | @node Substitutes |
931 | @section Substitutes | |
932 | ||
933 | @cindex substitutes | |
934 | @cindex pre-built binaries | |
935 | Guix supports transparent source/binary deployment, which means that it | |
936 | can either build things locally, or download pre-built items from a | |
937 | server. We call these pre-built items @dfn{substitutes}---they are | |
938 | substitutes for local build results. In many cases, downloading a | |
939 | substitute is much faster than building things locally. | |
940 | ||
941 | Substitutes can be anything resulting from a derivation build | |
942 | (@pxref{Derivations}). Of course, in the common case, they are | |
943 | pre-built package binaries, but source tarballs, for instance, which | |
944 | also result from derivation builds, can be available as substitutes. | |
945 | ||
946 | The @code{hydra.gnu.org} server is a front-end to a build farm that | |
947 | builds packages from the GNU distribution continuously for some | |
948 | architectures, and makes them available as substitutes. | |
949 | ||
950 | @cindex security | |
951 | @cindex digital signatures | |
952 | To allow Guix to download substitutes from @code{hydra.gnu.org}, you | |
953 | must add its public key to the access control list (ACL) of archive | |
954 | imports, using the @command{guix archive} command (@pxref{Invoking guix | |
955 | archive}). Doing so implies that you trust @code{hydra.gnu.org} to not | |
956 | be compromised and to serve genuine substitutes. | |
957 | ||
958 | This public key is installed along with Guix, in | |
959 | @code{@var{prefix}/share/guix/hydra.gnu.org.pub}, where @var{prefix} is | |
960 | the installation prefix of Guix. If you installed Guix from source, | |
961 | make sure you checked the GPG signature of | |
962 | @file{guix-@value{VERSION}.tar.gz}, which contains this public key file. | |
963 | Then, you can run something like this: | |
964 | ||
965 | @example | |
966 | # guix archive --authorize < hydra.gnu.org.pub | |
967 | @end example | |
968 | ||
969 | Once this is in place, the output of a command like @code{guix build} | |
970 | should change from something like: | |
971 | ||
972 | @example | |
973 | $ guix build emacs --dry-run | |
974 | The following derivations would be built: | |
975 | /gnu/store/yr7bnx8xwcayd6j95r2clmkdl1qh688w-emacs-24.3.drv | |
976 | /gnu/store/x8qsh1hlhgjx6cwsjyvybnfv2i37z23w-dbus-1.6.4.tar.gz.drv | |
977 | /gnu/store/1ixwp12fl950d15h2cj11c73733jay0z-alsa-lib-1.0.27.1.tar.bz2.drv | |
978 | /gnu/store/nlma1pw0p603fpfiqy7kn4zm105r5dmw-util-linux-2.21.drv | |
979 | @dots{} | |
980 | @end example | |
981 | ||
982 | @noindent | |
983 | to something like: | |
984 | ||
985 | @example | |
986 | $ guix build emacs --dry-run | |
987 | The following files would be downloaded: | |
988 | /gnu/store/pk3n22lbq6ydamyymqkkz7i69wiwjiwi-emacs-24.3 | |
989 | /gnu/store/2ygn4ncnhrpr61rssa6z0d9x22si0va3-libjpeg-8d | |
990 | /gnu/store/71yz6lgx4dazma9dwn2mcjxaah9w77jq-cairo-1.12.16 | |
991 | /gnu/store/7zdhgp0n1518lvfn8mb96sxqfmvqrl7v-libxrender-0.9.7 | |
992 | @dots{} | |
993 | @end example | |
994 | ||
995 | @noindent | |
996 | This indicates that substitutes from @code{hydra.gnu.org} are usable and | |
997 | will be downloaded, when possible, for future builds. | |
998 | ||
999 | Guix ignores substitutes that are not signed, or that are not signed by | |
ef27aa9c | 1000 | one of the keys listed in the ACL. It also detects and raises an error |
c4202d60 LC |
1001 | when attempting to use a substitute that has been tampered with. |
1002 | ||
1003 | The substitute mechanism can be disabled globally by running | |
1004 | @code{guix-daemon} with @code{--no-substitutes} (@pxref{Invoking | |
1005 | guix-daemon}). It can also be disabled temporarily by passing the | |
1006 | @code{--no-substitutes} option to @command{guix package}, @command{guix | |
1007 | build}, and other command-line tools. | |
1008 | ||
1009 | ||
1010 | Today, each individual's control over their own computing is at the | |
1011 | mercy of institutions, corporations, and groups with enough power and | |
1012 | determination to subvert the computing infrastructure and exploit its | |
1013 | weaknesses. While using @code{hydra.gnu.org} substitutes can be | |
1014 | convenient, we encourage users to also build on their own, or even run | |
1015 | their own build farm, such that @code{hydra.gnu.org} is less of an | |
1016 | interesting target. | |
1017 | ||
1018 | Guix has the foundations to maximize build reproducibility | |
1019 | (@pxref{Features}). In most cases, independent builds of a given | |
1020 | package or derivation should yield bit-identical results. Thus, through | |
1021 | a diverse set of independent package builds, we can strengthen the | |
1022 | integrity of our systems. | |
1023 | ||
1024 | In the future, we want Guix to have support to publish and retrieve | |
1025 | binaries to/from other users, in a peer-to-peer fashion. If you would | |
1026 | like to discuss this project, join us on @email{guix-devel@@gnu.org}. | |
1027 | ||
1028 | ||
6e721c4d LC |
1029 | @node Packages with Multiple Outputs |
1030 | @section Packages with Multiple Outputs | |
1031 | ||
1032 | @cindex multiple-output packages | |
1033 | @cindex package outputs | |
1034 | ||
1035 | Often, packages defined in Guix have a single @dfn{output}---i.e., the | |
1036 | source package leads exactly one directory in the store. When running | |
1037 | @command{guix package -i glibc}, one installs the default output of the | |
1038 | GNU libc package; the default output is called @code{out}, but its name | |
1039 | can be omitted as shown in this command. In this particular case, the | |
1040 | default output of @code{glibc} contains all the C header files, shared | |
1041 | libraries, static libraries, Info documentation, and other supporting | |
1042 | files. | |
1043 | ||
1044 | Sometimes it is more appropriate to separate the various types of files | |
1045 | produced from a single source package into separate outputs. For | |
1046 | instance, the GLib C library (used by GTK+ and related packages) | |
1047 | installs more than 20 MiB of reference documentation as HTML pages. | |
1048 | To save space for users who do not need it, the documentation goes to a | |
1049 | separate output, called @code{doc}. To install the main GLib output, | |
1050 | which contains everything but the documentation, one would run: | |
1051 | ||
1052 | @example | |
1053 | guix package -i glib | |
1054 | @end example | |
1055 | ||
1056 | The command to install its documentation is: | |
1057 | ||
1058 | @example | |
1059 | guix package -i glib:doc | |
1060 | @end example | |
1061 | ||
1062 | Some packages install programs with different ``dependency footprints''. | |
1063 | For instance, the WordNet package install both command-line tools and | |
1064 | graphical user interfaces (GUIs). The former depend solely on the C | |
1065 | library, whereas the latter depend on Tcl/Tk and the underlying X | |
1066 | libraries. In this case, we leave the command-line tools in the default | |
1067 | output, whereas the GUIs are in a separate output. This allows users | |
1068 | who do not need the GUIs to save space. | |
1069 | ||
1070 | There are several such multiple-output packages in the GNU distribution. | |
91ef73d4 LC |
1071 | Other conventional output names include @code{lib} for libraries and |
1072 | possibly header files, @code{bin} for stand-alone programs, and | |
1073 | @code{debug} for debugging information (@pxref{Installing Debugging | |
1074 | Files}). The outputs of a packages are listed in the third column of | |
1075 | the output of @command{guix package --list-available} (@pxref{Invoking | |
1076 | guix package}). | |
6e721c4d | 1077 | |
eeaf4427 | 1078 | |
e49951eb MW |
1079 | @node Invoking guix gc |
1080 | @section Invoking @command{guix gc} | |
fe8ff028 LC |
1081 | |
1082 | @cindex garbage collector | |
1083 | Packages that are installed but not used may be @dfn{garbage-collected}. | |
e49951eb | 1084 | The @command{guix gc} command allows users to explicitly run the garbage |
834129e0 | 1085 | collector to reclaim space from the @file{/gnu/store} directory. |
fe8ff028 LC |
1086 | |
1087 | The garbage collector has a set of known @dfn{roots}: any file under | |
834129e0 | 1088 | @file{/gnu/store} reachable from a root is considered @dfn{live} and |
fe8ff028 LC |
1089 | cannot be deleted; any other file is considered @dfn{dead} and may be |
1090 | deleted. The set of garbage collector roots includes default user | |
e49951eb MW |
1091 | profiles, and may be augmented with @command{guix build --root}, for |
1092 | example (@pxref{Invoking guix build}). | |
fe8ff028 | 1093 | |
1bb9900a LC |
1094 | Prior to running @code{guix gc --collect-garbage} to make space, it is |
1095 | often useful to remove old generations from user profiles; that way, old | |
1096 | package builds referenced by those generations can be reclaimed. This | |
1097 | is achieved by running @code{guix package --delete-generations} | |
1098 | (@pxref{Invoking guix package}). | |
1099 | ||
e49951eb | 1100 | The @command{guix gc} command has three modes of operation: it can be |
fe8ff028 LC |
1101 | used to garbage-collect any dead files (the default), to delete specific |
1102 | files (the @code{--delete} option), or to print garbage-collector | |
1103 | information. The available options are listed below: | |
1104 | ||
1105 | @table @code | |
1106 | @item --collect-garbage[=@var{min}] | |
1107 | @itemx -C [@var{min}] | |
834129e0 | 1108 | Collect garbage---i.e., unreachable @file{/gnu/store} files and |
fe8ff028 LC |
1109 | sub-directories. This is the default operation when no option is |
1110 | specified. | |
1111 | ||
1112 | When @var{min} is given, stop once @var{min} bytes have been collected. | |
1113 | @var{min} may be a number of bytes, or it may include a unit as a | |
1114 | suffix, such as @code{MiB} for mebibytes and @code{GB} for gigabytes. | |
1115 | ||
1116 | When @var{min} is omitted, collect all the garbage. | |
1117 | ||
1118 | @item --delete | |
1119 | @itemx -d | |
1120 | Attempt to delete all the store files and directories specified as | |
1121 | arguments. This fails if some of the files are not in the store, or if | |
1122 | they are still live. | |
1123 | ||
1124 | @item --list-dead | |
1125 | Show the list of dead files and directories still present in the | |
1126 | store---i.e., files and directories no longer reachable from any root. | |
1127 | ||
1128 | @item --list-live | |
1129 | Show the list of live store files and directories. | |
ba8b732d LC |
1130 | |
1131 | @end table | |
1132 | ||
1133 | In addition, the references among existing store files can be queried: | |
1134 | ||
1135 | @table @code | |
1136 | ||
1137 | @item --references | |
1138 | @itemx --referrers | |
1139 | List the references (respectively, the referrers) of store files given | |
1140 | as arguments. | |
1141 | ||
8e59fdd5 LC |
1142 | @item --requisites |
1143 | @itemx -R | |
1144 | List the requisites of the store files passed as arguments. Requisites | |
1145 | include the store files themselves, their references, and the references | |
1146 | of these, recursively. In other words, the returned list is the | |
1147 | @dfn{transitive closure} of the store files. | |
1148 | ||
fe8ff028 LC |
1149 | @end table |
1150 | ||
eeaf4427 | 1151 | |
f651b477 LC |
1152 | @node Invoking guix pull |
1153 | @section Invoking @command{guix pull} | |
1154 | ||
1155 | Packages are installed or upgraded to the latest version available in | |
1156 | the distribution currently available on your local machine. To update | |
1157 | that distribution, along with the Guix tools, you must run @command{guix | |
1158 | pull}: the command downloads the latest Guix source code and package | |
1159 | descriptions, and deploys it. | |
1160 | ||
1161 | On completion, @command{guix package} will use packages and package | |
1162 | versions from this just-retrieved copy of Guix. Not only that, but all | |
1163 | the Guix commands and Scheme modules will also be taken from that latest | |
1164 | version. New @command{guix} sub-commands added by the update also | |
1165 | become available. | |
1166 | ||
1167 | The @command{guix pull} command is usually invoked with no arguments, | |
1168 | but it supports the following options: | |
1169 | ||
1170 | @table @code | |
1171 | @item --verbose | |
1172 | Produce verbose output, writing build logs to the standard error output. | |
1173 | ||
ab5d72ad LC |
1174 | @item --url=@var{url} |
1175 | Download the source tarball of Guix from @var{url}. | |
1176 | ||
1177 | By default, the tarball is taken from its canonical address at | |
1178 | @code{gnu.org}, for the stable branch of Guix. | |
1179 | ||
f651b477 LC |
1180 | @item --bootstrap |
1181 | Use the bootstrap Guile to build the latest Guix. This option is only | |
1182 | useful to Guix developers. | |
1183 | @end table | |
1184 | ||
760c60d6 LC |
1185 | |
1186 | @node Invoking guix archive | |
1187 | @section Invoking @command{guix archive} | |
1188 | ||
1189 | The @command{guix archive} command allows users to @dfn{export} files | |
1190 | from the store into a single archive, and to later @dfn{import} them. | |
1191 | In particular, it allows store files to be transferred from one machine | |
1192 | to another machine's store. For example, to transfer the @code{emacs} | |
1193 | package to a machine connected over SSH, one would run: | |
1194 | ||
1195 | @example | |
1196 | guix archive --export emacs | ssh the-machine guix archive --import | |
1197 | @end example | |
1198 | ||
87236aed LC |
1199 | @noindent |
1200 | However, note that, in this example, all of @code{emacs} and its | |
1201 | dependencies are transferred, regardless of what is already available in | |
1202 | the target machine's store. The @code{--missing} option can help figure | |
1203 | out which items are missing from the target's store. | |
1204 | ||
760c60d6 | 1205 | Archives are stored in the ``Nix archive'' or ``Nar'' format, which is |
0dbd88db LC |
1206 | comparable in spirit to `tar', but with a few noteworthy differences |
1207 | that make it more appropriate for our purposes. First, rather than | |
1208 | recording all Unix meta-data for each file, the Nar format only mentions | |
1209 | the file type (regular, directory, or symbolic link); Unix permissions | |
1210 | and owner/group are dismissed. Second, the order in which directory | |
1211 | entries are stored always follows the order of file names according to | |
1212 | the C locale collation order. This makes archive production fully | |
1213 | deterministic. | |
1214 | ||
1215 | When exporting, the daemon digitally signs the contents of the archive, | |
1216 | and that digital signature is appended. When importing, the daemon | |
1217 | verifies the signature and rejects the import in case of an invalid | |
1218 | signature or if the signing key is not authorized. | |
760c60d6 LC |
1219 | @c FIXME: Add xref to daemon doc about signatures. |
1220 | ||
1221 | The main options are: | |
1222 | ||
1223 | @table @code | |
1224 | @item --export | |
1225 | Export the specified store files or packages (see below.) Write the | |
1226 | resulting archive to the standard output. | |
1227 | ||
1228 | @item --import | |
1229 | Read an archive from the standard input, and import the files listed | |
1230 | therein into the store. Abort if the archive has an invalid digital | |
f82cc5fd LC |
1231 | signature, or if it is signed by a public key not among the authorized |
1232 | keys (see @code{--authorize} below.) | |
554f26ec | 1233 | |
87236aed LC |
1234 | @item --missing |
1235 | Read a list of store file names from the standard input, one per line, | |
1236 | and write on the standard output the subset of these files missing from | |
1237 | the store. | |
1238 | ||
554f26ec | 1239 | @item --generate-key[=@var{parameters}] |
f82cc5fd | 1240 | @cindex signing, archives |
554f26ec LC |
1241 | Generate a new key pair for the daemons. This is a prerequisite before |
1242 | archives can be exported with @code{--export}. Note that this operation | |
1243 | usually takes time, because it needs to gather enough entropy to | |
1244 | generate the key pair. | |
1245 | ||
1246 | The generated key pair is typically stored under @file{/etc/guix}, in | |
1247 | @file{signing-key.pub} (public key) and @file{signing-key.sec} (private | |
1248 | key, which must be kept secret.) When @var{parameters} is omitted, it | |
1249 | is a 4096-bit RSA key. Alternately, @var{parameters} can specify | |
1250 | @code{genkey} parameters suitable for Libgcrypt (@pxref{General | |
1251 | public-key related Functions, @code{gcry_pk_genkey},, gcrypt, The | |
1252 | Libgcrypt Reference Manual}). | |
f82cc5fd LC |
1253 | |
1254 | @item --authorize | |
1255 | @cindex authorizing, archives | |
1256 | Authorize imports signed by the public key passed on standard input. | |
1257 | The public key must be in ``s-expression advanced format''---i.e., the | |
1258 | same format as the @file{signing-key.pub} file. | |
1259 | ||
1260 | The list of authorized keys is kept in the human-editable file | |
1261 | @file{/etc/guix/acl}. The file contains | |
1262 | @url{http://people.csail.mit.edu/rivest/Sexp.txt, ``advanced-format | |
1263 | s-expressions''} and is structured as an access-control list in the | |
1264 | @url{http://theworld.com/~cme/spki.txt, Simple Public-Key Infrastructure | |
1265 | (SPKI)}. | |
760c60d6 LC |
1266 | @end table |
1267 | ||
1268 | To export store files as an archive to the standard output, run: | |
1269 | ||
1270 | @example | |
1271 | guix archive --export @var{options} @var{specifications}... | |
1272 | @end example | |
1273 | ||
1274 | @var{specifications} may be either store file names or package | |
1275 | specifications, as for @command{guix package} (@pxref{Invoking guix | |
1276 | package}). For instance, the following command creates an archive | |
1277 | containing the @code{gui} output of the @code{git} package and the main | |
1278 | output of @code{emacs}: | |
1279 | ||
1280 | @example | |
834129e0 | 1281 | guix archive --export git:gui /gnu/store/...-emacs-24.3 > great.nar |
760c60d6 LC |
1282 | @end example |
1283 | ||
1284 | If the specified packages are not built yet, @command{guix archive} | |
1285 | automatically builds them. The build process may be controlled with the | |
1286 | same options that can be passed to the @command{guix build} command | |
70ee5642 | 1287 | (@pxref{Invoking guix build, common build options}). |
760c60d6 LC |
1288 | |
1289 | ||
568717fd LC |
1290 | @c ********************************************************************* |
1291 | @node Programming Interface | |
1292 | @chapter Programming Interface | |
1293 | ||
3dc1970d LC |
1294 | GNU Guix provides several Scheme programming interfaces (APIs) to |
1295 | define, build, and query packages. The first interface allows users to | |
1296 | write high-level package definitions. These definitions refer to | |
1297 | familiar packaging concepts, such as the name and version of a package, | |
1298 | its build system, and its dependencies. These definitions can then be | |
1299 | turned into concrete build actions. | |
1300 | ||
ba55b1cb | 1301 | Build actions are performed by the Guix daemon, on behalf of users. In a |
3dc1970d | 1302 | standard setup, the daemon has write access to the store---the |
834129e0 | 1303 | @file{/gnu/store} directory---whereas users do not. The recommended |
3dc1970d LC |
1304 | setup also has the daemon perform builds in chroots, under a specific |
1305 | build users, to minimize interference with the rest of the system. | |
1306 | ||
1307 | @cindex derivation | |
1308 | Lower-level APIs are available to interact with the daemon and the | |
1309 | store. To instruct the daemon to perform a build action, users actually | |
1310 | provide it with a @dfn{derivation}. A derivation is a low-level | |
1311 | representation of the build actions to be taken, and the environment in | |
1312 | which they should occur---derivations are to package definitions what | |
49ad317a LC |
1313 | assembly is to C programs. The term ``derivation'' comes from the fact |
1314 | that build results @emph{derive} from them. | |
3dc1970d LC |
1315 | |
1316 | This chapter describes all these APIs in turn, starting from high-level | |
1317 | package definitions. | |
1318 | ||
568717fd | 1319 | @menu |
b860f382 | 1320 | * Defining Packages:: Defining new packages. |
7458bd0a | 1321 | * Build Systems:: Specifying how packages are built. |
b860f382 LC |
1322 | * The Store:: Manipulating the package store. |
1323 | * Derivations:: Low-level interface to package derivations. | |
1324 | * The Store Monad:: Purely functional interface to the store. | |
21b679f6 | 1325 | * G-Expressions:: Manipulating build expressions. |
568717fd LC |
1326 | @end menu |
1327 | ||
1328 | @node Defining Packages | |
1329 | @section Defining Packages | |
1330 | ||
3dc1970d LC |
1331 | The high-level interface to package definitions is implemented in the |
1332 | @code{(guix packages)} and @code{(guix build-system)} modules. As an | |
1333 | example, the package definition, or @dfn{recipe}, for the GNU Hello | |
1334 | package looks like this: | |
1335 | ||
1336 | @example | |
e7f34eb0 LC |
1337 | (define-module (gnu packages hello) |
1338 | #:use-module (guix packages) | |
1339 | #:use-module (guix download) | |
1340 | #:use-module (guix build-system gnu) | |
1341 | #:use-module (guix licenses)) | |
b22a12fd | 1342 | |
3dc1970d LC |
1343 | (define hello |
1344 | (package | |
1345 | (name "hello") | |
1346 | (version "2.8") | |
1347 | (source (origin | |
1348 | (method url-fetch) | |
1349 | (uri (string-append "mirror://gnu/hello/hello-" version | |
1350 | ".tar.gz")) | |
1351 | (sha256 | |
1352 | (base32 "0wqd8sjmxfskrflaxywc7gqw7sfawrfvdxd9skxawzfgyy0pzdz6")))) | |
1353 | (build-system gnu-build-system) | |
7458bd0a | 1354 | (arguments `(#:configure-flags '("--enable-silent-rules"))) |
3dc1970d | 1355 | (inputs `(("gawk" ,gawk))) |
7458bd0a LC |
1356 | (synopsis "Hello, GNU world: An example GNU package") |
1357 | (description "Guess what GNU Hello prints!") | |
3dc1970d | 1358 | (home-page "http://www.gnu.org/software/hello/") |
b22a12fd | 1359 | (license gpl3+))) |
3dc1970d LC |
1360 | @end example |
1361 | ||
1362 | @noindent | |
1363 | Without being a Scheme expert, the reader may have guessed the meaning | |
e7f34eb0 | 1364 | of the various fields here. This expression binds variable @code{hello} |
3dc1970d LC |
1365 | to a @code{<package>} object, which is essentially a record |
1366 | (@pxref{SRFI-9, Scheme records,, guile, GNU Guile Reference Manual}). | |
1367 | This package object can be inspected using procedures found in the | |
1368 | @code{(guix packages)} module; for instance, @code{(package-name hello)} | |
1369 | returns---surprise!---@code{"hello"}. | |
1370 | ||
e7f34eb0 LC |
1371 | In the example above, @var{hello} is defined into a module of its own, |
1372 | @code{(gnu packages hello)}. Technically, this is not strictly | |
1373 | necessary, but it is convenient to do so: all the packages defined in | |
1374 | modules under @code{(gnu packages @dots{})} are automatically known to | |
1375 | the command-line tools (@pxref{Package Modules}). | |
1376 | ||
3dc1970d LC |
1377 | There are a few points worth noting in the above package definition: |
1378 | ||
1379 | @itemize | |
1380 | @item | |
1381 | The @code{source} field of the package is an @code{<origin>} object. | |
1382 | Here, the @code{url-fetch} method from @code{(guix download)} is used, | |
1383 | meaning that the source is a file to be downloaded over FTP or HTTP. | |
1384 | ||
1385 | The @code{mirror://gnu} prefix instructs @code{url-fetch} to use one of | |
1386 | the GNU mirrors defined in @code{(guix download)}. | |
1387 | ||
1388 | The @code{sha256} field specifies the expected SHA256 hash of the file | |
1389 | being downloaded. It is mandatory, and allows Guix to check the | |
1390 | integrity of the file. The @code{(base32 @dots{})} form introduces the | |
6c365eca | 1391 | base32 representation of the hash. You can obtain this information with |
210cc920 LC |
1392 | @code{guix download} (@pxref{Invoking guix download}) and @code{guix |
1393 | hash} (@pxref{Invoking guix hash}). | |
3dc1970d | 1394 | |
f9cc8971 LC |
1395 | @cindex patches |
1396 | When needed, the @code{origin} form can also have a @code{patches} field | |
1397 | listing patches to be applied, and a @code{snippet} field giving a | |
1398 | Scheme expression to modify the source code. | |
1399 | ||
3dc1970d LC |
1400 | @item |
1401 | @cindex GNU Build System | |
7458bd0a LC |
1402 | The @code{build-system} field specifies the procedure to build the |
1403 | package (@pxref{Build Systems}). Here, @var{gnu-build-system} | |
1404 | represents the familiar GNU Build System, where packages may be | |
1405 | configured, built, and installed with the usual @code{./configure && | |
1406 | make && make check && make install} command sequence. | |
1407 | ||
1408 | @item | |
1409 | The @code{arguments} field specifies options for the build system | |
1410 | (@pxref{Build Systems}). Here it is interpreted by | |
1411 | @var{gnu-build-system} as a request run @file{configure} with the | |
1412 | @code{--enable-silent-rules} flag. | |
3dc1970d LC |
1413 | |
1414 | @item | |
1415 | The @code{inputs} field specifies inputs to the build process---i.e., | |
1416 | build-time or run-time dependencies of the package. Here, we define an | |
1417 | input called @code{"gawk"} whose value is that of the @var{gawk} | |
1418 | variable; @var{gawk} is itself bound to a @code{<package>} object. | |
1419 | ||
1420 | Note that GCC, Coreutils, Bash, and other essential tools do not need to | |
1421 | be specified as inputs here. Instead, @var{gnu-build-system} takes care | |
7458bd0a | 1422 | of ensuring that they are present (@pxref{Build Systems}). |
3dc1970d LC |
1423 | |
1424 | However, any other dependencies need to be specified in the | |
1425 | @code{inputs} field. Any dependency not specified here will simply be | |
1426 | unavailable to the build process, possibly leading to a build failure. | |
1427 | @end itemize | |
1428 | ||
3dc1970d LC |
1429 | Once a package definition is in place@footnote{Simple package |
1430 | definitions like the one above may be automatically converted from the | |
e49951eb MW |
1431 | Nixpkgs distribution using the @command{guix import} command.}, the |
1432 | package may actually be built using the @code{guix build} command-line | |
7458bd0a LC |
1433 | tool (@pxref{Invoking guix build}). @xref{Packaging Guidelines}, for |
1434 | more information on how to test package definitions. | |
1435 | ||
1436 | Eventually, updating the package definition to a new upstream version | |
1437 | can be partly automated by the @command{guix refresh} command | |
1438 | (@pxref{Invoking guix refresh}). | |
3dc1970d LC |
1439 | |
1440 | Behind the scenes, a derivation corresponding to the @code{<package>} | |
1441 | object is first computed by the @code{package-derivation} procedure. | |
834129e0 | 1442 | That derivation is stored in a @code{.drv} file under @file{/gnu/store}. |
ba55b1cb | 1443 | The build actions it prescribes may then be realized by using the |
3dc1970d LC |
1444 | @code{build-derivations} procedure (@pxref{The Store}). |
1445 | ||
1446 | @deffn {Scheme Procedure} package-derivation @var{store} @var{package} [@var{system}] | |
59688fc4 LC |
1447 | Return the @code{<derivation>} object of @var{package} for @var{system} |
1448 | (@pxref{Derivations}). | |
3dc1970d LC |
1449 | |
1450 | @var{package} must be a valid @code{<package>} object, and @var{system} | |
1451 | must be a string denoting the target system type---e.g., | |
1452 | @code{"x86_64-linux"} for an x86_64 Linux-based GNU system. @var{store} | |
1453 | must be a connection to the daemon, which operates on the store | |
1454 | (@pxref{The Store}). | |
1455 | @end deffn | |
568717fd | 1456 | |
9c1edabd LC |
1457 | @noindent |
1458 | @cindex cross-compilation | |
1459 | Similarly, it is possible to compute a derivation that cross-builds a | |
1460 | package for some other system: | |
1461 | ||
1462 | @deffn {Scheme Procedure} package-cross-derivation @var{store} @ | |
1463 | @var{package} @var{target} [@var{system}] | |
59688fc4 LC |
1464 | Return the @code{<derivation>} object of @var{package} cross-built from |
1465 | @var{system} to @var{target}. | |
9c1edabd LC |
1466 | |
1467 | @var{target} must be a valid GNU triplet denoting the target hardware | |
1468 | and operating system, such as @code{"mips64el-linux-gnu"} | |
1469 | (@pxref{Configuration Names, GNU configuration triplets,, configure, GNU | |
1470 | Configure and Build System}). | |
1471 | @end deffn | |
1472 | ||
1473 | ||
7458bd0a LC |
1474 | @node Build Systems |
1475 | @section Build Systems | |
1476 | ||
1477 | @cindex build system | |
1478 | Each package definition specifies a @dfn{build system} and arguments for | |
1479 | that build system (@pxref{Defining Packages}). This @code{build-system} | |
1480 | field represents the build procedure of the package, as well implicit | |
1481 | dependencies of that build procedure. | |
1482 | ||
1483 | Build systems are @code{<build-system>} objects. The interface to | |
1484 | create and manipulate them is provided by the @code{(guix build-system)} | |
1485 | module, and actual build systems are exported by specific modules. | |
1486 | ||
1487 | Build systems accept an optional list of @dfn{arguments}. In package | |
1488 | definitions, these are passed @i{via} the @code{arguments} field | |
1489 | (@pxref{Defining Packages}). They are typically keyword arguments | |
1490 | (@pxref{Optional Arguments, keyword arguments in Guile,, guile, GNU | |
1491 | Guile Reference Manual}). The value of these arguments is usually | |
1492 | evaluated in the @dfn{build stratum}---i.e., by a Guile process launched | |
1493 | by the daemon (@pxref{Derivations}). | |
1494 | ||
1495 | The main build system is @var{gnu-build-system}, which implements the | |
1496 | standard build procedure for GNU packages and many other packages. It | |
1497 | is provided by the @code{(guix build-system gnu)} module. | |
1498 | ||
1499 | @defvr {Scheme Variable} gnu-build-system | |
1500 | @var{gnu-build-system} represents the GNU Build System, and variants | |
1501 | thereof (@pxref{Configuration, configuration and makefile conventions,, | |
1502 | standards, GNU Coding Standards}). | |
1503 | ||
1504 | @cindex build phases | |
1505 | In a nutshell, packages using it configured, built, and installed with | |
1506 | the usual @code{./configure && make && make check && make install} | |
1507 | command sequence. In practice, a few additional steps are often needed. | |
1508 | All these steps are split up in separate @dfn{phases}, | |
1509 | notably@footnote{Please see the @code{(guix build gnu-build-system)} | |
1510 | modules for more details about the build phases.}: | |
1511 | ||
1512 | @table @code | |
1513 | @item unpack | |
1514 | Unpack the source tarball, and change the current directory to the | |
1515 | extracted source tree. If the source is actually a directory, copy it | |
1516 | to the build tree, and enter that directory. | |
1517 | ||
1518 | @item patch-source-shebangs | |
1519 | Patch shebangs encountered in source files so they refer to the right | |
1520 | store file names. For instance, this changes @code{#!/bin/sh} to | |
1521 | @code{#!/gnu/store/@dots{}-bash-4.3/bin/sh}. | |
1522 | ||
1523 | @item configure | |
1524 | Run the @file{configure} script with a number of default options, such | |
1525 | as @code{--prefix=/gnu/store/@dots{}}, as well as the options specified | |
1526 | by the @code{#:configure-flags} argument. | |
1527 | ||
1528 | @item build | |
1529 | Run @code{make} with the list of flags specified with | |
1530 | @code{#:make-flags}. If the @code{#:parallel-builds?} argument is true | |
1531 | (the default), build with @code{make -j}. | |
1532 | ||
1533 | @item check | |
1534 | Run @code{make check}, or some other target specified with | |
1535 | @code{#:test-target}, unless @code{#:tests? #f} is passed. If the | |
1536 | @code{#:parallel-tests?} argument is true (the default), run @code{make | |
1537 | check -j}. | |
1538 | ||
1539 | @item install | |
1540 | Run @code{make install} with the flags listed in @code{#:make-flags}. | |
1541 | ||
1542 | @item patch-shebangs | |
1543 | Patch shebangs on the installed executable files. | |
1544 | ||
1545 | @item strip | |
1546 | Strip debugging symbols from ELF files (unless @code{#:strip-binaries?} | |
1547 | is false), copying them to the @code{debug} output when available | |
1548 | (@pxref{Installing Debugging Files}). | |
1549 | @end table | |
1550 | ||
1551 | @vindex %standard-phases | |
1552 | The build-side module @code{(guix build gnu-build-system)} defines | |
1553 | @var{%standard-phases} as the default list of build phases. | |
1554 | @var{%standard-phases} is a list of symbol/procedure pairs, where the | |
1555 | procedure implements the actual phase. | |
1556 | ||
1557 | The list of phases used for a particular package can be changed with the | |
1558 | @code{#:phases} parameter. For instance, passing: | |
1559 | ||
1560 | @example | |
1561 | #:phases (alist-delete 'configure %standard-phases) | |
1562 | @end example | |
1563 | ||
9bf404e9 | 1564 | means that all the phases described above will be used, except the |
7458bd0a LC |
1565 | @code{configure} phase. |
1566 | ||
1567 | In addition, this build system ensures that the ``standard'' environment | |
1568 | for GNU packages is available. This includes tools such as GCC, libc, | |
1569 | Coreutils, Bash, Make, Diffutils, grep, and sed (see the @code{(guix | |
1570 | build-system gnu)} module for a complete list.) We call these the | |
1571 | @dfn{implicit inputs} of a package, because package definitions don't | |
1572 | have to mention them. | |
1573 | @end defvr | |
1574 | ||
1575 | Other @code{<build-system>} objects are defined to support other | |
1576 | conventions and tools used by free software packages. They inherit most | |
1577 | of @var{gnu-build-system}, and differ mainly in the set of inputs | |
1578 | implicitly added to the build process, and in the list of phases | |
1579 | executed. Some of these build systems are listed below. | |
1580 | ||
1581 | @defvr {Scheme Variable} cmake-build-system | |
1582 | This variable is exported by @code{(guix build-system cmake)}. It | |
1583 | implements the build procedure for packages using the | |
1584 | @url{http://www.cmake.org, CMake build tool}. | |
1585 | ||
1586 | It automatically adds the @code{cmake} package to the set of inputs. | |
1587 | Which package is used can be specified with the @code{#:cmake} | |
1588 | parameter. | |
1589 | @end defvr | |
1590 | ||
1591 | @defvr {Scheme Variable} python-build-system | |
1592 | This variable is exported by @code{(guix build-system python)}. It | |
1593 | implements the more or less standard build procedure used by Python | |
1594 | packages, which consists in running @code{python setup.py build} and | |
1595 | then @code{python setup.py install --prefix=/gnu/store/@dots{}}. | |
1596 | ||
1597 | For packages that install stand-alone Python programs under @code{bin/}, | |
1598 | it takes care of wrapping these programs so their @code{PYTHONPATH} | |
1599 | environment variable points to all the Python libraries they depend on. | |
1600 | ||
1601 | Which Python package is used can be specified with the @code{#:python} | |
1602 | parameter. | |
1603 | @end defvr | |
1604 | ||
1605 | @defvr {Scheme Variable} perl-build-system | |
1606 | This variable is exported by @code{(guix build-system perl)}. It | |
1607 | implements the standard build procedure for Perl packages, which | |
1608 | consists in running @code{perl Makefile.PL PREFIX=/gnu/store/@dots{}}, | |
1609 | followed by @code{make} and @code{make install}. | |
1610 | ||
1611 | The initial @code{perl Makefile.PL} invocation passes flags specified by | |
1612 | the @code{#:make-maker-flags} parameter. | |
1613 | ||
1614 | Which Perl package is used can be specified with @code{#:perl}. | |
1615 | @end defvr | |
1616 | ||
1617 | ||
1618 | Lastly, for packages that do not need anything as sophisticated, a | |
1619 | ``trivial'' build system is provided. It is trivial in the sense that | |
1620 | it provides basically no support: it does not pull any implicit inputs, | |
1621 | and does not have a notion of build phases. | |
1622 | ||
1623 | @defvr {Scheme Variable} trivial-build-system | |
1624 | This variable is exported by @code{(guix build-system trivial)}. | |
1625 | ||
1626 | This build system requires a @code{#:builder} argument. This argument | |
1627 | must be a Scheme expression that builds the package's output(s)---as | |
1628 | with @code{build-expression->derivation} (@pxref{Derivations, | |
1629 | @code{build-expression->derivation}}). | |
1630 | @end defvr | |
1631 | ||
568717fd LC |
1632 | @node The Store |
1633 | @section The Store | |
1634 | ||
e531ac2a LC |
1635 | @cindex store |
1636 | @cindex store paths | |
1637 | ||
1638 | Conceptually, the @dfn{store} is where derivations that have been | |
834129e0 | 1639 | successfully built are stored---by default, under @file{/gnu/store}. |
e531ac2a LC |
1640 | Sub-directories in the store are referred to as @dfn{store paths}. The |
1641 | store has an associated database that contains information such has the | |
1642 | store paths referred to by each store path, and the list of @emph{valid} | |
1643 | store paths---paths that result from a successful build. | |
1644 | ||
1645 | The store is always accessed by the daemon on behalf of its clients | |
1646 | (@pxref{Invoking guix-daemon}). To manipulate the store, clients | |
1647 | connect to the daemon over a Unix-domain socket, send it requests, and | |
1648 | read the result---these are remote procedure calls, or RPCs. | |
1649 | ||
1650 | The @code{(guix store)} module provides procedures to connect to the | |
1651 | daemon, and to perform RPCs. These are described below. | |
1652 | ||
1653 | @deffn {Scheme Procedure} open-connection [@var{file}] [#:reserve-space? #t] | |
1654 | Connect to the daemon over the Unix-domain socket at @var{file}. When | |
1655 | @var{reserve-space?} is true, instruct it to reserve a little bit of | |
1656 | extra space on the file system so that the garbage collector can still | |
1657 | operate, should the disk become full. Return a server object. | |
1658 | ||
1659 | @var{file} defaults to @var{%default-socket-path}, which is the normal | |
1660 | location given the options that were passed to @command{configure}. | |
1661 | @end deffn | |
1662 | ||
1663 | @deffn {Scheme Procedure} close-connection @var{server} | |
1664 | Close the connection to @var{server}. | |
1665 | @end deffn | |
1666 | ||
1667 | @defvr {Scheme Variable} current-build-output-port | |
1668 | This variable is bound to a SRFI-39 parameter, which refers to the port | |
1669 | where build and error logs sent by the daemon should be written. | |
1670 | @end defvr | |
1671 | ||
1672 | Procedures that make RPCs all take a server object as their first | |
1673 | argument. | |
1674 | ||
1675 | @deffn {Scheme Procedure} valid-path? @var{server} @var{path} | |
1676 | Return @code{#t} when @var{path} is a valid store path. | |
1677 | @end deffn | |
1678 | ||
cfbf9160 | 1679 | @deffn {Scheme Procedure} add-text-to-store @var{server} @var{name} @var{text} [@var{references}] |
e531ac2a LC |
1680 | Add @var{text} under file @var{name} in the store, and return its store |
1681 | path. @var{references} is the list of store paths referred to by the | |
1682 | resulting store path. | |
1683 | @end deffn | |
1684 | ||
874e6874 | 1685 | @deffn {Scheme Procedure} build-derivations @var{server} @var{derivations} |
59688fc4 LC |
1686 | Build @var{derivations} (a list of @code{<derivation>} objects or |
1687 | derivation paths), and return when the worker is done building them. | |
1688 | Return @code{#t} on success. | |
874e6874 LC |
1689 | @end deffn |
1690 | ||
b860f382 LC |
1691 | Note that the @code{(guix monads)} module provides a monad as well as |
1692 | monadic versions of the above procedures, with the goal of making it | |
1693 | more convenient to work with code that accesses the store (@pxref{The | |
1694 | Store Monad}). | |
1695 | ||
e531ac2a LC |
1696 | @c FIXME |
1697 | @i{This section is currently incomplete.} | |
568717fd LC |
1698 | |
1699 | @node Derivations | |
1700 | @section Derivations | |
1701 | ||
874e6874 LC |
1702 | @cindex derivations |
1703 | Low-level build actions and the environment in which they are performed | |
1704 | are represented by @dfn{derivations}. A derivation contain the | |
1705 | following pieces of information: | |
1706 | ||
1707 | @itemize | |
1708 | @item | |
1709 | The outputs of the derivation---derivations produce at least one file or | |
1710 | directory in the store, but may produce more. | |
1711 | ||
1712 | @item | |
1713 | The inputs of the derivations, which may be other derivations or plain | |
1714 | files in the store (patches, build scripts, etc.) | |
1715 | ||
1716 | @item | |
1717 | The system type targeted by the derivation---e.g., @code{x86_64-linux}. | |
1718 | ||
1719 | @item | |
1720 | The file name of a build script in the store, along with the arguments | |
1721 | to be passed. | |
1722 | ||
1723 | @item | |
1724 | A list of environment variables to be defined. | |
1725 | ||
1726 | @end itemize | |
1727 | ||
1728 | @cindex derivation path | |
1729 | Derivations allow clients of the daemon to communicate build actions to | |
1730 | the store. They exist in two forms: as an in-memory representation, | |
1731 | both on the client- and daemon-side, and as files in the store whose | |
1732 | name end in @code{.drv}---these files are referred to as @dfn{derivation | |
1733 | paths}. Derivations paths can be passed to the @code{build-derivations} | |
1734 | procedure to perform the build actions they prescribe (@pxref{The | |
1735 | Store}). | |
1736 | ||
1737 | The @code{(guix derivations)} module provides a representation of | |
1738 | derivations as Scheme objects, along with procedures to create and | |
1739 | otherwise manipulate derivations. The lowest-level primitive to create | |
1740 | a derivation is the @code{derivation} procedure: | |
1741 | ||
1909431c LC |
1742 | @deffn {Scheme Procedure} derivation @var{store} @var{name} @var{builder} @ |
1743 | @var{args} [#:outputs '("out")] [#:hash #f] [#:hash-algo #f] @ | |
2096ef47 | 1744 | [#:recursive? #f] [#:inputs '()] [#:env-vars '()] @ |
1909431c | 1745 | [#:system (%current-system)] [#:references-graphs #f] @ |
b53be755 | 1746 | [#:allowed-references #f] [#:local-build? #f] |
59688fc4 LC |
1747 | Build a derivation with the given arguments, and return the resulting |
1748 | @code{<derivation>} object. | |
874e6874 | 1749 | |
2096ef47 | 1750 | When @var{hash} and @var{hash-algo} are given, a |
874e6874 | 1751 | @dfn{fixed-output derivation} is created---i.e., one whose result is |
36bbbbd1 LC |
1752 | known in advance, such as a file download. If, in addition, |
1753 | @var{recursive?} is true, then that fixed output may be an executable | |
1754 | file or a directory and @var{hash} must be the hash of an archive | |
1755 | containing this output. | |
5b0c9d16 | 1756 | |
858e9282 | 1757 | When @var{references-graphs} is true, it must be a list of file |
5b0c9d16 LC |
1758 | name/store path pairs. In that case, the reference graph of each store |
1759 | path is exported in the build environment in the corresponding file, in | |
1760 | a simple text format. | |
1909431c | 1761 | |
b53be755 LC |
1762 | When @var{allowed-references} is true, it must be a list of store items |
1763 | or outputs that the derivation's output may refer to. | |
1764 | ||
1909431c LC |
1765 | When @var{local-build?} is true, declare that the derivation is not a |
1766 | good candidate for offloading and should rather be built locally | |
1767 | (@pxref{Daemon Offload Setup}). This is the case for small derivations | |
1768 | where the costs of data transfers would outweigh the benefits. | |
874e6874 LC |
1769 | @end deffn |
1770 | ||
1771 | @noindent | |
1772 | Here's an example with a shell script as its builder, assuming | |
1773 | @var{store} is an open connection to the daemon, and @var{bash} points | |
1774 | to a Bash executable in the store: | |
1775 | ||
1776 | @lisp | |
1777 | (use-modules (guix utils) | |
1778 | (guix store) | |
1779 | (guix derivations)) | |
1780 | ||
59688fc4 LC |
1781 | (let ((builder ; add the Bash script to the store |
1782 | (add-text-to-store store "my-builder.sh" | |
1783 | "echo hello world > $out\n" '()))) | |
1784 | (derivation store "foo" | |
1785 | bash `("-e" ,builder) | |
21b679f6 | 1786 | #:inputs `((,bash) (,builder)) |
59688fc4 | 1787 | #:env-vars '(("HOME" . "/homeless")))) |
834129e0 | 1788 | @result{} #<derivation /gnu/store/@dots{}-foo.drv => /gnu/store/@dots{}-foo> |
874e6874 LC |
1789 | @end lisp |
1790 | ||
21b679f6 LC |
1791 | As can be guessed, this primitive is cumbersome to use directly. A |
1792 | better approach is to write build scripts in Scheme, of course! The | |
1793 | best course of action for that is to write the build code as a | |
1794 | ``G-expression'', and to pass it to @code{gexp->derivation}. For more | |
1795 | information, @ref{G-Expressions}. | |
1796 | ||
1797 | Once upon a time, @code{gexp->derivation} did not exist and constructing | |
1798 | derivations with build code written in Scheme was achieved with | |
1799 | @code{build-expression->derivation}, documented below. This procedure | |
1800 | is now deprecated in favor of the much nicer @code{gexp->derivation}. | |
874e6874 | 1801 | |
dd1a5a15 LC |
1802 | @deffn {Scheme Procedure} build-expression->derivation @var{store} @ |
1803 | @var{name} @var{exp} @ | |
1804 | [#:system (%current-system)] [#:inputs '()] @ | |
1805 | [#:outputs '("out")] [#:hash #f] [#:hash-algo #f] @ | |
36bbbbd1 | 1806 | [#:recursive? #f] [#:env-vars '()] [#:modules '()] @ |
63a42824 LC |
1807 | [#:references-graphs #f] [#:allowed-references #f] @ |
1808 | [#:local-build? #f] [#:guile-for-build #f] | |
874e6874 LC |
1809 | Return a derivation that executes Scheme expression @var{exp} as a |
1810 | builder for derivation @var{name}. @var{inputs} must be a list of | |
1811 | @code{(name drv-path sub-drv)} tuples; when @var{sub-drv} is omitted, | |
1812 | @code{"out"} is assumed. @var{modules} is a list of names of Guile | |
1813 | modules from the current search path to be copied in the store, | |
1814 | compiled, and made available in the load path during the execution of | |
1815 | @var{exp}---e.g., @code{((guix build utils) (guix build | |
1816 | gnu-build-system))}. | |
1817 | ||
1818 | @var{exp} is evaluated in an environment where @code{%outputs} is bound | |
1819 | to a list of output/path pairs, and where @code{%build-inputs} is bound | |
1820 | to a list of string/output-path pairs made from @var{inputs}. | |
1821 | Optionally, @var{env-vars} is a list of string pairs specifying the name | |
1822 | and value of environment variables visible to the builder. The builder | |
1823 | terminates by passing the result of @var{exp} to @code{exit}; thus, when | |
1824 | @var{exp} returns @code{#f}, the build is considered to have failed. | |
1825 | ||
1826 | @var{exp} is built using @var{guile-for-build} (a derivation). When | |
1827 | @var{guile-for-build} is omitted or is @code{#f}, the value of the | |
1828 | @code{%guile-for-build} fluid is used instead. | |
9c629a27 | 1829 | |
63a42824 LC |
1830 | See the @code{derivation} procedure for the meaning of |
1831 | @var{references-graphs}, @var{allowed-references}, and @var{local-build?}. | |
874e6874 LC |
1832 | @end deffn |
1833 | ||
1834 | @noindent | |
1835 | Here's an example of a single-output derivation that creates a directory | |
1836 | containing one file: | |
1837 | ||
1838 | @lisp | |
1839 | (let ((builder '(let ((out (assoc-ref %outputs "out"))) | |
834129e0 | 1840 | (mkdir out) ; create /gnu/store/@dots{}-goo |
874e6874 LC |
1841 | (call-with-output-file (string-append out "/test") |
1842 | (lambda (p) | |
1843 | (display '(hello guix) p)))))) | |
dd1a5a15 | 1844 | (build-expression->derivation store "goo" builder)) |
874e6874 | 1845 | |
834129e0 | 1846 | @result{} #<derivation /gnu/store/@dots{}-goo.drv => @dots{}> |
874e6874 LC |
1847 | @end lisp |
1848 | ||
568717fd | 1849 | |
b860f382 LC |
1850 | @node The Store Monad |
1851 | @section The Store Monad | |
1852 | ||
1853 | @cindex monad | |
1854 | ||
1855 | The procedures that operate on the store described in the previous | |
1856 | sections all take an open connection to the build daemon as their first | |
1857 | argument. Although the underlying model is functional, they either have | |
1858 | side effects or depend on the current state of the store. | |
1859 | ||
1860 | The former is inconvenient: the connection to the build daemon has to be | |
1861 | carried around in all those functions, making it impossible to compose | |
1862 | functions that do not take that parameter with functions that do. The | |
1863 | latter can be problematic: since store operations have side effects | |
1864 | and/or depend on external state, they have to be properly sequenced. | |
1865 | ||
1866 | @cindex monadic values | |
1867 | @cindex monadic functions | |
1868 | This is where the @code{(guix monads)} module comes in. This module | |
1869 | provides a framework for working with @dfn{monads}, and a particularly | |
1870 | useful monad for our uses, the @dfn{store monad}. Monads are a | |
1871 | construct that allows two things: associating ``context'' with values | |
1872 | (in our case, the context is the store), and building sequences of | |
1873 | computations (here computations includes accesses to the store.) Values | |
1874 | in a monad---values that carry this additional context---are called | |
1875 | @dfn{monadic values}; procedures that return such values are called | |
1876 | @dfn{monadic procedures}. | |
1877 | ||
1878 | Consider this ``normal'' procedure: | |
1879 | ||
1880 | @example | |
45adbd62 LC |
1881 | (define (sh-symlink store) |
1882 | ;; Return a derivation that symlinks the 'bash' executable. | |
1883 | (let* ((drv (package-derivation store bash)) | |
1884 | (out (derivation->output-path drv)) | |
1885 | (sh (string-append out "/bin/bash"))) | |
1886 | (build-expression->derivation store "sh" | |
1887 | `(symlink ,sh %output)))) | |
b860f382 LC |
1888 | @end example |
1889 | ||
1890 | Using @code{(guix monads)}, it may be rewritten as a monadic function: | |
1891 | ||
ada3df03 | 1892 | @c FIXME: Find a better example, one that uses 'mlet'. |
b860f382 | 1893 | @example |
45adbd62 | 1894 | (define (sh-symlink) |
b860f382 | 1895 | ;; Same, but return a monadic value. |
ada3df03 LC |
1896 | (gexp->derivation "sh" |
1897 | #~(symlink (string-append #$bash "/bin/bash") #$output))) | |
b860f382 LC |
1898 | @end example |
1899 | ||
1900 | There are two things to note in the second version: the @code{store} | |
1901 | parameter is now implicit, and the monadic value returned by | |
1902 | @code{package-file}---a wrapper around @code{package-derivation} and | |
1903 | @code{derivation->output-path}---is @dfn{bound} using @code{mlet} | |
1904 | instead of plain @code{let}. | |
1905 | ||
1906 | Calling the monadic @code{profile.sh} has no effect. To get the desired | |
1907 | effect, one must use @code{run-with-store}: | |
1908 | ||
1909 | @example | |
1910 | (run-with-store (open-connection) (profile.sh)) | |
834129e0 | 1911 | @result{} /gnu/store/...-profile.sh |
b860f382 LC |
1912 | @end example |
1913 | ||
1914 | The main syntactic forms to deal with monads in general are described | |
1915 | below. | |
1916 | ||
1917 | @deffn {Scheme Syntax} with-monad @var{monad} @var{body} ... | |
1918 | Evaluate any @code{>>=} or @code{return} forms in @var{body} as being | |
1919 | in @var{monad}. | |
1920 | @end deffn | |
1921 | ||
1922 | @deffn {Scheme Syntax} return @var{val} | |
1923 | Return a monadic value that encapsulates @var{val}. | |
1924 | @end deffn | |
1925 | ||
1926 | @deffn {Scheme Syntax} >>= @var{mval} @var{mproc} | |
1927 | @dfn{Bind} monadic value @var{mval}, passing its ``contents'' to monadic | |
1928 | procedure @var{mproc}@footnote{This operation is commonly referred to as | |
1929 | ``bind'', but that name denotes an unrelated procedure in Guile. Thus | |
1930 | we use this somewhat cryptic symbol inherited from the Haskell | |
1931 | language.}. | |
1932 | @end deffn | |
1933 | ||
1934 | @deffn {Scheme Syntax} mlet @var{monad} ((@var{var} @var{mval}) ...) @ | |
1935 | @var{body} ... | |
1936 | @deffnx {Scheme Syntax} mlet* @var{monad} ((@var{var} @var{mval}) ...) @ | |
1937 | @var{body} ... | |
1938 | Bind the variables @var{var} to the monadic values @var{mval} in | |
1939 | @var{body}. The form (@var{var} -> @var{val}) binds @var{var} to the | |
1940 | ``normal'' value @var{val}, as per @code{let}. | |
1941 | ||
1942 | @code{mlet*} is to @code{mlet} what @code{let*} is to @code{let} | |
1943 | (@pxref{Local Bindings,,, guile, GNU Guile Reference Manual}). | |
1944 | @end deffn | |
1945 | ||
1946 | The interface to the store monad provided by @code{(guix monads)} is as | |
1947 | follows. | |
1948 | ||
1949 | @defvr {Scheme Variable} %store-monad | |
1950 | The store monad. Values in the store monad encapsulate accesses to the | |
1951 | store. When its effect is needed, a value of the store monad must be | |
1952 | ``evaluated'' by passing it to the @code{run-with-store} procedure (see | |
1953 | below.) | |
1954 | @end defvr | |
1955 | ||
1956 | @deffn {Scheme Procedure} run-with-store @var{store} @var{mval} [#:guile-for-build] [#:system (%current-system)] | |
1957 | Run @var{mval}, a monadic value in the store monad, in @var{store}, an | |
1958 | open store connection. | |
1959 | @end deffn | |
1960 | ||
1961 | @deffn {Monadic Procedure} text-file @var{name} @var{text} | |
1962 | Return as a monadic value the absolute file name in the store of the file | |
45adbd62 LC |
1963 | containing @var{text}, a string. |
1964 | @end deffn | |
1965 | ||
1966 | @deffn {Monadic Procedure} text-file* @var{name} @var{text} @dots{} | |
1967 | Return as a monadic value a derivation that builds a text file | |
1968 | containing all of @var{text}. @var{text} may list, in addition to | |
1969 | strings, packages, derivations, and store file names; the resulting | |
1970 | store file holds references to all these. | |
1971 | ||
1972 | This variant should be preferred over @code{text-file} anytime the file | |
1973 | to create will reference items from the store. This is typically the | |
1974 | case when building a configuration file that embeds store file names, | |
1975 | like this: | |
1976 | ||
1977 | @example | |
1978 | (define (profile.sh) | |
1979 | ;; Return the name of a shell script in the store that | |
1980 | ;; initializes the 'PATH' environment variable. | |
1981 | (text-file* "profile.sh" | |
1982 | "export PATH=" coreutils "/bin:" | |
1983 | grep "/bin:" sed "/bin\n")) | |
1984 | @end example | |
1985 | ||
834129e0 | 1986 | In this example, the resulting @file{/gnu/store/@dots{}-profile.sh} file |
45adbd62 LC |
1987 | will references @var{coreutils}, @var{grep}, and @var{sed}, thereby |
1988 | preventing them from being garbage-collected during its lifetime. | |
b860f382 LC |
1989 | @end deffn |
1990 | ||
1991 | @deffn {Monadic Procedure} package-file @var{package} [@var{file}] @ | |
1992 | [#:system (%current-system)] [#:output "out"] Return as a monadic | |
1993 | value in the absolute file name of @var{file} within the @var{output} | |
1994 | directory of @var{package}. When @var{file} is omitted, return the name | |
1995 | of the @var{output} directory of @var{package}. | |
1996 | @end deffn | |
1997 | ||
b860f382 LC |
1998 | @deffn {Monadic Procedure} package->derivation @var{package} [@var{system}] |
1999 | Monadic version of @code{package-derivation} (@pxref{Defining | |
2000 | Packages}). | |
2001 | @end deffn | |
2002 | ||
2003 | ||
21b679f6 LC |
2004 | @node G-Expressions |
2005 | @section G-Expressions | |
2006 | ||
2007 | @cindex G-expression | |
2008 | @cindex build code quoting | |
2009 | So we have ``derivations'', which represent a sequence of build actions | |
2010 | to be performed to produce an item in the store (@pxref{Derivations}). | |
2011 | Those build actions are performed when asking the daemon to actually | |
2012 | build the derivations; they are run by the daemon in a container | |
2013 | (@pxref{Invoking guix-daemon}). | |
2014 | ||
2015 | @cindex strata of code | |
2016 | It should come as no surprise that we like to write those build actions | |
2017 | in Scheme. When we do that, we end up with two @dfn{strata} of Scheme | |
2018 | code@footnote{The term @dfn{stratum} in this context was coined by | |
ef4ab0a4 LC |
2019 | Manuel Serrano et al.@: in the context of their work on Hop. Oleg |
2020 | Kiselyov, who has written insightful | |
2021 | @url{http://okmij.org/ftp/meta-programming/#meta-scheme, essays and code | |
2022 | on this topic}, refers to this kind of code generation as | |
2023 | @dfn{staging}.}: the ``host code''---code that defines packages, talks | |
2024 | to the daemon, etc.---and the ``build code''---code that actually | |
2025 | performs build actions, such as making directories, invoking | |
2026 | @command{make}, etc. | |
21b679f6 LC |
2027 | |
2028 | To describe a derivation and its build actions, one typically needs to | |
2029 | embed build code inside host code. It boils down to manipulating build | |
2030 | code as data, and Scheme's homoiconicity---code has a direct | |
2031 | representation as data---comes in handy for that. But we need more than | |
2032 | Scheme's normal @code{quasiquote} mechanism to construct build | |
2033 | expressions. | |
2034 | ||
2035 | The @code{(guix gexp)} module implements @dfn{G-expressions}, a form of | |
2036 | S-expressions adapted to build expressions. G-expressions, or | |
2037 | @dfn{gexps}, consist essentially in three syntactic forms: @code{gexp}, | |
2038 | @code{ungexp}, and @code{ungexp-splicing} (or simply: @code{#~}, | |
2039 | @code{#$}, and @code{#$@@}), which are comparable respectively to | |
2040 | @code{quasiquote}, @code{unquote}, and @code{unquote-splicing} | |
2041 | (@pxref{Expression Syntax, @code{quasiquote},, guile, GNU Guile | |
2042 | Reference Manual}). However, there are major differences: | |
2043 | ||
2044 | @itemize | |
2045 | @item | |
2046 | Gexps are meant to be written to a file and run or manipulated by other | |
2047 | processes. | |
2048 | ||
2049 | @item | |
2050 | When a package or derivation is unquoted inside a gexp, the result is as | |
2051 | if its output file name had been introduced. | |
2052 | ||
2053 | @item | |
2054 | Gexps carry information about the packages or derivations they refer to, | |
2055 | and these dependencies are automatically added as inputs to the build | |
2056 | processes that use them. | |
2057 | @end itemize | |
2058 | ||
2059 | To illustrate the idea, here is an example of a gexp: | |
2060 | ||
2061 | @example | |
2062 | (define build-exp | |
2063 | #~(begin | |
2064 | (mkdir #$output) | |
2065 | (chdir #$output) | |
2066 | (symlink (string-append #$coreutils "/bin/ls") | |
2067 | "list-files"))) | |
2068 | @end example | |
2069 | ||
2070 | This gexp can be passed to @code{gexp->derivation}; we obtain a | |
2071 | derivation that builds a directory containing exactly one symlink to | |
2072 | @file{/gnu/store/@dots{}-coreutils-8.22/bin/ls}: | |
2073 | ||
2074 | @example | |
2075 | (gexp->derivation "the-thing" build-exp) | |
2076 | @end example | |
2077 | ||
e20fd1bf | 2078 | As one would expect, the @code{"/gnu/store/@dots{}-coreutils-8.22"} string is |
21b679f6 LC |
2079 | substituted to the reference to the @var{coreutils} package in the |
2080 | actual build code, and @var{coreutils} is automatically made an input to | |
2081 | the derivation. Likewise, @code{#$output} (equivalent to @code{(ungexp | |
2082 | output)}) is replaced by a string containing the derivation's output | |
2083 | directory name. The syntactic form to construct gexps is summarized | |
2084 | below. | |
2085 | ||
2086 | @deffn {Scheme Syntax} #~@var{exp} | |
2087 | @deffnx {Scheme Syntax} (gexp @var{exp}) | |
2088 | Return a G-expression containing @var{exp}. @var{exp} may contain one | |
2089 | or more of the following forms: | |
2090 | ||
2091 | @table @code | |
2092 | @item #$@var{obj} | |
2093 | @itemx (ungexp @var{obj}) | |
2094 | Introduce a reference to @var{obj}. @var{obj} may be a package or a | |
2095 | derivation, in which case the @code{ungexp} form is replaced by its | |
2096 | output file name---e.g., @code{"/gnu/store/@dots{}-coreutils-8.22}. | |
2097 | ||
2098 | If @var{obj} is a list, it is traversed and any package or derivation | |
2099 | references are substituted similarly. | |
2100 | ||
2101 | If @var{obj} is another gexp, its contents are inserted and its | |
2102 | dependencies are added to those of the containing gexp. | |
2103 | ||
2104 | If @var{obj} is another kind of object, it is inserted as is. | |
2105 | ||
2106 | @item #$@var{package-or-derivation}:@var{output} | |
2107 | @itemx (ungexp @var{package-or-derivation} @var{output}) | |
2108 | This is like the form above, but referring explicitly to the | |
2109 | @var{output} of @var{package-or-derivation}---this is useful when | |
2110 | @var{package-or-derivation} produces multiple outputs (@pxref{Packages | |
2111 | with Multiple Outputs}). | |
2112 | ||
2113 | @item #$output[:@var{output}] | |
2114 | @itemx (ungexp output [@var{output}]) | |
2115 | Insert a reference to derivation output @var{output}, or to the main | |
2116 | output when @var{output} is omitted. | |
2117 | ||
2118 | This only makes sense for gexps passed to @code{gexp->derivation}. | |
2119 | ||
2120 | @item #$@@@var{lst} | |
2121 | @itemx (ungexp-splicing @var{lst}) | |
2122 | Like the above, but splices the contents of @var{lst} inside the | |
2123 | containing list. | |
2124 | ||
2125 | @end table | |
2126 | ||
2127 | G-expressions created by @code{gexp} or @code{#~} are run-time objects | |
2128 | of the @code{gexp?} type (see below.) | |
2129 | @end deffn | |
2130 | ||
2131 | @deffn {Scheme Procedure} gexp? @var{obj} | |
2132 | Return @code{#t} if @var{obj} is a G-expression. | |
2133 | @end deffn | |
2134 | ||
2135 | G-expressions are meant to be written to disk, either as code building | |
2136 | some derivation, or as plain files in the store. The monadic procedures | |
2137 | below allow you to do that (@pxref{The Store Monad}, for more | |
2138 | information about monads.) | |
2139 | ||
2140 | @deffn {Monadic Procedure} gexp->derivation @var{name} @var{exp} @ | |
2141 | [#:system (%current-system)] [#:inputs '()] @ | |
2142 | [#:hash #f] [#:hash-algo #f] @ | |
2143 | [#:recursive? #f] [#:env-vars '()] [#:modules '()] @ | |
2144 | [#:references-graphs #f] [#:local-build? #f] @ | |
2145 | [#:guile-for-build #f] | |
2146 | Return a derivation @var{name} that runs @var{exp} (a gexp) with | |
2147 | @var{guile-for-build} (a derivation) on @var{system}. | |
2148 | ||
2149 | Make @var{modules} available in the evaluation context of @var{EXP}; | |
2150 | @var{MODULES} is a list of names of Guile modules from the current | |
2151 | search path to be copied in the store, compiled, and made available in | |
2152 | the load path during the execution of @var{exp}---e.g., @code{((guix | |
2153 | build utils) (guix build gnu-build-system))}. | |
2154 | ||
e20fd1bf | 2155 | The other arguments are as for @code{derivation} (@pxref{Derivations}). |
21b679f6 LC |
2156 | @end deffn |
2157 | ||
2158 | @deffn {Monadic Procedure} gexp->script @var{name} @var{exp} | |
2159 | Return an executable script @var{name} that runs @var{exp} using | |
2160 | @var{guile} with @var{modules} in its search path. | |
2161 | ||
2162 | The example below builds a script that simply invokes the @command{ls} | |
2163 | command: | |
2164 | ||
2165 | @example | |
2166 | (use-modules (guix gexp) (gnu packages base)) | |
2167 | ||
2168 | (gexp->script "list-files" | |
2169 | #~(execl (string-append #$coreutils "/bin/ls") | |
2170 | "ls")) | |
2171 | @end example | |
2172 | ||
2173 | When ``running'' it through the store (@pxref{The Store Monad, | |
e20fd1bf | 2174 | @code{run-with-store}}), we obtain a derivation that produces an |
21b679f6 LC |
2175 | executable file @file{/gnu/store/@dots{}-list-files} along these lines: |
2176 | ||
2177 | @example | |
2178 | #!/gnu/store/@dots{}-guile-2.0.11/bin/guile -ds | |
2179 | !# | |
2180 | (execl (string-append "/gnu/store/@dots{}-coreutils-8.22"/bin/ls") | |
2181 | "ls") | |
2182 | @end example | |
2183 | @end deffn | |
2184 | ||
2185 | @deffn {Monadic Procedure} gexp->file @var{name} @var{exp} | |
2186 | Return a derivation that builds a file @var{name} containing @var{exp}. | |
2187 | ||
2188 | The resulting file holds references to all the dependencies of @var{exp} | |
2189 | or a subset thereof. | |
2190 | @end deffn | |
2191 | ||
2192 | Of course, in addition to gexps embedded in ``host'' code, there are | |
2193 | also modules containing build tools. To make it clear that they are | |
2194 | meant to be used in the build stratum, these modules are kept in the | |
2195 | @code{(guix build @dots{})} name space. | |
2196 | ||
2197 | ||
568717fd LC |
2198 | @c ********************************************************************* |
2199 | @node Utilities | |
2200 | @chapter Utilities | |
2201 | ||
210cc920 LC |
2202 | This section describes tools primarily targeted at developers and users |
2203 | who write new package definitions. They complement the Scheme | |
2204 | programming interface of Guix in a convenient way. | |
2205 | ||
568717fd | 2206 | @menu |
37166310 | 2207 | * Invoking guix build:: Building packages from the command line. |
210cc920 | 2208 | * Invoking guix download:: Downloading a file and printing its hash. |
37166310 LC |
2209 | * Invoking guix hash:: Computing the cryptographic hash of a file. |
2210 | * Invoking guix refresh:: Updating package definitions. | |
568717fd LC |
2211 | @end menu |
2212 | ||
e49951eb MW |
2213 | @node Invoking guix build |
2214 | @section Invoking @command{guix build} | |
568717fd | 2215 | |
e49951eb | 2216 | The @command{guix build} command builds packages or derivations and |
6798a8e4 LC |
2217 | their dependencies, and prints the resulting store paths. Note that it |
2218 | does not modify the user's profile---this is the job of the | |
e49951eb | 2219 | @command{guix package} command (@pxref{Invoking guix package}). Thus, |
6798a8e4 LC |
2220 | it is mainly useful for distribution developers. |
2221 | ||
2222 | The general syntax is: | |
c78bd12b LC |
2223 | |
2224 | @example | |
e49951eb | 2225 | guix build @var{options} @var{package-or-derivation}@dots{} |
c78bd12b LC |
2226 | @end example |
2227 | ||
2228 | @var{package-or-derivation} may be either the name of a package found in | |
5401dd75 LC |
2229 | the software distribution such as @code{coreutils} or |
2230 | @code{coreutils-8.20}, or a derivation such as | |
834129e0 | 2231 | @file{/gnu/store/@dots{}-coreutils-8.19.drv}. In the former case, a |
e7f34eb0 LC |
2232 | package with the corresponding name (and optionally version) is searched |
2233 | for among the GNU distribution modules (@pxref{Package Modules}). | |
2234 | ||
2235 | Alternatively, the @code{--expression} option may be used to specify a | |
2236 | Scheme expression that evaluates to a package; this is useful when | |
2237 | disambiguation among several same-named packages or package variants is | |
2238 | needed. | |
c78bd12b LC |
2239 | |
2240 | The @var{options} may be zero or more of the following: | |
2241 | ||
2242 | @table @code | |
2243 | ||
2244 | @item --expression=@var{expr} | |
2245 | @itemx -e @var{expr} | |
ac5de156 | 2246 | Build the package or derivation @var{expr} evaluates to. |
c78bd12b | 2247 | |
5401dd75 | 2248 | For example, @var{expr} may be @code{(@@ (gnu packages guile) |
c78bd12b LC |
2249 | guile-1.8)}, which unambiguously designates this specific variant of |
2250 | version 1.8 of Guile. | |
2251 | ||
56b82106 LC |
2252 | Alternately, @var{expr} may be a G-expression, in which case it is used |
2253 | as a build program passed to @code{gexp->derivation} | |
2254 | (@pxref{G-Expressions}). | |
2255 | ||
2256 | Lastly, @var{expr} may refer to a zero-argument monadic procedure | |
ac5de156 LC |
2257 | (@pxref{The Store Monad}). The procedure must return a derivation as a |
2258 | monadic value, which is then passed through @code{run-with-store}. | |
2259 | ||
c78bd12b LC |
2260 | @item --source |
2261 | @itemx -S | |
2262 | Build the packages' source derivations, rather than the packages | |
2263 | themselves. | |
2264 | ||
e49951eb | 2265 | For instance, @code{guix build -S gcc} returns something like |
834129e0 | 2266 | @file{/gnu/store/@dots{}-gcc-4.7.2.tar.bz2}, which is GCC's source tarball. |
c78bd12b | 2267 | |
f9cc8971 LC |
2268 | The returned source tarball is the result of applying any patches and |
2269 | code snippets specified in the package's @code{origin} (@pxref{Defining | |
2270 | Packages}). | |
2271 | ||
c78bd12b LC |
2272 | @item --system=@var{system} |
2273 | @itemx -s @var{system} | |
2274 | Attempt to build for @var{system}---e.g., @code{i686-linux}---instead of | |
2275 | the host's system type. | |
2276 | ||
2277 | An example use of this is on Linux-based systems, which can emulate | |
2278 | different personalities. For instance, passing | |
2279 | @code{--system=i686-linux} on an @code{x86_64-linux} system allows users | |
2280 | to build packages in a complete 32-bit environment. | |
2281 | ||
e55ec43d LC |
2282 | @item --target=@var{triplet} |
2283 | @cindex cross-compilation | |
2284 | Cross-build for @var{triplet}, which must be a valid GNU triplet, such | |
2285 | as @code{"mips64el-linux-gnu"} (@pxref{Configuration Names, GNU | |
2286 | configuration triplets,, configure, GNU Configure and Build System}). | |
2287 | ||
7f3673f2 LC |
2288 | @item --with-source=@var{source} |
2289 | Use @var{source} as the source of the corresponding package. | |
2290 | @var{source} must be a file name or a URL, as for @command{guix | |
2291 | download} (@pxref{Invoking guix download}). | |
2292 | ||
2293 | The ``corresponding package'' is taken to be one specified on the | |
2294 | command line whose name matches the base of @var{source}---e.g., if | |
2295 | @var{source} is @code{/src/guile-2.0.10.tar.gz}, the corresponding | |
2296 | package is @code{guile}. Likewise, the version string is inferred from | |
2297 | @var{source}; in the previous example, it's @code{2.0.10}. | |
2298 | ||
2299 | This option allows users to try out versions of packages other than the | |
2300 | one provided by the distribution. The example below downloads | |
2301 | @file{ed-1.7.tar.gz} from a GNU mirror and uses that as the source for | |
2302 | the @code{ed} package: | |
2303 | ||
2304 | @example | |
2305 | guix build ed --with-source=mirror://gnu/ed/ed-1.7.tar.gz | |
2306 | @end example | |
2307 | ||
2308 | As a developer, @code{--with-source} makes it easy to test release | |
2309 | candidates: | |
2310 | ||
2311 | @example | |
2312 | guix build guile --with-source=../guile-2.0.9.219-e1bb7.tar.xz | |
2313 | @end example | |
2314 | ||
2315 | ||
c78bd12b LC |
2316 | @item --derivations |
2317 | @itemx -d | |
2318 | Return the derivation paths, not the output paths, of the given | |
2319 | packages. | |
2320 | ||
70ee5642 LC |
2321 | @item --root=@var{file} |
2322 | @itemx -r @var{file} | |
2323 | Make @var{file} a symlink to the result, and register it as a garbage | |
2324 | collector root. | |
2325 | ||
2326 | @item --log-file | |
2327 | Return the build log file names for the given | |
2328 | @var{package-or-derivation}s, or raise an error if build logs are | |
2329 | missing. | |
2330 | ||
2331 | This works regardless of how packages or derivations are specified. For | |
2332 | instance, the following invocations are equivalent: | |
2333 | ||
2334 | @example | |
2335 | guix build --log-file `guix build -d guile` | |
2336 | guix build --log-file `guix build guile` | |
2337 | guix build --log-file guile | |
2338 | guix build --log-file -e '(@@ (gnu packages guile) guile-2.0)' | |
2339 | @end example | |
2340 | ||
2341 | ||
2342 | @end table | |
2343 | ||
2344 | @cindex common build options | |
2345 | In addition, a number of options that control the build process are | |
2346 | common to @command{guix build} and other commands that can spawn builds, | |
2347 | such as @command{guix package} or @command{guix archive}. These are the | |
2348 | following: | |
2349 | ||
2350 | @table @code | |
2351 | ||
c78bd12b LC |
2352 | @item --keep-failed |
2353 | @itemx -K | |
2354 | Keep the build tree of failed builds. Thus, if a build fail, its build | |
2355 | tree is kept under @file{/tmp}, in a directory whose name is shown at | |
2356 | the end of the build log. This is useful when debugging build issues. | |
2357 | ||
2358 | @item --dry-run | |
2359 | @itemx -n | |
2360 | Do not build the derivations. | |
2361 | ||
56b1f4b7 LC |
2362 | @item --fallback |
2363 | When substituting a pre-built binary fails, fall back to building | |
2364 | packages locally. | |
2365 | ||
c78bd12b | 2366 | @item --no-substitutes |
b5385b52 | 2367 | Do not use substitutes for build products. That is, always build things |
c4202d60 LC |
2368 | locally instead of allowing downloads of pre-built binaries |
2369 | (@pxref{Substitutes}). | |
c78bd12b | 2370 | |
425b0bfc | 2371 | @item --no-build-hook |
4ec2e92d LC |
2372 | Do not attempt to offload builds @i{via} the daemon's ``build hook'' |
2373 | (@pxref{Daemon Offload Setup}). That is, always build things locally | |
2374 | instead of offloading builds to remote machines. | |
425b0bfc | 2375 | |
969e678e LC |
2376 | @item --max-silent-time=@var{seconds} |
2377 | When the build or substitution process remains silent for more than | |
2378 | @var{seconds}, terminate it and report a build failure. | |
2379 | ||
002622b6 LC |
2380 | @item --timeout=@var{seconds} |
2381 | Likewise, when the build or substitution process lasts for more than | |
2382 | @var{seconds}, terminate it and report a build failure. | |
2383 | ||
2384 | By default there is no timeout. This behavior can be restored with | |
2385 | @code{--timeout=0}. | |
2386 | ||
07ab4bf1 LC |
2387 | @item --verbosity=@var{level} |
2388 | Use the given verbosity level. @var{level} must be an integer between 0 | |
2389 | and 5; higher means more verbose output. Setting a level of 4 or more | |
2390 | may be helpful when debugging setup issues with the build daemon. | |
2391 | ||
70ee5642 LC |
2392 | @item --cores=@var{n} |
2393 | @itemx -c @var{n} | |
2394 | Allow the use of up to @var{n} CPU cores for the build. The special | |
2395 | value @code{0} means to use as many CPU cores as available. | |
bf421152 | 2396 | |
c78bd12b LC |
2397 | @end table |
2398 | ||
e49951eb | 2399 | Behind the scenes, @command{guix build} is essentially an interface to |
c78bd12b LC |
2400 | the @code{package-derivation} procedure of the @code{(guix packages)} |
2401 | module, and to the @code{build-derivations} procedure of the @code{(guix | |
2402 | store)} module. | |
2403 | ||
210cc920 LC |
2404 | @node Invoking guix download |
2405 | @section Invoking @command{guix download} | |
2406 | ||
2407 | When writing a package definition, developers typically need to download | |
2408 | the package's source tarball, compute its SHA256 hash, and write that | |
2409 | hash in the package definition (@pxref{Defining Packages}). The | |
2410 | @command{guix download} tool helps with this task: it downloads a file | |
2411 | from the given URI, adds it to the store, and prints both its file name | |
2412 | in the store and its SHA256 hash. | |
2413 | ||
2414 | The fact that the downloaded file is added to the store saves bandwidth: | |
2415 | when the developer eventually tries to build the newly defined package | |
2416 | with @command{guix build}, the source tarball will not have to be | |
2417 | downloaded again because it is already in the store. It is also a | |
2418 | convenient way to temporarily stash files, which may be deleted | |
2419 | eventually (@pxref{Invoking guix gc}). | |
2420 | ||
2421 | The @command{guix download} command supports the same URIs as used in | |
2422 | package definitions. In particular, it supports @code{mirror://} URIs. | |
2423 | @code{https} URIs (HTTP over TLS) are supported @emph{provided} the | |
2424 | Guile bindings for GnuTLS are available in the user's environment; when | |
2425 | they are not available, an error is raised. | |
2426 | ||
2427 | The following option is available: | |
2428 | ||
2429 | @table @code | |
2430 | @item --format=@var{fmt} | |
2431 | @itemx -f @var{fmt} | |
2432 | Write the hash in the format specified by @var{fmt}. For more | |
2433 | information on the valid values for @var{fmt}, @ref{Invoking guix hash}. | |
2434 | @end table | |
2435 | ||
6c365eca NK |
2436 | @node Invoking guix hash |
2437 | @section Invoking @command{guix hash} | |
2438 | ||
210cc920 | 2439 | The @command{guix hash} command computes the SHA256 hash of a file. |
6c365eca NK |
2440 | It is primarily a convenience tool for anyone contributing to the |
2441 | distribution: it computes the cryptographic hash of a file, which can be | |
2442 | used in the definition of a package (@pxref{Defining Packages}). | |
2443 | ||
2444 | The general syntax is: | |
2445 | ||
2446 | @example | |
2447 | guix hash @var{option} @var{file} | |
2448 | @end example | |
2449 | ||
2450 | @command{guix hash} has the following option: | |
2451 | ||
2452 | @table @code | |
2453 | ||
2454 | @item --format=@var{fmt} | |
2455 | @itemx -f @var{fmt} | |
210cc920 | 2456 | Write the hash in the format specified by @var{fmt}. |
6c365eca NK |
2457 | |
2458 | Supported formats: @code{nix-base32}, @code{base32}, @code{base16} | |
2459 | (@code{hex} and @code{hexadecimal} can be used as well). | |
2460 | ||
2461 | If the @option{--format} option is not specified, @command{guix hash} | |
2462 | will output the hash in @code{nix-base32}. This representation is used | |
2463 | in the definitions of packages. | |
2464 | ||
3140f2df LC |
2465 | @item --recursive |
2466 | @itemx -r | |
2467 | Compute the hash on @var{file} recursively. | |
2468 | ||
2469 | In this case, the hash is computed on an archive containing @var{file}, | |
2470 | including its children if it is a directory. Some of @var{file}'s | |
2471 | meta-data is part of the archive; for instance, when @var{file} is a | |
2472 | regular file, the hash is different depending on whether @var{file} is | |
2473 | executable or not. Meta-data such as time stamps has no impact on the | |
2474 | hash (@pxref{Invoking guix archive}). | |
2475 | @c FIXME: Replace xref above with xref to an ``Archive'' section when | |
2476 | @c it exists. | |
2477 | ||
6c365eca NK |
2478 | @end table |
2479 | ||
37166310 LC |
2480 | @node Invoking guix refresh |
2481 | @section Invoking @command{guix refresh} | |
2482 | ||
2483 | The primary audience of the @command{guix refresh} command is developers | |
2484 | of the GNU software distribution. By default, it reports any packages | |
2485 | provided by the distribution that are outdated compared to the latest | |
2486 | upstream version, like this: | |
2487 | ||
2488 | @example | |
2489 | $ guix refresh | |
2490 | gnu/packages/gettext.scm:29:13: gettext would be upgraded from 0.18.1.1 to 0.18.2.1 | |
2491 | gnu/packages/glib.scm:77:12: glib would be upgraded from 2.34.3 to 2.37.0 | |
2492 | @end example | |
2493 | ||
2494 | It does so by browsing each package's FTP directory and determining the | |
2495 | highest version number of the source tarballs | |
2496 | therein@footnote{Currently, this only works for GNU packages.}. | |
2497 | ||
2498 | When passed @code{--update}, it modifies distribution source files to | |
2499 | update the version numbers and source tarball hashes of those packages' | |
2500 | recipes (@pxref{Defining Packages}). This is achieved by downloading | |
2501 | each package's latest source tarball and its associated OpenPGP | |
2502 | signature, authenticating the downloaded tarball against its signature | |
2503 | using @command{gpg}, and finally computing its hash. When the public | |
2504 | key used to sign the tarball is missing from the user's keyring, an | |
2505 | attempt is made to automatically retrieve it from a public key server; | |
2506 | when it's successful, the key is added to the user's keyring; otherwise, | |
2507 | @command{guix refresh} reports an error. | |
2508 | ||
2509 | The following options are supported: | |
2510 | ||
2511 | @table @code | |
2512 | ||
2513 | @item --update | |
2514 | @itemx -u | |
2515 | Update distribution source files (package recipes) in place. | |
2516 | @ref{Defining Packages}, for more information on package definitions. | |
2517 | ||
2518 | @item --select=[@var{subset}] | |
2519 | @itemx -s @var{subset} | |
2520 | Select all the packages in @var{subset}, one of @code{core} or | |
2521 | @code{non-core}. | |
2522 | ||
2523 | The @code{core} subset refers to all the packages at the core of the | |
2524 | distribution---i.e., packages that are used to build ``everything | |
2525 | else''. This includes GCC, libc, Binutils, Bash, etc. Usually, | |
2526 | changing one of these packages in the distribution entails a rebuild of | |
2527 | all the others. Thus, such updates are an inconvenience to users in | |
2528 | terms of build time or bandwidth used to achieve the upgrade. | |
2529 | ||
2530 | The @code{non-core} subset refers to the remaining packages. It is | |
2531 | typically useful in cases where an update of the core packages would be | |
2532 | inconvenient. | |
2533 | ||
2534 | @end table | |
2535 | ||
2536 | In addition, @command{guix refresh} can be passed one or more package | |
2537 | names, as in this example: | |
2538 | ||
2539 | @example | |
2540 | guix refresh -u emacs idutils | |
2541 | @end example | |
2542 | ||
2543 | @noindent | |
2544 | The command above specifically updates the @code{emacs} and | |
2545 | @code{idutils} packages. The @code{--select} option would have no | |
2546 | effect in this case. | |
2547 | ||
f9230085 LC |
2548 | The following options can be used to customize GnuPG operation: |
2549 | ||
2550 | @table @code | |
2551 | ||
2552 | @item --key-server=@var{host} | |
2553 | Use @var{host} as the OpenPGP key server when importing a public key. | |
2554 | ||
2555 | @item --gpg=@var{command} | |
2556 | Use @var{command} as the GnuPG 2.x command. @var{command} is searched | |
2557 | for in @code{$PATH}. | |
2558 | ||
2559 | @end table | |
2560 | ||
37166310 | 2561 | |
a1ba8475 LC |
2562 | @c ********************************************************************* |
2563 | @node GNU Distribution | |
2564 | @chapter GNU Distribution | |
2565 | ||
2566 | Guix comes with a distribution of free software@footnote{The term | |
2567 | ``free'' here refers to the | |
2568 | @url{http://www.gnu.org/philosophy/free-sw.html,freedom provided to | |
c320011d | 2569 | users of that software}.} that forms the basis of the GNU system. This |
a1ba8475 LC |
2570 | includes core GNU packages such as GNU libc, GCC, and Binutils, as well |
2571 | as many GNU and non-GNU applications. The complete list of available | |
d03bb653 LC |
2572 | packages can be browsed |
2573 | @url{http://www.gnu.org/software/guix/package-list.html,on-line} or by | |
2574 | running @command{guix package} (@pxref{Invoking guix package}): | |
a1ba8475 LC |
2575 | |
2576 | @example | |
e49951eb | 2577 | guix package --list-available |
a1ba8475 LC |
2578 | @end example |
2579 | ||
401c53c4 LC |
2580 | Our goal is to build a practical 100% free software distribution of |
2581 | Linux-based and other variants of GNU, with a focus on the promotion and | |
2582 | tight integration of GNU components, and an emphasis on programs and | |
2583 | tools that help users exert that freedom. | |
2584 | ||
c320011d LC |
2585 | The GNU distribution is currently available on the following platforms: |
2586 | ||
2587 | @table @code | |
2588 | ||
2589 | @item x86_64-linux | |
2590 | Intel/AMD @code{x86_64} architecture, Linux-Libre kernel; | |
2591 | ||
2592 | @item i686-linux | |
2593 | Intel 32-bit architecture (IA32), Linux-Libre kernel; | |
2594 | ||
2595 | @item mips64el-linux | |
2596 | little-endian 64-bit MIPS processors, specifically the Loongson series, | |
2597 | n32 application binary interface (ABI), and Linux-Libre kernel. | |
2598 | ||
2599 | @end table | |
2600 | ||
2601 | @noindent | |
2602 | For information on porting to other architectures or kernels, | |
2603 | @xref{Porting}. | |
2604 | ||
401c53c4 | 2605 | @menu |
5af6de3e | 2606 | * System Installation:: Installing the whole operating system. |
91ef73d4 | 2607 | * Installing Debugging Files:: Feeding the debugger. |
401c53c4 | 2608 | * Package Modules:: Packages from the programmer's viewpoint. |
da7cabd4 | 2609 | * Packaging Guidelines:: Growing the distribution. |
401c53c4 | 2610 | * Bootstrapping:: GNU/Linux built from scratch. |
8b315a6d | 2611 | * Porting:: Targeting another platform or kernel. |
4af2447e | 2612 | * System Configuration:: Configuring a GNU system. |
401c53c4 LC |
2613 | @end menu |
2614 | ||
2615 | Building this distribution is a cooperative effort, and you are invited | |
2616 | to join! @ref{Contributing}, for information about how you can help. | |
2617 | ||
5af6de3e LC |
2618 | @node System Installation |
2619 | @section System Installation | |
2620 | ||
2621 | This section explains how to install the complete GNU operating system | |
2622 | on a machine. The Guix package manager can also be installed on top of | |
2623 | a running GNU/Linux system, @ref{Installation}. | |
2624 | ||
2625 | @ifinfo | |
2626 | @c This paragraph is for people reading this from tty2 of the | |
2627 | @c installation image. | |
2628 | You're reading this documentation with an Info reader. For details on | |
2629 | how to use it, hit the @key{RET} key (``return'' or ``enter'') on the | |
2630 | link that follows: @ref{Help,,, info, Info: An Introduction}. Hit | |
2631 | @kbd{l} afterwards to come back here. | |
2632 | @end ifinfo | |
2633 | ||
2634 | @emph{This section documents work-in-progress. The system lacks | |
2635 | features and may be buggy. You've been warned. But more than a | |
2636 | disclaimer, this is an invitation to report issues (and success | |
2637 | stories!), and join us in improving it. @xref{Contributing}, for more | |
2638 | info.} | |
2639 | ||
2640 | @subsection USB Stick Installation | |
2641 | ||
2642 | An installation image for USB sticks can be downloaded from | |
2643 | @url{ftp://alpha.gnu.org/gnu/guix/gnu-usb-install-@value{VERSION}.@var{system}.xz}, | |
2644 | where @var{system} is one of: | |
2645 | ||
2646 | @table @code | |
2647 | @item x86_64-linux | |
2648 | for a GNU/Linux system on Intel/AMD-compatible 64-bit CPUs; | |
2649 | ||
2650 | @item i686-linux | |
2651 | for a 32-bit GNU/Linux system on Intel-compatible CPUs. | |
2652 | @end table | |
2653 | ||
2654 | This image contains a single partition with the tools necessary for an | |
2655 | installation. It is meant to be copied @emph{as is} to a large-enough | |
2656 | USB stick. | |
2657 | ||
2658 | To copy the image to a USB stick, follow these steps: | |
2659 | ||
2660 | @enumerate | |
2661 | @item | |
2662 | Decompress the image using the @command{xz} command: | |
2663 | ||
2664 | @example | |
2665 | xz -d gnu-usb-install-@value{VERSION}.@var{system}.xz | |
2666 | @end example | |
2667 | ||
2668 | @item | |
2669 | Insert a USB stick of 1@tie{}GiB or more in your machine, and determine | |
2670 | its device name. Assuming that USB stick is known as @file{/dev/sdX}, | |
2671 | copy the image with: | |
2672 | ||
2673 | @example | |
2674 | dd if=gnu-usb-install-20140629.x86_64 of=/dev/sdX | |
2675 | @end example | |
2676 | ||
2677 | Access to @file{/dev/sdX} usually requires root privileges. | |
2678 | @end enumerate | |
2679 | ||
2680 | Once this is done, you should be able to reboot the system and boot from | |
2681 | the USB stick. The latter usually requires you to get in the BIOS' boot | |
2682 | menu, where you can choose to boot from the USB stick. | |
2683 | ||
2684 | @subsection Preparing for Installation | |
2685 | ||
2686 | Once you have successfully booted the image on the USB stick, you should | |
2687 | end up with a root prompt. Several console TTYs are configured and can | |
2688 | be used to run commands as root. TTY2 shows this documentation, | |
2689 | browsable using the Info reader commands (@pxref{Help,,, info, Info: An | |
2690 | Introduction}). | |
2691 | ||
2692 | To install the system, you would: | |
2693 | ||
2694 | @enumerate | |
2695 | ||
2696 | @item | |
2697 | Configure the network, by running @command{dhclient eth0} (to get an | |
2698 | automatically assigned IP address from the wired network interface | |
2699 | controller), or using the @command{ifconfig} command. | |
2700 | ||
2701 | The system automatically loads drivers for your network interface | |
2702 | controllers. | |
2703 | ||
2704 | Setting up network access is almost always a requirement because the | |
2705 | image does not contain all the software and tools that may be needed. | |
2706 | ||
2707 | @item | |
2708 | Unless this has already been done, you must partition and format the | |
2709 | target partitions. | |
2710 | ||
2711 | The installation image includes Parted (@pxref{Overview,,, parted, GNU | |
2712 | Parted User Manual}), @command{fdisk}, and e2fsprogs, the suite of tools | |
2713 | to manipulate ext2/ext3/ext4 file systems. | |
2714 | ||
2715 | @end enumerate | |
2716 | ||
2717 | Once that is done, mount the target root partition under @file{/mnt}. | |
2718 | ||
2719 | @subsection Proceeding with the Installation | |
2720 | ||
2721 | With the target partitions ready, you now have to edit a file and | |
2722 | provide the declaration of the operating system to be installed. To | |
2723 | that end, the installation system comes with two text editors: GNU nano | |
2724 | (@pxref{Top,,, nano, GNU nano Manual}), and GNU Zile, an Emacs clone. | |
2725 | It is better to store that file on the target root file system, say, as | |
2726 | @file{/mnt/etc/config.scm}. | |
2727 | ||
2728 | A minimal operating system configuration, with just the bare minimum and | |
2729 | only a root account would look like this: | |
2730 | ||
2731 | @example | |
2732 | (use-modules (gnu)) | |
2733 | ||
2734 | (operating-system | |
2735 | (host-name "foo") | |
2736 | (timezone "Europe/Paris") | |
2737 | (locale "en_US.UTF-8") | |
2738 | ||
2739 | ;; Assuming /dev/sdX is the target hard disk, and /dev/sdX1 the | |
2740 | ;; target root file system. | |
2741 | (bootloader (grub-configuration (device "/dev/sdX"))) | |
2742 | (file-systems (list (file-system | |
2743 | (device "/dev/sdX1") | |
2744 | (mount-point "/") | |
2745 | (type "ext4"))))) | |
2746 | @end example | |
2747 | ||
2748 | @noindent | |
2749 | For more information on @code{operating-system} declarations, | |
2750 | @xref{Using the Configuration System}. | |
2751 | ||
2752 | Once that is done, the new system must be initialized (remember that the | |
2753 | target root file system is mounted under @file{/mnt}): | |
2754 | ||
2755 | @example | |
2756 | guix system init /mnt/etc/config.scm /mnt | |
2757 | @end example | |
2758 | ||
2759 | @noindent | |
2760 | This will copy all the necessary files, and install GRUB on | |
2761 | @file{/dev/sdX}, unless you pass the @option{--no-grub} option. For | |
2762 | more information, @xref{Invoking guix system}. This command may trigger | |
2763 | downloads or builds of missing packages, which can take some time. | |
2764 | ||
2765 | Once that command has completed---and hopefully succeeded!---you can | |
2766 | unmount @file{/mnt} and boot into the new system. Cross fingers, and | |
2767 | join us on @code{#guix} on the Freenode IRC network or on | |
2768 | @file{guix-devel@@gnu.org} to share your experience---good or not so | |
2769 | good. | |
2770 | ||
2771 | @subsection Building the Installation Image | |
2772 | ||
2773 | The installation image described above was built using the @command{guix | |
2774 | system} command, specifically: | |
2775 | ||
2776 | @example | |
2777 | guix system disk-image --image-size=800MiB gnu/system/install.scm | |
2778 | @end example | |
2779 | ||
2780 | @xref{Invoking guix system}, for more information. See | |
2781 | @file{gnu/system/install.scm} in the source tree for more information | |
2782 | about the installation image. | |
2783 | ||
b208a005 | 2784 | |
91ef73d4 LC |
2785 | @node Installing Debugging Files |
2786 | @section Installing Debugging Files | |
2787 | ||
64d76fa6 | 2788 | @cindex debugging files |
91ef73d4 LC |
2789 | Program binaries, as produced by the GCC compilers for instance, are |
2790 | typically written in the ELF format, with a section containing | |
2791 | @dfn{debugging information}. Debugging information is what allows the | |
2792 | debugger, GDB, to map binary code to source code; it is required to | |
2793 | debug a compiled program in good conditions. | |
2794 | ||
2795 | The problem with debugging information is that is takes up a fair amount | |
2796 | of disk space. For example, debugging information for the GNU C Library | |
2797 | weighs in at more than 60 MiB. Thus, as a user, keeping all the | |
2798 | debugging info of all the installed programs is usually not an option. | |
2799 | Yet, space savings should not come at the cost of an impediment to | |
2800 | debugging---especially in the GNU system, which should make it easier | |
2801 | for users to exert their computing freedom (@pxref{GNU Distribution}). | |
2802 | ||
2803 | Thankfully, the GNU Binary Utilities (Binutils) and GDB provide a | |
2804 | mechanism that allows users to get the best of both worlds: debugging | |
2805 | information can be stripped from the binaries and stored in separate | |
2806 | files. GDB is then able to load debugging information from those files, | |
2807 | when they are available (@pxref{Separate Debug Files,,, gdb, Debugging | |
2808 | with GDB}). | |
2809 | ||
2810 | The GNU distribution takes advantage of this by storing debugging | |
2811 | information in the @code{lib/debug} sub-directory of a separate package | |
2812 | output unimaginatively called @code{debug} (@pxref{Packages with | |
2813 | Multiple Outputs}). Users can choose to install the @code{debug} output | |
2814 | of a package when they need it. For instance, the following command | |
2815 | installs the debugging information for the GNU C Library and for GNU | |
2816 | Guile: | |
2817 | ||
2818 | @example | |
64d76fa6 | 2819 | guix package -i glibc:debug guile:debug |
91ef73d4 LC |
2820 | @end example |
2821 | ||
2822 | GDB must then be told to look for debug files in the user's profile, by | |
2823 | setting the @code{debug-file-directory} variable (consider setting it | |
2824 | from the @file{~/.gdbinit} file, @pxref{Startup,,, gdb, Debugging with | |
2825 | GDB}): | |
2826 | ||
2827 | @example | |
2828 | (gdb) set debug-file-directory ~/.guix-profile/lib/debug | |
2829 | @end example | |
2830 | ||
2831 | From there on, GDB will pick up debugging information from the | |
2832 | @code{.debug} files under @file{~/.guix-profile/lib/debug}. | |
2833 | ||
64d76fa6 LC |
2834 | In addition, you will most likely want GDB to be able to show the source |
2835 | code being debugged. To do that, you will have to unpack the source | |
2836 | code of the package of interest (obtained with @code{guix build | |
2837 | --source}, @pxref{Invoking guix build}), and to point GDB to that source | |
2838 | directory using the @code{directory} command (@pxref{Source Path, | |
2839 | @code{directory},, gdb, Debugging with GDB}). | |
2840 | ||
91ef73d4 LC |
2841 | @c XXX: keep me up-to-date |
2842 | The @code{debug} output mechanism in Guix is implemented by the | |
64d76fa6 | 2843 | @code{gnu-build-system} (@pxref{Build Systems}). Currently, it is |
91ef73d4 LC |
2844 | opt-in---debugging information is available only for those packages |
2845 | whose definition explicitly declares a @code{debug} output. This may be | |
2846 | changed to opt-out in the future, if our build farm servers can handle | |
2847 | the load. To check whether a package has a @code{debug} output, use | |
2848 | @command{guix package --list-available} (@pxref{Invoking guix package}). | |
2849 | ||
2850 | ||
401c53c4 LC |
2851 | @node Package Modules |
2852 | @section Package Modules | |
2853 | ||
2854 | From a programming viewpoint, the package definitions of the | |
e7f34eb0 | 2855 | GNU distribution are provided by Guile modules in the @code{(gnu packages |
7e17f65d LC |
2856 | @dots{})} name space@footnote{Note that packages under the @code{(gnu |
2857 | packages @dots{})} module name space are not necessarily ``GNU | |
2858 | packages''. This module naming scheme follows the usual Guile module | |
2859 | naming convention: @code{gnu} means that these modules are distributed | |
2860 | as part of the GNU system, and @code{packages} identifies modules that | |
2861 | define packages.} (@pxref{Modules, Guile modules,, guile, GNU Guile | |
b81e1947 LC |
2862 | Reference Manual}). For instance, the @code{(gnu packages emacs)} |
2863 | module exports a variable named @code{emacs}, which is bound to a | |
e7f34eb0 LC |
2864 | @code{<package>} object (@pxref{Defining Packages}). |
2865 | ||
2866 | The @code{(gnu packages @dots{})} module name space is special: it is | |
2867 | automatically scanned for packages by the command-line tools. For | |
2868 | instance, when running @code{guix package -i emacs}, all the @code{(gnu | |
2869 | packages @dots{})} modules are scanned until one that exports a package | |
2870 | object whose name is @code{emacs} is found. This package search | |
2871 | facility is implemented in the @code{(gnu packages)} module. | |
2872 | ||
2873 | Users can store package definitions in modules with different | |
2874 | names---e.g., @code{(my-packages emacs)}. In that case, commands such | |
2875 | as @command{guix package} and @command{guix build} have to be used with | |
2876 | the @code{-e} option so that they know where to find the package. | |
a1ba8475 LC |
2877 | |
2878 | The distribution is fully @dfn{bootstrapped} and @dfn{self-contained}: | |
2879 | each package is built based solely on other packages in the | |
2880 | distribution. The root of this dependency graph is a small set of | |
2881 | @dfn{bootstrap binaries}, provided by the @code{(gnu packages | |
b81e1947 LC |
2882 | bootstrap)} module. For more information on bootstrapping, |
2883 | @ref{Bootstrapping}. | |
2884 | ||
da7cabd4 AE |
2885 | @node Packaging Guidelines |
2886 | @section Packaging Guidelines | |
b81e1947 LC |
2887 | |
2888 | The GNU distribution is nascent and may well lack some of your favorite | |
2889 | packages. This section describes how you can help make the distribution | |
c8c871d1 | 2890 | grow. @xref{Contributing}, for additional information on how you can |
b81e1947 LC |
2891 | help. |
2892 | ||
b81e1947 LC |
2893 | Free software packages are usually distributed in the form of |
2894 | @dfn{source code tarballs}---typically @file{tar.gz} files that contain | |
2895 | all the source files. Adding a package to the distribution means | |
2896 | essentially two things: adding a @dfn{recipe} that describes how to | |
2897 | build the package, including a list of other packages required to build | |
2898 | it, and adding @dfn{package meta-data} along with that recipe, such as a | |
2899 | description and licensing information. | |
2900 | ||
2901 | In Guix all this information is embodied in @dfn{package definitions}. | |
2902 | Package definitions provide a high-level view of the package. They are | |
2903 | written using the syntax of the Scheme programming language; in fact, | |
2904 | for each package we define a variable bound to the package definition, | |
2905 | and export that variable from a module (@pxref{Package Modules}). | |
2906 | However, in-depth Scheme knowledge is @emph{not} a prerequisite for | |
2907 | creating packages. For more information on package definitions, | |
2908 | @ref{Defining Packages}. | |
2909 | ||
2910 | Once a package definition is in place, stored in a file in the Guix | |
2911 | source tree, it can be tested using the @command{guix build} command | |
2912 | (@pxref{Invoking guix build}). For example, assuming the new package is | |
2913 | called @code{gnew}, you may run this command from the Guix build tree: | |
2914 | ||
2915 | @example | |
2916 | ./pre-inst-env guix build gnew --keep-failed | |
2917 | @end example | |
2918 | ||
2919 | Using @code{--keep-failed} makes it easier to debug build failures since | |
7458bd0a LC |
2920 | it provides access to the failed build tree. Another useful |
2921 | command-line option when debugging is @code{--log-file}, to access the | |
2922 | build log. | |
b81e1947 | 2923 | |
5ff3c4b8 PAR |
2924 | If the package is unknown to the @command{guix} command, it may be that |
2925 | the source file contains a syntax error, or lacks a @code{define-public} | |
2926 | clause to export the package variable. To figure it out, you may load | |
2927 | the module from Guile to get more information about the actual error: | |
2928 | ||
2929 | @example | |
2930 | ./pre-inst-env guile -c '(use-modules (gnu packages gnew))' | |
2931 | @end example | |
2932 | ||
b81e1947 LC |
2933 | Once your package builds correctly, please send us a patch |
2934 | (@pxref{Contributing}). Well, if you need help, we will be happy to | |
2935 | help you too. Once the patch is committed in the Guix repository, the | |
2936 | new package automatically gets built on the supported platforms by | |
2937 | @url{http://hydra.gnu.org/gnu/master, our continuous integration | |
2938 | system}. | |
2939 | ||
2940 | @cindex substituter | |
2941 | Users can obtain the new package definition simply by running | |
2942 | @command{guix pull} (@pxref{Invoking guix pull}). When | |
2943 | @code{hydra.gnu.org} is done building the package, installing the | |
c4202d60 LC |
2944 | package automatically downloads binaries from there |
2945 | (@pxref{Substitutes}). The only place where human intervention is | |
b81e1947 | 2946 | needed is to review and apply the patch. |
401c53c4 LC |
2947 | |
2948 | ||
da7cabd4 | 2949 | @menu |
ee85f3db AE |
2950 | * Software Freedom:: What may go into the distribution. |
2951 | * Package Naming:: What's in a name? | |
2952 | * Version Numbers:: When the name is not enough. | |
2953 | * Python Modules:: Taming the snake. | |
af8a56b8 | 2954 | * Perl Modules:: Little pearls. |
da7cabd4 AE |
2955 | @end menu |
2956 | ||
2957 | @node Software Freedom | |
2958 | @subsection Software Freedom | |
2959 | ||
2960 | @c Adapted from http://www.gnu.org/philosophy/philosophy.html. | |
2961 | ||
2962 | The GNU operating system has been developed so that users can have | |
2963 | freedom in their computing. GNU is @dfn{free software}, meaning that | |
2964 | users have the @url{http://www.gnu.org/philosophy/free-sw.html,four | |
2965 | essential freedoms}: to run the program, to study and change the program | |
2966 | in source code form, to redistribute exact copies, and to distribute | |
2967 | modified versions. Packages found in the GNU distribution provide only | |
2968 | software that conveys these four freedoms. | |
2969 | ||
2970 | In addition, the GNU distribution follow the | |
2971 | @url{http://www.gnu.org/distros/free-system-distribution-guidelines.html,free | |
2972 | software distribution guidelines}. Among other things, these guidelines | |
2973 | reject non-free firmware, recommendations of non-free software, and | |
2974 | discuss ways to deal with trademarks and patents. | |
2975 | ||
f9cc8971 LC |
2976 | Some packages contain a small and optional subset that violates the |
2977 | above guidelines, for instance because this subset is itself non-free | |
2978 | code. When that happens, the offending items are removed with | |
2979 | appropriate patches or code snippets in the package definition's | |
2980 | @code{origin} form (@pxref{Defining Packages}). That way, @code{guix | |
2981 | build --source} returns the ``freed'' source rather than the unmodified | |
2982 | upstream source. | |
2983 | ||
da7cabd4 | 2984 | |
ee85f3db AE |
2985 | @node Package Naming |
2986 | @subsection Package Naming | |
2987 | ||
c8c871d1 | 2988 | A package has actually two names associated with it: |
ee85f3db | 2989 | First, there is the name of the @emph{Scheme variable}, the one following |
c8c871d1 AE |
2990 | @code{define-public}. By this name, the package can be made known in the |
2991 | Scheme code, for instance as input to another package. Second, there is | |
2992 | the string in the @code{name} field of a package definition. This name | |
2993 | is used by package management commands such as | |
2994 | @command{guix package} and @command{guix build}. | |
ee85f3db | 2995 | |
25083588 LC |
2996 | Both are usually the same and correspond to the lowercase conversion of |
2997 | the project name chosen upstream, with underscores replaced with | |
2998 | hyphens. For instance, GNUnet is available as @code{gnunet}, and | |
2999 | SDL_net as @code{sdl-net}. | |
3000 | ||
3001 | We do not add @code{lib} prefixes for library packages, unless these are | |
3002 | already part of the official project name. But see @pxref{Python | |
3003 | Modules} and @ref{Perl Modules} for special rules concerning modules for | |
3004 | the Python and Perl languages. | |
ee85f3db AE |
3005 | |
3006 | ||
3007 | @node Version Numbers | |
3008 | @subsection Version Numbers | |
3009 | ||
3010 | We usually package only the latest version of a given free software | |
c8c871d1 AE |
3011 | project. But sometimes, for instance for incompatible library versions, |
3012 | two (or more) versions of the same package are needed. These require | |
3013 | different Scheme variable names. We use the name as defined | |
3014 | in @ref{Package Naming} | |
ee85f3db AE |
3015 | for the most recent version; previous versions use the same name, suffixed |
3016 | by @code{-} and the smallest prefix of the version number that may | |
3017 | distinguish the two versions. | |
3018 | ||
3019 | The name inside the package definition is the same for all versions of a | |
3020 | package and does not contain any version number. | |
3021 | ||
3022 | For instance, the versions 2.24.20 and 3.9.12 of GTK+ may be packaged as follows: | |
c8c871d1 | 3023 | |
ee85f3db AE |
3024 | @example |
3025 | (define-public gtk+ | |
3026 | (package | |
3027 | (name "gtk+") | |
3028 | (version "3.9.12") | |
3029 | ...)) | |
3030 | (define-public gtk+-2 | |
3031 | (package | |
3032 | (name "gtk+") | |
3033 | (version "2.24.20") | |
3034 | ...)) | |
3035 | @end example | |
3036 | If we also wanted GTK+ 3.8.2, this would be packaged as | |
3037 | @example | |
3038 | (define-public gtk+-3.8 | |
3039 | (package | |
3040 | (name "gtk+") | |
3041 | (version "3.8.2") | |
3042 | ...)) | |
3043 | @end example | |
3044 | ||
3045 | ||
3046 | @node Python Modules | |
3047 | @subsection Python Modules | |
3048 | ||
3049 | We currently package Python 2 and Python 3, under the Scheme variable names | |
3050 | @code{python-2} and @code{python} as explained in @ref{Version Numbers}. | |
3051 | To avoid confusion and naming clashes with other programming languages, it | |
3052 | seems desirable that the name of a package for a Python module contains | |
3053 | the word @code{python}. | |
c8c871d1 | 3054 | |
ee85f3db AE |
3055 | Some modules are compatible with only one version of Python, others with both. |
3056 | If the package Foo compiles only with Python 3, we name it | |
3057 | @code{python-foo}; if it compiles only with Python 2, we name it | |
3058 | @code{python2-foo}. If it is compatible with both versions, we create two | |
3059 | packages with the corresponding names. | |
3060 | ||
3061 | If a project already contains the word @code{python}, we drop this; | |
3062 | for instance, the module python-dateutil is packaged under the names | |
3063 | @code{python-dateutil} and @code{python2-dateutil}. | |
3064 | ||
3065 | ||
af8a56b8 AE |
3066 | @node Perl Modules |
3067 | @subsection Perl Modules | |
3068 | ||
3069 | Perl programs standing for themselves are named as any other package, | |
3070 | using the lowercase upstream name. | |
3071 | For Perl packages containing a single class, we use the lowercase class name, | |
3072 | replace all occurrences of @code{::} by dashes and prepend the prefix | |
3073 | @code{perl-}. | |
3074 | So the class @code{XML::Parser} becomes @code{perl-xml-parser}. | |
3075 | Modules containing several classes keep their lowercase upstream name and | |
3076 | are also prepended by @code{perl-}. Such modules tend to have the word | |
3077 | @code{perl} somewhere in their name, which gets dropped in favor of the | |
3078 | prefix. For instance, @code{libwww-perl} becomes @code{perl-libwww}. | |
ee85f3db AE |
3079 | |
3080 | ||
3081 | ||
401c53c4 LC |
3082 | @node Bootstrapping |
3083 | @section Bootstrapping | |
3084 | ||
3085 | @c Adapted from the ELS 2013 paper. | |
3086 | ||
3087 | @cindex bootstrapping | |
3088 | ||
3089 | Bootstrapping in our context refers to how the distribution gets built | |
3090 | ``from nothing''. Remember that the build environment of a derivation | |
3091 | contains nothing but its declared inputs (@pxref{Introduction}). So | |
3092 | there's an obvious chicken-and-egg problem: how does the first package | |
3093 | get built? How does the first compiler get compiled? Note that this is | |
3094 | a question of interest only to the curious hacker, not to the regular | |
3095 | user, so you can shamelessly skip this section if you consider yourself | |
3096 | a ``regular user''. | |
3097 | ||
3098 | @cindex bootstrap binaries | |
3099 | The GNU system is primarily made of C code, with libc at its core. The | |
3100 | GNU build system itself assumes the availability of a Bourne shell and | |
3101 | command-line tools provided by GNU Coreutils, Awk, Findutils, `sed', and | |
3102 | `grep'. Furthermore, build programs---programs that run | |
3103 | @code{./configure}, @code{make}, etc.---are written in Guile Scheme | |
3104 | (@pxref{Derivations}). Consequently, to be able to build anything at | |
3105 | all, from scratch, Guix relies on pre-built binaries of Guile, GCC, | |
3106 | Binutils, libc, and the other packages mentioned above---the | |
3107 | @dfn{bootstrap binaries}. | |
3108 | ||
3109 | These bootstrap binaries are ``taken for granted'', though we can also | |
ba7ea5ce | 3110 | re-create them if needed (more on that later). |
401c53c4 LC |
3111 | |
3112 | @unnumberedsubsec Preparing to Use the Bootstrap Binaries | |
3113 | ||
3114 | @c As of Emacs 24.3, Info-mode displays the image, but since it's a | |
3115 | @c large image, it's hard to scroll. Oh well. | |
29f66ddd | 3116 | @image{images/bootstrap-graph,6in,,Dependency graph of the early bootstrap derivations} |
401c53c4 LC |
3117 | |
3118 | The figure above shows the very beginning of the dependency graph of the | |
3119 | distribution, corresponding to the package definitions of the @code{(gnu | |
3120 | packages bootstrap)} module. At this level of detail, things are | |
3121 | slightly complex. First, Guile itself consists of an ELF executable, | |
3122 | along with many source and compiled Scheme files that are dynamically | |
3123 | loaded when it runs. This gets stored in the @file{guile-2.0.7.tar.xz} | |
3124 | tarball shown in this graph. This tarball is part of Guix's ``source'' | |
3125 | distribution, and gets inserted into the store with @code{add-to-store} | |
3126 | (@pxref{The Store}). | |
a1ba8475 | 3127 | |
401c53c4 LC |
3128 | But how do we write a derivation that unpacks this tarball and adds it |
3129 | to the store? To solve this problem, the @code{guile-bootstrap-2.0.drv} | |
3130 | derivation---the first one that gets built---uses @code{bash} as its | |
3131 | builder, which runs @code{build-bootstrap-guile.sh}, which in turn calls | |
3132 | @code{tar} to unpack the tarball. Thus, @file{bash}, @file{tar}, | |
3133 | @file{xz}, and @file{mkdir} are statically-linked binaries, also part of | |
3134 | the Guix source distribution, whose sole purpose is to allow the Guile | |
3135 | tarball to be unpacked. | |
3136 | ||
3137 | Once @code{guile-bootstrap-2.0.drv} is built, we have a functioning | |
3138 | Guile that can be used to run subsequent build programs. Its first task | |
3139 | is to download tarballs containing the other pre-built binaries---this | |
3140 | is what the @code{.tar.xz.drv} derivations do. Guix modules such as | |
3141 | @code{ftp-client.scm} are used for this purpose. The | |
3142 | @code{module-import.drv} derivations import those modules in a directory | |
3143 | in the store, using the original layout. The | |
3144 | @code{module-import-compiled.drv} derivations compile those modules, and | |
3145 | write them in an output directory with the right layout. This | |
3146 | corresponds to the @code{#:modules} argument of | |
3147 | @code{build-expression->derivation} (@pxref{Derivations}). | |
3148 | ||
3149 | Finally, the various tarballs are unpacked by the | |
3150 | derivations @code{gcc-bootstrap-0.drv}, @code{glibc-bootstrap-0.drv}, | |
3151 | etc., at which point we have a working C tool chain. | |
3152 | ||
3153 | ||
3154 | @unnumberedsubsec Building the Build Tools | |
3155 | ||
3156 | @c TODO: Add a package-level dependency graph generated from (gnu | |
3157 | @c packages base). | |
3158 | ||
3159 | Bootstrapping is complete when we have a full tool chain that does not | |
3160 | depend on the pre-built bootstrap tools discussed above. This | |
3161 | no-dependency requirement is verified by checking whether the files of | |
834129e0 | 3162 | the final tool chain contain references to the @file{/gnu/store} |
401c53c4 LC |
3163 | directories of the bootstrap inputs. The process that leads to this |
3164 | ``final'' tool chain is described by the package definitions found in | |
3165 | the @code{(gnu packages base)} module. | |
3166 | ||
3167 | @c See <http://lists.gnu.org/archive/html/gnu-system-discuss/2012-10/msg00000.html>. | |
3168 | The first tool that gets built with the bootstrap binaries is | |
3169 | GNU Make, which is a prerequisite for all the following packages. | |
3170 | From there Findutils and Diffutils get built. | |
3171 | ||
3172 | Then come the first-stage Binutils and GCC, built as pseudo cross | |
3173 | tools---i.e., with @code{--target} equal to @code{--host}. They are | |
3174 | used to build libc. Thanks to this cross-build trick, this libc is | |
3175 | guaranteed not to hold any reference to the initial tool chain. | |
3176 | ||
3177 | From there the final Binutils and GCC are built. GCC uses @code{ld} | |
3178 | from the final Binutils, and links programs against the just-built libc. | |
3179 | This tool chain is used to build the other packages used by Guix and by | |
3180 | the GNU Build System: Guile, Bash, Coreutils, etc. | |
3181 | ||
3182 | And voilà! At this point we have the complete set of build tools that | |
3183 | the GNU Build System expects. These are in the @code{%final-inputs} | |
3184 | variables of the @code{(gnu packages base)} module, and are implicitly | |
3185 | used by any package that uses @code{gnu-build-system} (@pxref{Defining | |
3186 | Packages}). | |
3187 | ||
3188 | ||
3189 | @unnumberedsubsec Building the Bootstrap Binaries | |
3190 | ||
3191 | Because the final tool chain does not depend on the bootstrap binaries, | |
3192 | those rarely need to be updated. Nevertheless, it is useful to have an | |
3193 | automated way to produce them, should an update occur, and this is what | |
3194 | the @code{(gnu packages make-bootstrap)} module provides. | |
3195 | ||
3196 | The following command builds the tarballs containing the bootstrap | |
3197 | binaries (Guile, Binutils, GCC, libc, and a tarball containing a mixture | |
3198 | of Coreutils and other basic command-line tools): | |
a1ba8475 | 3199 | |
401c53c4 LC |
3200 | @example |
3201 | guix build bootstrap-tarballs | |
3202 | @end example | |
3203 | ||
3204 | The generated tarballs are those that should be referred to in the | |
3205 | @code{(gnu packages bootstrap)} module mentioned at the beginning of | |
3206 | this section. | |
3207 | ||
3208 | Still here? Then perhaps by now you've started to wonder: when do we | |
3209 | reach a fixed point? That is an interesting question! The answer is | |
3210 | unknown, but if you would like to investigate further (and have | |
3211 | significant computational and storage resources to do so), then let us | |
3212 | know. | |
a1ba8475 | 3213 | |
8b315a6d LC |
3214 | @node Porting |
3215 | @section Porting to a New Platform | |
3216 | ||
3217 | As discussed above, the GNU distribution is self-contained, and | |
3218 | self-containment is achieved by relying on pre-built ``bootstrap | |
3219 | binaries'' (@pxref{Bootstrapping}). These binaries are specific to an | |
3220 | operating system kernel, CPU architecture, and application binary | |
3221 | interface (ABI). Thus, to port the distribution to a platform that is | |
3222 | not yet supported, one must build those bootstrap binaries, and update | |
3223 | the @code{(gnu packages bootstrap)} module to use them on that platform. | |
3224 | ||
3225 | Fortunately, Guix can @emph{cross compile} those bootstrap binaries. | |
3226 | When everything goes well, and assuming the GNU tool chain supports the | |
3227 | target platform, this can be as simple as running a command like this | |
3228 | one: | |
3229 | ||
3230 | @example | |
3231 | guix build --target=armv5tel-linux-gnueabi bootstrap-tarballs | |
3232 | @end example | |
3233 | ||
72e25e35 LC |
3234 | Once these are built, the @code{(gnu packages bootstrap)} module needs |
3235 | to be updated to refer to these binaries on the target platform. In | |
3236 | addition, the @code{glibc-dynamic-linker} procedure in that module must | |
3237 | be augmented to return the right file name for libc's dynamic linker on | |
3238 | that platform; likewise, @code{system->linux-architecture} in @code{(gnu | |
3239 | packages linux)} must be taught about the new platform. | |
3240 | ||
8b315a6d LC |
3241 | In practice, there may be some complications. First, it may be that the |
3242 | extended GNU triplet that specifies an ABI (like the @code{eabi} suffix | |
3243 | above) is not recognized by all the GNU tools. Typically, glibc | |
3244 | recognizes some of these, whereas GCC uses an extra @code{--with-abi} | |
ba7ea5ce | 3245 | configure flag (see @code{gcc.scm} for examples of how to handle this). |
8b315a6d LC |
3246 | Second, some of the required packages could fail to build for that |
3247 | platform. Lastly, the generated binaries could be broken for some | |
3248 | reason. | |
3249 | ||
9bf3c1a7 | 3250 | |
4af2447e LC |
3251 | @node System Configuration |
3252 | @section System Configuration | |
3253 | ||
4af2447e LC |
3254 | @cindex system configuration |
3255 | The GNU system supports a consistent whole-system configuration | |
3256 | mechanism. By that we mean that all aspects of the global system | |
3257 | configuration---such as the available system services, timezone and | |
68ad877c | 3258 | locale settings, user accounts---are declared in a single place. Such |
4af2447e LC |
3259 | a @dfn{system configuration} can be @dfn{instantiated}---i.e., effected. |
3260 | ||
68ad877c LC |
3261 | One of the advantages of putting all the system configuration under the |
3262 | control of Guix is that it supports transactional system upgrades, and | |
3263 | makes it possible to roll-back to a previous system instantiation, | |
3264 | should something go wrong with the new one (@pxref{Features}). Another | |
3265 | one is that it makes it easy to replicate the exact same configuration | |
3266 | across different machines, or at different points in time, without | |
3267 | having to resort to additional administration tools layered on top of | |
3268 | the system's own tools. | |
3269 | @c Yes, we're talking of Puppet, Chef, & co. here. ↑ | |
3270 | ||
4af2447e LC |
3271 | This section describes this mechanism. First we focus on the system |
3272 | administrator's viewpoint---explaining how the system is configured and | |
3273 | instantiated. Then we show how this mechanism can be extended, for | |
3274 | instance to support new system services. | |
3275 | ||
3276 | @menu | |
523e4896 | 3277 | * Using the Configuration System:: Customizing your GNU system. |
113daf62 LC |
3278 | * File Systems:: Configuring file system mounts. |
3279 | * User Accounts:: Specifying user accounts. | |
3280 | * Services:: Specifying system services. | |
523e4896 LC |
3281 | * Invoking guix system:: Instantiating a system configuration. |
3282 | * Defining Services:: Adding new service definitions. | |
4af2447e LC |
3283 | @end menu |
3284 | ||
3285 | @node Using the Configuration System | |
3286 | @subsection Using the Configuration System | |
3287 | ||
0918e64a LC |
3288 | The operating system is configured by providing an |
3289 | @code{operating-system} declaration in a file that can then be passed to | |
3290 | the @command{guix system} command (@pxref{Invoking guix system}). A | |
3291 | simple setup, with the default system services, the default Linux-Libre | |
3292 | kernel, initial RAM disk, and boot loader looks like this: | |
4af2447e LC |
3293 | |
3294 | @findex operating-system | |
3295 | @lisp | |
c9384945 | 3296 | (use-modules (gnu) ; for 'user-account', '%base-services', etc. |
6f436c54 LC |
3297 | (gnu packages emacs) ; for 'emacs' |
3298 | (gnu services ssh)) ; for 'lsh-service' | |
4af2447e | 3299 | |
0918e64a LC |
3300 | (operating-system |
3301 | (host-name "komputilo") | |
3302 | (timezone "Europe/Paris") | |
3303 | (locale "fr_FR.UTF-8") | |
3304 | (bootloader (grub-configuration | |
3305 | (device "/dev/sda"))) | |
3306 | (file-systems (list (file-system | |
3307 | (device "/dev/sda1") ; or partition label | |
3308 | (mount-point "/") | |
3309 | (type "ext3")))) | |
3310 | (users (list (user-account | |
3311 | (name "alice") | |
3312 | (password "") | |
3313 | (uid 1000) (gid 100) | |
3314 | (comment "Bob's sister") | |
3315 | (home-directory "/home/alice")))) | |
3316 | (packages (cons emacs %base-packages)) | |
3317 | (services (cons (lsh-service #:port 2222 #:allow-root-login? #t) | |
3318 | %base-services))) | |
4af2447e LC |
3319 | @end lisp |
3320 | ||
0918e64a LC |
3321 | This example should be self-describing. Some of the fields defined |
3322 | above, such as @code{host-name} and @code{bootloader}, are mandatory. | |
3323 | Others, such as @code{packages} and @code{services}, can be omitted, in | |
3324 | which case they get a default value. | |
3325 | ||
3326 | @vindex %base-packages | |
3327 | The @code{packages} field lists | |
6f436c54 LC |
3328 | packages that will be globally visible on the system, for all user |
3329 | accounts---i.e., in every user's @code{PATH} environment variable---in | |
3330 | addition to the per-user profiles (@pxref{Invoking guix package}). The | |
0918e64a | 3331 | @var{%base-packages} variable provides all the tools one would expect |
6f436c54 LC |
3332 | for basic user and administrator tasks---including the GNU Core |
3333 | Utilities, the GNU Networking Utilities, the GNU Zile lightweight text | |
3334 | editor, @command{find}, @command{grep}, etc. The example above adds | |
3335 | Emacs to those, taken from the @code{(gnu packages emacs)} module | |
3336 | (@pxref{Package Modules}). | |
4af2447e | 3337 | |
8b198abe | 3338 | @vindex %base-services |
4af2447e | 3339 | The @code{services} field lists @dfn{system services} to be made |
ef5dd60a | 3340 | available when the system starts (@pxref{Services}). |
4af2447e | 3341 | The @code{operating-system} declaration above specifies that, in |
ef5dd60a | 3342 | addition to the basic services, we want the @command{lshd} secure shell |
4af2447e LC |
3343 | daemon listening on port 2222, and allowing remote @code{root} logins |
3344 | (@pxref{Invoking lshd,,, lsh, GNU lsh Manual}). Under the hood, | |
3345 | @code{lsh-service} arranges so that @code{lshd} is started with the | |
3346 | right command-line options, possibly with supporting configuration files | |
3347 | generated as needed (@pxref{Defining Services}). | |
3348 | ||
4af2447e | 3349 | Assuming the above snippet is stored in the @file{my-system-config.scm} |
113daf62 | 3350 | file, the @command{guix system reconfigure my-system-config.scm} command |
523e4896 LC |
3351 | instantiates that configuration, and makes it the default GRUB boot |
3352 | entry (@pxref{Invoking guix system}). The normal way to change the | |
3353 | system's configuration is by updating this file and re-running the | |
3354 | @command{guix system} command. | |
4af2447e LC |
3355 | |
3356 | At the Scheme level, the bulk of an @code{operating-system} declaration | |
3357 | is instantiated with the following monadic procedure (@pxref{The Store | |
3358 | Monad}): | |
3359 | ||
3360 | @deffn {Monadic Procedure} operating-system-derivation os | |
3361 | Return a derivation that builds @var{os}, an @code{operating-system} | |
3362 | object (@pxref{Derivations}). | |
3363 | ||
3364 | The output of the derivation is a single directory that refers to all | |
3365 | the packages, configuration files, and other supporting files needed to | |
3366 | instantiate @var{os}. | |
3367 | @end deffn | |
3368 | ||
113daf62 LC |
3369 | @node File Systems |
3370 | @subsection File Systems | |
3371 | ||
3372 | The list of file systems to be mounted is specified in the | |
3373 | @code{file-systems} field of the operating system's declaration | |
3374 | (@pxref{Using the Configuration System}). Each file system is declared | |
3375 | using the @code{file-system} form, like this: | |
3376 | ||
3377 | @example | |
3378 | (file-system | |
3379 | (mount-point "/home") | |
3380 | (device "/dev/sda3") | |
3381 | (type "ext4")) | |
3382 | @end example | |
3383 | ||
3384 | As usual, some of the fields are mandatory---those shown in the example | |
3385 | above---while others can be omitted. These are described below. | |
3386 | ||
3387 | @deftp {Data Type} file-system | |
8451a568 | 3388 | Objects of this type represent file systems to be mounted. They |
113daf62 LC |
3389 | contain the following members: |
3390 | ||
3391 | @table @asis | |
3392 | @item @code{type} | |
3393 | This is a string specifying the type of the file system---e.g., | |
3394 | @code{"ext4"}. | |
3395 | ||
3396 | @item @code{mount-point} | |
3397 | This designates the place where the file system is to be mounted. | |
3398 | ||
3399 | @item @code{device} | |
3400 | This names the ``source'' of the file system. By default it is the name | |
3401 | of a node under @file{/dev}, but its meaning depends on the @code{title} | |
3402 | field described below. | |
3403 | ||
3404 | @item @code{title} (default: @code{'device}) | |
3405 | This is a symbol that specifies how the @code{device} field is to be | |
3406 | interpreted. | |
3407 | ||
3408 | When it is the symbol @code{device}, then the @code{device} field is | |
3409 | interpreted as a file name; when it is @code{label}, then @code{device} | |
3410 | is interpreted as a partition label name; when it is @code{uuid}, | |
3411 | @code{device} is interpreted as a partition unique identifier (UUID). | |
3412 | ||
3413 | The @code{label} and @code{uuid} options offer a way to refer to disk | |
3414 | partitions without having to hard-code their actual device name. | |
3415 | ||
3416 | @item @code{flags} (default: @code{'()}) | |
3417 | This is a list of symbols denoting mount flags. Recognized flags | |
3418 | include @code{read-only} and @code{bind-mount}. | |
3419 | ||
3420 | @item @code{options} (default: @code{#f}) | |
3421 | This is either @code{#f}, or a string denoting mount options. | |
3422 | ||
3423 | @item @code{needed-for-boot?} (default: @code{#f}) | |
3424 | This Boolean value indicates whether the file system is needed when | |
3425 | booting. If that is true, then the file system is mounted when the | |
3426 | initial RAM disk (initrd) is loaded. This is always the case, for | |
3427 | instance, for the root file system. | |
3428 | ||
3429 | @item @code{check?} (default: @code{#t}) | |
3430 | This Boolean indicates whether the file system needs to be checked for | |
3431 | errors before being mounted. | |
3432 | ||
3433 | @end table | |
3434 | @end deftp | |
3435 | ||
3436 | @node User Accounts | |
3437 | @subsection User Accounts | |
3438 | ||
8451a568 LC |
3439 | User accounts are specified with the @code{user-account} form: |
3440 | ||
3441 | @example | |
3442 | (user-account | |
3443 | (name "alice") | |
3444 | (group "users") | |
3445 | (supplementary-groups '("wheel")) ; allow use of sudo, etc. | |
3446 | (comment "Bob's sister") | |
3447 | (home-directory "/home/alice")) | |
3448 | @end example | |
3449 | ||
3450 | @deftp {Data Type} user-account | |
3451 | Objects of this type represent user accounts. The following members may | |
3452 | be specified: | |
3453 | ||
3454 | @table @asis | |
3455 | @item @code{name} | |
3456 | The name of the user account. | |
3457 | ||
3458 | @item @code{group} | |
3459 | This is the name (a string) or identifier (a number) of the user group | |
3460 | this account belongs to. | |
3461 | ||
3462 | @item @code{supplementary-groups} (default: @code{'()}) | |
3463 | Optionally, this can be defined as a list of group names that this | |
3464 | account belongs to. | |
3465 | ||
3466 | @item @code{uid} (default: @code{#f}) | |
3467 | This is the user ID for this account (a number), or @code{#f}. In the | |
3468 | latter case, a number is automatically chosen by the system when the | |
3469 | account is created. | |
3470 | ||
3471 | @item @code{comment} (default: @code{""}) | |
3472 | A comment about the account, such as the account's owner full name. | |
3473 | ||
3474 | @item @code{home-directory} | |
3475 | This is the name of the home directory for the account. | |
3476 | ||
3477 | @item @code{shell} (default: Bash) | |
3478 | This is a G-expression denoting the file name of a program to be used as | |
3479 | the shell (@pxref{G-Expressions}). | |
3480 | ||
3481 | @item @code{system?} (default: @code{#f}) | |
3482 | This Boolean value indicates whether the account is a ``system'' | |
3483 | account. System accounts are sometimes treated specially; for instance, | |
3484 | graphical login managers do not list them. | |
3485 | ||
3486 | @item @code{password} (default: @code{#f}) | |
3487 | Unless @code{#f}, this is the password to be used for the account. | |
3488 | ||
3489 | @end table | |
3490 | @end deftp | |
3491 | ||
3492 | User group declarations are even simpler: | |
3493 | ||
3494 | @example | |
3495 | (user-group (name "students")) | |
3496 | @end example | |
3497 | ||
3498 | @deftp {Data Type} user-group | |
3499 | This type is for, well, user groups. There are just a few fields: | |
3500 | ||
3501 | @table @asis | |
3502 | @item @code{name} | |
3503 | The group's name. | |
3504 | ||
3505 | @item @code{id} (default: @code{#f}) | |
3506 | The group identifier (a number). If @code{#f}, a new number is | |
3507 | automatically allocated when the group is created. | |
3508 | ||
3509 | @item @code{password} (default: @code{#f}) | |
3510 | What, user groups can have a password? Well, apparently yes. Unless | |
3511 | @code{#f}, this field specifies the group's password. | |
3512 | ||
3513 | @end table | |
3514 | @end deftp | |
3515 | ||
3516 | For convenience, a variable lists all the basic user groups one may | |
3517 | expect: | |
3518 | ||
3519 | @defvr {Scheme Variable} %base-groups | |
3520 | This is the list of basic user groups that users and/or packages expect | |
3521 | to be present on the system. This includes groups such as ``root'', | |
3522 | ``wheel'', and ``users'', as well as groups used to control access to | |
3523 | specific devices such as ``audio'', ``disk'', and ``cdrom''. | |
3524 | @end defvr | |
3525 | ||
113daf62 LC |
3526 | |
3527 | @node Services | |
3528 | @subsection Services | |
3529 | ||
ef5dd60a LC |
3530 | @cindex system services |
3531 | An important part of preparing an @code{operating-system} declaration is | |
3532 | listing @dfn{system services} and their configuration (@pxref{Using the | |
3533 | Configuration System}). System services are typically daemons launched | |
3534 | when the system boots, or other actions needed at that time---e.g., | |
3535 | configuring network access. They are managed by GNU@tie{}dmd | |
3536 | (@pxref{Introduction,,, dmd, GNU dmd Manual}). | |
3537 | ||
3538 | The following sections document the available services, starting with | |
3539 | the core services. | |
3540 | ||
3541 | @menu | |
3542 | * Base Services:: Essential system services. | |
3543 | * Networking Services:: Network setup, SSH daemon, etc. | |
3544 | * X Window:: Graphical display. | |
3545 | @end menu | |
3546 | ||
3547 | @node Base Services | |
3548 | @subsubsection Base Services | |
3549 | ||
3550 | The @code{(gnu services base)} module provides definitions for the basic | |
3551 | services that one expects from the system. The services exported by | |
3552 | this module are listed below. | |
3553 | ||
3554 | @defvr {Scheme Variable} %base-services | |
3555 | This variable contains a list of basic services@footnote{Technically, | |
3556 | this is a list of monadic services. @xref{The Store Monad}.} one would | |
3557 | expect from the system: a login service (mingetty) on each tty, syslogd, | |
3558 | libc's name service cache daemon (nscd), the udev device manager, and | |
3559 | more. | |
3560 | ||
3561 | This is the default value of the @code{services} field of | |
3562 | @code{operating-system} declarations. Usually, when customizing a | |
3563 | system, you will want to append services to @var{%base-services}, like | |
3564 | this: | |
3565 | ||
3566 | @example | |
3567 | (cons* (avahi-service) (lshd-service) %base-services) | |
3568 | @end example | |
3569 | @end defvr | |
3570 | ||
3571 | @deffn {Monadic Procedure} host-name-service @var{name} | |
3572 | Return a service that sets the host name to @var{name}. | |
3573 | @end deffn | |
3574 | ||
3575 | @deffn {Monadic Procedure} mingetty-service @var{tty} [#:motd] @ | |
3576 | [#:auto-login #f] [#:login-program] [#:login-pause? #f] @ | |
3577 | [#:allow-empty-passwords? #f] | |
3578 | Return a service to run mingetty on @var{tty}. | |
3579 | ||
3580 | When @var{allow-empty-passwords?} is true, allow empty log-in password. When | |
3581 | @var{auto-login} is true, it must be a user name under which to log-in | |
3582 | automatically. @var{login-pause?} can be set to @code{#t} in conjunction with | |
3583 | @var{auto-login}, in which case the user will have to press a key before the | |
3584 | login shell is launched. | |
3585 | ||
3586 | When true, @var{login-program} is a gexp or a monadic gexp denoting the name | |
3587 | of the log-in program (the default is the @code{login} program from the Shadow | |
3588 | tool suite.) | |
3589 | ||
3590 | @var{motd} is a monadic value containing a text file to use as | |
3591 | the ``message of the day''. | |
3592 | @end deffn | |
3593 | ||
3594 | @deffn {Monadic Procedure} nscd-service [#:glibc glibc] | |
3595 | Return a service that runs libc's name service cache daemon (nscd). | |
3596 | @end deffn | |
3597 | ||
3598 | @deffn {Monadic Procedure} syslog-service | |
3599 | Return a service that runs @code{syslogd} with reasonable default | |
3600 | settings. | |
3601 | @end deffn | |
3602 | ||
3603 | @deffn {Monadic Procedure} guix-service [#:guix guix] @ | |
3604 | [#:builder-group "guixbuild"] [#:build-accounts 10] @ | |
c11a6eb1 LC |
3605 | [#:authorize-hydra-key? #f] [#:use-substitutes? #t] @ |
3606 | [#:extra-options '()] | |
ef5dd60a LC |
3607 | Return a service that runs the build daemon from @var{guix}, and has |
3608 | @var{build-accounts} user accounts available under @var{builder-group}. | |
3609 | ||
3610 | When @var{authorize-hydra-key?} is true, the @code{hydra.gnu.org} public key | |
3611 | provided by @var{guix} is authorized upon activation, meaning that substitutes | |
3612 | from @code{hydra.gnu.org} are used by default. | |
c11a6eb1 LC |
3613 | |
3614 | If @var{use-substitutes?} is false, the daemon is run with | |
3615 | @option{--no-substitutes} (@pxref{Invoking guix-daemon, | |
3616 | @option{--no-substitutes}}). | |
3617 | ||
3618 | Finally, @var{extra-options} is a list of additional command-line options | |
3619 | passed to @command{guix-daemon}. | |
ef5dd60a LC |
3620 | @end deffn |
3621 | ||
3622 | @deffn {Monadic Procedure} udev-service [#:udev udev] | |
3623 | Run @var{udev}, which populates the @file{/dev} directory dynamically. | |
3624 | @end deffn | |
3625 | ||
3626 | @node Networking Services | |
3627 | @subsubsection Networking Services | |
3628 | ||
3629 | The @code{(gnu system networking)} module provides services to configure | |
3630 | the network interface. | |
3631 | ||
3632 | @deffn {Monadic Procedure} static-networking-service @var{interface} @var{ip} @ | |
3633 | [#:gateway #f] [#:name-services @code{'()}] | |
3634 | Return a service that starts @var{interface} with address @var{ip}. If | |
3635 | @var{gateway} is true, it must be a string specifying the default network | |
3636 | gateway. | |
3637 | @end deffn | |
3638 | ||
927097ef LC |
3639 | @deffn {Monadic Procedure} tor-service [#:tor tor] |
3640 | Return a service to run the @uref{https://torproject.org,Tor} daemon. | |
3641 | ||
3642 | The daemon runs with the default settings (in particular the default exit | |
3643 | policy) as the @code{tor} unprivileged user. | |
3644 | @end deffn | |
3645 | ||
ef5dd60a LC |
3646 | In addition, @code{(gnu system ssh)} provides the following service. |
3647 | ||
3648 | @deffn {Monadic Procedure} lsh-service [#:host-key "/etc/lsh/host-key"] @ | |
3649 | [#:interfaces '()] [#:port-number 22] @ | |
3650 | [#:allow-empty-passwords? #f] [#:root-login? #f] @ | |
3651 | [#:syslog-output? #t] [#:x11-forwarding? #t] @ | |
3652 | [#:tcp/ip-forwarding? #t] [#:password-authentication? #t] @ | |
3653 | [public-key-authentication? #t] [#:initialize? #f] | |
3654 | Run the @command{lshd} program from @var{lsh} to listen on port @var{port-number}. | |
3655 | @var{host-key} must designate a file containing the host key, and readable | |
3656 | only by root. | |
3657 | ||
3658 | When @var{initialize?} is true, automatically create the seed and host key | |
3659 | upon service activation if they do not exist yet. This may take long and | |
3660 | require interaction. | |
3661 | ||
3662 | When @var{interfaces} is empty, lshd listens for connections on all the | |
3663 | network interfaces; otherwise, @var{interfaces} must be a list of host names | |
3664 | or addresses. | |
3665 | ||
3666 | @var{allow-empty-passwords?} specifies whether to accepts log-ins with empty | |
3667 | passwords, and @var{root-login?} specifies whether to accepts log-ins as | |
3668 | root. | |
3669 | ||
3670 | The other options should be self-descriptive. | |
3671 | @end deffn | |
3672 | ||
3673 | @node X Window | |
3674 | @subsubsection X Window | |
3675 | ||
3676 | Support for the X Window graphical display system---specifically | |
3677 | Xorg---is provided by the @code{(gnu services xorg)} module. Note that | |
3678 | there is no @code{xorg-service} procedure. Instead, the X server is | |
3679 | started by the @dfn{login manager}, currently SLiM. | |
3680 | ||
3681 | @deffn {Monadic Procedure} slim-service [#:allow-empty-passwords? #f] @ | |
3682 | [#:auto-login? #f] [#:default-user ""] [#:startx] | |
3683 | Return a service that spawns the SLiM graphical login manager, which in | |
3684 | turn starts the X display server with @var{startx}, a command as returned by | |
3685 | @code{xorg-start-command}. | |
3686 | ||
3687 | When @var{allow-empty-passwords?} is true, allow logins with an empty | |
3688 | password. When @var{auto-login?} is true, log in automatically as | |
3689 | @var{default-user}. | |
3690 | @end deffn | |
3691 | ||
113daf62 | 3692 | |
523e4896 LC |
3693 | @node Invoking guix system |
3694 | @subsection Invoking @code{guix system} | |
3695 | ||
3696 | Once you have written an operating system declaration, as seen in the | |
3697 | previous section, it can be @dfn{instantiated} using the @command{guix | |
3698 | system} command. The synopsis is: | |
3699 | ||
3700 | @example | |
3701 | guix system @var{options}@dots{} @var{action} @var{file} | |
3702 | @end example | |
3703 | ||
3704 | @var{file} must be the name of a file containing an | |
3705 | @code{operating-system} declaration. @var{action} specifies how the | |
2e7b5cea LC |
3706 | operating system is instantiate. Currently the following values are |
3707 | supported: | |
523e4896 LC |
3708 | |
3709 | @table @code | |
b25937e3 LC |
3710 | @item reconfigure |
3711 | Build the operating system described in @var{file}, activate it, and | |
3712 | switch to it@footnote{This action is usable only on systems already | |
3713 | running GNU.}. | |
3714 | ||
3715 | This effects all the configuration specified in @var{file}: user | |
3716 | accounts, system services, global package list, setuid programs, etc. | |
3717 | ||
3718 | It also adds a GRUB menu entry for the new OS configuration, and moves | |
3719 | entries for older configurations to a submenu---unless | |
3720 | @option{--no-grub} is passed. | |
3721 | ||
7889394e LC |
3722 | @item build |
3723 | Build the operating system's derivation, which includes all the | |
3724 | configuration files and programs needed to boot and run the system. | |
3725 | This action does not actually install anything. | |
3726 | ||
72b9d60d LC |
3727 | @item init |
3728 | Populate the given directory with all the files necessary to run the | |
3729 | operating system specified in @var{file}. This is useful for first-time | |
3730 | installations of the GNU system. For instance: | |
3731 | ||
3732 | @example | |
3733 | guix system init my-os-config.scm /mnt | |
3734 | @end example | |
3735 | ||
3736 | copies to @file{/mnt} all the store items required by the configuration | |
3737 | specified in @file{my-os-config.scm}. This includes configuration | |
3738 | files, packages, and so on. It also creates other essential files | |
3739 | needed for the system to operate correctly---e.g., the @file{/etc}, | |
3740 | @file{/var}, and @file{/run} directories, and the @file{/bin/sh} file. | |
3741 | ||
c79d54fe LC |
3742 | This command also installs GRUB on the device specified in |
3743 | @file{my-os-config}, unless the @option{--no-grub} option was passed. | |
3744 | ||
523e4896 LC |
3745 | @item vm |
3746 | @cindex virtual machine | |
3747 | Build a virtual machine that contain the operating system declared in | |
3748 | @var{file}, and return a script to run that virtual machine (VM). | |
3749 | ||
3750 | The VM shares its store with the host system. | |
2e7b5cea LC |
3751 | |
3752 | @item vm-image | |
fb729425 LC |
3753 | @itemx disk-image |
3754 | Return a virtual machine or disk image of the operating system declared | |
3755 | in @var{file} that stands alone. Use the @option{--image-size} option | |
3756 | to specify the size of the image. | |
3757 | ||
3758 | When using @code{vm-image}, the returned image is in qcow2 format, which | |
3759 | the QEMU emulator can efficiently use. | |
3760 | ||
3761 | When using @code{disk-image}, a raw disk image is produced; it can be | |
3762 | copied as is to a USB stick, for instance. Assuming @code{/dev/sdc} is | |
3763 | the device corresponding to a USB stick, one can copy the image on it | |
3764 | using the following command: | |
3765 | ||
3766 | @example | |
3767 | # dd if=$(guix system disk-image my-os.scm) of=/dev/sdc | |
3768 | @end example | |
3769 | ||
523e4896 LC |
3770 | @end table |
3771 | ||
3772 | @var{options} can contain any of the common build options provided by | |
df2ce343 LC |
3773 | @command{guix build} (@pxref{Invoking guix build}). In addition, |
3774 | @var{options} can contain one of the following: | |
3775 | ||
3776 | @table @option | |
3777 | @item --system=@var{system} | |
3778 | @itemx -s @var{system} | |
3779 | Attempt to build for @var{system} instead of the host's system type. | |
3780 | This works as per @command{guix build} (@pxref{Invoking guix build}). | |
3781 | ||
3782 | @item --image-size=@var{size} | |
3783 | For the @code{vm-image} and @code{disk-image} actions, create an image | |
3784 | of the given @var{size}. @var{size} may be a number of bytes, or it may | |
3785 | include a unit as a suffix, such as @code{MiB} for mebibytes and | |
3786 | @code{GB} for gigabytes. | |
3787 | @end table | |
523e4896 | 3788 | |
080571ee LC |
3789 | Note that all the actions above, except @code{build} and @code{init}, |
3790 | rely on KVM support in the Linux-Libre kernel. Specifically, the | |
3791 | machine should have hardware virtualization support, the corresponding | |
3792 | KVM kernel module should be loaded, and the @file{/dev/kvm} device node | |
3793 | must exist and be readable and writable by the user and by the daemon's | |
3794 | build users. | |
4af2447e LC |
3795 | |
3796 | @node Defining Services | |
3797 | @subsection Defining Services | |
3798 | ||
db4fdc04 | 3799 | The @code{(gnu services @dots{})} modules define several procedures that allow |
4af2447e LC |
3800 | users to declare the operating system's services (@pxref{Using the |
3801 | Configuration System}). These procedures are @emph{monadic | |
3802 | procedures}---i.e., procedures that return a monadic value in the store | |
246a8106 LC |
3803 | monad (@pxref{The Store Monad}). For examples of such procedures, |
3804 | @xref{Services}. | |
4af2447e LC |
3805 | |
3806 | @cindex service definition | |
3807 | The monadic value returned by those procedures is a @dfn{service | |
3808 | definition}---a structure as returned by the @code{service} form. | |
3809 | Service definitions specifies the inputs the service depends on, and an | |
3810 | expression to start and stop the service. Behind the scenes, service | |
3811 | definitions are ``translated'' into the form suitable for the | |
3812 | configuration file of dmd, the init system (@pxref{Services,,, dmd, GNU | |
3813 | dmd Manual}). | |
3814 | ||
3815 | As an example, here is what the @code{nscd-service} procedure looks | |
3816 | like: | |
3817 | ||
3818 | @lisp | |
3819 | (define (nscd-service) | |
b5f4e686 | 3820 | (with-monad %store-monad |
4af2447e LC |
3821 | (return (service |
3822 | (documentation "Run libc's name service cache daemon.") | |
3823 | (provision '(nscd)) | |
4b2615e1 LC |
3824 | (activate #~(begin |
3825 | (use-modules (guix build utils)) | |
3826 | (mkdir-p "/var/run/nscd"))) | |
b5f4e686 LC |
3827 | (start #~(make-forkexec-constructor |
3828 | (string-append #$glibc "/sbin/nscd") | |
3829 | "-f" "/dev/null" "--foreground")) | |
3830 | (stop #~(make-kill-destructor)) | |
3831 | (respawn? #f))))) | |
4af2447e LC |
3832 | @end lisp |
3833 | ||
3834 | @noindent | |
4b2615e1 LC |
3835 | The @code{activate}, @code{start}, and @code{stop} fields are G-expressions |
3836 | (@pxref{G-Expressions}). The @code{activate} field contains a script to | |
3837 | run at ``activation'' time; it makes sure that the @file{/var/run/nscd} | |
3838 | directory exists before @command{nscd} is started. | |
3839 | ||
3840 | The @code{start} and @code{stop} fields refer to dmd's facilities to | |
3841 | start and stop processes (@pxref{Service De- and Constructors,,, dmd, | |
3842 | GNU dmd Manual}). The @code{provision} field specifies the name under | |
3843 | which this service is known to dmd, and @code{documentation} specifies | |
3844 | on-line documentation. Thus, the commands @command{deco start ncsd}, | |
b5f4e686 LC |
3845 | @command{deco stop nscd}, and @command{deco doc nscd} will do what you |
3846 | would expect (@pxref{Invoking deco,,, dmd, GNU dmd Manual}). | |
4af2447e LC |
3847 | |
3848 | ||
9bf3c1a7 LC |
3849 | @c ********************************************************************* |
3850 | @node Contributing | |
3851 | @chapter Contributing | |
3852 | ||
3853 | This project is a cooperative effort, and we need your help to make it | |
5ff3c4b8 PAR |
3854 | grow! Please get in touch with us on @email{guix-devel@@gnu.org} and |
3855 | @code{#guix} on the Freenode IRC network. We welcome ideas, bug | |
3856 | reports, patches, and anything that may be helpful to the project. We | |
3857 | particularly welcome help on packaging (@pxref{Packaging Guidelines}). | |
a1ba8475 | 3858 | |
9bf3c1a7 LC |
3859 | Please see the |
3860 | @url{http://git.savannah.gnu.org/cgit/guix.git/tree/HACKING, | |
3861 | @file{HACKING} file} that comes with the Guix source code for practical | |
3862 | details about contributions. | |
3863 | ||
c78bd12b | 3864 | |
568717fd LC |
3865 | @c ********************************************************************* |
3866 | @node Acknowledgments | |
3867 | @chapter Acknowledgments | |
3868 | ||
3869 | Guix is based on the Nix package manager, which was designed and | |
3870 | implemented by Eelco Dolstra. Nix pioneered functional package | |
3871 | management, and promoted unprecedented features, such as transactional | |
3872 | package upgrades and rollbacks, per-user profiles, and referentially | |
3873 | transparent build processes. Without this work, Guix would not exist. | |
3874 | ||
3875 | The Nix-based software distributions, Nixpkgs and NixOS, have also been | |
3876 | an inspiration for Guix. | |
3877 | ||
3878 | @c ********************************************************************* | |
3879 | @node GNU Free Documentation License | |
3880 | @appendix GNU Free Documentation License | |
3881 | ||
3882 | @include fdl-1.3.texi | |
3883 | ||
3884 | @c ********************************************************************* | |
3885 | @node Concept Index | |
3886 | @unnumbered Concept Index | |
3887 | @printindex cp | |
3888 | ||
3889 | @node Function Index | |
3890 | @unnumbered Function Index | |
3891 | @printindex fn | |
3892 | ||
3893 | @bye | |
3894 | ||
3895 | @c Local Variables: | |
3896 | @c ispell-local-dictionary: "american"; | |
3897 | @c End: |