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 | 11 | |
debc6360 | 12 | @c Identifier of the OpenPGP key used to sign tarballs and such. |
cccbc639 | 13 | @set OPENPGP-SIGNING-KEY-ID BCA689B636553801C3C62150197A5888235FACAC |
debc6360 | 14 | |
7df7a74e | 15 | @copying |
8de938d5 | 16 | Copyright @copyright{} 2012, 2013, 2014, 2015, 2016, 2017 Ludovic Courtès@* |
f97c9175 | 17 | Copyright @copyright{} 2013, 2014, 2016 Andreas Enge@* |
87eafdbd | 18 | Copyright @copyright{} 2013 Nikita Karetnikov@* |
1a3e6b15 | 19 | Copyright @copyright{} 2014, 2015, 2016 Alex Kost@* |
1b846da8 | 20 | Copyright @copyright{} 2015, 2016 Mathieu Lirzin@* |
8c01b9d0 | 21 | Copyright @copyright{} 2014 Pierre-Antoine Rault@* |
97d76250 | 22 | Copyright @copyright{} 2015 Taylan Ulrich Bayırlı/Kammer@* |
4d343a14 | 23 | Copyright @copyright{} 2015, 2016 Leo Famulari@* |
909147e4 | 24 | Copyright @copyright{} 2015, 2016 Ricardo Wurmus@* |
4d343a14 | 25 | Copyright @copyright{} 2016 Ben Woodcroft@* |
76192896 | 26 | Copyright @copyright{} 2016 Chris Marusich@* |
6e42660b | 27 | Copyright @copyright{} 2016 Efraim Flashner@* |
d6a07ee6 | 28 | Copyright @copyright{} 2016 John Darrington@* |
92c03a87 | 29 | Copyright @copyright{} 2016 ng0@* |
8c00b838 | 30 | Copyright @copyright{} 2016 Jan Nieuwenhuizen@* |
9747d189 AW |
31 | Copyright @copyright{} 2016 Julien Lepiller@* |
32 | Copyright @copyright{} 2016 Alex ter Weele | |
7df7a74e NK |
33 | |
34 | Permission is granted to copy, distribute and/or modify this document | |
35 | under the terms of the GNU Free Documentation License, Version 1.3 or | |
36 | any later version published by the Free Software Foundation; with no | |
37 | Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A | |
38 | copy of the license is included in the section entitled ``GNU Free | |
39 | Documentation License''. | |
40 | @end copying | |
568717fd | 41 | |
abd67856 | 42 | @dircategory System administration |
568717fd | 43 | @direntry |
abd67856 LC |
44 | * Guix: (guix). Manage installed software and system configuration. |
45 | * guix package: (guix)Invoking guix package. Installing, removing, and upgrading packages. | |
46 | * guix build: (guix)Invoking guix build. Building packages. | |
47 | * guix gc: (guix)Invoking guix gc. Reclaiming unused disk space. | |
48 | * guix pull: (guix)Invoking guix pull. Update the list of available packages. | |
49 | * guix system: (guix)Invoking guix system. Manage the operating system configuration. | |
568717fd | 50 | @end direntry |
568717fd | 51 | |
372c4bbc DT |
52 | @dircategory Software development |
53 | @direntry | |
abd67856 | 54 | * guix environment: (guix)Invoking guix environment. Building development environments with Guix. |
372c4bbc DT |
55 | @end direntry |
56 | ||
568717fd | 57 | @titlepage |
7730d112 LC |
58 | @title GNU Guix Reference Manual |
59 | @subtitle Using the GNU Guix Functional Package Manager | |
2cbed07e | 60 | @author The GNU Guix Developers |
568717fd LC |
61 | |
62 | @page | |
63 | @vskip 0pt plus 1filll | |
64 | Edition @value{EDITION} @* | |
65 | @value{UPDATED} @* | |
66 | ||
7df7a74e | 67 | @insertcopying |
568717fd LC |
68 | @end titlepage |
69 | ||
568717fd LC |
70 | @contents |
71 | ||
72 | @c ********************************************************************* | |
73 | @node Top | |
f8348b91 | 74 | @top GNU Guix |
568717fd | 75 | |
f8348b91 LC |
76 | This document describes GNU Guix version @value{VERSION}, a functional |
77 | package management tool written for the GNU system. | |
568717fd LC |
78 | |
79 | @menu | |
80 | * Introduction:: What is Guix about? | |
bd5e766b | 81 | * Installation:: Installing Guix. |
eeaf4427 | 82 | * Package Management:: Package installation, upgrade, etc. |
568717fd LC |
83 | * Programming Interface:: Using Guix in Scheme. |
84 | * Utilities:: Package management commands. | |
a1ba8475 | 85 | * GNU Distribution:: Software for your friendly GNU system. |
9bf3c1a7 | 86 | * Contributing:: Your help needed! |
568717fd LC |
87 | |
88 | * Acknowledgments:: Thanks! | |
89 | * GNU Free Documentation License:: The license of this manual. | |
90 | * Concept Index:: Concepts. | |
a85b83d2 | 91 | * Programming Index:: Data types, functions, and variables. |
aaa3eaa9 LC |
92 | |
93 | @detailmenu | |
94 | --- The Detailed Node Listing --- | |
95 | ||
96 | Installation | |
97 | ||
1b2b8177 | 98 | * Binary Installation:: Getting Guix running in no time! |
aaa3eaa9 | 99 | * Requirements:: Software needed to build and run Guix. |
ec0339cd | 100 | * Running the Test Suite:: Testing Guix. |
aaa3eaa9 LC |
101 | * Setting Up the Daemon:: Preparing the build daemon's environment. |
102 | * Invoking guix-daemon:: Running the build daemon. | |
0e2d0213 | 103 | * Application Setup:: Application-specific setup. |
aaa3eaa9 LC |
104 | |
105 | Setting Up the Daemon | |
106 | ||
107 | * Build Environment Setup:: Preparing the isolated build environment. | |
108 | * Daemon Offload Setup:: Offloading builds to remote machines. | |
109 | ||
110 | Package Management | |
111 | ||
112 | * Features:: How Guix will make your life brighter. | |
113 | * Invoking guix package:: Package installation, removal, etc. | |
aaa3eaa9 LC |
114 | * Substitutes:: Downloading pre-built binaries. |
115 | * Packages with Multiple Outputs:: Single source package, multiple outputs. | |
116 | * Invoking guix gc:: Running the garbage collector. | |
117 | * Invoking guix pull:: Fetching the latest Guix and distribution. | |
118 | * Invoking guix archive:: Exporting and importing store files. | |
119 | ||
120 | Programming Interface | |
121 | ||
122 | * Defining Packages:: Defining new packages. | |
123 | * Build Systems:: Specifying how packages are built. | |
124 | * The Store:: Manipulating the package store. | |
125 | * Derivations:: Low-level interface to package derivations. | |
126 | * The Store Monad:: Purely functional interface to the store. | |
127 | * G-Expressions:: Manipulating build expressions. | |
128 | ||
92492b23 LC |
129 | Defining Packages |
130 | ||
131 | * package Reference:: The package data type. | |
132 | * origin Reference:: The origin data type. | |
133 | ||
aaa3eaa9 LC |
134 | Utilities |
135 | ||
136 | * Invoking guix build:: Building packages from the command line. | |
fcc58db6 | 137 | * Invoking guix edit:: Editing package definitions. |
aaa3eaa9 LC |
138 | * Invoking guix download:: Downloading a file and printing its hash. |
139 | * Invoking guix hash:: Computing the cryptographic hash of a file. | |
140 | * Invoking guix import:: Importing package definitions. | |
141 | * Invoking guix refresh:: Updating package definitions. | |
142 | * Invoking guix lint:: Finding errors in package definitions. | |
fcc58db6 | 143 | * Invoking guix size:: Profiling disk usage. |
88856916 | 144 | * Invoking guix graph:: Visualizing the graph of packages. |
aaa3eaa9 | 145 | * Invoking guix environment:: Setting up development environments. |
aff8ce7c | 146 | * Invoking guix publish:: Sharing substitutes. |
d23c20f1 | 147 | * Invoking guix challenge:: Challenging substitute servers. |
f11c444d | 148 | * Invoking guix copy:: Copying to and from a remote store. |
32efa254 | 149 | * Invoking guix container:: Process isolation. |
aaa3eaa9 | 150 | |
e3009f60 LC |
151 | Invoking @command{guix build} |
152 | ||
153 | * Common Build Options:: Build options for most commands. | |
f11c444d | 154 | * Package Transformation Options:: Creating variants of packages. |
e3009f60 LC |
155 | * Additional Build Options:: Options specific to 'guix build'. |
156 | ||
aaa3eaa9 LC |
157 | GNU Distribution |
158 | ||
159 | * System Installation:: Installing the whole operating system. | |
35ed9306 | 160 | * System Configuration:: Configuring the operating system. |
aaa3eaa9 LC |
161 | * Installing Debugging Files:: Feeding the debugger. |
162 | * Security Updates:: Deploying security fixes quickly. | |
163 | * Package Modules:: Packages from the programmer's viewpoint. | |
164 | * Packaging Guidelines:: Growing the distribution. | |
165 | * Bootstrapping:: GNU/Linux built from scratch. | |
166 | * Porting:: Targeting another platform or kernel. | |
167 | ||
e3009f60 LC |
168 | System Installation |
169 | ||
170 | * Limitations:: What you can expect. | |
171 | * Hardware Considerations:: Supported hardware. | |
172 | * USB Stick Installation:: Preparing the installation medium. | |
173 | * Preparing for Installation:: Networking, partitioning, etc. | |
174 | * Proceeding with the Installation:: The real thing. | |
c8b54374 | 175 | * Installing GuixSD in a VM:: GuixSD playground. |
e3009f60 LC |
176 | * Building the Installation Image:: How this comes to be. |
177 | ||
aaa3eaa9 LC |
178 | System Configuration |
179 | ||
180 | * Using the Configuration System:: Customizing your GNU system. | |
181 | * operating-system Reference:: Detail of operating-system declarations. | |
182 | * File Systems:: Configuring file system mounts. | |
183 | * Mapped Devices:: Block device extra processing. | |
184 | * User Accounts:: Specifying user accounts. | |
598e19dc | 185 | * Locales:: Language and cultural convention settings. |
aaa3eaa9 LC |
186 | * Services:: Specifying system services. |
187 | * Setuid Programs:: Programs running with root privileges. | |
1b2b8177 | 188 | * X.509 Certificates:: Authenticating HTTPS servers. |
996ed739 | 189 | * Name Service Switch:: Configuring libc's name service switch. |
aaa3eaa9 LC |
190 | * Initial RAM Disk:: Linux-Libre bootstrapping. |
191 | * GRUB Configuration:: Configuring the boot loader. | |
192 | * Invoking guix system:: Instantiating a system configuration. | |
97d76250 | 193 | * Running GuixSD in a VM:: How to run GuixSD in a virtual machine. |
aaa3eaa9 LC |
194 | * Defining Services:: Adding new service definitions. |
195 | ||
196 | Services | |
197 | ||
198 | * Base Services:: Essential system services. | |
c311089b | 199 | * Scheduled Job Execution:: The mcron service. |
92c03a87 | 200 | * Log Rotation:: The rottlog service. |
aaa3eaa9 LC |
201 | * Networking Services:: Network setup, SSH daemon, etc. |
202 | * X Window:: Graphical display. | |
f11c444d | 203 | * Printing Services:: Local and remote printer support. |
1b2b8177 LC |
204 | * Desktop Services:: D-Bus and desktop services. |
205 | * Database Services:: SQL databases. | |
d8c18af8 | 206 | * Mail Services:: IMAP, POP3, SMTP, and all that. |
859e367d | 207 | * Kerberos Services:: Kerberos services. |
cbd02397 | 208 | * Web Services:: Web servers. |
eb419bc9 | 209 | * Network File System:: NFS related services. |
f11c444d | 210 | * Continuous Integration:: The Cuirass service. |
dbc6d370 | 211 | * Miscellaneous Services:: Other services. |
aaa3eaa9 | 212 | |
0adfe95a LC |
213 | Defining Services |
214 | ||
215 | * Service Composition:: The model for composing services. | |
216 | * Service Types and Services:: Types and services. | |
217 | * Service Reference:: API reference. | |
dd17bc38 | 218 | * Shepherd Services:: A particular type of service. |
0adfe95a | 219 | |
aaa3eaa9 LC |
220 | Packaging Guidelines |
221 | ||
ec0339cd LC |
222 | * Software Freedom:: What may go into the distribution. |
223 | * Package Naming:: What's in a name? | |
224 | * Version Numbers:: When the name is not enough. | |
cbd02397 | 225 | * Synopses and Descriptions:: Helping users find the right package. |
ec0339cd LC |
226 | * Python Modules:: Taming the snake. |
227 | * Perl Modules:: Little pearls. | |
e1c963bf | 228 | * Java Packages:: Coffee break. |
ec0339cd | 229 | * Fonts:: Fond of fonts. |
aaa3eaa9 | 230 | |
8c01b9d0 ML |
231 | Contributing |
232 | ||
233 | * Building from Git:: The latest and greatest. | |
234 | * Running Guix Before It Is Installed:: Hacker tricks. | |
235 | * The Perfect Setup:: The right tools. | |
236 | * Coding Style:: Hygiene of the contributor. | |
237 | * Submitting Patches:: Share your work. | |
238 | ||
239 | Coding Style | |
240 | ||
241 | * Programming Paradigm:: How to compose your elements. | |
242 | * Modules:: Where to store your code? | |
243 | * Data Types and Pattern Matching:: Implementing data structures. | |
244 | * Formatting Code:: Writing conventions. | |
245 | ||
aaa3eaa9 | 246 | @end detailmenu |
568717fd LC |
247 | @end menu |
248 | ||
249 | @c ********************************************************************* | |
250 | @node Introduction | |
251 | @chapter Introduction | |
252 | ||
6f773606 | 253 | @cindex purpose |
c80e7e55 | 254 | GNU Guix@footnote{``Guix'' is pronounced like ``geeks'', or ``ɡiːks'' |
6f773606 LC |
255 | using the international phonetic alphabet (IPA).} is a package |
256 | management tool for the GNU system. Guix makes it easy for unprivileged | |
257 | users to install, upgrade, or remove packages, to roll back to a | |
258 | previous package set, to build packages from source, and generally | |
259 | assists with the creation and maintenance of software environments. | |
260 | ||
261 | @cindex user interfaces | |
262 | Guix provides a command-line package management interface | |
263 | (@pxref{Invoking guix package}), a set of command-line utilities | |
deb6276d | 264 | (@pxref{Utilities}), as well as Scheme programming interfaces |
6f773606 LC |
265 | (@pxref{Programming Interface}). |
266 | @cindex build daemon | |
267 | Its @dfn{build daemon} is responsible for building packages on behalf of | |
268 | users (@pxref{Setting Up the Daemon}) and for downloading pre-built | |
269 | binaries from authorized sources (@pxref{Substitutes}). | |
270 | ||
271 | @cindex extensibility of the distribution | |
e32171ee | 272 | @cindex customization, of packages |
6f773606 LC |
273 | Guix includes package definitions for many GNU and non-GNU packages, all |
274 | of which @uref{https://www.gnu.org/philosophy/free-sw.html, respect the | |
275 | user's computing freedom}. It is @emph{extensible}: users can write | |
276 | their own package definitions (@pxref{Defining Packages}) and make them | |
277 | available as independent package modules (@pxref{Package Modules}). It | |
278 | is also @emph{customizable}: users can @emph{derive} specialized package | |
279 | definitions from existing ones, including from the command line | |
280 | (@pxref{Package Transformation Options}). | |
281 | ||
282 | @cindex Guix System Distribution | |
283 | @cindex GuixSD | |
284 | You can install GNU@tie{}Guix on top of an existing GNU/Linux system | |
285 | where it complements the available tools without interference | |
286 | (@pxref{Installation}), or you can use it as part of the standalone | |
287 | @dfn{Guix System Distribution} or GuixSD (@pxref{GNU Distribution}). | |
288 | With GNU@tie{}GuixSD, you @emph{declare} all aspects of the operating | |
289 | system configuration and Guix takes care of instantiating the | |
290 | configuration in a transactional, reproducible, and stateless fashion | |
291 | (@pxref{System Configuration}). | |
568717fd LC |
292 | |
293 | @cindex functional package management | |
6f773606 | 294 | Under the hood, Guix implements the @dfn{functional package management} |
136787cb LC |
295 | discipline pioneered by Nix (@pxref{Acknowledgments}). |
296 | In Guix, the package build and installation process is seen | |
6f773606 | 297 | as a @emph{function}, in the mathematical sense. That function takes inputs, |
4bfc4ea3 NK |
298 | such as build scripts, a compiler, and libraries, and |
299 | returns an installed package. As a pure function, its result depends | |
568717fd LC |
300 | solely on its inputs---for instance, it cannot refer to software or |
301 | scripts that were not explicitly passed as inputs. A build function | |
4bfc4ea3 | 302 | always produces the same result when passed a given set of inputs. It |
f97c9175 | 303 | cannot alter the environment of the running system in |
568717fd LC |
304 | any way; for instance, it cannot create, modify, or delete files outside |
305 | of its build and installation directories. This is achieved by running | |
e900c503 | 306 | build processes in isolated environments (or @dfn{containers}), where only their |
4bfc4ea3 | 307 | explicit inputs are visible. |
568717fd | 308 | |
e531ac2a | 309 | @cindex store |
568717fd | 310 | The result of package build functions is @dfn{cached} in the file |
e531ac2a | 311 | system, in a special directory called @dfn{the store} (@pxref{The |
f97c9175 | 312 | Store}). Each package is installed in a directory of its own in the |
834129e0 | 313 | store---by default under @file{/gnu/store}. The directory name contains |
568717fd LC |
314 | a hash of all the inputs used to build that package; thus, changing an |
315 | input yields a different directory name. | |
316 | ||
f97c9175 AE |
317 | This approach is the foundation for the salient features of Guix: support |
318 | for transactional package upgrade and rollback, per-user installation, and | |
eeaf4427 | 319 | garbage collection of packages (@pxref{Features}). |
568717fd | 320 | |
a1ba8475 | 321 | |
bd5e766b LC |
322 | @c ********************************************************************* |
323 | @node Installation | |
324 | @chapter Installation | |
325 | ||
e32171ee | 326 | @cindex installing Guix |
48febeb8 LC |
327 | GNU Guix is available for download from its website at |
328 | @url{http://www.gnu.org/software/guix/}. This section describes the | |
329 | software requirements of Guix, as well as how to install it and get | |
330 | ready to use it. | |
bd5e766b | 331 | |
5af6de3e LC |
332 | Note that this section is concerned with the installation of the package |
333 | manager, which can be done on top of a running GNU/Linux system. If, | |
334 | instead, you want to install the complete GNU operating system, | |
6621cdb6 | 335 | @pxref{System Installation}. |
5af6de3e | 336 | |
d23ef788 LC |
337 | @cindex foreign distro |
338 | When installed on a running GNU/Linux system---thereafter called a | |
339 | @dfn{foreign distro}---GNU@tie{}Guix complements the available tools | |
340 | without interference. Its data lives exclusively in two directories, | |
341 | usually @file{/gnu/store} and @file{/var/guix}; other files on your | |
342 | system, such as @file{/etc}, are left untouched. | |
343 | ||
7fcf2a0b LC |
344 | Once installed, Guix can be updated by running @command{guix pull} |
345 | (@pxref{Invoking guix pull}). | |
346 | ||
bd5e766b | 347 | @menu |
09722b11 | 348 | * Binary Installation:: Getting Guix running in no time! |
bd5e766b | 349 | * Requirements:: Software needed to build and run Guix. |
ec0339cd | 350 | * Running the Test Suite:: Testing Guix. |
bd5e766b LC |
351 | * Setting Up the Daemon:: Preparing the build daemon's environment. |
352 | * Invoking guix-daemon:: Running the build daemon. | |
0e2d0213 | 353 | * Application Setup:: Application-specific setup. |
bd5e766b LC |
354 | @end menu |
355 | ||
09722b11 LC |
356 | @node Binary Installation |
357 | @section Binary Installation | |
358 | ||
e32171ee | 359 | @cindex installing Guix from binaries |
09722b11 LC |
360 | This section describes how to install Guix on an arbitrary system from a |
361 | self-contained tarball providing binaries for Guix and for all its | |
362 | dependencies. This is often quicker than installing from source, which | |
363 | is described in the next sections. The only requirement is to have | |
364 | GNU@tie{}tar and Xz. | |
365 | ||
366 | Installing goes along these lines: | |
367 | ||
368 | @enumerate | |
369 | @item | |
e32171ee | 370 | @cindex downloading Guix binary |
09722b11 | 371 | Download the binary tarball from |
daa8922a LC |
372 | @indicateurl{ftp://alpha.gnu.org/gnu/guix/guix-binary-@value{VERSION}.@var{system}.tar.xz}, |
373 | where @var{system} is @code{x86_64-linux} for an @code{x86_64} machine | |
374 | already running the kernel Linux, and so on. | |
375 | ||
debc6360 | 376 | @c The following is somewhat duplicated in ``System Installation''. |
daa8922a LC |
377 | Make sure to download the associated @file{.sig} file and to verify the |
378 | authenticity of the tarball against it, along these lines: | |
379 | ||
380 | @example | |
381 | $ wget ftp://alpha.gnu.org/gnu/guix/guix-binary-@value{VERSION}.@var{system}.tar.xz.sig | |
382 | $ gpg --verify guix-binary-@value{VERSION}.@var{system}.tar.xz.sig | |
383 | @end example | |
384 | ||
f97c9175 | 385 | If that command fails because you do not have the required public key, |
daa8922a LC |
386 | then run this command to import it: |
387 | ||
388 | @example | |
debc6360 | 389 | $ gpg --keyserver pgp.mit.edu --recv-keys @value{OPENPGP-SIGNING-KEY-ID} |
daa8922a LC |
390 | @end example |
391 | ||
392 | @noindent | |
393 | and rerun the @code{gpg --verify} command. | |
debc6360 | 394 | @c end authentication part |
09722b11 LC |
395 | |
396 | @item | |
397 | As @code{root}, run: | |
398 | ||
399 | @example | |
5dc42964 | 400 | # cd /tmp |
254b1c2e LC |
401 | # tar --warning=no-timestamp -xf \ |
402 | guix-binary-@value{VERSION}.@var{system}.tar.xz | |
5dc42964 | 403 | # mv var/guix /var/ && mv gnu / |
09722b11 LC |
404 | @end example |
405 | ||
7acd3439 LC |
406 | This creates @file{/gnu/store} (@pxref{The Store}) and @file{/var/guix}. |
407 | The latter contains a ready-to-use profile for @code{root} (see next | |
408 | step.) | |
09722b11 | 409 | |
5dc3ce5f LC |
410 | Do @emph{not} unpack the tarball on a working Guix system since that |
411 | would overwrite its own essential files. | |
412 | ||
254b1c2e | 413 | The @code{--warning=no-timestamp} option makes sure GNU@tie{}tar does |
e9ba6357 LC |
414 | not emit warnings about ``implausibly old time stamps'' (such |
415 | warnings were triggered by GNU@tie{}tar 1.26 and older; recent | |
416 | versions are fine.) | |
417 | They stem from the fact that all the | |
254b1c2e LC |
418 | files in the archive have their modification time set to zero (which |
419 | means January 1st, 1970.) This is done on purpose to make sure the | |
420 | archive content is independent of its creation time, thus making it | |
421 | reproducible. | |
422 | ||
7acd3439 LC |
423 | @item |
424 | Make @code{root}'s profile available under @file{~/.guix-profile}: | |
425 | ||
426 | @example | |
427 | # ln -sf /var/guix/profiles/per-user/root/guix-profile \ | |
428 | ~root/.guix-profile | |
429 | @end example | |
430 | ||
43c33047 LC |
431 | @item |
432 | Create the group and user accounts for build users as explained below | |
433 | (@pxref{Build Environment Setup}). | |
434 | ||
09722b11 | 435 | @item |
bf98aea9 | 436 | Run the daemon, and set it to automatically start on boot. |
c8e26887 | 437 | |
bf98aea9 LC |
438 | If your host distro uses the systemd init system, this can be achieved |
439 | with these commands: | |
c8e26887 GC |
440 | |
441 | @example | |
b7230de5 | 442 | # ln -s ~root/.guix-profile/lib/systemd/system/guix-daemon.service \ |
c8e26887 GC |
443 | /etc/systemd/system/ |
444 | # systemctl start guix-daemon && systemctl enable guix-daemon | |
445 | @end example | |
446 | ||
447 | If your host distro uses the Upstart init system: | |
09722b11 LC |
448 | |
449 | @example | |
b7230de5 | 450 | # ln -s ~root/.guix-profile/lib/upstart/system/guix-daemon.conf /etc/init/ |
bf98aea9 | 451 | # start guix-daemon |
09722b11 LC |
452 | @end example |
453 | ||
c8e26887 GC |
454 | Otherwise, you can still start the daemon manually with: |
455 | ||
456 | @example | |
457 | # ~root/.guix-profile/bin/guix-daemon --build-users-group=guixbuild | |
458 | @end example | |
d2825c96 | 459 | |
09722b11 LC |
460 | @item |
461 | Make the @command{guix} command available to other users on the machine, | |
462 | for instance with: | |
463 | ||
464 | @example | |
465 | # mkdir -p /usr/local/bin | |
466 | # cd /usr/local/bin | |
d72d05f9 | 467 | # ln -s /var/guix/profiles/per-user/root/guix-profile/bin/guix |
09722b11 | 468 | @end example |
39f8ed14 | 469 | |
aca738f3 LC |
470 | It is also a good idea to make the Info version of this manual available |
471 | there: | |
472 | ||
473 | @example | |
474 | # mkdir -p /usr/local/share/info | |
475 | # cd /usr/local/share/info | |
476 | # for i in /var/guix/profiles/per-user/root/guix-profile/share/info/* ; | |
477 | do ln -s $i ; done | |
478 | @end example | |
479 | ||
480 | That way, assuming @file{/usr/local/share/info} is in the search path, | |
481 | running @command{info guix} will open this manual (@pxref{Other Info | |
482 | Directories,,, texinfo, GNU Texinfo}, for more details on changing the | |
483 | Info search path.) | |
484 | ||
39f8ed14 | 485 | @item |
e32171ee | 486 | @cindex substitutes, authorization thereof |
df061d07 LC |
487 | To use substitutes from @code{hydra.gnu.org} or one of its mirrors |
488 | (@pxref{Substitutes}), authorize them: | |
39f8ed14 LC |
489 | |
490 | @example | |
7acd3439 | 491 | # guix archive --authorize < ~root/.guix-profile/share/guix/hydra.gnu.org.pub |
39f8ed14 | 492 | @end example |
09722b11 LC |
493 | @end enumerate |
494 | ||
bf98aea9 | 495 | This completes root-level install of Guix. Each user will need to |
7414de0a | 496 | perform additional steps to make their Guix environment ready for use, |
c8e26887 | 497 | @pxref{Application Setup}. |
09722b11 | 498 | |
c8e26887 GC |
499 | You can confirm that Guix is working by installing a sample package into |
500 | the root profile: | |
09722b11 LC |
501 | |
502 | @example | |
c8e26887 | 503 | # guix package -i hello |
09722b11 LC |
504 | @end example |
505 | ||
c8e26887 GC |
506 | The @code{guix} package must remain available in @code{root}'s profile, |
507 | or it would become subject to garbage collection---in which case you | |
508 | would find yourself badly handicapped by the lack of the @command{guix} | |
bf98aea9 LC |
509 | command. In other words, do not remove @code{guix} by running |
510 | @code{guix package -r guix}. | |
511 | ||
512 | The binary installation tarball can be (re)produced and verified simply | |
513 | by running the following command in the Guix source tree: | |
514 | ||
515 | @example | |
516 | make guix-binary.@var{system}.tar.xz | |
517 | @end example | |
c8e26887 | 518 | |
09722b11 | 519 | |
bd5e766b LC |
520 | @node Requirements |
521 | @section Requirements | |
522 | ||
09722b11 LC |
523 | This section lists requirements when building Guix from source. The |
524 | build procedure for Guix is the same as for other GNU software, and is | |
525 | not covered here. Please see the files @file{README} and @file{INSTALL} | |
526 | in the Guix source tree for additional details. | |
527 | ||
bd5e766b LC |
528 | GNU Guix depends on the following packages: |
529 | ||
530 | @itemize | |
47c66da0 | 531 | @item @url{http://gnu.org/software/guile/, GNU Guile}, version 2.0.7 or later; |
288dca55 | 532 | @item @url{http://gnupg.org/, GNU libgcrypt}; |
f0b98b84 | 533 | @item @url{http://www.gnu.org/software/make/, GNU Make}. |
8a96bd4b ID |
534 | @end itemize |
535 | ||
536 | The following dependencies are optional: | |
537 | ||
538 | @itemize | |
9b7bd1b1 LC |
539 | @item |
540 | Installing @uref{http://gnutls.org/, GnuTLS-Guile} will allow you to | |
541 | access @code{https} URLs for substitutes, which is highly recommended | |
542 | (@pxref{Substitutes}). It also allows you to access HTTPS URLs with the | |
543 | @command{guix download} command (@pxref{Invoking guix download}), the | |
544 | @command{guix import pypi} command, and the @command{guix import cpan} | |
545 | command. @xref{Guile Preparations, how to install the GnuTLS bindings | |
546 | for Guile,, gnutls-guile, GnuTLS-Guile}. | |
547 | ||
288dca55 | 548 | @item |
8a96bd4b | 549 | Installing |
288dca55 | 550 | @url{http://savannah.nongnu.org/projects/guile-json/, Guile-JSON} will |
2f7d2d91 LC |
551 | allow you to use the @command{guix import pypi} command (@pxref{Invoking |
552 | guix import}). It is of | |
288dca55 | 553 | interest primarily for developers and not for casual users. |
4591c02e | 554 | |
21531add LC |
555 | @item |
556 | @c Note: We need at least 0.10.2 for 'channel-send-eof'. | |
f11c444d LC |
557 | Support for build offloading (@pxref{Daemon Offload Setup}) and |
558 | @command{guix copy} (@pxref{Invoking guix copy}) depends on | |
21531add LC |
559 | @uref{https://github.com/artyom-poptsov/guile-ssh, Guile-SSH}, |
560 | version 0.10.2 or later. | |
561 | ||
4591c02e LC |
562 | @item |
563 | When @url{http://zlib.net, zlib} is available, @command{guix publish} | |
564 | can compress build byproducts (@pxref{Invoking guix publish}). | |
bd5e766b LC |
565 | @end itemize |
566 | ||
567 | Unless @code{--disable-daemon} was passed to @command{configure}, the | |
568 | following packages are also needed: | |
569 | ||
570 | @itemize | |
368d08f7 LC |
571 | @item @url{http://sqlite.org, SQLite 3}; |
572 | @item @url{http://www.bzip.org, libbz2}; | |
573 | @item @url{http://gcc.gnu.org, GCC's g++}, with support for the | |
574 | C++11 standard. | |
bd5e766b LC |
575 | @end itemize |
576 | ||
e32171ee | 577 | @cindex state directory |
ef5f5c86 LC |
578 | When configuring Guix on a system that already has a Guix installation, |
579 | be sure to specify the same state directory as the existing installation | |
580 | using the @code{--localstatedir} option of the @command{configure} | |
581 | script (@pxref{Directory Variables, @code{localstatedir},, standards, | |
582 | GNU Coding Standards}). The @command{configure} script protects against | |
583 | unintended misconfiguration of @var{localstatedir} so you do not | |
584 | inadvertently corrupt your store (@pxref{The Store}). | |
585 | ||
e32171ee | 586 | @cindex Nix, compatibility |
4bfc4ea3 NK |
587 | When a working installation of @url{http://nixos.org/nix/, the Nix package |
588 | manager} is available, you | |
bd5e766b | 589 | can instead configure Guix with @code{--disable-daemon}. In that case, |
4bfc4ea3 | 590 | Nix replaces the three dependencies above. |
bd5e766b | 591 | |
b22a12fd LC |
592 | Guix is compatible with Nix, so it is possible to share the same store |
593 | between both. To do so, you must pass @command{configure} not only the | |
594 | same @code{--with-store-dir} value, but also the same | |
4bfc4ea3 NK |
595 | @code{--localstatedir} value. The latter is essential because it |
596 | specifies where the database that stores metadata about the store is | |
834129e0 | 597 | located, among other things. The default values for Nix are |
b22a12fd | 598 | @code{--with-store-dir=/nix/store} and @code{--localstatedir=/nix/var}. |
4bfc4ea3 NK |
599 | Note that @code{--disable-daemon} is not required if |
600 | your goal is to share the store with Nix. | |
b22a12fd | 601 | |
ec0339cd LC |
602 | @node Running the Test Suite |
603 | @section Running the Test Suite | |
604 | ||
e32171ee | 605 | @cindex test suite |
ec0339cd LC |
606 | After a successful @command{configure} and @code{make} run, it is a good |
607 | idea to run the test suite. It can help catch issues with the setup or | |
608 | environment, or bugs in Guix itself---and really, reporting test | |
609 | failures is a good way to help improve the software. To run the test | |
610 | suite, type: | |
611 | ||
612 | @example | |
613 | make check | |
614 | @end example | |
615 | ||
616 | Test cases can run in parallel: you can use the @code{-j} option of | |
617 | GNU@tie{}make to speed things up. The first run may take a few minutes | |
618 | on a recent machine; subsequent runs will be faster because the store | |
619 | that is created for test purposes will already have various things in | |
620 | cache. | |
621 | ||
a887fd8d LC |
622 | It is also possible to run a subset of the tests by defining the |
623 | @code{TESTS} makefile variable as in this example: | |
624 | ||
625 | @example | |
626 | make check TESTS="tests/store.scm tests/cpio.scm" | |
627 | @end example | |
628 | ||
a9edb211 ML |
629 | By default, tests results are displayed at a file level. In order to |
630 | see the details of every individual test cases, it is possible to define | |
631 | the @code{SCM_LOG_DRIVER_FLAGS} makefile variable as in this example: | |
632 | ||
633 | @example | |
634 | make check TESTS="tests/base64.scm" SCM_LOG_DRIVER_FLAGS="--brief=no" | |
635 | @end example | |
636 | ||
ec0339cd | 637 | Upon failure, please email @email{bug-guix@@gnu.org} and attach the |
a9edb211 ML |
638 | @file{test-suite.log} file. Please specify the Guix version being used |
639 | as well as version numbers of the dependencies (@pxref{Requirements}) in | |
640 | your message. | |
ec0339cd | 641 | |
0a2f2848 LC |
642 | Guix also comes with a whole-system test suite that tests complete |
643 | GuixSD operating system instances. It can only run on systems where | |
644 | Guix is already installed, using: | |
645 | ||
646 | @example | |
647 | make check-system | |
648 | @end example | |
649 | ||
650 | @noindent | |
651 | or, again, by defining @code{TESTS} to select a subset of tests to run: | |
652 | ||
653 | @example | |
654 | make check-system TESTS="basic mcron" | |
655 | @end example | |
656 | ||
657 | These system tests are defined in the @code{(gnu tests @dots{})} | |
658 | modules. They work by running the operating systems under test with | |
659 | lightweight instrumentation in a virtual machine (VM). They can be | |
660 | computationally intensive or rather cheap, depending on whether | |
661 | substitutes are available for their dependencies (@pxref{Substitutes}). | |
662 | Some of them require a lot of storage space to hold VM images. | |
663 | ||
664 | Again in case of test failures, please send @email{bug-guix@@gnu.org} | |
665 | all the details. | |
666 | ||
bd5e766b LC |
667 | @node Setting Up the Daemon |
668 | @section Setting Up the Daemon | |
669 | ||
670 | @cindex daemon | |
671 | Operations such as building a package or running the garbage collector | |
49e6291a | 672 | are all performed by a specialized process, the @dfn{build daemon}, on |
bd5e766b LC |
673 | behalf of clients. Only the daemon may access the store and its |
674 | associated database. Thus, any operation that manipulates the store | |
675 | goes through the daemon. For instance, command-line tools such as | |
e49951eb | 676 | @command{guix package} and @command{guix build} communicate with the |
bd5e766b LC |
677 | daemon (@i{via} remote procedure calls) to instruct it what to do. |
678 | ||
49e6291a | 679 | The following sections explain how to prepare the build daemon's |
f97c9175 | 680 | environment. See also @ref{Substitutes}, for information on how to allow |
225dafde | 681 | the daemon to download pre-built binaries. |
49e6291a LC |
682 | |
683 | @menu | |
684 | * Build Environment Setup:: Preparing the isolated build environment. | |
685 | * Daemon Offload Setup:: Offloading builds to remote machines. | |
686 | @end menu | |
687 | ||
688 | @node Build Environment Setup | |
689 | @subsection Build Environment Setup | |
690 | ||
e32171ee | 691 | @cindex build environment |
bd5e766b LC |
692 | In a standard multi-user setup, Guix and its daemon---the |
693 | @command{guix-daemon} program---are installed by the system | |
834129e0 | 694 | administrator; @file{/gnu/store} is owned by @code{root} and |
bd5e766b LC |
695 | @command{guix-daemon} runs as @code{root}. Unprivileged users may use |
696 | Guix tools to build packages or otherwise access the store, and the | |
697 | daemon will do it on their behalf, ensuring that the store is kept in a | |
698 | consistent state, and allowing built packages to be shared among users. | |
699 | ||
700 | @cindex build users | |
701 | When @command{guix-daemon} runs as @code{root}, you may not want package | |
702 | build processes themselves to run as @code{root} too, for obvious | |
703 | security reasons. To avoid that, a special pool of @dfn{build users} | |
704 | should be created for use by build processes started by the daemon. | |
705 | These build users need not have a shell and a home directory: they will | |
706 | just be used when the daemon drops @code{root} privileges in build | |
707 | processes. Having several such users allows the daemon to launch | |
708 | distinct build processes under separate UIDs, which guarantees that they | |
709 | do not interfere with each other---an essential feature since builds are | |
710 | regarded as pure functions (@pxref{Introduction}). | |
711 | ||
712 | On a GNU/Linux system, a build user pool may be created like this (using | |
713 | Bash syntax and the @code{shadow} commands): | |
714 | ||
091196b3 LC |
715 | @c See http://lists.gnu.org/archive/html/bug-guix/2013-01/msg00239.html |
716 | @c for why `-G' is needed. | |
bd5e766b | 717 | @example |
cfc149dc LC |
718 | # groupadd --system guixbuild |
719 | # for i in `seq -w 1 10`; | |
bd5e766b | 720 | do |
cfc149dc LC |
721 | useradd -g guixbuild -G guixbuild \ |
722 | -d /var/empty -s `which nologin` \ | |
723 | -c "Guix build user $i" --system \ | |
724 | guixbuilder$i; | |
bd5e766b LC |
725 | done |
726 | @end example | |
727 | ||
728 | @noindent | |
54eb03ab LC |
729 | The number of build users determines how many build jobs may run in |
730 | parallel, as specified by the @option{--max-jobs} option | |
eca69fc0 LC |
731 | (@pxref{Invoking guix-daemon, @option{--max-jobs}}). To use |
732 | @command{guix system vm} and related commands, you may need to add the | |
733 | build users to the @code{kvm} group so they can access @file{/dev/kvm}, | |
734 | using @code{-G guixbuild,kvm} instead of @code{-G guixbuild} | |
735 | (@pxref{Invoking guix system}). | |
736 | ||
737 | The @code{guix-daemon} program may then be run as @code{root} with the | |
d2825c96 LC |
738 | following command@footnote{If your machine uses the systemd init system, |
739 | dropping the @file{@var{prefix}/lib/systemd/system/guix-daemon.service} | |
740 | file in @file{/etc/systemd/system} will ensure that | |
ad227484 MDRS |
741 | @command{guix-daemon} is automatically started. Similarly, if your |
742 | machine uses the Upstart init system, drop the | |
743 | @file{@var{prefix}/lib/upstart/system/guix-daemon.conf} | |
744 | file in @file{/etc/init}.}: | |
bd5e766b LC |
745 | |
746 | @example | |
cfc149dc | 747 | # guix-daemon --build-users-group=guixbuild |
bd5e766b LC |
748 | @end example |
749 | ||
e900c503 | 750 | @cindex chroot |
b095792f LC |
751 | @noindent |
752 | This way, the daemon starts build processes in a chroot, under one of | |
cfc149dc | 753 | the @code{guixbuilder} users. On GNU/Linux, by default, the chroot |
6dc99317 LC |
754 | environment contains nothing but: |
755 | ||
756 | @c Keep this list in sync with libstore/build.cc! ----------------------- | |
757 | @itemize | |
758 | @item | |
4743a4da LC |
759 | a minimal @code{/dev} directory, created mostly independently from the |
760 | host @code{/dev}@footnote{``Mostly'', because while the set of files | |
761 | that appear in the chroot's @code{/dev} is fixed, most of these files | |
762 | can only be created if the host has them.}; | |
763 | ||
764 | @item | |
f97c9175 | 765 | the @code{/proc} directory; it only shows the processes of the container |
4743a4da | 766 | since a separate PID name space is used; |
6dc99317 LC |
767 | |
768 | @item | |
769 | @file{/etc/passwd} with an entry for the current user and an entry for | |
770 | user @file{nobody}; | |
771 | ||
772 | @item | |
773 | @file{/etc/group} with an entry for the user's group; | |
774 | ||
775 | @item | |
776 | @file{/etc/hosts} with an entry that maps @code{localhost} to | |
777 | @code{127.0.0.1}; | |
778 | ||
779 | @item | |
780 | a writable @file{/tmp} directory. | |
781 | @end itemize | |
b095792f | 782 | |
cb960102 ED |
783 | You can influence the directory where the daemon stores build trees |
784 | @i{via} the @code{TMPDIR} environment variable. However, the build tree | |
f97c9175 | 785 | within the chroot is always called @file{/tmp/guix-build-@var{name}.drv-0}, |
cb960102 ED |
786 | where @var{name} is the derivation name---e.g., @code{coreutils-8.24}. |
787 | This way, the value of @code{TMPDIR} does not leak inside build | |
788 | environments, which avoids discrepancies in cases where build processes | |
789 | capture the name of their build tree. | |
790 | ||
e0c941fe LC |
791 | @vindex http_proxy |
792 | The daemon also honors the @code{http_proxy} environment variable for | |
793 | HTTP downloads it performs, be it for fixed-output derivations | |
794 | (@pxref{Derivations}) or for substitutes (@pxref{Substitutes}). | |
795 | ||
1e2644bb LC |
796 | If you are installing Guix as an unprivileged user, it is still possible |
797 | to run @command{guix-daemon} provided you pass @code{--disable-chroot}. | |
798 | However, build processes will not be isolated from one another, and not | |
799 | from the rest of the system. Thus, build processes may interfere with | |
800 | each other, and may access programs, libraries, and other files | |
801 | available on the system---making it much harder to view them as | |
802 | @emph{pure} functions. | |
bd5e766b | 803 | |
49e6291a LC |
804 | |
805 | @node Daemon Offload Setup | |
806 | @subsection Using the Offload Facility | |
807 | ||
808 | @cindex offloading | |
4ec2e92d | 809 | @cindex build hook |
21531add LC |
810 | When desired, the build daemon can @dfn{offload} derivation builds to |
811 | other machines running Guix, using the @code{offload} @dfn{build | |
812 | hook}@footnote{This feature is available only when | |
813 | @uref{https://github.com/artyom-poptsov/guile-ssh, Guile-SSH} is | |
814 | present.}. When that | |
49e6291a | 815 | feature is enabled, a list of user-specified build machines is read from |
f97c9175 | 816 | @file{/etc/guix/machines.scm}; every time a build is requested, for |
49e6291a | 817 | instance via @code{guix build}, the daemon attempts to offload it to one |
f97c9175 | 818 | of the machines that satisfy the constraints of the derivation, in |
49e6291a LC |
819 | particular its system type---e.g., @file{x86_64-linux}. Missing |
820 | prerequisites for the build are copied over SSH to the target machine, | |
821 | which then proceeds with the build; upon success the output(s) of the | |
822 | build are copied back to the initial machine. | |
823 | ||
4ec2e92d | 824 | The @file{/etc/guix/machines.scm} file typically looks like this: |
49e6291a LC |
825 | |
826 | @example | |
827 | (list (build-machine | |
828 | (name "eightysix.example.org") | |
829 | (system "x86_64-linux") | |
21531add | 830 | (host-key "ssh-ed25519 AAAAC3Nza@dots{}") |
49e6291a | 831 | (user "bob") |
21531add | 832 | (speed 2.)) ;incredibly fast! |
49e6291a LC |
833 | |
834 | (build-machine | |
835 | (name "meeps.example.org") | |
836 | (system "mips64el-linux") | |
21531add | 837 | (host-key "ssh-rsa AAAAB3Nza@dots{}") |
49e6291a LC |
838 | (user "alice") |
839 | (private-key | |
840 | (string-append (getenv "HOME") | |
21531add | 841 | "/.ssh/identity-for-guix")))) |
49e6291a LC |
842 | @end example |
843 | ||
844 | @noindent | |
845 | In the example above we specify a list of two build machines, one for | |
846 | the @code{x86_64} architecture and one for the @code{mips64el} | |
4ec2e92d LC |
847 | architecture. |
848 | ||
849 | In fact, this file is---not surprisingly!---a Scheme file that is | |
850 | evaluated when the @code{offload} hook is started. Its return value | |
851 | must be a list of @code{build-machine} objects. While this example | |
852 | shows a fixed list of build machines, one could imagine, say, using | |
853 | DNS-SD to return a list of potential build machines discovered in the | |
854 | local network (@pxref{Introduction, Guile-Avahi,, guile-avahi, Using | |
c678a4ee LC |
855 | Avahi in Guile Scheme Programs}). The @code{build-machine} data type is |
856 | detailed below. | |
4ec2e92d | 857 | |
c678a4ee | 858 | @deftp {Data Type} build-machine |
f97c9175 AE |
859 | This data type represents build machines to which the daemon may offload |
860 | builds. The important fields are: | |
49e6291a LC |
861 | |
862 | @table @code | |
863 | ||
864 | @item name | |
f97c9175 | 865 | The host name of the remote machine. |
49e6291a LC |
866 | |
867 | @item system | |
f97c9175 | 868 | The system type of the remote machine---e.g., @code{"x86_64-linux"}. |
49e6291a LC |
869 | |
870 | @item user | |
871 | The user account to use when connecting to the remote machine over SSH. | |
872 | Note that the SSH key pair must @emph{not} be passphrase-protected, to | |
873 | allow non-interactive logins. | |
874 | ||
21531add LC |
875 | @item host-key |
876 | This must be the machine's SSH @dfn{public host key} in OpenSSH format. | |
877 | This is used to authenticate the machine when we connect to it. It is a | |
878 | long string that looks like this: | |
879 | ||
880 | @example | |
881 | ssh-ed25519 AAAAC3NzaC@dots{}mde+UhL hint@@example.org | |
882 | @end example | |
883 | ||
884 | If the machine is running the OpenSSH daemon, @command{sshd}, the host | |
885 | key can be found in a file such as | |
886 | @file{/etc/ssh/ssh_host_ed25519_key.pub}. | |
887 | ||
888 | If the machine is running the SSH daemon of GNU@tie{}lsh, | |
889 | @command{lshd}, the host key is in @file{/etc/lsh/host-key.pub} or a | |
890 | similar file. It can be converted to the OpenSSH format using | |
891 | @command{lsh-export-key} (@pxref{Converting keys,,, lsh, LSH Manual}): | |
892 | ||
893 | @example | |
894 | $ lsh-export-key --openssh < /etc/lsh/host-key.pub | |
895 | ssh-rsa AAAAB3NzaC1yc2EAAAAEOp8FoQAAAQEAs1eB46LV@dots{} | |
896 | @end example | |
897 | ||
49e6291a LC |
898 | @end table |
899 | ||
4ec2e92d | 900 | A number of optional fields may be specified: |
49e6291a | 901 | |
21531add | 902 | @table @asis |
49e6291a | 903 | |
21531add LC |
904 | @item @code{port} (default: @code{22}) |
905 | Port number of SSH server on the machine. | |
cecd72d5 | 906 | |
21531add LC |
907 | @item @code{private-key} (default: @file{~/.ssh/id_rsa}) |
908 | The SSH private key file to use when connecting to the machine, in | |
909 | OpenSSH format. | |
49e6291a | 910 | |
1d48cf94 LC |
911 | @item @code{compression} (default: @code{"zlib@@openssh.com,zlib"}) |
912 | @itemx @code{compression-level} (default: @code{3}) | |
913 | The SSH-level compression methods and compression level requested. | |
914 | ||
915 | Note that offloading relies on SSH compression to reduce bandwidth usage | |
916 | when transferring files to and from build machines. | |
917 | ||
cf283dd9 LC |
918 | @item @code{daemon-socket} (default: @code{"/var/guix/daemon-socket/socket"}) |
919 | File name of the Unix-domain socket @command{guix-daemon} is listening | |
920 | to on that machine. | |
c4fdfd6f | 921 | |
21531add LC |
922 | @item @code{parallel-builds} (default: @code{1}) |
923 | The number of builds that may run in parallel on the machine. | |
49e6291a | 924 | |
21531add | 925 | @item @code{speed} (default: @code{1.0}) |
49e6291a LC |
926 | A ``relative speed factor''. The offload scheduler will tend to prefer |
927 | machines with a higher speed factor. | |
928 | ||
21531add | 929 | @item @code{features} (default: @code{'()}) |
49e6291a LC |
930 | A list of strings denoting specific features supported by the machine. |
931 | An example is @code{"kvm"} for machines that have the KVM Linux modules | |
932 | and corresponding hardware support. Derivations can request features by | |
933 | name, and they will be scheduled on matching build machines. | |
934 | ||
935 | @end table | |
c678a4ee | 936 | @end deftp |
49e6291a | 937 | |
aebaee95 LC |
938 | The @code{guile} command must be in the search path on the build |
939 | machines. In addition, the Guix modules must be in | |
c4fdfd6f LC |
940 | @code{$GUILE_LOAD_PATH} on the build machine---you can check whether |
941 | this is the case by running: | |
942 | ||
943 | @example | |
21531add | 944 | ssh build-machine guile -c "'(use-modules (guix config))'" |
c4fdfd6f | 945 | @end example |
49e6291a | 946 | |
f97c9175 | 947 | There is one last thing to do once @file{machines.scm} is in place. As |
49e6291a | 948 | explained above, when offloading, files are transferred back and forth |
c4fdfd6f LC |
949 | between the machine stores. For this to work, you first need to |
950 | generate a key pair on each machine to allow the daemon to export signed | |
951 | archives of files from the store (@pxref{Invoking guix archive}): | |
49e6291a LC |
952 | |
953 | @example | |
954 | # guix archive --generate-key | |
955 | @end example | |
956 | ||
957 | @noindent | |
c4fdfd6f LC |
958 | Each build machine must authorize the key of the master machine so that |
959 | it accepts store items it receives from the master: | |
960 | ||
961 | @example | |
962 | # guix archive --authorize < master-public-key.txt | |
963 | @end example | |
964 | ||
965 | @noindent | |
966 | Likewise, the master machine must authorize the key of each build machine. | |
967 | ||
968 | All the fuss with keys is here to express pairwise mutual trust | |
969 | relations between the master and the build machines. Concretely, when | |
970 | the master receives files from a build machine (and @i{vice versa}), its | |
971 | build daemon can make sure they are genuine, have not been tampered | |
972 | with, and that they are signed by an authorized key. | |
49e6291a | 973 | |
aebaee95 LC |
974 | @cindex offload test |
975 | To test whether your setup is operational, run this command on the | |
976 | master node: | |
977 | ||
978 | @example | |
979 | # guix offload test | |
980 | @end example | |
981 | ||
982 | This will attempt to connect to each of the build machines specified in | |
983 | @file{/etc/guix/machines.scm}, make sure Guile and the Guix modules are | |
984 | available on each machine, attempt to export to the machine and import | |
985 | from it, and report any error in the process. | |
986 | ||
987 | If you want to test a different machine file, just specify it on the | |
988 | command line: | |
989 | ||
990 | @example | |
991 | # guix offload test machines-qualif.scm | |
992 | @end example | |
993 | ||
27991c97 LC |
994 | Last, you can test the subset of the machines whose name matches a |
995 | regular expression like this: | |
996 | ||
997 | @example | |
998 | # guix offload test machines.scm '\.gnu\.org$' | |
999 | @end example | |
49e6291a | 1000 | |
bd5e766b LC |
1001 | @node Invoking guix-daemon |
1002 | @section Invoking @command{guix-daemon} | |
1003 | ||
1004 | The @command{guix-daemon} program implements all the functionality to | |
1005 | access the store. This includes launching build processes, running the | |
1006 | garbage collector, querying the availability of a build result, etc. It | |
1007 | is normally run as @code{root} like this: | |
1008 | ||
1009 | @example | |
cfc149dc | 1010 | # guix-daemon --build-users-group=guixbuild |
bd5e766b LC |
1011 | @end example |
1012 | ||
1013 | @noindent | |
081145cf | 1014 | For details on how to set it up, @pxref{Setting Up the Daemon}. |
bd5e766b | 1015 | |
e900c503 LC |
1016 | @cindex chroot |
1017 | @cindex container, build environment | |
1018 | @cindex build environment | |
1019 | @cindex reproducible builds | |
bd5e766b LC |
1020 | By default, @command{guix-daemon} launches build processes under |
1021 | different UIDs, taken from the build group specified with | |
1022 | @code{--build-users-group}. In addition, each build process is run in a | |
1023 | chroot environment that only contains the subset of the store that the | |
1024 | build process depends on, as specified by its derivation | |
1025 | (@pxref{Programming Interface, derivation}), plus a set of specific | |
1026 | system directories. By default, the latter contains @file{/dev} and | |
e900c503 LC |
1027 | @file{/dev/pts}. Furthermore, on GNU/Linux, the build environment is a |
1028 | @dfn{container}: in addition to having its own file system tree, it has | |
1029 | a separate mount name space, its own PID name space, network name space, | |
1030 | etc. This helps achieve reproducible builds (@pxref{Features}). | |
bd5e766b | 1031 | |
cbc538fe LC |
1032 | When the daemon performs a build on behalf of the user, it creates a |
1033 | build directory under @file{/tmp} or under the directory specified by | |
1034 | its @code{TMPDIR} environment variable; this directory is shared with | |
1035 | the container for the duration of the build. Be aware that using a | |
1036 | directory other than @file{/tmp} can affect build results---for example, | |
1037 | with a longer directory name, a build process that uses Unix-domain | |
1038 | sockets might hit the name length limitation for @code{sun_path}, which | |
1039 | it would otherwise not hit. | |
1040 | ||
1041 | The build directory is automatically deleted upon completion, unless the | |
1042 | build failed and the client specified @option{--keep-failed} | |
1043 | (@pxref{Invoking guix build, @option{--keep-failed}}). | |
1044 | ||
bd5e766b LC |
1045 | The following command-line options are supported: |
1046 | ||
1047 | @table @code | |
1048 | @item --build-users-group=@var{group} | |
1049 | Take users from @var{group} to run build processes (@pxref{Setting Up | |
1050 | the Daemon, build users}). | |
1051 | ||
6858f9d1 | 1052 | @item --no-substitutes |
b5385b52 | 1053 | @cindex substitutes |
6858f9d1 | 1054 | Do not use substitutes for build products. That is, always build things |
c4202d60 LC |
1055 | locally instead of allowing downloads of pre-built binaries |
1056 | (@pxref{Substitutes}). | |
6858f9d1 | 1057 | |
b5385b52 LC |
1058 | By default substitutes are used, unless the client---such as the |
1059 | @command{guix package} command---is explicitly invoked with | |
1060 | @code{--no-substitutes}. | |
1061 | ||
1062 | When the daemon runs with @code{--no-substitutes}, clients can still | |
1063 | explicitly enable substitution @i{via} the @code{set-build-options} | |
1064 | remote procedure call (@pxref{The Store}). | |
1065 | ||
9176607e | 1066 | @item --substitute-urls=@var{urls} |
f8a8e0fe | 1067 | @anchor{daemon-substitute-urls} |
9176607e | 1068 | Consider @var{urls} the default whitespace-separated list of substitute |
df061d07 LC |
1069 | source URLs. When this option is omitted, |
1070 | @indicateurl{https://mirror.hydra.gnu.org https://hydra.gnu.org} is used | |
1071 | (@code{mirror.hydra.gnu.org} is a mirror of @code{hydra.gnu.org}). | |
9176607e LC |
1072 | |
1073 | This means that substitutes may be downloaded from @var{urls}, as long | |
1074 | as they are signed by a trusted signature (@pxref{Substitutes}). | |
1075 | ||
4ec2e92d LC |
1076 | @cindex build hook |
1077 | @item --no-build-hook | |
1078 | Do not use the @dfn{build hook}. | |
1079 | ||
1080 | The build hook is a helper program that the daemon can start and to | |
1081 | which it submits build requests. This mechanism is used to offload | |
1082 | builds to other machines (@pxref{Daemon Offload Setup}). | |
1083 | ||
bd5e766b LC |
1084 | @item --cache-failures |
1085 | Cache build failures. By default, only successful builds are cached. | |
1086 | ||
30d9aa54 LC |
1087 | When this option is used, @command{guix gc --list-failures} can be used |
1088 | to query the set of store items marked as failed; @command{guix gc | |
1089 | --clear-failures} removes store items from the set of cached failures. | |
1090 | @xref{Invoking guix gc}. | |
1091 | ||
bd5e766b LC |
1092 | @item --cores=@var{n} |
1093 | @itemx -c @var{n} | |
1094 | Use @var{n} CPU cores to build each derivation; @code{0} means as many | |
1095 | as available. | |
1096 | ||
6efc160e | 1097 | The default value is @code{0}, but it may be overridden by clients, such |
e49951eb MW |
1098 | as the @code{--cores} option of @command{guix build} (@pxref{Invoking |
1099 | guix build}). | |
bd5e766b LC |
1100 | |
1101 | The effect is to define the @code{NIX_BUILD_CORES} environment variable | |
1102 | in the build process, which can then use it to exploit internal | |
1103 | parallelism---for instance, by running @code{make -j$NIX_BUILD_CORES}. | |
1104 | ||
1105 | @item --max-jobs=@var{n} | |
1106 | @itemx -M @var{n} | |
1107 | Allow at most @var{n} build jobs in parallel. The default value is | |
f6526eb3 LC |
1108 | @code{1}. Setting it to @code{0} means that no builds will be performed |
1109 | locally; instead, the daemon will offload builds (@pxref{Daemon Offload | |
1110 | Setup}), or simply fail. | |
bd5e766b | 1111 | |
ecf84b7c LC |
1112 | @item --rounds=@var{N} |
1113 | Build each derivation @var{n} times in a row, and raise an error if | |
1114 | consecutive build results are not bit-for-bit identical. Note that this | |
1115 | setting can be overridden by clients such as @command{guix build} | |
1116 | (@pxref{Invoking guix build}). | |
1117 | ||
b4528110 ED |
1118 | When used in conjunction with @option{--keep-failed}, the differing |
1119 | output is kept in the store, under @file{/gnu/store/@dots{}-check}. | |
1120 | This makes it easy to look for differences between the two results. | |
1121 | ||
bd5e766b LC |
1122 | @item --debug |
1123 | Produce debugging output. | |
1124 | ||
1125 | This is useful to debug daemon start-up issues, but then it may be | |
1126 | overridden by clients, for example the @code{--verbosity} option of | |
e49951eb | 1127 | @command{guix build} (@pxref{Invoking guix build}). |
bd5e766b LC |
1128 | |
1129 | @item --chroot-directory=@var{dir} | |
1130 | Add @var{dir} to the build chroot. | |
1131 | ||
1132 | Doing this may change the result of build processes---for instance if | |
1133 | they use optional dependencies found in @var{dir} when it is available, | |
1134 | and not otherwise. For that reason, it is not recommended to do so. | |
1135 | Instead, make sure that each derivation declares all the inputs that it | |
1136 | needs. | |
1137 | ||
1138 | @item --disable-chroot | |
1139 | Disable chroot builds. | |
1140 | ||
1141 | Using this option is not recommended since, again, it would allow build | |
1e2644bb LC |
1142 | processes to gain access to undeclared dependencies. It is necessary, |
1143 | though, when @command{guix-daemon} is running under an unprivileged user | |
1144 | account. | |
bd5e766b LC |
1145 | |
1146 | @item --disable-log-compression | |
1147 | Disable compression of the build logs. | |
1148 | ||
1da983b9 LC |
1149 | Unless @code{--lose-logs} is used, all the build logs are kept in the |
1150 | @var{localstatedir}. To save space, the daemon automatically compresses | |
1151 | them with bzip2 by default. This option disables that. | |
1152 | ||
ab3893d7 LC |
1153 | @item --disable-deduplication |
1154 | @cindex deduplication | |
bd5e766b LC |
1155 | Disable automatic file ``deduplication'' in the store. |
1156 | ||
1da983b9 | 1157 | By default, files added to the store are automatically ``deduplicated'': |
ab3893d7 LC |
1158 | if a newly added file is identical to another one found in the store, |
1159 | the daemon makes the new file a hard link to the other file. This can | |
4988dd40 | 1160 | noticeably reduce disk usage, at the expense of slightly increased |
ab3893d7 LC |
1161 | input/output load at the end of a build process. This option disables |
1162 | this optimization. | |
1da983b9 | 1163 | |
6e37066e LC |
1164 | @item --gc-keep-outputs[=yes|no] |
1165 | Tell whether the garbage collector (GC) must keep outputs of live | |
1166 | derivations. | |
1167 | ||
1168 | When set to ``yes'', the GC will keep the outputs of any live derivation | |
1169 | available in the store---the @code{.drv} files. The default is ``no'', | |
1170 | meaning that derivation outputs are kept only if they are GC roots. | |
1171 | ||
1172 | @item --gc-keep-derivations[=yes|no] | |
1173 | Tell whether the garbage collector (GC) must keep derivations | |
1174 | corresponding to live outputs. | |
1175 | ||
1176 | When set to ``yes'', as is the case by default, the GC keeps | |
1177 | derivations---i.e., @code{.drv} files---as long as at least one of their | |
1178 | outputs is live. This allows users to keep track of the origins of | |
1179 | items in their store. Setting it to ``no'' saves a bit of disk space. | |
1180 | ||
1181 | Note that when both @code{--gc-keep-derivations} and | |
1182 | @code{--gc-keep-outputs} are used, the effect is to keep all the build | |
1183 | prerequisites (the sources, compiler, libraries, and other build-time | |
1184 | tools) of live objects in the store, regardless of whether these | |
1185 | prerequisites are live. This is convenient for developers since it | |
1186 | saves rebuilds or downloads. | |
1187 | ||
bd5e766b LC |
1188 | @item --impersonate-linux-2.6 |
1189 | On Linux-based systems, impersonate Linux 2.6. This means that the | |
1190 | kernel's @code{uname} system call will report 2.6 as the release number. | |
1191 | ||
1192 | This might be helpful to build programs that (usually wrongfully) depend | |
1193 | on the kernel version number. | |
1194 | ||
1195 | @item --lose-logs | |
1196 | Do not keep build logs. By default they are kept under | |
ce33631f | 1197 | @code{@var{localstatedir}/guix/log}. |
bd5e766b LC |
1198 | |
1199 | @item --system=@var{system} | |
1200 | Assume @var{system} as the current system type. By default it is the | |
1201 | architecture/kernel pair found at configure time, such as | |
1202 | @code{x86_64-linux}. | |
b8d2aa26 LC |
1203 | |
1204 | @item --listen=@var{socket} | |
1205 | Listen for connections on @var{socket}, the file name of a Unix-domain | |
1206 | socket. The default socket is | |
1207 | @file{@var{localstatedir}/daemon-socket/socket}. This option is only | |
1208 | useful in exceptional circumstances, such as if you need to run several | |
1209 | daemons on the same machine. | |
bd5e766b LC |
1210 | @end table |
1211 | ||
1212 | ||
0e2d0213 LC |
1213 | @node Application Setup |
1214 | @section Application Setup | |
1215 | ||
d23ef788 | 1216 | @cindex foreign distro |
85e57214 LC |
1217 | When using Guix on top of GNU/Linux distribution other than GuixSD---a |
1218 | so-called @dfn{foreign distro}---a few additional steps are needed to | |
1219 | get everything in place. Here are some of them. | |
0e2d0213 LC |
1220 | |
1221 | @subsection Locales | |
1222 | ||
5c3c1427 | 1223 | @anchor{locales-and-locpath} |
0e2d0213 | 1224 | @cindex locales, when not on GuixSD |
5c3c1427 | 1225 | @vindex LOCPATH |
85e57214 | 1226 | @vindex GUIX_LOCPATH |
f97c9175 AE |
1227 | Packages installed @i{via} Guix will not use the locale data of the |
1228 | host system. Instead, you must first install one of the locale packages | |
85e57214 LC |
1229 | available with Guix and then define the @code{GUIX_LOCPATH} environment |
1230 | variable: | |
0e2d0213 LC |
1231 | |
1232 | @example | |
1233 | $ guix package -i glibc-locales | |
85e57214 | 1234 | $ export GUIX_LOCPATH=$HOME/.guix-profile/lib/locale |
0e2d0213 LC |
1235 | @end example |
1236 | ||
1237 | Note that the @code{glibc-locales} package contains data for all the | |
1238 | locales supported by the GNU@tie{}libc and weighs in at around | |
f97c9175 | 1239 | 110@tie{}MiB. Alternatively, the @code{glibc-utf8-locales} is smaller but |
0e2d0213 LC |
1240 | limited to a few UTF-8 locales. |
1241 | ||
85e57214 LC |
1242 | The @code{GUIX_LOCPATH} variable plays a role similar to @code{LOCPATH} |
1243 | (@pxref{Locale Names, @code{LOCPATH},, libc, The GNU C Library Reference | |
1244 | Manual}). There are two important differences though: | |
1245 | ||
1246 | @enumerate | |
1247 | @item | |
f97c9175 | 1248 | @code{GUIX_LOCPATH} is honored only by the libc in Guix, and not by the libc |
85e57214 | 1249 | provided by foreign distros. Thus, using @code{GUIX_LOCPATH} allows you |
f97c9175 | 1250 | to make sure the programs of the foreign distro will not end up loading |
85e57214 LC |
1251 | incompatible locale data. |
1252 | ||
1253 | @item | |
1254 | libc suffixes each entry of @code{GUIX_LOCPATH} with @code{/X.Y}, where | |
1255 | @code{X.Y} is the libc version---e.g., @code{2.22}. This means that, | |
1256 | should your Guix profile contain a mixture of programs linked against | |
1257 | different libc version, each libc version will only try to load locale | |
1258 | data in the right format. | |
1259 | @end enumerate | |
1260 | ||
1261 | This is important because the locale data format used by different libc | |
1262 | versions may be incompatible. | |
1263 | ||
9a5187b6 LC |
1264 | @subsection Name Service Switch |
1265 | ||
1266 | @cindex name service switch, glibc | |
1267 | @cindex NSS (name service switch), glibc | |
1268 | @cindex nscd (name service caching daemon) | |
1269 | @cindex name service caching daemon (nscd) | |
1270 | When using Guix on a foreign distro, we @emph{strongly recommend} that | |
1271 | the system run the GNU C library's @dfn{name service cache daemon}, | |
1272 | @command{nscd}, which should be listening on the | |
1273 | @file{/var/run/nscd/socket} socket. Failing to do that, applications | |
1274 | installed with Guix may fail to look up host names or user accounts, or | |
1275 | may even crash. The next paragraphs explain why. | |
1276 | ||
1277 | @cindex @file{nsswitch.conf} | |
1278 | The GNU C library implements a @dfn{name service switch} (NSS), which is | |
1279 | an extensible mechanism for ``name lookups'' in general: host name | |
1280 | resolution, user accounts, and more (@pxref{Name Service Switch,,, libc, | |
1281 | The GNU C Library Reference Manual}). | |
1282 | ||
1283 | @cindex Network information service (NIS) | |
1284 | @cindex NIS (Network information service) | |
1285 | Being extensible, the NSS supports @dfn{plugins}, which provide new name | |
1286 | lookup implementations: for example, the @code{nss-mdns} plugin allow | |
1287 | resolution of @code{.local} host names, the @code{nis} plugin allows | |
1288 | user account lookup using the Network information service (NIS), and so | |
1289 | on. These extra ``lookup services'' are configured system-wide in | |
1290 | @file{/etc/nsswitch.conf}, and all the programs running on the system | |
1291 | honor those settings (@pxref{NSS Configuration File,,, libc, The GNU C | |
1292 | Reference Manual}). | |
1293 | ||
1294 | When they perform a name lookup---for instance by calling the | |
1295 | @code{getaddrinfo} function in C---applications first try to connect to | |
1296 | the nscd; on success, nscd performs name lookups on their behalf. If | |
1297 | the nscd is not running, then they perform the name lookup by | |
1298 | themselves, by loading the name lookup services into their own address | |
1299 | space and running it. These name lookup services---the | |
1300 | @file{libnss_*.so} files---are @code{dlopen}'d, but they may come from | |
1301 | the host system's C library, rather than from the C library the | |
1302 | application is linked against (the C library coming from Guix). | |
1303 | ||
1304 | And this is where the problem is: if your application is linked against | |
1305 | Guix's C library (say, glibc 2.24) and tries to load NSS plugins from | |
1306 | another C library (say, @code{libnss_mdns.so} for glibc 2.22), it will | |
1307 | likely crash or have its name lookups fail unexpectedly. | |
1308 | ||
1309 | Running @command{nscd} on the system, among other advantages, eliminates | |
1310 | this binary incompatibility problem because those @code{libnss_*.so} | |
1311 | files are loaded in the @command{nscd} process, not in applications | |
1312 | themselves. | |
1313 | ||
0e2d0213 LC |
1314 | @subsection X11 Fonts |
1315 | ||
e32171ee | 1316 | @cindex fonts |
4988dd40 | 1317 | The majority of graphical applications use Fontconfig to locate and |
f97c9175 AE |
1318 | load fonts and perform X11-client-side rendering. The @code{fontconfig} |
1319 | package in Guix looks for fonts in @file{$HOME/.guix-profile} | |
0e2d0213 | 1320 | by default. Thus, to allow graphical applications installed with Guix |
f97c9175 | 1321 | to display fonts, you have to install fonts with Guix as well. |
0e2d0213 | 1322 | Essential font packages include @code{gs-fonts}, @code{font-dejavu}, and |
8fe5b1d1 | 1323 | @code{font-gnu-freefont-ttf}. |
0e2d0213 | 1324 | |
5c36edc8 LC |
1325 | To display text written in Chinese languages, Japanese, or Korean in |
1326 | graphical applications, consider installing | |
1327 | @code{font-adobe-source-han-sans} or @code{font-wqy-zenhei}. The former | |
1328 | has multiple outputs, one per language family (@pxref{Packages with | |
1329 | Multiple Outputs}). For instance, the following command installs fonts | |
1330 | for Chinese languages: | |
1331 | ||
1332 | @example | |
1333 | guix package -i font-adobe-source-han-sans:cn | |
1334 | @end example | |
1335 | ||
e32171ee | 1336 | @cindex @code{xterm} |
1a3e6b15 AK |
1337 | Older programs such as @command{xterm} do not use Fontconfig and instead |
1338 | rely on server-side font rendering. Such programs require to specify a | |
1339 | full name of a font using XLFD (X Logical Font Description), like this: | |
1340 | ||
1341 | @example | |
1342 | -*-dejavu sans-medium-r-normal-*-*-100-*-*-*-*-*-1 | |
1343 | @end example | |
1344 | ||
1345 | To be able to use such full names for the TrueType fonts installed in | |
1346 | your Guix profile, you need to extend the font path of the X server: | |
1347 | ||
1348 | @example | |
1349 | xset +fp ~/.guix-profile/share/fonts/truetype | |
1350 | @end example | |
1351 | ||
e32171ee | 1352 | @cindex @code{xlsfonts} |
1a3e6b15 AK |
1353 | After that, you can run @code{xlsfonts} (from @code{xlsfonts} package) |
1354 | to make sure your TrueType fonts are listed there. | |
1355 | ||
b3129f2b LC |
1356 | @subsection X.509 Certificates |
1357 | ||
e32171ee | 1358 | @cindex @code{nss-certs} |
b3129f2b LC |
1359 | The @code{nss-certs} package provides X.509 certificates, which allow |
1360 | programs to authenticate Web servers accessed over HTTPS. | |
1361 | ||
1362 | When using Guix on a foreign distro, you can install this package and | |
1363 | define the relevant environment variables so that packages know where to | |
80d944b7 | 1364 | look for certificates. @xref{X.509 Certificates}, for detailed |
b3129f2b LC |
1365 | information. |
1366 | ||
6d97319c AK |
1367 | @subsection Emacs Packages |
1368 | ||
e32171ee | 1369 | @cindex @code{emacs} |
6d97319c AK |
1370 | When you install Emacs packages with Guix, the elisp files may be placed |
1371 | either in @file{$HOME/.guix-profile/share/emacs/site-lisp/} or in | |
1372 | sub-directories of | |
1373 | @file{$HOME/.guix-profile/share/emacs/site-lisp/guix.d/}. The latter | |
1374 | directory exists because potentially there may exist thousands of Emacs | |
1375 | packages and storing all their files in a single directory may be not | |
1376 | reliable (because of name conflicts). So we think using a separate | |
1377 | directory for each package is a good idea. It is very similar to how | |
1378 | the Emacs package system organizes the file structure (@pxref{Package | |
1379 | Files,,, emacs, The GNU Emacs Manual}). | |
1380 | ||
1381 | By default, Emacs (installed with Guix) ``knows'' where these packages | |
f97c9175 | 1382 | are placed, so you do not need to perform any configuration. If, for |
6d97319c | 1383 | some reason, you want to avoid auto-loading Emacs packages installed |
f97c9175 | 1384 | with Guix, you can do so by running Emacs with @code{--no-site-file} |
6d97319c AK |
1385 | option (@pxref{Init File,,, emacs, The GNU Emacs Manual}). |
1386 | ||
0e2d0213 LC |
1387 | @c TODO What else? |
1388 | ||
eeaf4427 LC |
1389 | @c ********************************************************************* |
1390 | @node Package Management | |
1391 | @chapter Package Management | |
1392 | ||
e32171ee | 1393 | @cindex packages |
f8348b91 | 1394 | The purpose of GNU Guix is to allow users to easily install, upgrade, and |
eeaf4427 | 1395 | remove software packages, without having to know about their build |
f97c9175 | 1396 | procedures or dependencies. Guix also goes beyond this obvious set of |
eeaf4427 LC |
1397 | features. |
1398 | ||
1399 | This chapter describes the main features of Guix, as well as the package | |
deb6276d AK |
1400 | management tools it provides. Along with the command-line interface |
1401 | described below (@pxref{Invoking guix package, @code{guix package}}), | |
1402 | you may also use Emacs Interface, after installing @code{emacs-guix} | |
1403 | package (run @kbd{M-x guix-help} command to start with it): | |
1404 | ||
1405 | @example | |
1406 | guix package -i emacs-guix | |
1407 | @end example | |
eeaf4427 LC |
1408 | |
1409 | @menu | |
1410 | * Features:: How Guix will make your life brighter. | |
e49951eb | 1411 | * Invoking guix package:: Package installation, removal, etc. |
c4202d60 | 1412 | * Substitutes:: Downloading pre-built binaries. |
760c60d6 | 1413 | * Packages with Multiple Outputs:: Single source package, multiple outputs. |
e49951eb | 1414 | * Invoking guix gc:: Running the garbage collector. |
f651b477 | 1415 | * Invoking guix pull:: Fetching the latest Guix and distribution. |
760c60d6 | 1416 | * Invoking guix archive:: Exporting and importing store files. |
eeaf4427 LC |
1417 | @end menu |
1418 | ||
1419 | @node Features | |
1420 | @section Features | |
1421 | ||
1422 | When using Guix, each package ends up in the @dfn{package store}, in its | |
1423 | own directory---something that resembles | |
deb6276d | 1424 | @file{/gnu/store/xxx-package-1.2}, where @code{xxx} is a base32 string. |
eeaf4427 LC |
1425 | |
1426 | Instead of referring to these directories, users have their own | |
1427 | @dfn{profile}, which points to the packages that they actually want to | |
821b0015 LC |
1428 | use. These profiles are stored within each user's home directory, at |
1429 | @code{$HOME/.guix-profile}. | |
eeaf4427 | 1430 | |
821b0015 | 1431 | For example, @code{alice} installs GCC 4.7.2. As a result, |
eeaf4427 | 1432 | @file{/home/alice/.guix-profile/bin/gcc} points to |
834129e0 | 1433 | @file{/gnu/store/@dots{}-gcc-4.7.2/bin/gcc}. Now, on the same machine, |
821b0015 LC |
1434 | @code{bob} had already installed GCC 4.8.0. The profile of @code{bob} |
1435 | simply continues to point to | |
834129e0 | 1436 | @file{/gnu/store/@dots{}-gcc-4.8.0/bin/gcc}---i.e., both versions of GCC |
821b0015 | 1437 | coexist on the same system without any interference. |
eeaf4427 | 1438 | |
e49951eb | 1439 | The @command{guix package} command is the central tool to manage |
f97c9175 | 1440 | packages (@pxref{Invoking guix package}). It operates on the per-user |
821b0015 | 1441 | profiles, and can be used @emph{with normal user privileges}. |
eeaf4427 | 1442 | |
e32171ee | 1443 | @cindex transactions |
eeaf4427 LC |
1444 | The command provides the obvious install, remove, and upgrade |
1445 | operations. Each invocation is actually a @emph{transaction}: either | |
ba55b1cb | 1446 | the specified operation succeeds, or nothing happens. Thus, if the |
e49951eb | 1447 | @command{guix package} process is terminated during the transaction, |
eeaf4427 LC |
1448 | or if a power outage occurs during the transaction, then the user's |
1449 | profile remains in its previous state, and remains usable. | |
1450 | ||
1451 | In addition, any package transaction may be @emph{rolled back}. So, if, | |
1452 | for example, an upgrade installs a new version of a package that turns | |
1453 | out to have a serious bug, users may roll back to the previous instance | |
4af2447e | 1454 | of their profile, which was known to work well. Similarly, the global |
6f773606 LC |
1455 | system configuration on GuixSD is subject to |
1456 | transactional upgrades and roll-back | |
4af2447e | 1457 | (@pxref{Using the Configuration System}). |
eeaf4427 | 1458 | |
f97c9175 AE |
1459 | All packages in the package store may be @emph{garbage-collected}. |
1460 | Guix can determine which packages are still referenced by user | |
fe8ff028 | 1461 | profiles, and remove those that are provably no longer referenced |
e49951eb | 1462 | (@pxref{Invoking guix gc}). Users may also explicitly remove old |
fe8ff028 LC |
1463 | generations of their profile so that the packages they refer to can be |
1464 | collected. | |
eeaf4427 | 1465 | |
e900c503 LC |
1466 | @cindex reproducibility |
1467 | @cindex reproducible builds | |
eeaf4427 LC |
1468 | Finally, Guix takes a @dfn{purely functional} approach to package |
1469 | management, as described in the introduction (@pxref{Introduction}). | |
834129e0 | 1470 | Each @file{/gnu/store} package directory name contains a hash of all the |
eeaf4427 LC |
1471 | inputs that were used to build that package---compiler, libraries, build |
1472 | scripts, etc. This direct correspondence allows users to make sure a | |
1473 | given package installation matches the current state of their | |
e900c503 LC |
1474 | distribution. It also helps maximize @dfn{build reproducibility}: |
1475 | thanks to the isolated build environments that are used, a given build | |
1476 | is likely to yield bit-identical files when performed on different | |
1477 | machines (@pxref{Invoking guix-daemon, container}). | |
eeaf4427 | 1478 | |
c4202d60 | 1479 | @cindex substitutes |
eeaf4427 | 1480 | This foundation allows Guix to support @dfn{transparent binary/source |
c4202d60 | 1481 | deployment}. When a pre-built binary for a @file{/gnu/store} item is |
18f2887b | 1482 | available from an external source---a @dfn{substitute}, Guix just |
c4202d60 LC |
1483 | downloads it and unpacks it; |
1484 | otherwise, it builds the package from source, locally | |
bf9eacd2 LC |
1485 | (@pxref{Substitutes}). Because build results are usually bit-for-bit |
1486 | reproducible, users do not have to trust servers that provide | |
1487 | substitutes: they can force a local build and @emph{challenge} providers | |
1488 | (@pxref{Invoking guix challenge}). | |
eeaf4427 | 1489 | |
f5fd4fd2 LC |
1490 | Control over the build environment is a feature that is also useful for |
1491 | developers. The @command{guix environment} command allows developers of | |
1492 | a package to quickly set up the right development environment for their | |
f97c9175 AE |
1493 | package, without having to manually install the dependencies of the |
1494 | package into their profile (@pxref{Invoking guix environment}). | |
f5fd4fd2 | 1495 | |
e49951eb MW |
1496 | @node Invoking guix package |
1497 | @section Invoking @command{guix package} | |
eeaf4427 | 1498 | |
e32171ee JD |
1499 | @cindex installing packages |
1500 | @cindex removing packages | |
1501 | @cindex package installation | |
1502 | @cindex package removal | |
e49951eb | 1503 | The @command{guix package} command is the tool that allows users to |
eeaf4427 LC |
1504 | install, upgrade, and remove packages, as well as rolling back to |
1505 | previous configurations. It operates only on the user's own profile, | |
1506 | and works with normal user privileges (@pxref{Features}). Its syntax | |
1507 | is: | |
1508 | ||
1509 | @example | |
e49951eb | 1510 | guix package @var{options} |
eeaf4427 | 1511 | @end example |
e32171ee | 1512 | @cindex transactions |
ba55b1cb | 1513 | Primarily, @var{options} specifies the operations to be performed during |
eeaf4427 | 1514 | the transaction. Upon completion, a new profile is created, but |
99bd74d5 | 1515 | previous @dfn{generations} of the profile remain available, should the user |
eeaf4427 LC |
1516 | want to roll back. |
1517 | ||
6447738c MW |
1518 | For example, to remove @code{lua} and install @code{guile} and |
1519 | @code{guile-cairo} in a single transaction: | |
1520 | ||
1521 | @example | |
1522 | guix package -r lua -i guile guile-cairo | |
1523 | @end example | |
1524 | ||
99bd74d5 LC |
1525 | @command{guix package} also supports a @dfn{declarative approach} |
1526 | whereby the user specifies the exact set of packages to be available and | |
1527 | passes it @i{via} the @option{--manifest} option | |
1528 | (@pxref{profile-manifest, @option{--manifest}}). | |
1529 | ||
e32171ee | 1530 | @cindex profile |
b9e5c0a9 | 1531 | For each user, a symlink to the user's default profile is automatically |
0ec1af59 | 1532 | created in @file{$HOME/.guix-profile}. This symlink always points to the |
b9e5c0a9 LC |
1533 | current generation of the user's default profile. Thus, users can add |
1534 | @file{$HOME/.guix-profile/bin} to their @code{PATH} environment | |
1535 | variable, and so on. | |
d664f1b4 LC |
1536 | @cindex search paths |
1537 | If you are not using the Guix System Distribution, consider adding the | |
1538 | following lines to your @file{~/.bash_profile} (@pxref{Bash Startup | |
1539 | Files,,, bash, The GNU Bash Reference Manual}) so that newly-spawned | |
1540 | shells get all the right environment variable definitions: | |
1541 | ||
1542 | @example | |
1543 | GUIX_PROFILE="$HOME/.guix-profile" \ | |
1544 | source "$HOME/.guix-profile/etc/profile" | |
1545 | @end example | |
b9e5c0a9 | 1546 | |
4379c35b LC |
1547 | In a multi-user setup, user profiles are stored in a place registered as |
1548 | a @dfn{garbage-collector root}, which @file{$HOME/.guix-profile} points | |
1549 | to (@pxref{Invoking guix gc}). That directory is normally | |
0ec1af59 LC |
1550 | @code{@var{localstatedir}/profiles/per-user/@var{user}}, where |
1551 | @var{localstatedir} is the value passed to @code{configure} as | |
4379c35b LC |
1552 | @code{--localstatedir}, and @var{user} is the user name. The |
1553 | @file{per-user} directory is created when @command{guix-daemon} is | |
1554 | started, and the @var{user} sub-directory is created by @command{guix | |
1555 | package}. | |
0ec1af59 LC |
1556 | |
1557 | The @var{options} can be among the following: | |
1558 | ||
eeaf4427 LC |
1559 | @table @code |
1560 | ||
6447738c MW |
1561 | @item --install=@var{package} @dots{} |
1562 | @itemx -i @var{package} @dots{} | |
1563 | Install the specified @var{package}s. | |
eeaf4427 | 1564 | |
6447738c | 1565 | Each @var{package} may specify either a simple package name, such as |
1b846da8 ML |
1566 | @code{guile}, or a package name followed by an at-sign and version number, |
1567 | such as @code{guile@@1.8.8} or simply @code{guile@@1.8} (in the latter | |
724311a2 LC |
1568 | case, the newest version prefixed by @code{1.8} is selected.) |
1569 | ||
1570 | If no version number is specified, the | |
dc5669cd MW |
1571 | newest available version will be selected. In addition, @var{package} |
1572 | may contain a colon, followed by the name of one of the outputs of the | |
1b846da8 | 1573 | package, as in @code{gcc:doc} or @code{binutils@@2.22:lib} |
e7f34eb0 LC |
1574 | (@pxref{Packages with Multiple Outputs}). Packages with a corresponding |
1575 | name (and optionally version) are searched for among the GNU | |
1576 | distribution modules (@pxref{Package Modules}). | |
eeaf4427 | 1577 | |
461572cc LC |
1578 | @cindex propagated inputs |
1579 | Sometimes packages have @dfn{propagated inputs}: these are dependencies | |
21461f27 LC |
1580 | that automatically get installed along with the required package |
1581 | (@pxref{package-propagated-inputs, @code{propagated-inputs} in | |
1582 | @code{package} objects}, for information about propagated inputs in | |
1583 | package definitions). | |
461572cc | 1584 | |
21461f27 | 1585 | @anchor{package-cmd-propagated-inputs} |
461572cc LC |
1586 | An example is the GNU MPC library: its C header files refer to those of |
1587 | the GNU MPFR library, which in turn refer to those of the GMP library. | |
1588 | Thus, when installing MPC, the MPFR and GMP libraries also get installed | |
1589 | in the profile; removing MPC also removes MPFR and GMP---unless they had | |
f97c9175 | 1590 | also been explicitly installed by the user. |
461572cc | 1591 | |
ba7ea5ce | 1592 | Besides, packages sometimes rely on the definition of environment |
5924080d | 1593 | variables for their search paths (see explanation of |
ba7ea5ce | 1594 | @code{--search-paths} below). Any missing or possibly incorrect |
5924080d LC |
1595 | environment variable definitions are reported here. |
1596 | ||
5d4b411f LC |
1597 | @item --install-from-expression=@var{exp} |
1598 | @itemx -e @var{exp} | |
1599 | Install the package @var{exp} evaluates to. | |
1600 | ||
1601 | @var{exp} must be a Scheme expression that evaluates to a | |
1602 | @code{<package>} object. This option is notably useful to disambiguate | |
1603 | between same-named variants of a package, with expressions such as | |
1604 | @code{(@@ (gnu packages base) guile-final)}. | |
1605 | ||
1606 | Note that this option installs the first output of the specified | |
1607 | package, which may be insufficient when needing a specific output of a | |
1608 | multiple-output package. | |
1609 | ||
0d279400 DT |
1610 | @item --install-from-file=@var{file} |
1611 | @itemx -f @var{file} | |
1612 | Install the package that the code within @var{file} evaluates to. | |
1613 | ||
1614 | As an example, @var{file} might contain a definition like this | |
1615 | (@pxref{Defining Packages}): | |
1616 | ||
1617 | @example | |
1618 | @verbatiminclude package-hello.scm | |
1619 | @end example | |
1620 | ||
baacf042 | 1621 | Developers may find it useful to include such a @file{guix.scm} file |
f97c9175 | 1622 | in the root of their project source tree that can be used to test |
0d279400 DT |
1623 | development snapshots and create reproducible development environments |
1624 | (@pxref{Invoking guix environment}). | |
1625 | ||
6447738c MW |
1626 | @item --remove=@var{package} @dots{} |
1627 | @itemx -r @var{package} @dots{} | |
1628 | Remove the specified @var{package}s. | |
eeaf4427 | 1629 | |
6447738c | 1630 | As for @code{--install}, each @var{package} may specify a version number |
13ed095c LC |
1631 | and/or output name in addition to the package name. For instance, |
1632 | @code{-r glibc:debug} would remove the @code{debug} output of | |
1633 | @code{glibc}. | |
1634 | ||
6447738c MW |
1635 | @item --upgrade[=@var{regexp} @dots{}] |
1636 | @itemx -u [@var{regexp} @dots{}] | |
e32171ee | 1637 | @cindex upgrading packages |
6447738c MW |
1638 | Upgrade all the installed packages. If one or more @var{regexp}s are |
1639 | specified, upgrade only installed packages whose name matches a | |
d5f01e48 | 1640 | @var{regexp}. Also see the @code{--do-not-upgrade} option below. |
eeaf4427 | 1641 | |
f651b477 LC |
1642 | Note that this upgrades package to the latest version of packages found |
1643 | in the distribution currently installed. To update your distribution, | |
1644 | you should regularly run @command{guix pull} (@pxref{Invoking guix | |
1645 | pull}). | |
1646 | ||
d5f01e48 MW |
1647 | @item --do-not-upgrade[=@var{regexp} @dots{}] |
1648 | When used together with the @code{--upgrade} option, do @emph{not} | |
1649 | upgrade any packages whose name matches a @var{regexp}. For example, to | |
1650 | upgrade all packages in the current profile except those containing the | |
1651 | substring ``emacs'': | |
1652 | ||
1653 | @example | |
1654 | $ guix package --upgrade . --do-not-upgrade emacs | |
1655 | @end example | |
1656 | ||
99bd74d5 | 1657 | @item @anchor{profile-manifest}--manifest=@var{file} |
1b676447 | 1658 | @itemx -m @var{file} |
99bd74d5 LC |
1659 | @cindex profile declaration |
1660 | @cindex profile manifest | |
1661 | Create a new generation of the profile from the manifest object | |
1b676447 DT |
1662 | returned by the Scheme code in @var{file}. |
1663 | ||
99bd74d5 LC |
1664 | This allows you to @emph{declare} the profile's contents rather than |
1665 | constructing it through a sequence of @code{--install} and similar | |
1666 | commands. The advantage is that @var{file} can be put under version | |
1667 | control, copied to different machines to reproduce the same profile, and | |
1668 | so on. | |
1669 | ||
1670 | @c FIXME: Add reference to (guix profile) documentation when available. | |
1671 | @var{file} must return a @dfn{manifest} object, which is roughly a list | |
1672 | of packages: | |
1b676447 | 1673 | |
99bd74d5 | 1674 | @findex packages->manifest |
1b676447 | 1675 | @example |
99bd74d5 | 1676 | (use-package-modules guile emacs) |
1b676447 DT |
1677 | |
1678 | (packages->manifest | |
99bd74d5 LC |
1679 | (list emacs |
1680 | guile-2.0 | |
1b676447 | 1681 | ;; Use a specific package output. |
99bd74d5 | 1682 | (list guile-2.0 "debug"))) |
1b676447 DT |
1683 | @end example |
1684 | ||
24e262f0 | 1685 | @item --roll-back |
e32171ee JD |
1686 | @cindex rolling back |
1687 | @cindex undoing transactions | |
1688 | @cindex transactions, undoing | |
24e262f0 LC |
1689 | Roll back to the previous @dfn{generation} of the profile---i.e., undo |
1690 | the last transaction. | |
1691 | ||
1692 | When combined with options such as @code{--install}, roll back occurs | |
1693 | before any other actions. | |
1694 | ||
d9307267 | 1695 | When rolling back from the first generation that actually contains |
4b2bc804 | 1696 | installed packages, the profile is made to point to the @dfn{zeroth |
f97c9175 | 1697 | generation}, which contains no files apart from its own metadata. |
d9307267 | 1698 | |
f97c9175 AE |
1699 | After having rolled back, installing, removing, or upgrading packages |
1700 | overwrites previous future generations. Thus, the history of the | |
1701 | generations in a profile is always linear. | |
82fe08ed | 1702 | |
b3bb82f1 AK |
1703 | @item --switch-generation=@var{pattern} |
1704 | @itemx -S @var{pattern} | |
e32171ee | 1705 | @cindex generations |
b3bb82f1 AK |
1706 | Switch to a particular generation defined by @var{pattern}. |
1707 | ||
1708 | @var{pattern} may be either a generation number or a number prefixed | |
1709 | with ``+'' or ``-''. The latter means: move forward/backward by a | |
1710 | specified number of generations. For example, if you want to return to | |
1711 | the latest generation after @code{--roll-back}, use | |
1712 | @code{--switch-generation=+1}. | |
1713 | ||
1714 | The difference between @code{--roll-back} and | |
1715 | @code{--switch-generation=-1} is that @code{--switch-generation} will | |
1716 | not make a zeroth generation, so if a specified generation does not | |
1717 | exist, the current generation will not be changed. | |
1718 | ||
dbc31ab2 | 1719 | @item --search-paths[=@var{kind}] |
5924080d LC |
1720 | @cindex search paths |
1721 | Report environment variable definitions, in Bash syntax, that may be | |
1722 | needed in order to use the set of installed packages. These environment | |
1723 | variables are used to specify @dfn{search paths} for files used by some | |
1724 | of the installed packages. | |
1725 | ||
1726 | For example, GCC needs the @code{CPATH} and @code{LIBRARY_PATH} | |
1727 | environment variables to be defined so it can look for headers and | |
1728 | libraries in the user's profile (@pxref{Environment Variables,,, gcc, | |
1729 | Using the GNU Compiler Collection (GCC)}). If GCC and, say, the C | |
1730 | library are installed in the profile, then @code{--search-paths} will | |
1731 | suggest setting these variables to @code{@var{profile}/include} and | |
1732 | @code{@var{profile}/lib}, respectively. | |
1733 | ||
dbc31ab2 LC |
1734 | The typical use case is to define these environment variables in the |
1735 | shell: | |
1736 | ||
1737 | @example | |
1738 | $ eval `guix package --search-paths` | |
1739 | @end example | |
1740 | ||
1741 | @var{kind} may be one of @code{exact}, @code{prefix}, or @code{suffix}, | |
1742 | meaning that the returned environment variable definitions will either | |
1743 | be exact settings, or prefixes or suffixes of the current value of these | |
1744 | variables. When omitted, @var{kind} defaults to @code{exact}. | |
1745 | ||
fc2d2339 LC |
1746 | This option can also be used to compute the @emph{combined} search paths |
1747 | of several profiles. Consider this example: | |
1748 | ||
1749 | @example | |
1750 | $ guix package -p foo -i guile | |
1751 | $ guix package -p bar -i guile-json | |
1752 | $ guix package -p foo -p bar --search-paths | |
1753 | @end example | |
1754 | ||
1755 | The last command above reports about the @code{GUILE_LOAD_PATH} | |
1756 | variable, even though, taken individually, neither @file{foo} nor | |
1757 | @file{bar} would lead to that recommendation. | |
1758 | ||
1759 | ||
eeaf4427 LC |
1760 | @item --profile=@var{profile} |
1761 | @itemx -p @var{profile} | |
1762 | Use @var{profile} instead of the user's default profile. | |
1763 | ||
70915c1a | 1764 | @item --verbose |
f97c9175 AE |
1765 | Produce verbose output. In particular, emit the build log of the |
1766 | environment on the standard error port. | |
70915c1a | 1767 | |
eeaf4427 LC |
1768 | @item --bootstrap |
1769 | Use the bootstrap Guile to build the profile. This option is only | |
1770 | useful to distribution developers. | |
1771 | ||
1772 | @end table | |
1773 | ||
f97c9175 | 1774 | In addition to these actions, @command{guix package} supports the |
733b4130 LC |
1775 | following options to query the current state of a profile, or the |
1776 | availability of packages: | |
eeaf4427 | 1777 | |
733b4130 LC |
1778 | @table @option |
1779 | ||
acc08466 NK |
1780 | @item --search=@var{regexp} |
1781 | @itemx -s @var{regexp} | |
b110869d | 1782 | @cindex searching for packages |
5763ad92 | 1783 | List the available packages whose name, synopsis, or description matches |
f97c9175 | 1784 | @var{regexp}. Print all the metadata of matching packages in |
299112d3 LC |
1785 | @code{recutils} format (@pxref{Top, GNU recutils databases,, recutils, |
1786 | GNU recutils manual}). | |
acc08466 | 1787 | |
299112d3 LC |
1788 | This allows specific fields to be extracted using the @command{recsel} |
1789 | command, for instance: | |
1790 | ||
1791 | @example | |
e49951eb | 1792 | $ guix package -s malloc | recsel -p name,version |
299112d3 LC |
1793 | name: glibc |
1794 | version: 2.17 | |
1795 | ||
1796 | name: libgc | |
1797 | version: 7.2alpha6 | |
1798 | @end example | |
acc08466 | 1799 | |
a12d92f5 LC |
1800 | Similarly, to show the name of all the packages available under the |
1801 | terms of the GNU@tie{}LGPL version 3: | |
1802 | ||
1803 | @example | |
1804 | $ guix package -s "" | recsel -p name -e 'license ~ "LGPL 3"' | |
1805 | name: elfutils | |
1806 | ||
1807 | name: gmp | |
1808 | @dots{} | |
1809 | @end example | |
1810 | ||
db5a9444 LC |
1811 | It is also possible to refine search results using several @code{-s} |
1812 | flags. For example, the following command returns a list of board | |
1813 | games: | |
1814 | ||
1815 | @example | |
1816 | $ guix package -s '\<board\>' -s game | recsel -p name | |
1817 | name: gnubg | |
1818 | @dots{} | |
1819 | @end example | |
1820 | ||
1821 | If we were to omit @code{-s game}, we would also get software packages | |
1822 | that deal with printed circuit boards; removing the angle brackets | |
1823 | around @code{board} would further add packages that have to do with | |
1824 | keyboards. | |
1825 | ||
b110869d LC |
1826 | And now for a more elaborate example. The following command searches |
1827 | for cryptographic libraries, filters out Haskell, Perl, Python, and Ruby | |
1828 | libraries, and prints the name and synopsis of the matching packages: | |
1829 | ||
1830 | @example | |
1831 | $ guix package -s crypto -s library | \ | |
1832 | recsel -e '! (name ~ "^(ghc|perl|python|ruby)")' -p name,synopsis | |
1833 | @end example | |
1834 | ||
1835 | @noindent | |
1836 | @xref{Selection Expressions,,, recutils, GNU recutils manual}, for more | |
1837 | information on @dfn{selection expressions} for @code{recsel -e}. | |
1838 | ||
2aa6efb0 CR |
1839 | @item --show=@var{package} |
1840 | Show details about @var{package}, taken from the list of available packages, in | |
1841 | @code{recutils} format (@pxref{Top, GNU recutils databases,, recutils, GNU | |
1842 | recutils manual}). | |
1843 | ||
1844 | @example | |
1845 | $ guix package --show=python | recsel -p name,version | |
1846 | name: python | |
1847 | version: 2.7.6 | |
1848 | ||
1849 | name: python | |
1850 | version: 3.3.5 | |
1851 | @end example | |
1852 | ||
1853 | You may also specify the full name of a package to only get details about a | |
1854 | specific version of it: | |
1855 | @example | |
ea206df4 | 1856 | $ guix package --show=python@@3.4 | recsel -p name,version |
2aa6efb0 | 1857 | name: python |
ea206df4 | 1858 | version: 3.4.3 |
2aa6efb0 CR |
1859 | @end example |
1860 | ||
1861 | ||
1862 | ||
733b4130 LC |
1863 | @item --list-installed[=@var{regexp}] |
1864 | @itemx -I [@var{regexp}] | |
bd9bde1c LC |
1865 | List the currently installed packages in the specified profile, with the |
1866 | most recently installed packages shown last. When @var{regexp} is | |
1867 | specified, list only installed packages whose name matches @var{regexp}. | |
733b4130 LC |
1868 | |
1869 | For each installed package, print the following items, separated by | |
1870 | tabs: the package name, its version string, the part of the package that | |
1871 | is installed (for instance, @code{out} for the default output, | |
1872 | @code{include} for its headers, etc.), and the path of this package in | |
1873 | the store. | |
1874 | ||
64fc89b6 LC |
1875 | @item --list-available[=@var{regexp}] |
1876 | @itemx -A [@var{regexp}] | |
5763ad92 | 1877 | List packages currently available in the distribution for this system |
a1ba8475 LC |
1878 | (@pxref{GNU Distribution}). When @var{regexp} is specified, list only |
1879 | installed packages whose name matches @var{regexp}. | |
64fc89b6 LC |
1880 | |
1881 | For each package, print the following items separated by tabs: its name, | |
6e721c4d LC |
1882 | its version string, the parts of the package (@pxref{Packages with |
1883 | Multiple Outputs}), and the source location of its definition. | |
64fc89b6 | 1884 | |
f566d765 LC |
1885 | @item --list-generations[=@var{pattern}] |
1886 | @itemx -l [@var{pattern}] | |
e32171ee | 1887 | @cindex generations |
f566d765 LC |
1888 | Return a list of generations along with their creation dates; for each |
1889 | generation, show the installed packages, with the most recently | |
4b2bc804 NK |
1890 | installed packages shown last. Note that the zeroth generation is never |
1891 | shown. | |
f566d765 LC |
1892 | |
1893 | For each installed package, print the following items, separated by | |
1894 | tabs: the name of a package, its version string, the part of the package | |
1895 | that is installed (@pxref{Packages with Multiple Outputs}), and the | |
1896 | location of this package in the store. | |
1897 | ||
1898 | When @var{pattern} is used, the command returns only matching | |
1899 | generations. Valid patterns include: | |
1900 | ||
1901 | @itemize | |
1902 | @item @emph{Integers and comma-separated integers}. Both patterns denote | |
1903 | generation numbers. For instance, @code{--list-generations=1} returns | |
1904 | the first one. | |
1905 | ||
1906 | And @code{--list-generations=1,8,2} outputs three generations in the | |
1907 | specified order. Neither spaces nor trailing commas are allowed. | |
1908 | ||
1909 | @item @emph{Ranges}. @code{--list-generations=2..9} prints the | |
1910 | specified generations and everything in between. Note that the start of | |
f97c9175 | 1911 | a range must be smaller than its end. |
f566d765 LC |
1912 | |
1913 | It is also possible to omit the endpoint. For example, | |
1914 | @code{--list-generations=2..}, returns all generations starting from the | |
1915 | second one. | |
1916 | ||
1917 | @item @emph{Durations}. You can also get the last @emph{N}@tie{}days, weeks, | |
1918 | or months by passing an integer along with the first letter of the | |
d7ddb257 LC |
1919 | duration. For example, @code{--list-generations=20d} lists generations |
1920 | that are up to 20 days old. | |
f566d765 LC |
1921 | @end itemize |
1922 | ||
b7884ca3 NK |
1923 | @item --delete-generations[=@var{pattern}] |
1924 | @itemx -d [@var{pattern}] | |
d7ddb257 LC |
1925 | When @var{pattern} is omitted, delete all generations except the current |
1926 | one. | |
b7884ca3 NK |
1927 | |
1928 | This command accepts the same patterns as @option{--list-generations}. | |
d7ddb257 LC |
1929 | When @var{pattern} is specified, delete the matching generations. When |
1930 | @var{pattern} specifies a duration, generations @emph{older} than the | |
1931 | specified duration match. For instance, @code{--delete-generations=1m} | |
1932 | deletes generations that are more than one month old. | |
1933 | ||
391bdd8f LC |
1934 | If the current generation matches, it is @emph{not} deleted. Also, the |
1935 | zeroth generation is never deleted. | |
b7884ca3 | 1936 | |
f97c9175 | 1937 | Note that deleting generations prevents rolling back to them. |
1bb9900a LC |
1938 | Consequently, this command must be used with care. |
1939 | ||
733b4130 | 1940 | @end table |
eeaf4427 | 1941 | |
70ee5642 | 1942 | Finally, since @command{guix package} may actually start build |
ccd7158d | 1943 | processes, it supports all the common build options (@pxref{Common Build |
f97c9175 | 1944 | Options}). It also supports package transformation options, such as |
b8638f03 LC |
1945 | @option{--with-source} (@pxref{Package Transformation Options}). |
1946 | However, note that package transformations are lost when upgrading; to | |
f97c9175 | 1947 | preserve transformations across upgrades, you should define your own |
b8638f03 LC |
1948 | package variant in a Guile module and add it to @code{GUIX_PACKAGE_PATH} |
1949 | (@pxref{Defining Packages}). | |
1950 | ||
70ee5642 | 1951 | |
c4202d60 LC |
1952 | @node Substitutes |
1953 | @section Substitutes | |
1954 | ||
1955 | @cindex substitutes | |
1956 | @cindex pre-built binaries | |
1957 | Guix supports transparent source/binary deployment, which means that it | |
1958 | can either build things locally, or download pre-built items from a | |
1959 | server. We call these pre-built items @dfn{substitutes}---they are | |
1960 | substitutes for local build results. In many cases, downloading a | |
1961 | substitute is much faster than building things locally. | |
1962 | ||
1963 | Substitutes can be anything resulting from a derivation build | |
1964 | (@pxref{Derivations}). Of course, in the common case, they are | |
1965 | pre-built package binaries, but source tarballs, for instance, which | |
1966 | also result from derivation builds, can be available as substitutes. | |
1967 | ||
1968 | The @code{hydra.gnu.org} server is a front-end to a build farm that | |
1969 | builds packages from the GNU distribution continuously for some | |
deb6276d | 1970 | architectures, and makes them available as substitutes. This is the |
f8a8e0fe LC |
1971 | default source of substitutes; it can be overridden by passing the |
1972 | @option{--substitute-urls} option either to @command{guix-daemon} | |
1973 | (@pxref{daemon-substitute-urls,, @code{guix-daemon --substitute-urls}}) | |
1974 | or to client tools such as @command{guix package} | |
1975 | (@pxref{client-substitute-urls,, client @option{--substitute-urls} | |
1976 | option}). | |
c4202d60 | 1977 | |
9b7bd1b1 LC |
1978 | Substitute URLs can be either HTTP or HTTPS@footnote{For HTTPS access, |
1979 | the Guile bindings of GnuTLS must be installed. @xref{Requirements}.} | |
1980 | HTTPS is recommended because communications are encrypted; conversely, | |
1981 | using HTTP makes all communications visible to an eavesdropper, who | |
1982 | could use the information gathered to determine, for instance, whether | |
1983 | your system has unpatched security vulnerabilities. | |
1984 | ||
c4202d60 LC |
1985 | @cindex security |
1986 | @cindex digital signatures | |
e32171ee | 1987 | @cindex substitutes, authorization thereof |
df061d07 LC |
1988 | To allow Guix to download substitutes from @code{hydra.gnu.org} or a |
1989 | mirror thereof, you | |
c4202d60 LC |
1990 | must add its public key to the access control list (ACL) of archive |
1991 | imports, using the @command{guix archive} command (@pxref{Invoking guix | |
1992 | archive}). Doing so implies that you trust @code{hydra.gnu.org} to not | |
1993 | be compromised and to serve genuine substitutes. | |
1994 | ||
1995 | This public key is installed along with Guix, in | |
1996 | @code{@var{prefix}/share/guix/hydra.gnu.org.pub}, where @var{prefix} is | |
1997 | the installation prefix of Guix. If you installed Guix from source, | |
1998 | make sure you checked the GPG signature of | |
1999 | @file{guix-@value{VERSION}.tar.gz}, which contains this public key file. | |
2000 | Then, you can run something like this: | |
2001 | ||
2002 | @example | |
2003 | # guix archive --authorize < hydra.gnu.org.pub | |
2004 | @end example | |
2005 | ||
2006 | Once this is in place, the output of a command like @code{guix build} | |
2007 | should change from something like: | |
2008 | ||
2009 | @example | |
2010 | $ guix build emacs --dry-run | |
2011 | The following derivations would be built: | |
2012 | /gnu/store/yr7bnx8xwcayd6j95r2clmkdl1qh688w-emacs-24.3.drv | |
2013 | /gnu/store/x8qsh1hlhgjx6cwsjyvybnfv2i37z23w-dbus-1.6.4.tar.gz.drv | |
2014 | /gnu/store/1ixwp12fl950d15h2cj11c73733jay0z-alsa-lib-1.0.27.1.tar.bz2.drv | |
2015 | /gnu/store/nlma1pw0p603fpfiqy7kn4zm105r5dmw-util-linux-2.21.drv | |
2016 | @dots{} | |
2017 | @end example | |
2018 | ||
2019 | @noindent | |
2020 | to something like: | |
2021 | ||
2022 | @example | |
2023 | $ guix build emacs --dry-run | |
2024 | The following files would be downloaded: | |
2025 | /gnu/store/pk3n22lbq6ydamyymqkkz7i69wiwjiwi-emacs-24.3 | |
2026 | /gnu/store/2ygn4ncnhrpr61rssa6z0d9x22si0va3-libjpeg-8d | |
2027 | /gnu/store/71yz6lgx4dazma9dwn2mcjxaah9w77jq-cairo-1.12.16 | |
2028 | /gnu/store/7zdhgp0n1518lvfn8mb96sxqfmvqrl7v-libxrender-0.9.7 | |
2029 | @dots{} | |
2030 | @end example | |
2031 | ||
2032 | @noindent | |
2033 | This indicates that substitutes from @code{hydra.gnu.org} are usable and | |
2034 | will be downloaded, when possible, for future builds. | |
2035 | ||
2036 | Guix ignores substitutes that are not signed, or that are not signed by | |
ef27aa9c | 2037 | one of the keys listed in the ACL. It also detects and raises an error |
c4202d60 LC |
2038 | when attempting to use a substitute that has been tampered with. |
2039 | ||
e0c941fe | 2040 | @vindex http_proxy |
9b7bd1b1 LC |
2041 | Substitutes are downloaded over HTTP or HTTPS. |
2042 | The @code{http_proxy} environment | |
e0c941fe LC |
2043 | variable can be set in the environment of @command{guix-daemon} and is |
2044 | honored for downloads of substitutes. Note that the value of | |
2045 | @code{http_proxy} in the environment where @command{guix build}, | |
2046 | @command{guix package}, and other client commands are run has | |
2047 | @emph{absolutely no effect}. | |
2048 | ||
9b7bd1b1 LC |
2049 | When using HTTPS, the server's X.509 certificate is @emph{not} validated |
2050 | (in other words, the server is not authenticated), contrary to what | |
2051 | HTTPS clients such as Web browsers usually do. This is because Guix | |
2052 | authenticates substitute information itself, as explained above, which | |
2053 | is what we care about (whereas X.509 certificates are about | |
2054 | authenticating bindings between domain names and public keys.) | |
2055 | ||
c4202d60 LC |
2056 | The substitute mechanism can be disabled globally by running |
2057 | @code{guix-daemon} with @code{--no-substitutes} (@pxref{Invoking | |
2058 | guix-daemon}). It can also be disabled temporarily by passing the | |
2059 | @code{--no-substitutes} option to @command{guix package}, @command{guix | |
2060 | build}, and other command-line tools. | |
2061 | ||
2062 | ||
9b7bd1b1 LC |
2063 | @unnumberedsubsec On Trusting Binaries |
2064 | ||
c4202d60 LC |
2065 | Today, each individual's control over their own computing is at the |
2066 | mercy of institutions, corporations, and groups with enough power and | |
2067 | determination to subvert the computing infrastructure and exploit its | |
2068 | weaknesses. While using @code{hydra.gnu.org} substitutes can be | |
2069 | convenient, we encourage users to also build on their own, or even run | |
2070 | their own build farm, such that @code{hydra.gnu.org} is less of an | |
8ce229fc LC |
2071 | interesting target. One way to help is by publishing the software you |
2072 | build using @command{guix publish} so that others have one more choice | |
2073 | of server to download substitutes from (@pxref{Invoking guix publish}). | |
c4202d60 LC |
2074 | |
2075 | Guix has the foundations to maximize build reproducibility | |
2076 | (@pxref{Features}). In most cases, independent builds of a given | |
2077 | package or derivation should yield bit-identical results. Thus, through | |
2078 | a diverse set of independent package builds, we can strengthen the | |
d23c20f1 LC |
2079 | integrity of our systems. The @command{guix challenge} command aims to |
2080 | help users assess substitute servers, and to assist developers in | |
2081 | finding out about non-deterministic package builds (@pxref{Invoking guix | |
a8d65643 LC |
2082 | challenge}). Similarly, the @option{--check} option of @command{guix |
2083 | build} allows users to check whether previously-installed substitutes | |
2084 | are genuine by rebuilding them locally (@pxref{build-check, | |
2085 | @command{guix build --check}}). | |
c4202d60 LC |
2086 | |
2087 | In the future, we want Guix to have support to publish and retrieve | |
2088 | binaries to/from other users, in a peer-to-peer fashion. If you would | |
2089 | like to discuss this project, join us on @email{guix-devel@@gnu.org}. | |
2090 | ||
2091 | ||
6e721c4d LC |
2092 | @node Packages with Multiple Outputs |
2093 | @section Packages with Multiple Outputs | |
2094 | ||
2095 | @cindex multiple-output packages | |
2096 | @cindex package outputs | |
e32171ee | 2097 | @cindex outputs |
6e721c4d LC |
2098 | |
2099 | Often, packages defined in Guix have a single @dfn{output}---i.e., the | |
f97c9175 | 2100 | source package leads to exactly one directory in the store. When running |
6e721c4d LC |
2101 | @command{guix package -i glibc}, one installs the default output of the |
2102 | GNU libc package; the default output is called @code{out}, but its name | |
2103 | can be omitted as shown in this command. In this particular case, the | |
2104 | default output of @code{glibc} contains all the C header files, shared | |
2105 | libraries, static libraries, Info documentation, and other supporting | |
2106 | files. | |
2107 | ||
2108 | Sometimes it is more appropriate to separate the various types of files | |
2109 | produced from a single source package into separate outputs. For | |
2110 | instance, the GLib C library (used by GTK+ and related packages) | |
2111 | installs more than 20 MiB of reference documentation as HTML pages. | |
2112 | To save space for users who do not need it, the documentation goes to a | |
2113 | separate output, called @code{doc}. To install the main GLib output, | |
2114 | which contains everything but the documentation, one would run: | |
2115 | ||
2116 | @example | |
2117 | guix package -i glib | |
2118 | @end example | |
2119 | ||
e32171ee | 2120 | @cindex documentation |
6e721c4d LC |
2121 | The command to install its documentation is: |
2122 | ||
2123 | @example | |
2124 | guix package -i glib:doc | |
2125 | @end example | |
2126 | ||
2127 | Some packages install programs with different ``dependency footprints''. | |
f97c9175 | 2128 | For instance, the WordNet package installs both command-line tools and |
6e721c4d LC |
2129 | graphical user interfaces (GUIs). The former depend solely on the C |
2130 | library, whereas the latter depend on Tcl/Tk and the underlying X | |
2131 | libraries. In this case, we leave the command-line tools in the default | |
2132 | output, whereas the GUIs are in a separate output. This allows users | |
fcc58db6 LC |
2133 | who do not need the GUIs to save space. The @command{guix size} command |
2134 | can help find out about such situations (@pxref{Invoking guix size}). | |
88856916 | 2135 | @command{guix graph} can also be helpful (@pxref{Invoking guix graph}). |
6e721c4d LC |
2136 | |
2137 | There are several such multiple-output packages in the GNU distribution. | |
91ef73d4 LC |
2138 | Other conventional output names include @code{lib} for libraries and |
2139 | possibly header files, @code{bin} for stand-alone programs, and | |
2140 | @code{debug} for debugging information (@pxref{Installing Debugging | |
2141 | Files}). The outputs of a packages are listed in the third column of | |
2142 | the output of @command{guix package --list-available} (@pxref{Invoking | |
2143 | guix package}). | |
6e721c4d | 2144 | |
eeaf4427 | 2145 | |
e49951eb MW |
2146 | @node Invoking guix gc |
2147 | @section Invoking @command{guix gc} | |
fe8ff028 LC |
2148 | |
2149 | @cindex garbage collector | |
e32171ee | 2150 | @cindex disk space |
f97c9175 | 2151 | Packages that are installed, but not used, may be @dfn{garbage-collected}. |
e49951eb | 2152 | The @command{guix gc} command allows users to explicitly run the garbage |
c22eb992 LC |
2153 | collector to reclaim space from the @file{/gnu/store} directory. It is |
2154 | the @emph{only} way to remove files from @file{/gnu/store}---removing | |
2155 | files or directories manually may break it beyond repair! | |
fe8ff028 LC |
2156 | |
2157 | The garbage collector has a set of known @dfn{roots}: any file under | |
834129e0 | 2158 | @file{/gnu/store} reachable from a root is considered @dfn{live} and |
fe8ff028 LC |
2159 | cannot be deleted; any other file is considered @dfn{dead} and may be |
2160 | deleted. The set of garbage collector roots includes default user | |
e49951eb MW |
2161 | profiles, and may be augmented with @command{guix build --root}, for |
2162 | example (@pxref{Invoking guix build}). | |
fe8ff028 | 2163 | |
1bb9900a LC |
2164 | Prior to running @code{guix gc --collect-garbage} to make space, it is |
2165 | often useful to remove old generations from user profiles; that way, old | |
2166 | package builds referenced by those generations can be reclaimed. This | |
2167 | is achieved by running @code{guix package --delete-generations} | |
2168 | (@pxref{Invoking guix package}). | |
2169 | ||
e49951eb | 2170 | The @command{guix gc} command has three modes of operation: it can be |
fe8ff028 | 2171 | used to garbage-collect any dead files (the default), to delete specific |
7770aafc LC |
2172 | files (the @code{--delete} option), to print garbage-collector |
2173 | information, or for more advanced queries. The garbage collection | |
2174 | options are as follows: | |
fe8ff028 LC |
2175 | |
2176 | @table @code | |
2177 | @item --collect-garbage[=@var{min}] | |
2178 | @itemx -C [@var{min}] | |
834129e0 | 2179 | Collect garbage---i.e., unreachable @file{/gnu/store} files and |
fe8ff028 LC |
2180 | sub-directories. This is the default operation when no option is |
2181 | specified. | |
2182 | ||
2183 | When @var{min} is given, stop once @var{min} bytes have been collected. | |
2184 | @var{min} may be a number of bytes, or it may include a unit as a | |
4a44d7bb LC |
2185 | suffix, such as @code{MiB} for mebibytes and @code{GB} for gigabytes |
2186 | (@pxref{Block size, size specifications,, coreutils, GNU Coreutils}). | |
fe8ff028 LC |
2187 | |
2188 | When @var{min} is omitted, collect all the garbage. | |
2189 | ||
0054e470 LC |
2190 | @item --free-space=@var{free} |
2191 | @itemx -F @var{free} | |
2192 | Collect garbage until @var{free} space is available under | |
2193 | @file{/gnu/store}, if possible; @var{free} denotes storage space, such | |
2194 | as @code{500MiB}, as described above. | |
2195 | ||
2196 | When @var{free} or more is already available in @file{/gnu/store}, do | |
2197 | nothing and exit immediately. | |
2198 | ||
fe8ff028 LC |
2199 | @item --delete |
2200 | @itemx -d | |
2201 | Attempt to delete all the store files and directories specified as | |
2202 | arguments. This fails if some of the files are not in the store, or if | |
2203 | they are still live. | |
2204 | ||
30d9aa54 LC |
2205 | @item --list-failures |
2206 | List store items corresponding to cached build failures. | |
2207 | ||
2208 | This prints nothing unless the daemon was started with | |
2209 | @option{--cache-failures} (@pxref{Invoking guix-daemon, | |
2210 | @option{--cache-failures}}). | |
2211 | ||
2212 | @item --clear-failures | |
2213 | Remove the specified store items from the failed-build cache. | |
2214 | ||
2215 | Again, this option only makes sense when the daemon is started with | |
2216 | @option{--cache-failures}. Otherwise, it does nothing. | |
2217 | ||
fe8ff028 LC |
2218 | @item --list-dead |
2219 | Show the list of dead files and directories still present in the | |
2220 | store---i.e., files and directories no longer reachable from any root. | |
2221 | ||
2222 | @item --list-live | |
2223 | Show the list of live store files and directories. | |
ba8b732d LC |
2224 | |
2225 | @end table | |
2226 | ||
2227 | In addition, the references among existing store files can be queried: | |
2228 | ||
2229 | @table @code | |
2230 | ||
2231 | @item --references | |
2232 | @itemx --referrers | |
e32171ee | 2233 | @cindex package dependencies |
ba8b732d LC |
2234 | List the references (respectively, the referrers) of store files given |
2235 | as arguments. | |
2236 | ||
8e59fdd5 LC |
2237 | @item --requisites |
2238 | @itemx -R | |
fcc58db6 | 2239 | @cindex closure |
8e59fdd5 LC |
2240 | List the requisites of the store files passed as arguments. Requisites |
2241 | include the store files themselves, their references, and the references | |
2242 | of these, recursively. In other words, the returned list is the | |
2243 | @dfn{transitive closure} of the store files. | |
2244 | ||
f97c9175 AE |
2245 | @xref{Invoking guix size}, for a tool to profile the size of the closure |
2246 | of an element. @xref{Invoking guix graph}, for a tool to visualize | |
88856916 | 2247 | the graph of references. |
fcc58db6 | 2248 | |
fe8ff028 LC |
2249 | @end table |
2250 | ||
7770aafc LC |
2251 | Lastly, the following options allow you to check the integrity of the |
2252 | store and to control disk usage. | |
2253 | ||
2254 | @table @option | |
2255 | ||
2256 | @item --verify[=@var{options}] | |
2257 | @cindex integrity, of the store | |
2258 | @cindex integrity checking | |
2259 | Verify the integrity of the store. | |
2260 | ||
2261 | By default, make sure that all the store items marked as valid in the | |
f97c9175 | 2262 | database of the daemon actually exist in @file{/gnu/store}. |
7770aafc | 2263 | |
f97c9175 | 2264 | When provided, @var{options} must be a comma-separated list containing one |
7770aafc LC |
2265 | or more of @code{contents} and @code{repair}. |
2266 | ||
7414de0a | 2267 | When passing @option{--verify=contents}, the daemon computes the |
f97c9175 | 2268 | content hash of each store item and compares it against its hash in the |
7770aafc LC |
2269 | database. Hash mismatches are reported as data corruptions. Because it |
2270 | traverses @emph{all the files in the store}, this command can take a | |
2271 | long time, especially on systems with a slow disk drive. | |
2272 | ||
2273 | @cindex repairing the store | |
2274 | Using @option{--verify=repair} or @option{--verify=contents,repair} | |
2275 | causes the daemon to try to repair corrupt store items by fetching | |
2276 | substitutes for them (@pxref{Substitutes}). Because repairing is not | |
2277 | atomic, and thus potentially dangerous, it is available only to the | |
2278 | system administrator. | |
2279 | ||
2280 | @item --optimize | |
2281 | @cindex deduplication | |
2282 | Optimize the store by hard-linking identical files---this is | |
2283 | @dfn{deduplication}. | |
2284 | ||
2285 | The daemon performs deduplication after each successful build or archive | |
2286 | import, unless it was started with @code{--disable-deduplication} | |
2287 | (@pxref{Invoking guix-daemon, @code{--disable-deduplication}}). Thus, | |
2288 | this option is primarily useful when the daemon was running with | |
2289 | @code{--disable-deduplication}. | |
2290 | ||
2291 | @end table | |
eeaf4427 | 2292 | |
f651b477 LC |
2293 | @node Invoking guix pull |
2294 | @section Invoking @command{guix pull} | |
2295 | ||
e32171ee | 2296 | @cindex upgrading Guix |
7fcf2a0b | 2297 | @cindex updating Guix |
e32171ee JD |
2298 | @cindex @command{guix pull} |
2299 | @cindex pull | |
f651b477 LC |
2300 | Packages are installed or upgraded to the latest version available in |
2301 | the distribution currently available on your local machine. To update | |
2302 | that distribution, along with the Guix tools, you must run @command{guix | |
2303 | pull}: the command downloads the latest Guix source code and package | |
2304 | descriptions, and deploys it. | |
2305 | ||
2306 | On completion, @command{guix package} will use packages and package | |
2307 | versions from this just-retrieved copy of Guix. Not only that, but all | |
2308 | the Guix commands and Scheme modules will also be taken from that latest | |
2309 | version. New @command{guix} sub-commands added by the update also | |
cb05108a LC |
2310 | become available. |
2311 | ||
2312 | Any user can update their Guix copy using @command{guix pull}, and the | |
2313 | effect is limited to the user who run @command{guix pull}. For | |
2314 | instance, when user @code{root} runs @command{guix pull}, this has no | |
2315 | effect on the version of Guix that user @code{alice} sees, and vice | |
2316 | versa@footnote{Under the hood, @command{guix pull} updates the | |
2317 | @file{~/.config/guix/latest} symbolic link to point to the latest Guix, | |
2318 | and the @command{guix} command loads code from there.}. | |
f651b477 LC |
2319 | |
2320 | The @command{guix pull} command is usually invoked with no arguments, | |
2321 | but it supports the following options: | |
2322 | ||
2323 | @table @code | |
2324 | @item --verbose | |
2325 | Produce verbose output, writing build logs to the standard error output. | |
2326 | ||
ab5d72ad LC |
2327 | @item --url=@var{url} |
2328 | Download the source tarball of Guix from @var{url}. | |
2329 | ||
2330 | By default, the tarball is taken from its canonical address at | |
2331 | @code{gnu.org}, for the stable branch of Guix. | |
2332 | ||
f651b477 LC |
2333 | @item --bootstrap |
2334 | Use the bootstrap Guile to build the latest Guix. This option is only | |
2335 | useful to Guix developers. | |
2336 | @end table | |
2337 | ||
760c60d6 LC |
2338 | |
2339 | @node Invoking guix archive | |
2340 | @section Invoking @command{guix archive} | |
2341 | ||
e32171ee JD |
2342 | @cindex @command{guix archive} |
2343 | @cindex archive | |
760c60d6 LC |
2344 | The @command{guix archive} command allows users to @dfn{export} files |
2345 | from the store into a single archive, and to later @dfn{import} them. | |
2346 | In particular, it allows store files to be transferred from one machine | |
4d4c4816 AE |
2347 | to the store on another machine. |
2348 | ||
e32171ee | 2349 | @cindex exporting store items |
4d4c4816 AE |
2350 | To export store files as an archive to standard output, run: |
2351 | ||
2352 | @example | |
2353 | guix archive --export @var{options} @var{specifications}... | |
2354 | @end example | |
2355 | ||
2356 | @var{specifications} may be either store file names or package | |
2357 | specifications, as for @command{guix package} (@pxref{Invoking guix | |
2358 | package}). For instance, the following command creates an archive | |
2359 | containing the @code{gui} output of the @code{git} package and the main | |
2360 | output of @code{emacs}: | |
2361 | ||
2362 | @example | |
2363 | guix archive --export git:gui /gnu/store/...-emacs-24.3 > great.nar | |
2364 | @end example | |
2365 | ||
2366 | If the specified packages are not built yet, @command{guix archive} | |
2367 | automatically builds them. The build process may be controlled with the | |
2368 | common build options (@pxref{Common Build Options}). | |
2369 | ||
2370 | To transfer the @code{emacs} package to a machine connected over SSH, | |
2371 | one would run: | |
760c60d6 LC |
2372 | |
2373 | @example | |
56607088 | 2374 | guix archive --export -r emacs | ssh the-machine guix archive --import |
760c60d6 LC |
2375 | @end example |
2376 | ||
87236aed | 2377 | @noindent |
56607088 LC |
2378 | Similarly, a complete user profile may be transferred from one machine |
2379 | to another like this: | |
2380 | ||
2381 | @example | |
2382 | guix archive --export -r $(readlink -f ~/.guix-profile) | \ | |
2383 | ssh the-machine guix-archive --import | |
2384 | @end example | |
2385 | ||
2386 | @noindent | |
2387 | However, note that, in both examples, all of @code{emacs} and the | |
2388 | profile as well as all of their dependencies are transferred (due to | |
f97c9175 AE |
2389 | @code{-r}), regardless of what is already available in the store on the |
2390 | target machine. The @code{--missing} option can help figure out which | |
f11c444d LC |
2391 | items are missing from the target store. The @command{guix copy} |
2392 | command simplifies and optimizes this whole process, so this is probably | |
2393 | what you should use in this case (@pxref{Invoking guix copy}). | |
87236aed | 2394 | |
5597b3ae LC |
2395 | @cindex nar, archive format |
2396 | @cindex normalized archive (nar) | |
2397 | Archives are stored in the ``normalized archive'' or ``nar'' format, which is | |
2398 | comparable in spirit to `tar', but with differences | |
0dbd88db | 2399 | that make it more appropriate for our purposes. First, rather than |
5597b3ae | 2400 | recording all Unix metadata for each file, the nar format only mentions |
0dbd88db LC |
2401 | the file type (regular, directory, or symbolic link); Unix permissions |
2402 | and owner/group are dismissed. Second, the order in which directory | |
2403 | entries are stored always follows the order of file names according to | |
2404 | the C locale collation order. This makes archive production fully | |
2405 | deterministic. | |
2406 | ||
2407 | When exporting, the daemon digitally signs the contents of the archive, | |
2408 | and that digital signature is appended. When importing, the daemon | |
2409 | verifies the signature and rejects the import in case of an invalid | |
2410 | signature or if the signing key is not authorized. | |
760c60d6 LC |
2411 | @c FIXME: Add xref to daemon doc about signatures. |
2412 | ||
2413 | The main options are: | |
2414 | ||
2415 | @table @code | |
2416 | @item --export | |
2417 | Export the specified store files or packages (see below.) Write the | |
2418 | resulting archive to the standard output. | |
2419 | ||
56607088 LC |
2420 | Dependencies are @emph{not} included in the output, unless |
2421 | @code{--recursive} is passed. | |
2422 | ||
2423 | @item -r | |
2424 | @itemx --recursive | |
2425 | When combined with @code{--export}, this instructs @command{guix | |
2426 | archive} to include dependencies of the given items in the archive. | |
2427 | Thus, the resulting archive is self-contained: it contains the closure | |
2428 | of the exported store items. | |
2429 | ||
760c60d6 LC |
2430 | @item --import |
2431 | Read an archive from the standard input, and import the files listed | |
2432 | therein into the store. Abort if the archive has an invalid digital | |
f82cc5fd LC |
2433 | signature, or if it is signed by a public key not among the authorized |
2434 | keys (see @code{--authorize} below.) | |
554f26ec | 2435 | |
87236aed LC |
2436 | @item --missing |
2437 | Read a list of store file names from the standard input, one per line, | |
2438 | and write on the standard output the subset of these files missing from | |
2439 | the store. | |
2440 | ||
554f26ec | 2441 | @item --generate-key[=@var{parameters}] |
f82cc5fd | 2442 | @cindex signing, archives |
f97c9175 | 2443 | Generate a new key pair for the daemon. This is a prerequisite before |
554f26ec LC |
2444 | archives can be exported with @code{--export}. Note that this operation |
2445 | usually takes time, because it needs to gather enough entropy to | |
2446 | generate the key pair. | |
2447 | ||
2448 | The generated key pair is typically stored under @file{/etc/guix}, in | |
2449 | @file{signing-key.pub} (public key) and @file{signing-key.sec} (private | |
867d8473 LC |
2450 | key, which must be kept secret.) When @var{parameters} is omitted, |
2451 | an ECDSA key using the Ed25519 curve is generated, or, for Libgcrypt | |
2452 | versions before 1.6.0, it is a 4096-bit RSA key. | |
f97c9175 | 2453 | Alternatively, @var{parameters} can specify |
554f26ec LC |
2454 | @code{genkey} parameters suitable for Libgcrypt (@pxref{General |
2455 | public-key related Functions, @code{gcry_pk_genkey},, gcrypt, The | |
2456 | Libgcrypt Reference Manual}). | |
f82cc5fd LC |
2457 | |
2458 | @item --authorize | |
2459 | @cindex authorizing, archives | |
2460 | Authorize imports signed by the public key passed on standard input. | |
2461 | The public key must be in ``s-expression advanced format''---i.e., the | |
2462 | same format as the @file{signing-key.pub} file. | |
2463 | ||
2464 | The list of authorized keys is kept in the human-editable file | |
2465 | @file{/etc/guix/acl}. The file contains | |
2466 | @url{http://people.csail.mit.edu/rivest/Sexp.txt, ``advanced-format | |
2467 | s-expressions''} and is structured as an access-control list in the | |
2468 | @url{http://theworld.com/~cme/spki.txt, Simple Public-Key Infrastructure | |
2469 | (SPKI)}. | |
c6f8e9dd LC |
2470 | |
2471 | @item --extract=@var{directory} | |
2472 | @itemx -x @var{directory} | |
2473 | Read a single-item archive as served by substitute servers | |
2474 | (@pxref{Substitutes}) and extract it to @var{directory}. This is a | |
2475 | low-level operation needed in only very narrow use cases; see below. | |
2476 | ||
2477 | For example, the following command extracts the substitute for Emacs | |
2478 | served by @code{hydra.gnu.org} to @file{/tmp/emacs}: | |
2479 | ||
2480 | @example | |
2481 | $ wget -O - \ | |
df061d07 | 2482 | https://hydra.gnu.org/nar/@dots{}-emacs-24.5 \ |
c6f8e9dd LC |
2483 | | bunzip2 | guix archive -x /tmp/emacs |
2484 | @end example | |
2485 | ||
2486 | Single-item archives are different from multiple-item archives produced | |
2487 | by @command{guix archive --export}; they contain a single store item, | |
2488 | and they do @emph{not} embed a signature. Thus this operation does | |
2489 | @emph{no} signature verification and its output should be considered | |
2490 | unsafe. | |
2491 | ||
2492 | The primary purpose of this operation is to facilitate inspection of | |
2493 | archive contents coming from possibly untrusted substitute servers. | |
2494 | ||
760c60d6 LC |
2495 | @end table |
2496 | ||
568717fd LC |
2497 | @c ********************************************************************* |
2498 | @node Programming Interface | |
2499 | @chapter Programming Interface | |
2500 | ||
3dc1970d LC |
2501 | GNU Guix provides several Scheme programming interfaces (APIs) to |
2502 | define, build, and query packages. The first interface allows users to | |
2503 | write high-level package definitions. These definitions refer to | |
2504 | familiar packaging concepts, such as the name and version of a package, | |
2505 | its build system, and its dependencies. These definitions can then be | |
2506 | turned into concrete build actions. | |
2507 | ||
ba55b1cb | 2508 | Build actions are performed by the Guix daemon, on behalf of users. In a |
3dc1970d | 2509 | standard setup, the daemon has write access to the store---the |
834129e0 | 2510 | @file{/gnu/store} directory---whereas users do not. The recommended |
3dc1970d LC |
2511 | setup also has the daemon perform builds in chroots, under a specific |
2512 | build users, to minimize interference with the rest of the system. | |
2513 | ||
2514 | @cindex derivation | |
2515 | Lower-level APIs are available to interact with the daemon and the | |
2516 | store. To instruct the daemon to perform a build action, users actually | |
2517 | provide it with a @dfn{derivation}. A derivation is a low-level | |
2518 | representation of the build actions to be taken, and the environment in | |
2519 | which they should occur---derivations are to package definitions what | |
49ad317a LC |
2520 | assembly is to C programs. The term ``derivation'' comes from the fact |
2521 | that build results @emph{derive} from them. | |
3dc1970d LC |
2522 | |
2523 | This chapter describes all these APIs in turn, starting from high-level | |
2524 | package definitions. | |
2525 | ||
568717fd | 2526 | @menu |
b860f382 | 2527 | * Defining Packages:: Defining new packages. |
7458bd0a | 2528 | * Build Systems:: Specifying how packages are built. |
b860f382 LC |
2529 | * The Store:: Manipulating the package store. |
2530 | * Derivations:: Low-level interface to package derivations. | |
2531 | * The Store Monad:: Purely functional interface to the store. | |
21b679f6 | 2532 | * G-Expressions:: Manipulating build expressions. |
568717fd LC |
2533 | @end menu |
2534 | ||
2535 | @node Defining Packages | |
2536 | @section Defining Packages | |
2537 | ||
3dc1970d LC |
2538 | The high-level interface to package definitions is implemented in the |
2539 | @code{(guix packages)} and @code{(guix build-system)} modules. As an | |
2540 | example, the package definition, or @dfn{recipe}, for the GNU Hello | |
2541 | package looks like this: | |
2542 | ||
2543 | @example | |
e7f34eb0 LC |
2544 | (define-module (gnu packages hello) |
2545 | #:use-module (guix packages) | |
2546 | #:use-module (guix download) | |
2547 | #:use-module (guix build-system gnu) | |
a6dcdcac SB |
2548 | #:use-module (guix licenses) |
2549 | #:use-module (gnu packages gawk)) | |
b22a12fd | 2550 | |
79f5dd59 | 2551 | (define-public hello |
3dc1970d LC |
2552 | (package |
2553 | (name "hello") | |
17d8e33f | 2554 | (version "2.10") |
3dc1970d | 2555 | (source (origin |
17d8e33f ML |
2556 | (method url-fetch) |
2557 | (uri (string-append "mirror://gnu/hello/hello-" version | |
2558 | ".tar.gz")) | |
2559 | (sha256 | |
2560 | (base32 | |
2561 | "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i")))) | |
3dc1970d | 2562 | (build-system gnu-build-system) |
654c0d97 | 2563 | (arguments '(#:configure-flags '("--enable-silent-rules"))) |
3dc1970d | 2564 | (inputs `(("gawk" ,gawk))) |
7458bd0a LC |
2565 | (synopsis "Hello, GNU world: An example GNU package") |
2566 | (description "Guess what GNU Hello prints!") | |
3dc1970d | 2567 | (home-page "http://www.gnu.org/software/hello/") |
b22a12fd | 2568 | (license gpl3+))) |
3dc1970d LC |
2569 | @end example |
2570 | ||
2571 | @noindent | |
2572 | Without being a Scheme expert, the reader may have guessed the meaning | |
f97c9175 AE |
2573 | of the various fields here. This expression binds the variable |
2574 | @code{hello} to a @code{<package>} object, which is essentially a record | |
3dc1970d LC |
2575 | (@pxref{SRFI-9, Scheme records,, guile, GNU Guile Reference Manual}). |
2576 | This package object can be inspected using procedures found in the | |
2577 | @code{(guix packages)} module; for instance, @code{(package-name hello)} | |
2578 | returns---surprise!---@code{"hello"}. | |
2579 | ||
2f7d2d91 LC |
2580 | With luck, you may be able to import part or all of the definition of |
2581 | the package you are interested in from another repository, using the | |
2582 | @code{guix import} command (@pxref{Invoking guix import}). | |
2583 | ||
f97c9175 | 2584 | In the example above, @var{hello} is defined in a module of its own, |
e7f34eb0 LC |
2585 | @code{(gnu packages hello)}. Technically, this is not strictly |
2586 | necessary, but it is convenient to do so: all the packages defined in | |
2587 | modules under @code{(gnu packages @dots{})} are automatically known to | |
2588 | the command-line tools (@pxref{Package Modules}). | |
2589 | ||
3dc1970d LC |
2590 | There are a few points worth noting in the above package definition: |
2591 | ||
2592 | @itemize | |
2593 | @item | |
a2bf4907 LC |
2594 | The @code{source} field of the package is an @code{<origin>} object |
2595 | (@pxref{origin Reference}, for the complete reference). | |
3dc1970d LC |
2596 | Here, the @code{url-fetch} method from @code{(guix download)} is used, |
2597 | meaning that the source is a file to be downloaded over FTP or HTTP. | |
2598 | ||
2599 | The @code{mirror://gnu} prefix instructs @code{url-fetch} to use one of | |
2600 | the GNU mirrors defined in @code{(guix download)}. | |
2601 | ||
2602 | The @code{sha256} field specifies the expected SHA256 hash of the file | |
2603 | being downloaded. It is mandatory, and allows Guix to check the | |
2604 | integrity of the file. The @code{(base32 @dots{})} form introduces the | |
6c365eca | 2605 | base32 representation of the hash. You can obtain this information with |
210cc920 LC |
2606 | @code{guix download} (@pxref{Invoking guix download}) and @code{guix |
2607 | hash} (@pxref{Invoking guix hash}). | |
3dc1970d | 2608 | |
f9cc8971 LC |
2609 | @cindex patches |
2610 | When needed, the @code{origin} form can also have a @code{patches} field | |
2611 | listing patches to be applied, and a @code{snippet} field giving a | |
2612 | Scheme expression to modify the source code. | |
2613 | ||
3dc1970d LC |
2614 | @item |
2615 | @cindex GNU Build System | |
7458bd0a LC |
2616 | The @code{build-system} field specifies the procedure to build the |
2617 | package (@pxref{Build Systems}). Here, @var{gnu-build-system} | |
2618 | represents the familiar GNU Build System, where packages may be | |
2619 | configured, built, and installed with the usual @code{./configure && | |
2620 | make && make check && make install} command sequence. | |
2621 | ||
2622 | @item | |
2623 | The @code{arguments} field specifies options for the build system | |
2624 | (@pxref{Build Systems}). Here it is interpreted by | |
2625 | @var{gnu-build-system} as a request run @file{configure} with the | |
2626 | @code{--enable-silent-rules} flag. | |
3dc1970d | 2627 | |
654c0d97 LC |
2628 | @cindex quote |
2629 | @cindex quoting | |
2630 | @findex ' | |
2631 | @findex quote | |
2632 | What about these quote (@code{'}) characters? They are Scheme syntax to | |
2633 | introduce a literal list; @code{'} is synonymous with @code{quote}. | |
2634 | @xref{Expression Syntax, quoting,, guile, GNU Guile Reference Manual}, | |
2635 | for details. Here the value of the @code{arguments} field is a list of | |
2636 | arguments passed to the build system down the road, as with @code{apply} | |
2637 | (@pxref{Fly Evaluation, @code{apply},, guile, GNU Guile Reference | |
2638 | Manual}). | |
2639 | ||
2640 | The hash-colon (@code{#:}) sequence defines a Scheme @dfn{keyword} | |
2641 | (@pxref{Keywords,,, guile, GNU Guile Reference Manual}), and | |
2642 | @code{#:configure-flags} is a keyword used to pass a keyword argument | |
2643 | to the build system (@pxref{Coding With Keywords,,, guile, GNU Guile | |
2644 | Reference Manual}). | |
2645 | ||
3dc1970d LC |
2646 | @item |
2647 | The @code{inputs} field specifies inputs to the build process---i.e., | |
2648 | build-time or run-time dependencies of the package. Here, we define an | |
2649 | input called @code{"gawk"} whose value is that of the @var{gawk} | |
2650 | variable; @var{gawk} is itself bound to a @code{<package>} object. | |
2651 | ||
654c0d97 LC |
2652 | @cindex backquote (quasiquote) |
2653 | @findex ` | |
2654 | @findex quasiquote | |
2655 | @cindex comma (unquote) | |
2656 | @findex , | |
2657 | @findex unquote | |
2658 | @findex ,@@ | |
2659 | @findex unquote-splicing | |
2660 | Again, @code{`} (a backquote, synonymous with @code{quasiquote}) allows | |
2661 | us to introduce a literal list in the @code{inputs} field, while | |
2662 | @code{,} (a comma, synonymous with @code{unquote}) allows us to insert a | |
2663 | value in that list (@pxref{Expression Syntax, unquote,, guile, GNU Guile | |
2664 | Reference Manual}). | |
2665 | ||
3dc1970d LC |
2666 | Note that GCC, Coreutils, Bash, and other essential tools do not need to |
2667 | be specified as inputs here. Instead, @var{gnu-build-system} takes care | |
7458bd0a | 2668 | of ensuring that they are present (@pxref{Build Systems}). |
3dc1970d LC |
2669 | |
2670 | However, any other dependencies need to be specified in the | |
2671 | @code{inputs} field. Any dependency not specified here will simply be | |
2672 | unavailable to the build process, possibly leading to a build failure. | |
2673 | @end itemize | |
2674 | ||
87eafdbd TUBK |
2675 | @xref{package Reference}, for a full description of possible fields. |
2676 | ||
2f7d2d91 | 2677 | Once a package definition is in place, the |
e49951eb | 2678 | package may actually be built using the @code{guix build} command-line |
39bee8a2 LC |
2679 | tool (@pxref{Invoking guix build}). You can easily jump back to the |
2680 | package definition using the @command{guix edit} command | |
2681 | (@pxref{Invoking guix edit}). | |
2682 | @xref{Packaging Guidelines}, for | |
b4f5e0e8 CR |
2683 | more information on how to test package definitions, and |
2684 | @ref{Invoking guix lint}, for information on how to check a definition | |
2685 | for style conformance. | |
2686 | ||
f97c9175 | 2687 | Finally, updating the package definition to a new upstream version |
7458bd0a LC |
2688 | can be partly automated by the @command{guix refresh} command |
2689 | (@pxref{Invoking guix refresh}). | |
3dc1970d LC |
2690 | |
2691 | Behind the scenes, a derivation corresponding to the @code{<package>} | |
2692 | object is first computed by the @code{package-derivation} procedure. | |
834129e0 | 2693 | That derivation is stored in a @code{.drv} file under @file{/gnu/store}. |
ba55b1cb | 2694 | The build actions it prescribes may then be realized by using the |
3dc1970d LC |
2695 | @code{build-derivations} procedure (@pxref{The Store}). |
2696 | ||
2697 | @deffn {Scheme Procedure} package-derivation @var{store} @var{package} [@var{system}] | |
59688fc4 LC |
2698 | Return the @code{<derivation>} object of @var{package} for @var{system} |
2699 | (@pxref{Derivations}). | |
3dc1970d LC |
2700 | |
2701 | @var{package} must be a valid @code{<package>} object, and @var{system} | |
2702 | must be a string denoting the target system type---e.g., | |
2703 | @code{"x86_64-linux"} for an x86_64 Linux-based GNU system. @var{store} | |
2704 | must be a connection to the daemon, which operates on the store | |
2705 | (@pxref{The Store}). | |
2706 | @end deffn | |
568717fd | 2707 | |
9c1edabd LC |
2708 | @noindent |
2709 | @cindex cross-compilation | |
2710 | Similarly, it is possible to compute a derivation that cross-builds a | |
2711 | package for some other system: | |
2712 | ||
2713 | @deffn {Scheme Procedure} package-cross-derivation @var{store} @ | |
2714 | @var{package} @var{target} [@var{system}] | |
59688fc4 LC |
2715 | Return the @code{<derivation>} object of @var{package} cross-built from |
2716 | @var{system} to @var{target}. | |
9c1edabd LC |
2717 | |
2718 | @var{target} must be a valid GNU triplet denoting the target hardware | |
2719 | and operating system, such as @code{"mips64el-linux-gnu"} | |
2720 | (@pxref{Configuration Names, GNU configuration triplets,, configure, GNU | |
2721 | Configure and Build System}). | |
2722 | @end deffn | |
2723 | ||
2a75b0b6 LC |
2724 | @cindex package transformations |
2725 | @cindex input rewriting | |
2726 | @cindex dependency tree rewriting | |
2727 | Packages can be manipulated in arbitrary ways. An example of a useful | |
2728 | transformation is @dfn{input rewriting}, whereby the dependency tree of | |
2729 | a package is rewritten by replacing specific inputs by others: | |
2730 | ||
2731 | @deffn {Scheme Procedure} package-input-rewriting @var{replacements} @ | |
2732 | [@var{rewrite-name}] | |
2733 | Return a procedure that, when passed a package, replaces its direct and | |
2734 | indirect dependencies (but not its implicit inputs) according to | |
2735 | @var{replacements}. @var{replacements} is a list of package pairs; the | |
2736 | first element of each pair is the package to replace, and the second one | |
2737 | is the replacement. | |
2738 | ||
2739 | Optionally, @var{rewrite-name} is a one-argument procedure that takes | |
2740 | the name of a package and returns its new name after rewrite. | |
2741 | @end deffn | |
2742 | ||
2743 | @noindent | |
2744 | Consider this example: | |
2745 | ||
2746 | @example | |
2747 | (define libressl-instead-of-openssl | |
2748 | ;; This is a procedure to replace OPENSSL by LIBRESSL, | |
2749 | ;; recursively. | |
2750 | (package-input-rewriting `((,openssl . ,libressl)))) | |
2751 | ||
2752 | (define git-with-libressl | |
2753 | (libressl-instead-of-openssl git)) | |
2754 | @end example | |
2755 | ||
2756 | @noindent | |
2757 | Here we first define a rewriting procedure that replaces @var{openssl} | |
2758 | with @var{libressl}. Then we use it to define a @dfn{variant} of the | |
2759 | @var{git} package that uses @var{libressl} instead of @var{openssl}. | |
2760 | This is exactly what the @option{--with-input} command-line option does | |
2761 | (@pxref{Package Transformation Options, @option{--with-input}}). | |
2762 | ||
87eafdbd TUBK |
2763 | @menu |
2764 | * package Reference :: The package data type. | |
2765 | * origin Reference:: The origin data type. | |
2766 | @end menu | |
2767 | ||
2768 | ||
2769 | @node package Reference | |
2770 | @subsection @code{package} Reference | |
2771 | ||
2772 | This section summarizes all the options available in @code{package} | |
2773 | declarations (@pxref{Defining Packages}). | |
2774 | ||
2775 | @deftp {Data Type} package | |
2776 | This is the data type representing a package recipe. | |
2777 | ||
2778 | @table @asis | |
2779 | @item @code{name} | |
2780 | The name of the package, as a string. | |
2781 | ||
2782 | @item @code{version} | |
2783 | The version of the package, as a string. | |
2784 | ||
2785 | @item @code{source} | |
da675305 LC |
2786 | An object telling how the source code for the package should be |
2787 | acquired. Most of the time, this is an @code{origin} object, which | |
2788 | denotes a file fetched from the Internet (@pxref{origin Reference}). It | |
2789 | can also be any other ``file-like'' object such as a @code{local-file}, | |
2790 | which denotes a file from the local file system (@pxref{G-Expressions, | |
2791 | @code{local-file}}). | |
87eafdbd TUBK |
2792 | |
2793 | @item @code{build-system} | |
2794 | The build system that should be used to build the package (@pxref{Build | |
2795 | Systems}). | |
2796 | ||
2797 | @item @code{arguments} (default: @code{'()}) | |
2798 | The arguments that should be passed to the build system. This is a | |
2799 | list, typically containing sequential keyword-value pairs. | |
2800 | ||
2801 | @item @code{inputs} (default: @code{'()}) | |
70650c68 LC |
2802 | @itemx @code{native-inputs} (default: @code{'()}) |
2803 | @itemx @code{propagated-inputs} (default: @code{'()}) | |
2804 | @cindex inputs, of packages | |
2805 | These fields list dependencies of the package. Each one is a list of | |
2806 | tuples, where each tuple has a label for the input (a string) as its | |
2807 | first element, a package, origin, or derivation as its second element, | |
2808 | and optionally the name of the output thereof that should be used, which | |
2809 | defaults to @code{"out"} (@pxref{Packages with Multiple Outputs}, for | |
f97c9175 | 2810 | more on package outputs). For example, the list below specifies three |
70650c68 | 2811 | inputs: |
87eafdbd | 2812 | |
70650c68 LC |
2813 | @example |
2814 | `(("libffi" ,libffi) | |
2815 | ("libunistring" ,libunistring) | |
2816 | ("glib:bin" ,glib "bin")) ;the "bin" output of Glib | |
2817 | @end example | |
2818 | ||
2819 | @cindex cross compilation, package dependencies | |
2820 | The distinction between @code{native-inputs} and @code{inputs} is | |
2821 | necessary when considering cross-compilation. When cross-compiling, | |
2822 | dependencies listed in @code{inputs} are built for the @emph{target} | |
2823 | architecture; conversely, dependencies listed in @code{native-inputs} | |
2824 | are built for the architecture of the @emph{build} machine. | |
2825 | ||
f97c9175 AE |
2826 | @code{native-inputs} is typically used to list tools needed at |
2827 | build time, but not at run time, such as Autoconf, Automake, pkg-config, | |
70650c68 LC |
2828 | Gettext, or Bison. @command{guix lint} can report likely mistakes in |
2829 | this area (@pxref{Invoking guix lint}). | |
2830 | ||
2831 | @anchor{package-propagated-inputs} | |
2832 | Lastly, @code{propagated-inputs} is similar to @code{inputs}, but the | |
f97c9175 AE |
2833 | specified packages will be automatically installed alongside the package |
2834 | they belong to (@pxref{package-cmd-propagated-inputs, @command{guix | |
70650c68 LC |
2835 | package}}, for information on how @command{guix package} deals with |
2836 | propagated inputs.) | |
21461f27 | 2837 | |
e0508b6b LC |
2838 | For example this is necessary when a C/C++ library needs headers of |
2839 | another library to compile, or when a pkg-config file refers to another | |
2840 | one @i{via} its @code{Requires} field. | |
2841 | ||
f97c9175 AE |
2842 | Another example where @code{propagated-inputs} is useful is for languages |
2843 | that lack a facility to record the run-time search path akin to the | |
c8ebb4c4 | 2844 | @code{RUNPATH} of ELF files; this includes Guile, Python, Perl, and |
e0508b6b LC |
2845 | more. To ensure that libraries written in those languages can find |
2846 | library code they depend on at run time, run-time dependencies must be | |
2847 | listed in @code{propagated-inputs} rather than @code{inputs}. | |
87eafdbd | 2848 | |
87eafdbd TUBK |
2849 | @item @code{self-native-input?} (default: @code{#f}) |
2850 | This is a Boolean field telling whether the package should use itself as | |
2851 | a native input when cross-compiling. | |
2852 | ||
2853 | @item @code{outputs} (default: @code{'("out")}) | |
2854 | The list of output names of the package. @xref{Packages with Multiple | |
2855 | Outputs}, for typical uses of additional outputs. | |
2856 | ||
2857 | @item @code{native-search-paths} (default: @code{'()}) | |
2858 | @itemx @code{search-paths} (default: @code{'()}) | |
2859 | A list of @code{search-path-specification} objects describing | |
2860 | search-path environment variables honored by the package. | |
2861 | ||
2862 | @item @code{replacement} (default: @code{#f}) | |
f97c9175 | 2863 | This must be either @code{#f} or a package object that will be used as a |
87eafdbd TUBK |
2864 | @dfn{replacement} for this package. @xref{Security Updates, grafts}, |
2865 | for details. | |
2866 | ||
2867 | @item @code{synopsis} | |
2868 | A one-line description of the package. | |
2869 | ||
2870 | @item @code{description} | |
2871 | A more elaborate description of the package. | |
2872 | ||
2873 | @item @code{license} | |
e32171ee | 2874 | @cindex license, of packages |
f97c9175 AE |
2875 | The license of the package; a value from @code{(guix licenses)}, |
2876 | or a list of such values. | |
87eafdbd TUBK |
2877 | |
2878 | @item @code{home-page} | |
2879 | The URL to the home-page of the package, as a string. | |
2880 | ||
2881 | @item @code{supported-systems} (default: @var{%supported-systems}) | |
2882 | The list of systems supported by the package, as strings of the form | |
2883 | @code{architecture-kernel}, for example @code{"x86_64-linux"}. | |
2884 | ||
2885 | @item @code{maintainers} (default: @code{'()}) | |
2886 | The list of maintainers of the package, as @code{maintainer} objects. | |
2887 | ||
2888 | @item @code{location} (default: source location of the @code{package} form) | |
f97c9175 | 2889 | The source location of the package. It is useful to override this when |
87eafdbd TUBK |
2890 | inheriting from another package, in which case this field is not |
2891 | automatically corrected. | |
2892 | @end table | |
2893 | @end deftp | |
2894 | ||
2895 | ||
2896 | @node origin Reference | |
2897 | @subsection @code{origin} Reference | |
2898 | ||
2899 | This section summarizes all the options available in @code{origin} | |
2900 | declarations (@pxref{Defining Packages}). | |
2901 | ||
2902 | @deftp {Data Type} origin | |
2903 | This is the data type representing a source code origin. | |
2904 | ||
2905 | @table @asis | |
2906 | @item @code{uri} | |
2907 | An object containing the URI of the source. The object type depends on | |
2908 | the @code{method} (see below). For example, when using the | |
2909 | @var{url-fetch} method of @code{(guix download)}, the valid @code{uri} | |
2910 | values are: a URL represented as a string, or a list thereof. | |
2911 | ||
2912 | @item @code{method} | |
f97c9175 | 2913 | A procedure that handles the URI. |
87eafdbd TUBK |
2914 | |
2915 | Examples include: | |
2916 | ||
2917 | @table @asis | |
2918 | @item @var{url-fetch} from @code{(guix download)} | |
f97c9175 | 2919 | download a file from the HTTP, HTTPS, or FTP URL specified in the |
87eafdbd TUBK |
2920 | @code{uri} field; |
2921 | ||
db97a03a | 2922 | @vindex git-fetch |
87eafdbd TUBK |
2923 | @item @var{git-fetch} from @code{(guix git-download)} |
2924 | clone the Git version control repository, and check out the revision | |
2925 | specified in the @code{uri} field as a @code{git-reference} object; a | |
2926 | @code{git-reference} looks like this: | |
2927 | ||
2928 | @example | |
2929 | (git-reference | |
2930 | (url "git://git.debian.org/git/pkg-shadow/shadow") | |
2931 | (commit "v4.1.5.1")) | |
2932 | @end example | |
2933 | @end table | |
2934 | ||
2935 | @item @code{sha256} | |
2936 | A bytevector containing the SHA-256 hash of the source. Typically the | |
2937 | @code{base32} form is used here to generate the bytevector from a | |
2938 | base-32 string. | |
2939 | ||
db97a03a LC |
2940 | You can obtain this information using @code{guix download} |
2941 | (@pxref{Invoking guix download}) or @code{guix hash} (@pxref{Invoking | |
2942 | guix hash}). | |
2943 | ||
87eafdbd TUBK |
2944 | @item @code{file-name} (default: @code{#f}) |
2945 | The file name under which the source code should be saved. When this is | |
2946 | @code{#f}, a sensible default value will be used in most cases. In case | |
2947 | the source is fetched from a URL, the file name from the URL will be | |
f97c9175 | 2948 | used. For version control checkouts, it is recommended to provide the |
87eafdbd TUBK |
2949 | file name explicitly because the default is not very descriptive. |
2950 | ||
2951 | @item @code{patches} (default: @code{'()}) | |
2952 | A list of file names containing patches to be applied to the source. | |
2953 | ||
0dfebdaa LC |
2954 | This list of patches must be unconditional. In particular, it cannot |
2955 | depend on the value of @code{%current-system} or | |
2956 | @code{%current-target-system}. | |
2957 | ||
87eafdbd | 2958 | @item @code{snippet} (default: @code{#f}) |
1929fdba LC |
2959 | A G-expression (@pxref{G-Expressions}) or S-expression that will be run |
2960 | in the source directory. This is a convenient way to modify the source, | |
2961 | sometimes more convenient than a patch. | |
87eafdbd TUBK |
2962 | |
2963 | @item @code{patch-flags} (default: @code{'("-p1")}) | |
2964 | A list of command-line flags that should be passed to the @code{patch} | |
2965 | command. | |
2966 | ||
2967 | @item @code{patch-inputs} (default: @code{#f}) | |
2968 | Input packages or derivations to the patching process. When this is | |
2969 | @code{#f}, the usual set of inputs necessary for patching are provided, | |
2970 | such as GNU@tie{}Patch. | |
2971 | ||
2972 | @item @code{modules} (default: @code{'()}) | |
2973 | A list of Guile modules that should be loaded during the patching | |
2974 | process and while running the code in the @code{snippet} field. | |
2975 | ||
87eafdbd TUBK |
2976 | @item @code{patch-guile} (default: @code{#f}) |
2977 | The Guile package that should be used in the patching process. When | |
2978 | this is @code{#f}, a sensible default is used. | |
2979 | @end table | |
2980 | @end deftp | |
2981 | ||
9c1edabd | 2982 | |
7458bd0a LC |
2983 | @node Build Systems |
2984 | @section Build Systems | |
2985 | ||
2986 | @cindex build system | |
2987 | Each package definition specifies a @dfn{build system} and arguments for | |
2988 | that build system (@pxref{Defining Packages}). This @code{build-system} | |
f97c9175 | 2989 | field represents the build procedure of the package, as well as implicit |
7458bd0a LC |
2990 | dependencies of that build procedure. |
2991 | ||
2992 | Build systems are @code{<build-system>} objects. The interface to | |
2993 | create and manipulate them is provided by the @code{(guix build-system)} | |
2994 | module, and actual build systems are exported by specific modules. | |
2995 | ||
f5fd4fd2 | 2996 | @cindex bag (low-level package representation) |
0d5a559f LC |
2997 | Under the hood, build systems first compile package objects to |
2998 | @dfn{bags}. A @dfn{bag} is like a package, but with less | |
2999 | ornamentation---in other words, a bag is a lower-level representation of | |
3000 | a package, which includes all the inputs of that package, including some | |
3001 | that were implicitly added by the build system. This intermediate | |
3002 | representation is then compiled to a derivation (@pxref{Derivations}). | |
3003 | ||
7458bd0a LC |
3004 | Build systems accept an optional list of @dfn{arguments}. In package |
3005 | definitions, these are passed @i{via} the @code{arguments} field | |
3006 | (@pxref{Defining Packages}). They are typically keyword arguments | |
3007 | (@pxref{Optional Arguments, keyword arguments in Guile,, guile, GNU | |
3008 | Guile Reference Manual}). The value of these arguments is usually | |
3009 | evaluated in the @dfn{build stratum}---i.e., by a Guile process launched | |
3010 | by the daemon (@pxref{Derivations}). | |
3011 | ||
3012 | The main build system is @var{gnu-build-system}, which implements the | |
f97c9175 | 3013 | standard build procedure for GNU and many other packages. It |
7458bd0a LC |
3014 | is provided by the @code{(guix build-system gnu)} module. |
3015 | ||
3016 | @defvr {Scheme Variable} gnu-build-system | |
3017 | @var{gnu-build-system} represents the GNU Build System, and variants | |
3018 | thereof (@pxref{Configuration, configuration and makefile conventions,, | |
3019 | standards, GNU Coding Standards}). | |
3020 | ||
3021 | @cindex build phases | |
f97c9175 | 3022 | In a nutshell, packages using it are configured, built, and installed with |
7458bd0a LC |
3023 | the usual @code{./configure && make && make check && make install} |
3024 | command sequence. In practice, a few additional steps are often needed. | |
3025 | All these steps are split up in separate @dfn{phases}, | |
3026 | notably@footnote{Please see the @code{(guix build gnu-build-system)} | |
3027 | modules for more details about the build phases.}: | |
3028 | ||
3029 | @table @code | |
3030 | @item unpack | |
3031 | Unpack the source tarball, and change the current directory to the | |
3032 | extracted source tree. If the source is actually a directory, copy it | |
3033 | to the build tree, and enter that directory. | |
3034 | ||
3035 | @item patch-source-shebangs | |
3036 | Patch shebangs encountered in source files so they refer to the right | |
3037 | store file names. For instance, this changes @code{#!/bin/sh} to | |
3038 | @code{#!/gnu/store/@dots{}-bash-4.3/bin/sh}. | |
3039 | ||
3040 | @item configure | |
3041 | Run the @file{configure} script with a number of default options, such | |
3042 | as @code{--prefix=/gnu/store/@dots{}}, as well as the options specified | |
3043 | by the @code{#:configure-flags} argument. | |
3044 | ||
3045 | @item build | |
3046 | Run @code{make} with the list of flags specified with | |
0917e80e | 3047 | @code{#:make-flags}. If the @code{#:parallel-build?} argument is true |
7458bd0a LC |
3048 | (the default), build with @code{make -j}. |
3049 | ||
3050 | @item check | |
3051 | Run @code{make check}, or some other target specified with | |
3052 | @code{#:test-target}, unless @code{#:tests? #f} is passed. If the | |
3053 | @code{#:parallel-tests?} argument is true (the default), run @code{make | |
3054 | check -j}. | |
3055 | ||
3056 | @item install | |
3057 | Run @code{make install} with the flags listed in @code{#:make-flags}. | |
3058 | ||
3059 | @item patch-shebangs | |
3060 | Patch shebangs on the installed executable files. | |
3061 | ||
3062 | @item strip | |
3063 | Strip debugging symbols from ELF files (unless @code{#:strip-binaries?} | |
3064 | is false), copying them to the @code{debug} output when available | |
3065 | (@pxref{Installing Debugging Files}). | |
3066 | @end table | |
3067 | ||
3068 | @vindex %standard-phases | |
3069 | The build-side module @code{(guix build gnu-build-system)} defines | |
3070 | @var{%standard-phases} as the default list of build phases. | |
3071 | @var{%standard-phases} is a list of symbol/procedure pairs, where the | |
3072 | procedure implements the actual phase. | |
3073 | ||
3074 | The list of phases used for a particular package can be changed with the | |
3075 | @code{#:phases} parameter. For instance, passing: | |
3076 | ||
3077 | @example | |
c2c5dc79 | 3078 | #:phases (modify-phases %standard-phases (delete 'configure)) |
7458bd0a LC |
3079 | @end example |
3080 | ||
9bf404e9 | 3081 | means that all the phases described above will be used, except the |
7458bd0a LC |
3082 | @code{configure} phase. |
3083 | ||
3084 | In addition, this build system ensures that the ``standard'' environment | |
3085 | for GNU packages is available. This includes tools such as GCC, libc, | |
3086 | Coreutils, Bash, Make, Diffutils, grep, and sed (see the @code{(guix | |
f97c9175 AE |
3087 | build-system gnu)} module for a complete list). We call these the |
3088 | @dfn{implicit inputs} of a package, because package definitions do not | |
7458bd0a LC |
3089 | have to mention them. |
3090 | @end defvr | |
3091 | ||
3092 | Other @code{<build-system>} objects are defined to support other | |
3093 | conventions and tools used by free software packages. They inherit most | |
3094 | of @var{gnu-build-system}, and differ mainly in the set of inputs | |
3095 | implicitly added to the build process, and in the list of phases | |
3096 | executed. Some of these build systems are listed below. | |
3097 | ||
5f7a1a4d RW |
3098 | @defvr {Scheme Variable} ant-build-system |
3099 | This variable is exported by @code{(guix build-system ant)}. It | |
3100 | implements the build procedure for Java packages that can be built with | |
3101 | @url{http://ant.apache.org/, Ant build tool}. | |
3102 | ||
3103 | It adds both @code{ant} and the @dfn{Java Development Kit} (JDK) as | |
3104 | provided by the @code{icedtea} package to the set of inputs. Different | |
3105 | packages can be specified with the @code{#:ant} and @code{#:jdk} | |
3106 | parameters, respectively. | |
3107 | ||
3108 | When the original package does not provide a suitable Ant build file, | |
3109 | the parameter @code{#:jar-name} can be used to generate a minimal Ant | |
3110 | build file @file{build.xml} with tasks to build the specified jar | |
3111 | archive. | |
3112 | ||
3113 | The parameter @code{#:build-target} can be used to specify the Ant task | |
3114 | that should be run during the @code{build} phase. By default the | |
3115 | ``jar'' task will be run. | |
3116 | ||
3117 | @end defvr | |
3118 | ||
a1b30f99 AP |
3119 | @defvr {Scheme Variable} asdf-build-system/source |
3120 | @defvrx {Scheme Variable} asdf-build-system/sbcl | |
3121 | @defvrx {Scheme Variable} asdf-build-system/ecl | |
3122 | ||
3123 | These variables, exported by @code{(guix build-system asdf)}, implement | |
3124 | build procedures for Common Lisp packages using | |
3125 | @url{https://common-lisp.net/project/asdf/, ``ASDF''}. ASDF is a system | |
3126 | definition facility for Common Lisp programs and libraries. | |
3127 | ||
3128 | The @code{asdf-build-system/source} system installs the packages in | |
3129 | source form, and can be loaded using any common lisp implementation, via | |
3130 | ASDF. The others, such as @code{asdf-build-system/sbcl}, install binary | |
3131 | systems in the format which a particular implementation understands. | |
3132 | These build systems can also be used to produce executable programs, or | |
3133 | lisp images which contain a set of packages pre-loaded. | |
3134 | ||
3135 | The build system uses naming conventions. For binary packages, the | |
3136 | package itself as well as its run-time dependencies should begin their | |
3137 | name with the lisp implementation, such as @code{sbcl-} for | |
3138 | @code{asdf-build-system/sbcl}. Beginning the input name with this | |
3139 | prefix will allow the build system to encode its location into the | |
3140 | resulting library, so that the input can be found at run-time. | |
3141 | ||
3142 | If dependencies are used only for tests, it is convenient to use a | |
3143 | different prefix in order to avoid having a run-time dependency on such | |
3144 | systems. For example, | |
3145 | ||
3146 | @example | |
3147 | (define-public sbcl-bordeaux-threads | |
3148 | (package | |
3149 | ... | |
3150 | (native-inputs `(("tests:cl-fiveam" ,sbcl-fiveam))) | |
3151 | ...)) | |
3152 | @end example | |
3153 | ||
3154 | Additionally, the corresponding source package should be labeled using | |
3155 | the same convention as python packages (see @ref{Python Modules}), using | |
3156 | the @code{cl-} prefix. | |
3157 | ||
3158 | For binary packages, each system should be defined as a Guix package. | |
3159 | If one package @code{origin} contains several systems, package variants | |
3160 | can be created in order to build all the systems. Source packages, | |
3161 | which use @code{asdf-build-system/source}, may contain several systems. | |
3162 | ||
3163 | In order to create executable programs and images, the build-side | |
3164 | procedures @code{build-program} and @code{build-image} can be used. | |
3165 | They should be called in a build phase after the @code{create-symlinks} | |
3166 | phase, so that the system which was just built can be used within the | |
3167 | resulting image. @code{build-program} requires a list of Common Lisp | |
3168 | expressions to be passed as the @code{#:entry-program} argument. | |
3169 | ||
3170 | If the system is not defined within its own @code{.asd} file of the same | |
3171 | name, then the @code{#:asd-file} parameter should be used to specify | |
3172 | which file the system is defined in. | |
3173 | ||
3174 | @end defvr | |
3175 | ||
1ec34dd7 LC |
3176 | @defvr {Scheme Variable} cargo-build-system |
3177 | @cindex Rust programming language | |
3178 | @cindex Cargo (Rust build system) | |
3179 | This variable is exported by @code{(guix build-system cargo)}. It | |
3180 | supports builds of packages using Cargo, the build tool of the | |
3181 | @uref{https://www.rust-lang.org, Rust programming language}. | |
3182 | ||
3183 | In its @code{configure} phase, this build system replaces dependencies | |
3184 | specified in the @file{Carto.toml} file with inputs to the Guix package. | |
3185 | The @code{install} phase installs the binaries, and it also installs the | |
3186 | source code and @file{Cargo.toml} file. | |
3187 | @end defvr | |
3188 | ||
7458bd0a LC |
3189 | @defvr {Scheme Variable} cmake-build-system |
3190 | This variable is exported by @code{(guix build-system cmake)}. It | |
3191 | implements the build procedure for packages using the | |
3192 | @url{http://www.cmake.org, CMake build tool}. | |
3193 | ||
3194 | It automatically adds the @code{cmake} package to the set of inputs. | |
3195 | Which package is used can be specified with the @code{#:cmake} | |
3196 | parameter. | |
9849cfc1 LC |
3197 | |
3198 | The @code{#:configure-flags} parameter is taken as a list of flags | |
3199 | passed to the @command{cmake} command. The @code{#:build-type} | |
3200 | parameter specifies in abstract terms the flags passed to the compiler; | |
3201 | it defaults to @code{"RelWithDebInfo"} (short for ``release mode with | |
3202 | debugging information''), which roughly means that code is compiled with | |
3203 | @code{-O2 -g}, as is the case for Autoconf-based packages by default. | |
7458bd0a LC |
3204 | @end defvr |
3205 | ||
3afcf52b FB |
3206 | @defvr {Scheme Variable} glib-or-gtk-build-system |
3207 | This variable is exported by @code{(guix build-system glib-or-gtk)}. It | |
3208 | is intended for use with packages making use of GLib or GTK+. | |
3209 | ||
3210 | This build system adds the following two phases to the ones defined by | |
3211 | @var{gnu-build-system}: | |
3212 | ||
3213 | @table @code | |
3214 | @item glib-or-gtk-wrap | |
f97c9175 AE |
3215 | The phase @code{glib-or-gtk-wrap} ensures that programs in |
3216 | @file{bin/} are able to find GLib ``schemas'' and | |
3afcf52b FB |
3217 | @uref{https://developer.gnome.org/gtk3/stable/gtk-running.html, GTK+ |
3218 | modules}. This is achieved by wrapping the programs in launch scripts | |
3219 | that appropriately set the @code{XDG_DATA_DIRS} and @code{GTK_PATH} | |
3220 | environment variables. | |
3221 | ||
73aa8ddb LC |
3222 | It is possible to exclude specific package outputs from that wrapping |
3223 | process by listing their names in the | |
3224 | @code{#:glib-or-gtk-wrap-excluded-outputs} parameter. This is useful | |
3225 | when an output is known not to contain any GLib or GTK+ binaries, and | |
3226 | where wrapping would gratuitously add a dependency of that output on | |
3227 | GLib and GTK+. | |
3228 | ||
3afcf52b | 3229 | @item glib-or-gtk-compile-schemas |
f97c9175 | 3230 | The phase @code{glib-or-gtk-compile-schemas} makes sure that all |
3afcf52b | 3231 | @uref{https://developer.gnome.org/gio/stable/glib-compile-schemas.html, |
f97c9175 | 3232 | GSettings schemas} of GLib are compiled. Compilation is performed by the |
3afcf52b FB |
3233 | @command{glib-compile-schemas} program. It is provided by the package |
3234 | @code{glib:bin} which is automatically imported by the build system. | |
3235 | The @code{glib} package providing @command{glib-compile-schemas} can be | |
3236 | specified with the @code{#:glib} parameter. | |
3237 | @end table | |
3238 | ||
3239 | Both phases are executed after the @code{install} phase. | |
3240 | @end defvr | |
3241 | ||
7458bd0a LC |
3242 | @defvr {Scheme Variable} python-build-system |
3243 | This variable is exported by @code{(guix build-system python)}. It | |
3244 | implements the more or less standard build procedure used by Python | |
3245 | packages, which consists in running @code{python setup.py build} and | |
3246 | then @code{python setup.py install --prefix=/gnu/store/@dots{}}. | |
3247 | ||
3248 | For packages that install stand-alone Python programs under @code{bin/}, | |
f97c9175 | 3249 | it takes care of wrapping these programs so that their @code{PYTHONPATH} |
7458bd0a LC |
3250 | environment variable points to all the Python libraries they depend on. |
3251 | ||
8a46205b CM |
3252 | Which Python package is used to perform the build can be specified with |
3253 | the @code{#:python} parameter. This is a useful way to force a package | |
3254 | to be built for a specific version of the Python interpreter, which | |
3255 | might be necessary if the package is only compatible with a single | |
3256 | interpreter version. | |
5f7565d1 HG |
3257 | |
3258 | By default guix calls @code{setup.py} under control of | |
3259 | @code{setuptools}, much like @command{pip} does. Some packages are not | |
3260 | compatible with setuptools (and pip), thus you can disable this by | |
3261 | setting the @code{#:use-setuptools} parameter to @code{#f}. | |
7458bd0a LC |
3262 | @end defvr |
3263 | ||
3264 | @defvr {Scheme Variable} perl-build-system | |
3265 | This variable is exported by @code{(guix build-system perl)}. It | |
2d2a53fc EB |
3266 | implements the standard build procedure for Perl packages, which either |
3267 | consists in running @code{perl Build.PL --prefix=/gnu/store/@dots{}}, | |
3268 | followed by @code{Build} and @code{Build install}; or in running | |
3269 | @code{perl Makefile.PL PREFIX=/gnu/store/@dots{}}, followed by | |
f97c9175 | 3270 | @code{make} and @code{make install}, depending on which of |
2d2a53fc EB |
3271 | @code{Build.PL} or @code{Makefile.PL} is present in the package |
3272 | distribution. Preference is given to the former if both @code{Build.PL} | |
3273 | and @code{Makefile.PL} exist in the package distribution. This | |
3274 | preference can be reversed by specifying @code{#t} for the | |
3275 | @code{#:make-maker?} parameter. | |
3276 | ||
3277 | The initial @code{perl Makefile.PL} or @code{perl Build.PL} invocation | |
3278 | passes flags specified by the @code{#:make-maker-flags} or | |
3279 | @code{#:module-build-flags} parameter, respectively. | |
7458bd0a LC |
3280 | |
3281 | Which Perl package is used can be specified with @code{#:perl}. | |
3282 | @end defvr | |
3283 | ||
f8f3bef6 RW |
3284 | @defvr {Scheme Variable} r-build-system |
3285 | This variable is exported by @code{(guix build-system r)}. It | |
3286 | implements the build procedure used by @uref{http://r-project.org, R} | |
3287 | packages, which essentially is little more than running @code{R CMD | |
3288 | INSTALL --library=/gnu/store/@dots{}} in an environment where | |
3289 | @code{R_LIBS_SITE} contains the paths to all R package inputs. Tests | |
3290 | are run after installation using the R function | |
3291 | @code{tools::testInstalledPackage}. | |
3292 | @end defvr | |
3293 | ||
c08f9818 DT |
3294 | @defvr {Scheme Variable} ruby-build-system |
3295 | This variable is exported by @code{(guix build-system ruby)}. It | |
3296 | implements the RubyGems build procedure used by Ruby packages, which | |
3297 | involves running @code{gem build} followed by @code{gem install}. | |
3298 | ||
5dc87623 DT |
3299 | The @code{source} field of a package that uses this build system |
3300 | typically references a gem archive, since this is the format that Ruby | |
3301 | developers use when releasing their software. The build system unpacks | |
3302 | the gem archive, potentially patches the source, runs the test suite, | |
3303 | repackages the gem, and installs it. Additionally, directories and | |
3304 | tarballs may be referenced to allow building unreleased gems from Git or | |
3305 | a traditional source release tarball. | |
e83c6d00 | 3306 | |
c08f9818 | 3307 | Which Ruby package is used can be specified with the @code{#:ruby} |
6e9f2913 PP |
3308 | parameter. A list of additional flags to be passed to the @command{gem} |
3309 | command can be specified with the @code{#:gem-flags} parameter. | |
c08f9818 | 3310 | @end defvr |
7458bd0a | 3311 | |
a677c726 RW |
3312 | @defvr {Scheme Variable} waf-build-system |
3313 | This variable is exported by @code{(guix build-system waf)}. It | |
3314 | implements a build procedure around the @code{waf} script. The common | |
3315 | phases---@code{configure}, @code{build}, and @code{install}---are | |
3316 | implemented by passing their names as arguments to the @code{waf} | |
3317 | script. | |
3318 | ||
3319 | The @code{waf} script is executed by the Python interpreter. Which | |
3320 | Python package is used to run the script can be specified with the | |
3321 | @code{#:python} parameter. | |
3322 | @end defvr | |
3323 | ||
14dfdf2e FB |
3324 | @defvr {Scheme Variable} haskell-build-system |
3325 | This variable is exported by @code{(guix build-system haskell)}. It | |
3326 | implements the Cabal build procedure used by Haskell packages, which | |
3327 | involves running @code{runhaskell Setup.hs configure | |
3328 | --prefix=/gnu/store/@dots{}} and @code{runhaskell Setup.hs build}. | |
3329 | Instead of installing the package by running @code{runhaskell Setup.hs | |
3330 | install}, to avoid trying to register libraries in the read-only | |
3331 | compiler store directory, the build system uses @code{runhaskell | |
3332 | Setup.hs copy}, followed by @code{runhaskell Setup.hs register}. In | |
3333 | addition, the build system generates the package documentation by | |
3334 | running @code{runhaskell Setup.hs haddock}, unless @code{#:haddock? #f} | |
3335 | is passed. Optional Haddock parameters can be passed with the help of | |
3336 | the @code{#:haddock-flags} parameter. If the file @code{Setup.hs} is | |
3337 | not found, the build system looks for @code{Setup.lhs} instead. | |
3338 | ||
3339 | Which Haskell compiler is used can be specified with the @code{#:haskell} | |
a54bd6d7 | 3340 | parameter which defaults to @code{ghc}. |
14dfdf2e FB |
3341 | @end defvr |
3342 | ||
e9137a53 FB |
3343 | @defvr {Scheme Variable} emacs-build-system |
3344 | This variable is exported by @code{(guix build-system emacs)}. It | |
f97c9175 AE |
3345 | implements an installation procedure similar to the packaging system |
3346 | of Emacs itself (@pxref{Packages,,, emacs, The GNU Emacs Manual}). | |
e9137a53 FB |
3347 | |
3348 | It first creates the @code{@var{package}-autoloads.el} file, then it | |
3349 | byte compiles all Emacs Lisp files. Differently from the Emacs | |
3350 | packaging system, the Info documentation files are moved to the standard | |
3351 | documentation directory and the @file{dir} file is deleted. Each | |
3352 | package is installed in its own directory under | |
3353 | @file{share/emacs/site-lisp/guix.d}. | |
3354 | @end defvr | |
3355 | ||
7458bd0a LC |
3356 | Lastly, for packages that do not need anything as sophisticated, a |
3357 | ``trivial'' build system is provided. It is trivial in the sense that | |
3358 | it provides basically no support: it does not pull any implicit inputs, | |
3359 | and does not have a notion of build phases. | |
3360 | ||
3361 | @defvr {Scheme Variable} trivial-build-system | |
3362 | This variable is exported by @code{(guix build-system trivial)}. | |
3363 | ||
3364 | This build system requires a @code{#:builder} argument. This argument | |
f97c9175 | 3365 | must be a Scheme expression that builds the package output(s)---as |
7458bd0a LC |
3366 | with @code{build-expression->derivation} (@pxref{Derivations, |
3367 | @code{build-expression->derivation}}). | |
3368 | @end defvr | |
3369 | ||
568717fd LC |
3370 | @node The Store |
3371 | @section The Store | |
3372 | ||
e531ac2a | 3373 | @cindex store |
1ddee424 | 3374 | @cindex store items |
e531ac2a LC |
3375 | @cindex store paths |
3376 | ||
f97c9175 AE |
3377 | Conceptually, the @dfn{store} is the place where derivations that have |
3378 | been built successfully are stored---by default, @file{/gnu/store}. | |
1ddee424 LC |
3379 | Sub-directories in the store are referred to as @dfn{store items} or |
3380 | sometimes @dfn{store paths}. The store has an associated database that | |
3381 | contains information such as the store paths referred to by each store | |
3382 | path, and the list of @emph{valid} store items---results of successful | |
ef5f5c86 LC |
3383 | builds. This database resides in @file{@var{localstatedir}/guix/db}, |
3384 | where @var{localstatedir} is the state directory specified @i{via} | |
3385 | @option{--localstatedir} at configure time, usually @file{/var}. | |
1ddee424 LC |
3386 | |
3387 | The store is @emph{always} accessed by the daemon on behalf of its clients | |
e531ac2a | 3388 | (@pxref{Invoking guix-daemon}). To manipulate the store, clients |
f97c9175 AE |
3389 | connect to the daemon over a Unix-domain socket, send requests to it, |
3390 | and read the result---these are remote procedure calls, or RPCs. | |
e531ac2a | 3391 | |
1ddee424 LC |
3392 | @quotation Note |
3393 | Users must @emph{never} modify files under @file{/gnu/store} directly. | |
3394 | This would lead to inconsistencies and break the immutability | |
3395 | assumptions of Guix's functional model (@pxref{Introduction}). | |
3396 | ||
3397 | @xref{Invoking guix gc, @command{guix gc --verify}}, for information on | |
3398 | how to check the integrity of the store and attempt recovery from | |
3399 | accidental modifications. | |
3400 | @end quotation | |
3401 | ||
e531ac2a LC |
3402 | The @code{(guix store)} module provides procedures to connect to the |
3403 | daemon, and to perform RPCs. These are described below. | |
3404 | ||
3405 | @deffn {Scheme Procedure} open-connection [@var{file}] [#:reserve-space? #t] | |
3406 | Connect to the daemon over the Unix-domain socket at @var{file}. When | |
3407 | @var{reserve-space?} is true, instruct it to reserve a little bit of | |
3408 | extra space on the file system so that the garbage collector can still | |
f97c9175 | 3409 | operate should the disk become full. Return a server object. |
e531ac2a LC |
3410 | |
3411 | @var{file} defaults to @var{%default-socket-path}, which is the normal | |
3412 | location given the options that were passed to @command{configure}. | |
3413 | @end deffn | |
3414 | ||
3415 | @deffn {Scheme Procedure} close-connection @var{server} | |
3416 | Close the connection to @var{server}. | |
3417 | @end deffn | |
3418 | ||
3419 | @defvr {Scheme Variable} current-build-output-port | |
3420 | This variable is bound to a SRFI-39 parameter, which refers to the port | |
3421 | where build and error logs sent by the daemon should be written. | |
3422 | @end defvr | |
3423 | ||
3424 | Procedures that make RPCs all take a server object as their first | |
3425 | argument. | |
3426 | ||
3427 | @deffn {Scheme Procedure} valid-path? @var{server} @var{path} | |
06b76acc LC |
3428 | @cindex invalid store items |
3429 | Return @code{#t} when @var{path} designates a valid store item and | |
3430 | @code{#f} otherwise (an invalid item may exist on disk but still be | |
3431 | invalid, for instance because it is the result of an aborted or failed | |
3432 | build.) | |
3433 | ||
3434 | A @code{&nix-protocol-error} condition is raised if @var{path} is not | |
3435 | prefixed by the store directory (@file{/gnu/store}). | |
e531ac2a LC |
3436 | @end deffn |
3437 | ||
cfbf9160 | 3438 | @deffn {Scheme Procedure} add-text-to-store @var{server} @var{name} @var{text} [@var{references}] |
e531ac2a LC |
3439 | Add @var{text} under file @var{name} in the store, and return its store |
3440 | path. @var{references} is the list of store paths referred to by the | |
3441 | resulting store path. | |
3442 | @end deffn | |
3443 | ||
874e6874 | 3444 | @deffn {Scheme Procedure} build-derivations @var{server} @var{derivations} |
59688fc4 LC |
3445 | Build @var{derivations} (a list of @code{<derivation>} objects or |
3446 | derivation paths), and return when the worker is done building them. | |
3447 | Return @code{#t} on success. | |
874e6874 LC |
3448 | @end deffn |
3449 | ||
b860f382 LC |
3450 | Note that the @code{(guix monads)} module provides a monad as well as |
3451 | monadic versions of the above procedures, with the goal of making it | |
3452 | more convenient to work with code that accesses the store (@pxref{The | |
3453 | Store Monad}). | |
3454 | ||
e531ac2a LC |
3455 | @c FIXME |
3456 | @i{This section is currently incomplete.} | |
568717fd LC |
3457 | |
3458 | @node Derivations | |
3459 | @section Derivations | |
3460 | ||
874e6874 LC |
3461 | @cindex derivations |
3462 | Low-level build actions and the environment in which they are performed | |
70458ed5 | 3463 | are represented by @dfn{derivations}. A derivation contains the |
874e6874 LC |
3464 | following pieces of information: |
3465 | ||
3466 | @itemize | |
3467 | @item | |
3468 | The outputs of the derivation---derivations produce at least one file or | |
3469 | directory in the store, but may produce more. | |
3470 | ||
3471 | @item | |
3472 | The inputs of the derivations, which may be other derivations or plain | |
3473 | files in the store (patches, build scripts, etc.) | |
3474 | ||
3475 | @item | |
3476 | The system type targeted by the derivation---e.g., @code{x86_64-linux}. | |
3477 | ||
3478 | @item | |
3479 | The file name of a build script in the store, along with the arguments | |
3480 | to be passed. | |
3481 | ||
3482 | @item | |
3483 | A list of environment variables to be defined. | |
3484 | ||
3485 | @end itemize | |
3486 | ||
3487 | @cindex derivation path | |
3488 | Derivations allow clients of the daemon to communicate build actions to | |
3489 | the store. They exist in two forms: as an in-memory representation, | |
3490 | both on the client- and daemon-side, and as files in the store whose | |
3491 | name end in @code{.drv}---these files are referred to as @dfn{derivation | |
3492 | paths}. Derivations paths can be passed to the @code{build-derivations} | |
3493 | procedure to perform the build actions they prescribe (@pxref{The | |
3494 | Store}). | |
3495 | ||
3496 | The @code{(guix derivations)} module provides a representation of | |
3497 | derivations as Scheme objects, along with procedures to create and | |
3498 | otherwise manipulate derivations. The lowest-level primitive to create | |
3499 | a derivation is the @code{derivation} procedure: | |
3500 | ||
1909431c LC |
3501 | @deffn {Scheme Procedure} derivation @var{store} @var{name} @var{builder} @ |
3502 | @var{args} [#:outputs '("out")] [#:hash #f] [#:hash-algo #f] @ | |
2096ef47 | 3503 | [#:recursive? #f] [#:inputs '()] [#:env-vars '()] @ |
1909431c | 3504 | [#:system (%current-system)] [#:references-graphs #f] @ |
35b5ca78 LC |
3505 | [#:allowed-references #f] [#:disallowed-references #f] @ |
3506 | [#:leaked-env-vars #f] [#:local-build? #f] @ | |
4a6aeb67 | 3507 | [#:substitutable? #t] |
59688fc4 LC |
3508 | Build a derivation with the given arguments, and return the resulting |
3509 | @code{<derivation>} object. | |
874e6874 | 3510 | |
2096ef47 | 3511 | When @var{hash} and @var{hash-algo} are given, a |
874e6874 | 3512 | @dfn{fixed-output derivation} is created---i.e., one whose result is |
36bbbbd1 LC |
3513 | known in advance, such as a file download. If, in addition, |
3514 | @var{recursive?} is true, then that fixed output may be an executable | |
3515 | file or a directory and @var{hash} must be the hash of an archive | |
3516 | containing this output. | |
5b0c9d16 | 3517 | |
858e9282 | 3518 | When @var{references-graphs} is true, it must be a list of file |
5b0c9d16 LC |
3519 | name/store path pairs. In that case, the reference graph of each store |
3520 | path is exported in the build environment in the corresponding file, in | |
3521 | a simple text format. | |
1909431c | 3522 | |
b53be755 | 3523 | When @var{allowed-references} is true, it must be a list of store items |
35b5ca78 LC |
3524 | or outputs that the derivation's output may refer to. Likewise, |
3525 | @var{disallowed-references}, if true, must be a list of things the | |
3526 | outputs may @emph{not} refer to. | |
b53be755 | 3527 | |
c0468155 LC |
3528 | When @var{leaked-env-vars} is true, it must be a list of strings |
3529 | denoting environment variables that are allowed to ``leak'' from the | |
3530 | daemon's environment to the build environment. This is only applicable | |
3531 | to fixed-output derivations---i.e., when @var{hash} is true. The main | |
3532 | use is to allow variables such as @code{http_proxy} to be passed to | |
3533 | derivations that download files. | |
3534 | ||
1909431c LC |
3535 | When @var{local-build?} is true, declare that the derivation is not a |
3536 | good candidate for offloading and should rather be built locally | |
3537 | (@pxref{Daemon Offload Setup}). This is the case for small derivations | |
3538 | where the costs of data transfers would outweigh the benefits. | |
4a6aeb67 LC |
3539 | |
3540 | When @var{substitutable?} is false, declare that substitutes of the | |
3541 | derivation's output should not be used (@pxref{Substitutes}). This is | |
3542 | useful, for instance, when building packages that capture details of the | |
3543 | host CPU instruction set. | |
874e6874 LC |
3544 | @end deffn |
3545 | ||
3546 | @noindent | |
3547 | Here's an example with a shell script as its builder, assuming | |
3548 | @var{store} is an open connection to the daemon, and @var{bash} points | |
3549 | to a Bash executable in the store: | |
3550 | ||
3551 | @lisp | |
3552 | (use-modules (guix utils) | |
3553 | (guix store) | |
3554 | (guix derivations)) | |
3555 | ||
59688fc4 LC |
3556 | (let ((builder ; add the Bash script to the store |
3557 | (add-text-to-store store "my-builder.sh" | |
3558 | "echo hello world > $out\n" '()))) | |
3559 | (derivation store "foo" | |
3560 | bash `("-e" ,builder) | |
21b679f6 | 3561 | #:inputs `((,bash) (,builder)) |
59688fc4 | 3562 | #:env-vars '(("HOME" . "/homeless")))) |
834129e0 | 3563 | @result{} #<derivation /gnu/store/@dots{}-foo.drv => /gnu/store/@dots{}-foo> |
874e6874 LC |
3564 | @end lisp |
3565 | ||
21b679f6 LC |
3566 | As can be guessed, this primitive is cumbersome to use directly. A |
3567 | better approach is to write build scripts in Scheme, of course! The | |
3568 | best course of action for that is to write the build code as a | |
3569 | ``G-expression'', and to pass it to @code{gexp->derivation}. For more | |
6621cdb6 | 3570 | information, @pxref{G-Expressions}. |
21b679f6 | 3571 | |
f2fadbc1 AE |
3572 | Once upon a time, @code{gexp->derivation} did not exist and constructing |
3573 | derivations with build code written in Scheme was achieved with | |
3574 | @code{build-expression->derivation}, documented below. This procedure | |
3575 | is now deprecated in favor of the much nicer @code{gexp->derivation}. | |
3576 | ||
3577 | @deffn {Scheme Procedure} build-expression->derivation @var{store} @ | |
3578 | @var{name} @var{exp} @ | |
3579 | [#:system (%current-system)] [#:inputs '()] @ | |
3580 | [#:outputs '("out")] [#:hash #f] [#:hash-algo #f] @ | |
3581 | [#:recursive? #f] [#:env-vars '()] [#:modules '()] @ | |
3582 | [#:references-graphs #f] [#:allowed-references #f] @ | |
35b5ca78 | 3583 | [#:disallowed-references #f] @ |
f2fadbc1 AE |
3584 | [#:local-build? #f] [#:substitutable? #t] [#:guile-for-build #f] |
3585 | Return a derivation that executes Scheme expression @var{exp} as a | |
3586 | builder for derivation @var{name}. @var{inputs} must be a list of | |
3587 | @code{(name drv-path sub-drv)} tuples; when @var{sub-drv} is omitted, | |
3588 | @code{"out"} is assumed. @var{modules} is a list of names of Guile | |
3589 | modules from the current search path to be copied in the store, | |
3590 | compiled, and made available in the load path during the execution of | |
3591 | @var{exp}---e.g., @code{((guix build utils) (guix build | |
3592 | gnu-build-system))}. | |
3593 | ||
3594 | @var{exp} is evaluated in an environment where @code{%outputs} is bound | |
3595 | to a list of output/path pairs, and where @code{%build-inputs} is bound | |
3596 | to a list of string/output-path pairs made from @var{inputs}. | |
3597 | Optionally, @var{env-vars} is a list of string pairs specifying the name | |
3598 | and value of environment variables visible to the builder. The builder | |
3599 | terminates by passing the result of @var{exp} to @code{exit}; thus, when | |
3600 | @var{exp} returns @code{#f}, the build is considered to have failed. | |
3601 | ||
3602 | @var{exp} is built using @var{guile-for-build} (a derivation). When | |
3603 | @var{guile-for-build} is omitted or is @code{#f}, the value of the | |
3604 | @code{%guile-for-build} fluid is used instead. | |
3605 | ||
3606 | See the @code{derivation} procedure for the meaning of | |
35b5ca78 LC |
3607 | @var{references-graphs}, @var{allowed-references}, |
3608 | @var{disallowed-references}, @var{local-build?}, and | |
3609 | @var{substitutable?}. | |
f2fadbc1 AE |
3610 | @end deffn |
3611 | ||
3612 | @noindent | |
3613 | Here's an example of a single-output derivation that creates a directory | |
3614 | containing one file: | |
3615 | ||
3616 | @lisp | |
3617 | (let ((builder '(let ((out (assoc-ref %outputs "out"))) | |
3618 | (mkdir out) ; create /gnu/store/@dots{}-goo | |
3619 | (call-with-output-file (string-append out "/test") | |
3620 | (lambda (p) | |
3621 | (display '(hello guix) p)))))) | |
3622 | (build-expression->derivation store "goo" builder)) | |
3623 | ||
3624 | @result{} #<derivation /gnu/store/@dots{}-goo.drv => @dots{}> | |
3625 | @end lisp | |
3626 | ||
568717fd | 3627 | |
b860f382 LC |
3628 | @node The Store Monad |
3629 | @section The Store Monad | |
3630 | ||
3631 | @cindex monad | |
3632 | ||
3633 | The procedures that operate on the store described in the previous | |
3634 | sections all take an open connection to the build daemon as their first | |
3635 | argument. Although the underlying model is functional, they either have | |
3636 | side effects or depend on the current state of the store. | |
3637 | ||
3638 | The former is inconvenient: the connection to the build daemon has to be | |
3639 | carried around in all those functions, making it impossible to compose | |
3640 | functions that do not take that parameter with functions that do. The | |
3641 | latter can be problematic: since store operations have side effects | |
3642 | and/or depend on external state, they have to be properly sequenced. | |
3643 | ||
3644 | @cindex monadic values | |
3645 | @cindex monadic functions | |
3646 | This is where the @code{(guix monads)} module comes in. This module | |
3647 | provides a framework for working with @dfn{monads}, and a particularly | |
3648 | useful monad for our uses, the @dfn{store monad}. Monads are a | |
3649 | construct that allows two things: associating ``context'' with values | |
3650 | (in our case, the context is the store), and building sequences of | |
4827b36d | 3651 | computations (here computations include accesses to the store). Values |
b860f382 LC |
3652 | in a monad---values that carry this additional context---are called |
3653 | @dfn{monadic values}; procedures that return such values are called | |
3654 | @dfn{monadic procedures}. | |
3655 | ||
3656 | Consider this ``normal'' procedure: | |
3657 | ||
3658 | @example | |
45adbd62 LC |
3659 | (define (sh-symlink store) |
3660 | ;; Return a derivation that symlinks the 'bash' executable. | |
3661 | (let* ((drv (package-derivation store bash)) | |
3662 | (out (derivation->output-path drv)) | |
3663 | (sh (string-append out "/bin/bash"))) | |
3664 | (build-expression->derivation store "sh" | |
3665 | `(symlink ,sh %output)))) | |
b860f382 LC |
3666 | @end example |
3667 | ||
c6f30b81 LC |
3668 | Using @code{(guix monads)} and @code{(guix gexp)}, it may be rewritten |
3669 | as a monadic function: | |
b860f382 LC |
3670 | |
3671 | @example | |
45adbd62 | 3672 | (define (sh-symlink) |
b860f382 | 3673 | ;; Same, but return a monadic value. |
c6f30b81 LC |
3674 | (mlet %store-monad ((drv (package->derivation bash))) |
3675 | (gexp->derivation "sh" | |
3676 | #~(symlink (string-append #$drv "/bin/bash") | |
3677 | #$output)))) | |
b860f382 LC |
3678 | @end example |
3679 | ||
4827b36d | 3680 | There are several things to note in the second version: the @code{store} |
c6f30b81 LC |
3681 | parameter is now implicit and is ``threaded'' in the calls to the |
3682 | @code{package->derivation} and @code{gexp->derivation} monadic | |
3683 | procedures, and the monadic value returned by @code{package->derivation} | |
3684 | is @dfn{bound} using @code{mlet} instead of plain @code{let}. | |
3685 | ||
3686 | As it turns out, the call to @code{package->derivation} can even be | |
3687 | omitted since it will take place implicitly, as we will see later | |
3688 | (@pxref{G-Expressions}): | |
3689 | ||
3690 | @example | |
3691 | (define (sh-symlink) | |
3692 | (gexp->derivation "sh" | |
3693 | #~(symlink (string-append #$bash "/bin/bash") | |
3694 | #$output))) | |
3695 | @end example | |
b860f382 | 3696 | |
7ce21611 | 3697 | @c See |
a01ad638 | 3698 | @c <https://syntaxexclamation.wordpress.com/2014/06/26/escaping-continuations/> |
7ce21611 LC |
3699 | @c for the funny quote. |
3700 | Calling the monadic @code{sh-symlink} has no effect. As someone once | |
3701 | said, ``you exit a monad like you exit a building on fire: by running''. | |
3702 | So, to exit the monad and get the desired effect, one must use | |
3703 | @code{run-with-store}: | |
b860f382 LC |
3704 | |
3705 | @example | |
8e9aa37f CAW |
3706 | (run-with-store (open-connection) (sh-symlink)) |
3707 | @result{} /gnu/store/...-sh-symlink | |
b860f382 LC |
3708 | @end example |
3709 | ||
f97c9175 | 3710 | Note that the @code{(guix monad-repl)} module extends the Guile REPL with |
b9b86078 | 3711 | new ``meta-commands'' to make it easier to deal with monadic procedures: |
f97c9175 | 3712 | @code{run-in-store}, and @code{enter-store-monad}. The former is used |
b9b86078 LC |
3713 | to ``run'' a single monadic value through the store: |
3714 | ||
3715 | @example | |
3716 | scheme@@(guile-user)> ,run-in-store (package->derivation hello) | |
3717 | $1 = #<derivation /gnu/store/@dots{}-hello-2.9.drv => @dots{}> | |
3718 | @end example | |
3719 | ||
3720 | The latter enters a recursive REPL, where all the return values are | |
3721 | automatically run through the store: | |
3722 | ||
3723 | @example | |
3724 | scheme@@(guile-user)> ,enter-store-monad | |
3725 | store-monad@@(guile-user) [1]> (package->derivation hello) | |
3726 | $2 = #<derivation /gnu/store/@dots{}-hello-2.9.drv => @dots{}> | |
3727 | store-monad@@(guile-user) [1]> (text-file "foo" "Hello!") | |
3728 | $3 = "/gnu/store/@dots{}-foo" | |
3729 | store-monad@@(guile-user) [1]> ,q | |
3730 | scheme@@(guile-user)> | |
3731 | @end example | |
3732 | ||
3733 | @noindent | |
3734 | Note that non-monadic values cannot be returned in the | |
3735 | @code{store-monad} REPL. | |
3736 | ||
e87f0591 LC |
3737 | The main syntactic forms to deal with monads in general are provided by |
3738 | the @code{(guix monads)} module and are described below. | |
b860f382 LC |
3739 | |
3740 | @deffn {Scheme Syntax} with-monad @var{monad} @var{body} ... | |
3741 | Evaluate any @code{>>=} or @code{return} forms in @var{body} as being | |
3742 | in @var{monad}. | |
3743 | @end deffn | |
3744 | ||
3745 | @deffn {Scheme Syntax} return @var{val} | |
3746 | Return a monadic value that encapsulates @var{val}. | |
3747 | @end deffn | |
3748 | ||
751630c9 | 3749 | @deffn {Scheme Syntax} >>= @var{mval} @var{mproc} ... |
b860f382 | 3750 | @dfn{Bind} monadic value @var{mval}, passing its ``contents'' to monadic |
751630c9 LC |
3751 | procedures @var{mproc}@dots{}@footnote{This operation is commonly |
3752 | referred to as ``bind'', but that name denotes an unrelated procedure in | |
3753 | Guile. Thus we use this somewhat cryptic symbol inherited from the | |
3754 | Haskell language.}. There can be one @var{mproc} or several of them, as | |
3755 | in this example: | |
3756 | ||
3757 | @example | |
3758 | (run-with-state | |
3759 | (with-monad %state-monad | |
3760 | (>>= (return 1) | |
3761 | (lambda (x) (return (+ 1 x))) | |
3762 | (lambda (x) (return (* 2 x))))) | |
3763 | 'some-state) | |
3764 | ||
3765 | @result{} 4 | |
3766 | @result{} some-state | |
3767 | @end example | |
b860f382 LC |
3768 | @end deffn |
3769 | ||
3770 | @deffn {Scheme Syntax} mlet @var{monad} ((@var{var} @var{mval}) ...) @ | |
3771 | @var{body} ... | |
3772 | @deffnx {Scheme Syntax} mlet* @var{monad} ((@var{var} @var{mval}) ...) @ | |
3773 | @var{body} ... | |
3774 | Bind the variables @var{var} to the monadic values @var{mval} in | |
3775 | @var{body}. The form (@var{var} -> @var{val}) binds @var{var} to the | |
3776 | ``normal'' value @var{val}, as per @code{let}. | |
3777 | ||
3778 | @code{mlet*} is to @code{mlet} what @code{let*} is to @code{let} | |
3779 | (@pxref{Local Bindings,,, guile, GNU Guile Reference Manual}). | |
3780 | @end deffn | |
3781 | ||
405a9d4e LC |
3782 | @deffn {Scheme System} mbegin @var{monad} @var{mexp} ... |
3783 | Bind @var{mexp} and the following monadic expressions in sequence, | |
3784 | returning the result of the last expression. | |
3785 | ||
3786 | This is akin to @code{mlet}, except that the return values of the | |
3787 | monadic expressions are ignored. In that sense, it is analogous to | |
3788 | @code{begin}, but applied to monadic expressions. | |
3789 | @end deffn | |
3790 | ||
561fb6c3 LC |
3791 | @cindex state monad |
3792 | The @code{(guix monads)} module provides the @dfn{state monad}, which | |
3793 | allows an additional value---the state---to be @emph{threaded} through | |
3794 | monadic procedure calls. | |
3795 | ||
3796 | @defvr {Scheme Variable} %state-monad | |
3797 | The state monad. Procedures in the state monad can access and change | |
3798 | the state that is threaded. | |
3799 | ||
3800 | Consider the example below. The @code{square} procedure returns a value | |
3801 | in the state monad. It returns the square of its argument, but also | |
3802 | increments the current state value: | |
3803 | ||
3804 | @example | |
3805 | (define (square x) | |
3806 | (mlet %state-monad ((count (current-state))) | |
3807 | (mbegin %state-monad | |
3808 | (set-current-state (+ 1 count)) | |
3809 | (return (* x x))))) | |
3810 | ||
3811 | (run-with-state (sequence %state-monad (map square (iota 3))) 0) | |
3812 | @result{} (0 1 4) | |
3813 | @result{} 3 | |
3814 | @end example | |
3815 | ||
3816 | When ``run'' through @var{%state-monad}, we obtain that additional state | |
3817 | value, which is the number of @code{square} calls. | |
3818 | @end defvr | |
3819 | ||
3820 | @deffn {Monadic Procedure} current-state | |
3821 | Return the current state as a monadic value. | |
3822 | @end deffn | |
3823 | ||
3824 | @deffn {Monadic Procedure} set-current-state @var{value} | |
3825 | Set the current state to @var{value} and return the previous state as a | |
3826 | monadic value. | |
3827 | @end deffn | |
3828 | ||
3829 | @deffn {Monadic Procedure} state-push @var{value} | |
3830 | Push @var{value} to the current state, which is assumed to be a list, | |
3831 | and return the previous state as a monadic value. | |
3832 | @end deffn | |
3833 | ||
3834 | @deffn {Monadic Procedure} state-pop | |
3835 | Pop a value from the current state and return it as a monadic value. | |
3836 | The state is assumed to be a list. | |
3837 | @end deffn | |
3838 | ||
3839 | @deffn {Scheme Procedure} run-with-state @var{mval} [@var{state}] | |
3840 | Run monadic value @var{mval} starting with @var{state} as the initial | |
3841 | state. Return two values: the resulting value, and the resulting state. | |
3842 | @end deffn | |
3843 | ||
e87f0591 LC |
3844 | The main interface to the store monad, provided by the @code{(guix |
3845 | store)} module, is as follows. | |
b860f382 LC |
3846 | |
3847 | @defvr {Scheme Variable} %store-monad | |
561fb6c3 LC |
3848 | The store monad---an alias for @var{%state-monad}. |
3849 | ||
3850 | Values in the store monad encapsulate accesses to the store. When its | |
3851 | effect is needed, a value of the store monad must be ``evaluated'' by | |
3852 | passing it to the @code{run-with-store} procedure (see below.) | |
b860f382 LC |
3853 | @end defvr |
3854 | ||
3855 | @deffn {Scheme Procedure} run-with-store @var{store} @var{mval} [#:guile-for-build] [#:system (%current-system)] | |
3856 | Run @var{mval}, a monadic value in the store monad, in @var{store}, an | |
3857 | open store connection. | |
3858 | @end deffn | |
3859 | ||
ad372953 | 3860 | @deffn {Monadic Procedure} text-file @var{name} @var{text} [@var{references}] |
b860f382 | 3861 | Return as a monadic value the absolute file name in the store of the file |
ad372953 LC |
3862 | containing @var{text}, a string. @var{references} is a list of store items that the |
3863 | resulting text file refers to; it defaults to the empty list. | |
45adbd62 LC |
3864 | @end deffn |
3865 | ||
0a90af15 | 3866 | @deffn {Monadic Procedure} interned-file @var{file} [@var{name}] @ |
1ec32f4a | 3867 | [#:recursive? #t] [#:select? (const #t)] |
0a90af15 LC |
3868 | Return the name of @var{file} once interned in the store. Use |
3869 | @var{name} as its store name, or the basename of @var{file} if | |
3870 | @var{name} is omitted. | |
3871 | ||
3872 | When @var{recursive?} is true, the contents of @var{file} are added | |
3873 | recursively; if @var{file} designates a flat file and @var{recursive?} | |
3874 | is true, its contents are added, and its permission bits are kept. | |
3875 | ||
1ec32f4a LC |
3876 | When @var{recursive?} is true, call @code{(@var{select?} @var{file} |
3877 | @var{stat})} for each directory entry, where @var{file} is the entry's | |
3878 | absolute file name and @var{stat} is the result of @code{lstat}; exclude | |
3879 | entries for which @var{select?} does not return true. | |
3880 | ||
0a90af15 LC |
3881 | The example below adds a file to the store, under two different names: |
3882 | ||
3883 | @example | |
3884 | (run-with-store (open-connection) | |
3885 | (mlet %store-monad ((a (interned-file "README")) | |
3886 | (b (interned-file "README" "LEGU-MIN"))) | |
3887 | (return (list a b)))) | |
3888 | ||
3889 | @result{} ("/gnu/store/rwm@dots{}-README" "/gnu/store/44i@dots{}-LEGU-MIN") | |
3890 | @end example | |
3891 | ||
3892 | @end deffn | |
3893 | ||
e87f0591 LC |
3894 | The @code{(guix packages)} module exports the following package-related |
3895 | monadic procedures: | |
3896 | ||
b860f382 | 3897 | @deffn {Monadic Procedure} package-file @var{package} [@var{file}] @ |
4231f05b | 3898 | [#:system (%current-system)] [#:target #f] @ |
f97c9175 AE |
3899 | [#:output "out"] |
3900 | Return as a monadic | |
b860f382 LC |
3901 | value in the absolute file name of @var{file} within the @var{output} |
3902 | directory of @var{package}. When @var{file} is omitted, return the name | |
4231f05b LC |
3903 | of the @var{output} directory of @var{package}. When @var{target} is |
3904 | true, use it as a cross-compilation target triplet. | |
b860f382 LC |
3905 | @end deffn |
3906 | ||
b860f382 | 3907 | @deffn {Monadic Procedure} package->derivation @var{package} [@var{system}] |
4231f05b LC |
3908 | @deffnx {Monadic Procedure} package->cross-derivation @var{package} @ |
3909 | @var{target} [@var{system}] | |
3910 | Monadic version of @code{package-derivation} and | |
3911 | @code{package-cross-derivation} (@pxref{Defining Packages}). | |
b860f382 LC |
3912 | @end deffn |
3913 | ||
3914 | ||
21b679f6 LC |
3915 | @node G-Expressions |
3916 | @section G-Expressions | |
3917 | ||
3918 | @cindex G-expression | |
3919 | @cindex build code quoting | |
3920 | So we have ``derivations'', which represent a sequence of build actions | |
3921 | to be performed to produce an item in the store (@pxref{Derivations}). | |
f97c9175 | 3922 | These build actions are performed when asking the daemon to actually |
21b679f6 LC |
3923 | build the derivations; they are run by the daemon in a container |
3924 | (@pxref{Invoking guix-daemon}). | |
3925 | ||
3926 | @cindex strata of code | |
f97c9175 | 3927 | It should come as no surprise that we like to write these build actions |
21b679f6 LC |
3928 | in Scheme. When we do that, we end up with two @dfn{strata} of Scheme |
3929 | code@footnote{The term @dfn{stratum} in this context was coined by | |
ef4ab0a4 LC |
3930 | Manuel Serrano et al.@: in the context of their work on Hop. Oleg |
3931 | Kiselyov, who has written insightful | |
3932 | @url{http://okmij.org/ftp/meta-programming/#meta-scheme, essays and code | |
3933 | on this topic}, refers to this kind of code generation as | |
3934 | @dfn{staging}.}: the ``host code''---code that defines packages, talks | |
3935 | to the daemon, etc.---and the ``build code''---code that actually | |
3936 | performs build actions, such as making directories, invoking | |
3937 | @command{make}, etc. | |
21b679f6 LC |
3938 | |
3939 | To describe a derivation and its build actions, one typically needs to | |
3940 | embed build code inside host code. It boils down to manipulating build | |
f97c9175 | 3941 | code as data, and the homoiconicity of Scheme---code has a direct |
21b679f6 | 3942 | representation as data---comes in handy for that. But we need more than |
f97c9175 | 3943 | the normal @code{quasiquote} mechanism in Scheme to construct build |
21b679f6 LC |
3944 | expressions. |
3945 | ||
3946 | The @code{(guix gexp)} module implements @dfn{G-expressions}, a form of | |
3947 | S-expressions adapted to build expressions. G-expressions, or | |
f97c9175 | 3948 | @dfn{gexps}, consist essentially of three syntactic forms: @code{gexp}, |
21b679f6 | 3949 | @code{ungexp}, and @code{ungexp-splicing} (or simply: @code{#~}, |
f97c9175 AE |
3950 | @code{#$}, and @code{#$@@}), which are comparable to |
3951 | @code{quasiquote}, @code{unquote}, and @code{unquote-splicing}, | |
4827b36d | 3952 | respectively (@pxref{Expression Syntax, @code{quasiquote},, guile, |
f97c9175 | 3953 | GNU Guile Reference Manual}). However, there are major differences: |
21b679f6 LC |
3954 | |
3955 | @itemize | |
3956 | @item | |
3957 | Gexps are meant to be written to a file and run or manipulated by other | |
3958 | processes. | |
3959 | ||
3960 | @item | |
b39fc6f7 LC |
3961 | When a high-level object such as a package or derivation is unquoted |
3962 | inside a gexp, the result is as if its output file name had been | |
3963 | introduced. | |
ff40e9b7 | 3964 | |
21b679f6 LC |
3965 | @item |
3966 | Gexps carry information about the packages or derivations they refer to, | |
3967 | and these dependencies are automatically added as inputs to the build | |
3968 | processes that use them. | |
3969 | @end itemize | |
3970 | ||
c2b84676 | 3971 | @cindex lowering, of high-level objects in gexps |
343eacbe LC |
3972 | This mechanism is not limited to package and derivation |
3973 | objects: @dfn{compilers} able to ``lower'' other high-level objects to | |
c2b84676 LC |
3974 | derivations or files in the store can be defined, |
3975 | such that these objects can also be inserted | |
f97c9175 | 3976 | into gexps. For example, a useful type of high-level objects that can be |
343eacbe | 3977 | inserted in a gexp is ``file-like objects'', which make it easy to |
f97c9175 | 3978 | add files to the store and to refer to them in |
558e8b11 LC |
3979 | derivations and such (see @code{local-file} and @code{plain-file} |
3980 | below.) | |
b39fc6f7 | 3981 | |
21b679f6 LC |
3982 | To illustrate the idea, here is an example of a gexp: |
3983 | ||
3984 | @example | |
3985 | (define build-exp | |
3986 | #~(begin | |
3987 | (mkdir #$output) | |
3988 | (chdir #$output) | |
aff8ce7c | 3989 | (symlink (string-append #$coreutils "/bin/ls") |
21b679f6 LC |
3990 | "list-files"))) |
3991 | @end example | |
3992 | ||
3993 | This gexp can be passed to @code{gexp->derivation}; we obtain a | |
3994 | derivation that builds a directory containing exactly one symlink to | |
3995 | @file{/gnu/store/@dots{}-coreutils-8.22/bin/ls}: | |
3996 | ||
3997 | @example | |
3998 | (gexp->derivation "the-thing" build-exp) | |
3999 | @end example | |
4000 | ||
e20fd1bf | 4001 | As one would expect, the @code{"/gnu/store/@dots{}-coreutils-8.22"} string is |
21b679f6 LC |
4002 | substituted to the reference to the @var{coreutils} package in the |
4003 | actual build code, and @var{coreutils} is automatically made an input to | |
4004 | the derivation. Likewise, @code{#$output} (equivalent to @code{(ungexp | |
f97c9175 AE |
4005 | output)}) is replaced by a string containing the directory name of the |
4006 | output of the derivation. | |
667b2508 LC |
4007 | |
4008 | @cindex cross compilation | |
4009 | In a cross-compilation context, it is useful to distinguish between | |
4010 | references to the @emph{native} build of a package---that can run on the | |
4011 | host---versus references to cross builds of a package. To that end, the | |
4012 | @code{#+} plays the same role as @code{#$}, but is a reference to a | |
4013 | native package build: | |
4014 | ||
4015 | @example | |
4016 | (gexp->derivation "vi" | |
4017 | #~(begin | |
4018 | (mkdir #$output) | |
4019 | (system* (string-append #+coreutils "/bin/ln") | |
4020 | "-s" | |
4021 | (string-append #$emacs "/bin/emacs") | |
4022 | (string-append #$output "/bin/vi"))) | |
4a3b6aa5 | 4023 | #:target "mips64el-linux-gnu") |
667b2508 LC |
4024 | @end example |
4025 | ||
4026 | @noindent | |
4027 | In the example above, the native build of @var{coreutils} is used, so | |
4028 | that @command{ln} can actually run on the host; but then the | |
4029 | cross-compiled build of @var{emacs} is referenced. | |
4030 | ||
0bb9929e LC |
4031 | @cindex imported modules, for gexps |
4032 | @findex with-imported-modules | |
4033 | Another gexp feature is @dfn{imported modules}: sometimes you want to be | |
4034 | able to use certain Guile modules from the ``host environment'' in the | |
4035 | gexp, so those modules should be imported in the ``build environment''. | |
4036 | The @code{with-imported-modules} form allows you to express that: | |
4037 | ||
4038 | @example | |
4039 | (let ((build (with-imported-modules '((guix build utils)) | |
4040 | #~(begin | |
4041 | (use-modules (guix build utils)) | |
4042 | (mkdir-p (string-append #$output "/bin")))))) | |
4043 | (gexp->derivation "empty-dir" | |
4044 | #~(begin | |
4045 | #$build | |
4046 | (display "success!\n") | |
4047 | #t))) | |
4048 | @end example | |
4049 | ||
4050 | @noindent | |
4051 | In this example, the @code{(guix build utils)} module is automatically | |
4052 | pulled into the isolated build environment of our gexp, such that | |
4053 | @code{(use-modules (guix build utils))} works as expected. | |
4054 | ||
7ca87354 LC |
4055 | @cindex module closure |
4056 | @findex source-module-closure | |
4057 | Usually you want the @emph{closure} of the module to be imported---i.e., | |
4058 | the module itself and all the modules it depends on---rather than just | |
4059 | the module; failing to do that, attempts to use the module will fail | |
4060 | because of missing dependent modules. The @code{source-module-closure} | |
4061 | procedure computes the closure of a module by looking at its source file | |
4062 | headers, which comes in handy in this case: | |
4063 | ||
4064 | @example | |
4065 | (use-modules (guix modules)) ;for 'source-module-closure' | |
4066 | ||
4067 | (with-imported-modules (source-module-closure | |
4068 | '((guix build utils) | |
4069 | (gnu build vm))) | |
4070 | (gexp->derivation "something-with-vms" | |
4071 | #~(begin | |
4072 | (use-modules (guix build utils) | |
4073 | (gnu build vm)) | |
4074 | @dots{}))) | |
4075 | @end example | |
4076 | ||
667b2508 | 4077 | The syntactic form to construct gexps is summarized below. |
21b679f6 LC |
4078 | |
4079 | @deffn {Scheme Syntax} #~@var{exp} | |
4080 | @deffnx {Scheme Syntax} (gexp @var{exp}) | |
4081 | Return a G-expression containing @var{exp}. @var{exp} may contain one | |
4082 | or more of the following forms: | |
4083 | ||
4084 | @table @code | |
4085 | @item #$@var{obj} | |
4086 | @itemx (ungexp @var{obj}) | |
b39fc6f7 LC |
4087 | Introduce a reference to @var{obj}. @var{obj} may have one of the |
4088 | supported types, for example a package or a | |
21b679f6 LC |
4089 | derivation, in which case the @code{ungexp} form is replaced by its |
4090 | output file name---e.g., @code{"/gnu/store/@dots{}-coreutils-8.22}. | |
4091 | ||
b39fc6f7 LC |
4092 | If @var{obj} is a list, it is traversed and references to supported |
4093 | objects are substituted similarly. | |
21b679f6 LC |
4094 | |
4095 | If @var{obj} is another gexp, its contents are inserted and its | |
4096 | dependencies are added to those of the containing gexp. | |
4097 | ||
4098 | If @var{obj} is another kind of object, it is inserted as is. | |
4099 | ||
b39fc6f7 LC |
4100 | @item #$@var{obj}:@var{output} |
4101 | @itemx (ungexp @var{obj} @var{output}) | |
21b679f6 | 4102 | This is like the form above, but referring explicitly to the |
b39fc6f7 LC |
4103 | @var{output} of @var{obj}---this is useful when @var{obj} produces |
4104 | multiple outputs (@pxref{Packages with Multiple Outputs}). | |
21b679f6 | 4105 | |
667b2508 LC |
4106 | @item #+@var{obj} |
4107 | @itemx #+@var{obj}:output | |
4108 | @itemx (ungexp-native @var{obj}) | |
4109 | @itemx (ungexp-native @var{obj} @var{output}) | |
4110 | Same as @code{ungexp}, but produces a reference to the @emph{native} | |
4111 | build of @var{obj} when used in a cross compilation context. | |
4112 | ||
21b679f6 LC |
4113 | @item #$output[:@var{output}] |
4114 | @itemx (ungexp output [@var{output}]) | |
4115 | Insert a reference to derivation output @var{output}, or to the main | |
4116 | output when @var{output} is omitted. | |
4117 | ||
4118 | This only makes sense for gexps passed to @code{gexp->derivation}. | |
4119 | ||
4120 | @item #$@@@var{lst} | |
4121 | @itemx (ungexp-splicing @var{lst}) | |
4122 | Like the above, but splices the contents of @var{lst} inside the | |
4123 | containing list. | |
4124 | ||
667b2508 LC |
4125 | @item #+@@@var{lst} |
4126 | @itemx (ungexp-native-splicing @var{lst}) | |
4127 | Like the above, but refers to native builds of the objects listed in | |
4128 | @var{lst}. | |
4129 | ||
21b679f6 LC |
4130 | @end table |
4131 | ||
4132 | G-expressions created by @code{gexp} or @code{#~} are run-time objects | |
4133 | of the @code{gexp?} type (see below.) | |
4134 | @end deffn | |
4135 | ||
0bb9929e LC |
4136 | @deffn {Scheme Syntax} with-imported-modules @var{modules} @var{body}@dots{} |
4137 | Mark the gexps defined in @var{body}@dots{} as requiring @var{modules} | |
4138 | in their execution environment. @var{modules} must be a list of Guile | |
4139 | module names, such as @code{'((guix build utils) (guix build gremlin))}. | |
4140 | ||
4141 | This form has @emph{lexical} scope: it has an effect on the gexps | |
4142 | directly defined in @var{body}@dots{}, but not on those defined, say, in | |
4143 | procedures called from @var{body}@dots{}. | |
4144 | @end deffn | |
4145 | ||
21b679f6 LC |
4146 | @deffn {Scheme Procedure} gexp? @var{obj} |
4147 | Return @code{#t} if @var{obj} is a G-expression. | |
4148 | @end deffn | |
4149 | ||
4150 | G-expressions are meant to be written to disk, either as code building | |
4151 | some derivation, or as plain files in the store. The monadic procedures | |
4152 | below allow you to do that (@pxref{The Store Monad}, for more | |
4153 | information about monads.) | |
4154 | ||
4155 | @deffn {Monadic Procedure} gexp->derivation @var{name} @var{exp} @ | |
ce45eb4c | 4156 | [#:system (%current-system)] [#:target #f] [#:graft? #t] @ |
21b679f6 LC |
4157 | [#:hash #f] [#:hash-algo #f] @ |
4158 | [#:recursive? #f] [#:env-vars '()] [#:modules '()] @ | |
4684f301 | 4159 | [#:module-path @var{%load-path}] @ |
c8351d9a | 4160 | [#:references-graphs #f] [#:allowed-references #f] @ |
3f4ecf32 | 4161 | [#:disallowed-references #f] @ |
c0468155 | 4162 | [#:leaked-env-vars #f] @ |
0309e1b0 | 4163 | [#:script-name (string-append @var{name} "-builder")] @ |
4a6aeb67 | 4164 | [#:local-build? #f] [#:substitutable? #t] [#:guile-for-build #f] |
21b679f6 | 4165 | Return a derivation @var{name} that runs @var{exp} (a gexp) with |
0309e1b0 LC |
4166 | @var{guile-for-build} (a derivation) on @var{system}; @var{exp} is |
4167 | stored in a file called @var{script-name}. When @var{target} is true, | |
4168 | it is used as the cross-compilation target triplet for packages referred | |
4169 | to by @var{exp}. | |
21b679f6 | 4170 | |
0bb9929e LC |
4171 | @var{modules} is deprecated in favor of @code{with-imported-modules}. |
4172 | Its meaning is to | |
4173 | make @var{modules} available in the evaluation context of @var{exp}; | |
ce45eb4c LC |
4174 | @var{modules} is a list of names of Guile modules searched in |
4175 | @var{module-path} to be copied in the store, compiled, and made available in | |
21b679f6 LC |
4176 | the load path during the execution of @var{exp}---e.g., @code{((guix |
4177 | build utils) (guix build gnu-build-system))}. | |
4178 | ||
ce45eb4c LC |
4179 | @var{graft?} determines whether packages referred to by @var{exp} should be grafted when |
4180 | applicable. | |
4181 | ||
b53833b2 LC |
4182 | When @var{references-graphs} is true, it must be a list of tuples of one of the |
4183 | following forms: | |
4184 | ||
4185 | @example | |
4186 | (@var{file-name} @var{package}) | |
4187 | (@var{file-name} @var{package} @var{output}) | |
4188 | (@var{file-name} @var{derivation}) | |
4189 | (@var{file-name} @var{derivation} @var{output}) | |
4190 | (@var{file-name} @var{store-item}) | |
4191 | @end example | |
4192 | ||
4193 | The right-hand-side of each element of @var{references-graphs} is automatically made | |
4194 | an input of the build process of @var{exp}. In the build environment, each | |
4195 | @var{file-name} contains the reference graph of the corresponding item, in a simple | |
4196 | text format. | |
4197 | ||
c8351d9a LC |
4198 | @var{allowed-references} must be either @code{#f} or a list of output names and packages. |
4199 | In the latter case, the list denotes store items that the result is allowed to | |
4200 | refer to. Any reference to another store item will lead to a build error. | |
3f4ecf32 LC |
4201 | Similarly for @var{disallowed-references}, which can list items that must not be |
4202 | referenced by the outputs. | |
c8351d9a | 4203 | |
e20fd1bf | 4204 | The other arguments are as for @code{derivation} (@pxref{Derivations}). |
21b679f6 LC |
4205 | @end deffn |
4206 | ||
343eacbe | 4207 | @cindex file-like objects |
e1c153e0 LC |
4208 | The @code{local-file}, @code{plain-file}, @code{computed-file}, |
4209 | @code{program-file}, and @code{scheme-file} procedures below return | |
4210 | @dfn{file-like objects}. That is, when unquoted in a G-expression, | |
4211 | these objects lead to a file in the store. Consider this G-expression: | |
343eacbe LC |
4212 | |
4213 | @example | |
a9e5e92f | 4214 | #~(system* #$(file-append glibc "/sbin/nscd") "-f" |
343eacbe LC |
4215 | #$(local-file "/tmp/my-nscd.conf")) |
4216 | @end example | |
4217 | ||
4218 | The effect here is to ``intern'' @file{/tmp/my-nscd.conf} by copying it | |
4219 | to the store. Once expanded, for instance @i{via} | |
4220 | @code{gexp->derivation}, the G-expression refers to that copy under | |
4221 | @file{/gnu/store}; thus, modifying or removing the file in @file{/tmp} | |
4222 | does not have any effect on what the G-expression does. | |
4223 | @code{plain-file} can be used similarly; it differs in that the file | |
4224 | content is directly passed as a string. | |
4225 | ||
d9ae938f | 4226 | @deffn {Scheme Procedure} local-file @var{file} [@var{name}] @ |
0687fc9c | 4227 | [#:recursive? #f] [#:select? (const #t)] |
d9ae938f | 4228 | Return an object representing local file @var{file} to add to the store; this |
9d3994f7 LC |
4229 | object can be used in a gexp. If @var{file} is a relative file name, it is looked |
4230 | up relative to the source file where this form appears. @var{file} will be added to | |
4231 | the store under @var{name}--by default the base name of @var{file}. | |
d9ae938f LC |
4232 | |
4233 | When @var{recursive?} is true, the contents of @var{file} are added recursively; if @var{file} | |
4234 | designates a flat file and @var{recursive?} is true, its contents are added, and its | |
4235 | permission bits are kept. | |
4236 | ||
0687fc9c LC |
4237 | When @var{recursive?} is true, call @code{(@var{select?} @var{file} |
4238 | @var{stat})} for each directory entry, where @var{file} is the entry's | |
4239 | absolute file name and @var{stat} is the result of @code{lstat}; exclude | |
4240 | entries for which @var{select?} does not return true. | |
4241 | ||
d9ae938f LC |
4242 | This is the declarative counterpart of the @code{interned-file} monadic |
4243 | procedure (@pxref{The Store Monad, @code{interned-file}}). | |
4244 | @end deffn | |
4245 | ||
558e8b11 LC |
4246 | @deffn {Scheme Procedure} plain-file @var{name} @var{content} |
4247 | Return an object representing a text file called @var{name} with the given | |
4248 | @var{content} (a string) to be added to the store. | |
4249 | ||
4250 | This is the declarative counterpart of @code{text-file}. | |
4251 | @end deffn | |
4252 | ||
91937029 | 4253 | @deffn {Scheme Procedure} computed-file @var{name} @var{gexp} @ |
a769bffb | 4254 | [#:options '(#:local-build? #t)] |
91937029 | 4255 | Return an object representing the store item @var{name}, a file or |
a769bffb | 4256 | directory computed by @var{gexp}. @var{options} |
91937029 LC |
4257 | is a list of additional arguments to pass to @code{gexp->derivation}. |
4258 | ||
4259 | This is the declarative counterpart of @code{gexp->derivation}. | |
4260 | @end deffn | |
4261 | ||
21b679f6 LC |
4262 | @deffn {Monadic Procedure} gexp->script @var{name} @var{exp} |
4263 | Return an executable script @var{name} that runs @var{exp} using | |
9c14a487 | 4264 | @var{guile}, with @var{exp}'s imported modules in its search path. |
21b679f6 LC |
4265 | |
4266 | The example below builds a script that simply invokes the @command{ls} | |
4267 | command: | |
4268 | ||
4269 | @example | |
4270 | (use-modules (guix gexp) (gnu packages base)) | |
4271 | ||
4272 | (gexp->script "list-files" | |
a9e5e92f | 4273 | #~(execl #$(file-append coreutils "/bin/ls") |
21b679f6 LC |
4274 | "ls")) |
4275 | @end example | |
4276 | ||
4277 | When ``running'' it through the store (@pxref{The Store Monad, | |
e20fd1bf | 4278 | @code{run-with-store}}), we obtain a derivation that produces an |
21b679f6 LC |
4279 | executable file @file{/gnu/store/@dots{}-list-files} along these lines: |
4280 | ||
4281 | @example | |
4282 | #!/gnu/store/@dots{}-guile-2.0.11/bin/guile -ds | |
4283 | !# | |
a9e5e92f | 4284 | (execl "/gnu/store/@dots{}-coreutils-8.22"/bin/ls" "ls") |
21b679f6 LC |
4285 | @end example |
4286 | @end deffn | |
4287 | ||
15a01c72 | 4288 | @deffn {Scheme Procedure} program-file @var{name} @var{exp} @ |
9c14a487 | 4289 | [#:guile #f] |
15a01c72 LC |
4290 | Return an object representing the executable store item @var{name} that |
4291 | runs @var{gexp}. @var{guile} is the Guile package used to execute that | |
9c14a487 | 4292 | script. |
15a01c72 LC |
4293 | |
4294 | This is the declarative counterpart of @code{gexp->script}. | |
4295 | @end deffn | |
4296 | ||
2b418579 LC |
4297 | @deffn {Monadic Procedure} gexp->file @var{name} @var{exp} @ |
4298 | [#:set-load-path? #t] | |
21b679f6 | 4299 | Return a derivation that builds a file @var{name} containing @var{exp}. |
2b418579 LC |
4300 | When @var{set-load-path?} is true, emit code in the resulting file to |
4301 | set @code{%load-path} and @code{%load-compiled-path} to honor | |
4302 | @var{exp}'s imported modules. | |
21b679f6 LC |
4303 | |
4304 | The resulting file holds references to all the dependencies of @var{exp} | |
4305 | or a subset thereof. | |
4306 | @end deffn | |
1ed19464 | 4307 | |
e1c153e0 LC |
4308 | @deffn {Scheme Procedure} scheme-file @var{name} @var{exp} |
4309 | Return an object representing the Scheme file @var{name} that contains | |
4310 | @var{exp}. | |
4311 | ||
4312 | This is the declarative counterpart of @code{gexp->file}. | |
4313 | @end deffn | |
4314 | ||
1ed19464 LC |
4315 | @deffn {Monadic Procedure} text-file* @var{name} @var{text} @dots{} |
4316 | Return as a monadic value a derivation that builds a text file | |
4317 | containing all of @var{text}. @var{text} may list, in addition to | |
d9ae938f LC |
4318 | strings, objects of any type that can be used in a gexp: packages, |
4319 | derivations, local file objects, etc. The resulting store file holds | |
4320 | references to all these. | |
1ed19464 LC |
4321 | |
4322 | This variant should be preferred over @code{text-file} anytime the file | |
4323 | to create will reference items from the store. This is typically the | |
4324 | case when building a configuration file that embeds store file names, | |
4325 | like this: | |
4326 | ||
4327 | @example | |
4328 | (define (profile.sh) | |
4329 | ;; Return the name of a shell script in the store that | |
4330 | ;; initializes the 'PATH' environment variable. | |
4331 | (text-file* "profile.sh" | |
4332 | "export PATH=" coreutils "/bin:" | |
4333 | grep "/bin:" sed "/bin\n")) | |
4334 | @end example | |
4335 | ||
4336 | In this example, the resulting @file{/gnu/store/@dots{}-profile.sh} file | |
b7899749 | 4337 | will reference @var{coreutils}, @var{grep}, and @var{sed}, thereby |
1ed19464 LC |
4338 | preventing them from being garbage-collected during its lifetime. |
4339 | @end deffn | |
21b679f6 | 4340 | |
b751cde3 LC |
4341 | @deffn {Scheme Procedure} mixed-text-file @var{name} @var{text} @dots{} |
4342 | Return an object representing store file @var{name} containing | |
4343 | @var{text}. @var{text} is a sequence of strings and file-like objects, | |
4344 | as in: | |
4345 | ||
4346 | @example | |
4347 | (mixed-text-file "profile" | |
4348 | "export PATH=" coreutils "/bin:" grep "/bin") | |
4349 | @end example | |
4350 | ||
4351 | This is the declarative counterpart of @code{text-file*}. | |
4352 | @end deffn | |
4353 | ||
a9e5e92f LC |
4354 | @deffn {Scheme Procedure} file-append @var{obj} @var{suffix} @dots{} |
4355 | Return a file-like object that expands to the concatenation of @var{obj} | |
4356 | and @var{suffix}, where @var{obj} is a lowerable object and each | |
4357 | @var{suffix} is a string. | |
4358 | ||
4359 | As an example, consider this gexp: | |
4360 | ||
4361 | @example | |
4362 | (gexp->script "run-uname" | |
4363 | #~(system* #$(file-append coreutils | |
4364 | "/bin/uname"))) | |
4365 | @end example | |
4366 | ||
4367 | The same effect could be achieved with: | |
4368 | ||
4369 | @example | |
4370 | (gexp->script "run-uname" | |
4371 | #~(system* (string-append #$coreutils | |
4372 | "/bin/uname"))) | |
4373 | @end example | |
4374 | ||
4375 | There is one difference though: in the @code{file-append} case, the | |
4376 | resulting script contains the absolute file name as a string, whereas in | |
4377 | the second case, the resulting script contains a @code{(string-append | |
4378 | @dots{})} expression to construct the file name @emph{at run time}. | |
4379 | @end deffn | |
4380 | ||
4381 | ||
21b679f6 LC |
4382 | Of course, in addition to gexps embedded in ``host'' code, there are |
4383 | also modules containing build tools. To make it clear that they are | |
4384 | meant to be used in the build stratum, these modules are kept in the | |
4385 | @code{(guix build @dots{})} name space. | |
4386 | ||
c2b84676 LC |
4387 | @cindex lowering, of high-level objects in gexps |
4388 | Internally, high-level objects are @dfn{lowered}, using their compiler, | |
4389 | to either derivations or store items. For instance, lowering a package | |
4390 | yields a derivation, and lowering a @code{plain-file} yields a store | |
4391 | item. This is achieved using the @code{lower-object} monadic procedure. | |
4392 | ||
4393 | @deffn {Monadic Procedure} lower-object @var{obj} [@var{system}] @ | |
4394 | [#:target #f] | |
4395 | Return as a value in @var{%store-monad} the derivation or store item | |
4396 | corresponding to @var{obj} for @var{system}, cross-compiling for | |
4397 | @var{target} if @var{target} is true. @var{obj} must be an object that | |
4398 | has an associated gexp compiler, such as a @code{<package>}. | |
4399 | @end deffn | |
4400 | ||
21b679f6 | 4401 | |
568717fd LC |
4402 | @c ********************************************************************* |
4403 | @node Utilities | |
4404 | @chapter Utilities | |
4405 | ||
6f773606 LC |
4406 | This section describes Guix command-line utilities. Some of them are |
4407 | primarily targeted at developers and users who write new package | |
4408 | definitions, while others are more generally useful. They complement | |
4409 | the Scheme programming interface of Guix in a convenient way. | |
210cc920 | 4410 | |
568717fd | 4411 | @menu |
37166310 | 4412 | * Invoking guix build:: Building packages from the command line. |
39bee8a2 | 4413 | * Invoking guix edit:: Editing package definitions. |
210cc920 | 4414 | * Invoking guix download:: Downloading a file and printing its hash. |
37166310 | 4415 | * Invoking guix hash:: Computing the cryptographic hash of a file. |
2f7d2d91 | 4416 | * Invoking guix import:: Importing package definitions. |
37166310 | 4417 | * Invoking guix refresh:: Updating package definitions. |
b4f5e0e8 | 4418 | * Invoking guix lint:: Finding errors in package definitions. |
fcc58db6 | 4419 | * Invoking guix size:: Profiling disk usage. |
88856916 | 4420 | * Invoking guix graph:: Visualizing the graph of packages. |
372c4bbc | 4421 | * Invoking guix environment:: Setting up development environments. |
aff8ce7c | 4422 | * Invoking guix publish:: Sharing substitutes. |
d23c20f1 | 4423 | * Invoking guix challenge:: Challenging substitute servers. |
f11c444d | 4424 | * Invoking guix copy:: Copying to and from a remote store. |
32efa254 | 4425 | * Invoking guix container:: Process isolation. |
568717fd LC |
4426 | @end menu |
4427 | ||
e49951eb MW |
4428 | @node Invoking guix build |
4429 | @section Invoking @command{guix build} | |
568717fd | 4430 | |
e32171ee JD |
4431 | @cindex package building |
4432 | @cindex @command{guix build} | |
e49951eb | 4433 | The @command{guix build} command builds packages or derivations and |
6798a8e4 LC |
4434 | their dependencies, and prints the resulting store paths. Note that it |
4435 | does not modify the user's profile---this is the job of the | |
e49951eb | 4436 | @command{guix package} command (@pxref{Invoking guix package}). Thus, |
6798a8e4 LC |
4437 | it is mainly useful for distribution developers. |
4438 | ||
4439 | The general syntax is: | |
c78bd12b LC |
4440 | |
4441 | @example | |
e49951eb | 4442 | guix build @var{options} @var{package-or-derivation}@dots{} |
c78bd12b LC |
4443 | @end example |
4444 | ||
f97c9175 | 4445 | As an example, the following command builds the latest versions of Emacs |
ccd7158d LC |
4446 | and of Guile, displays their build logs, and finally displays the |
4447 | resulting directories: | |
4448 | ||
4449 | @example | |
4450 | guix build emacs guile | |
4451 | @end example | |
4452 | ||
4453 | Similarly, the following command builds all the available packages: | |
4454 | ||
4455 | @example | |
5284339d | 4456 | guix build --quiet --keep-going \ |
ccd7158d LC |
4457 | `guix package -A | cut -f1,2 --output-delimiter=@@` |
4458 | @end example | |
4459 | ||
c78bd12b | 4460 | @var{package-or-derivation} may be either the name of a package found in |
5401dd75 LC |
4461 | the software distribution such as @code{coreutils} or |
4462 | @code{coreutils-8.20}, or a derivation such as | |
834129e0 | 4463 | @file{/gnu/store/@dots{}-coreutils-8.19.drv}. In the former case, a |
e7f34eb0 LC |
4464 | package with the corresponding name (and optionally version) is searched |
4465 | for among the GNU distribution modules (@pxref{Package Modules}). | |
4466 | ||
4467 | Alternatively, the @code{--expression} option may be used to specify a | |
4468 | Scheme expression that evaluates to a package; this is useful when | |
b7899749 | 4469 | disambiguating among several same-named packages or package variants is |
e7f34eb0 | 4470 | needed. |
c78bd12b | 4471 | |
ccd7158d LC |
4472 | There may be zero or more @var{options}. The available options are |
4473 | described in the subsections below. | |
4474 | ||
4475 | @menu | |
4476 | * Common Build Options:: Build options for most commands. | |
f11c444d | 4477 | * Package Transformation Options:: Creating variants of packages. |
ccd7158d LC |
4478 | * Additional Build Options:: Options specific to 'guix build'. |
4479 | @end menu | |
4480 | ||
4481 | @node Common Build Options | |
4482 | @subsection Common Build Options | |
4483 | ||
4484 | A number of options that control the build process are common to | |
4485 | @command{guix build} and other commands that can spawn builds, such as | |
4486 | @command{guix package} or @command{guix archive}. These are the | |
4487 | following: | |
4488 | ||
4489 | @table @code | |
4490 | ||
4491 | @item --load-path=@var{directory} | |
4492 | @itemx -L @var{directory} | |
4493 | Add @var{directory} to the front of the package module search path | |
4494 | (@pxref{Package Modules}). | |
4495 | ||
4496 | This allows users to define their own packages and make them visible to | |
4497 | the command-line tools. | |
4498 | ||
4499 | @item --keep-failed | |
4500 | @itemx -K | |
b7899749 | 4501 | Keep the build tree of failed builds. Thus, if a build fails, its build |
ccd7158d LC |
4502 | tree is kept under @file{/tmp}, in a directory whose name is shown at |
4503 | the end of the build log. This is useful when debugging build issues. | |
4504 | ||
4505 | @item --keep-going | |
4506 | @itemx -k | |
4507 | Keep going when some of the derivations fail to build; return only once | |
4508 | all the builds have either completed or failed. | |
4509 | ||
4510 | The default behavior is to stop as soon as one of the specified | |
4511 | derivations has failed. | |
4512 | ||
4513 | @item --dry-run | |
4514 | @itemx -n | |
4515 | Do not build the derivations. | |
4516 | ||
4517 | @item --fallback | |
4518 | When substituting a pre-built binary fails, fall back to building | |
4519 | packages locally. | |
4520 | ||
4521 | @item --substitute-urls=@var{urls} | |
4522 | @anchor{client-substitute-urls} | |
4523 | Consider @var{urls} the whitespace-separated list of substitute source | |
4524 | URLs, overriding the default list of URLs of @command{guix-daemon} | |
4525 | (@pxref{daemon-substitute-urls,, @command{guix-daemon} URLs}). | |
4526 | ||
4527 | This means that substitutes may be downloaded from @var{urls}, provided | |
4528 | they are signed by a key authorized by the system administrator | |
4529 | (@pxref{Substitutes}). | |
4530 | ||
71e2065a LC |
4531 | When @var{urls} is the empty string, substitutes are effectively |
4532 | disabled. | |
4533 | ||
ccd7158d LC |
4534 | @item --no-substitutes |
4535 | Do not use substitutes for build products. That is, always build things | |
4536 | locally instead of allowing downloads of pre-built binaries | |
4537 | (@pxref{Substitutes}). | |
4538 | ||
7573d30f LC |
4539 | @item --no-grafts |
4540 | Do not ``graft'' packages. In practice, this means that package updates | |
4541 | available as grafts are not applied. @xref{Security Updates}, for more | |
4542 | information on grafts. | |
4543 | ||
ccd7158d LC |
4544 | @item --rounds=@var{n} |
4545 | Build each derivation @var{n} times in a row, and raise an error if | |
4546 | consecutive build results are not bit-for-bit identical. | |
4547 | ||
4548 | This is a useful way to detect non-deterministic builds processes. | |
4549 | Non-deterministic build processes are a problem because they make it | |
4550 | practically impossible for users to @emph{verify} whether third-party | |
4551 | binaries are genuine. @xref{Invoking guix challenge}, for more. | |
4552 | ||
4553 | Note that, currently, the differing build results are not kept around, | |
4554 | so you will have to manually investigate in case of an error---e.g., by | |
e66d1f59 ML |
4555 | stashing one of the build results with @code{guix archive --export} |
4556 | (@pxref{Invoking guix archive}), then rebuilding, and finally comparing | |
4557 | the two results. | |
ccd7158d LC |
4558 | |
4559 | @item --no-build-hook | |
f97c9175 | 4560 | Do not attempt to offload builds @i{via} the ``build hook'' of the daemon |
ccd7158d LC |
4561 | (@pxref{Daemon Offload Setup}). That is, always build things locally |
4562 | instead of offloading builds to remote machines. | |
4563 | ||
4564 | @item --max-silent-time=@var{seconds} | |
4565 | When the build or substitution process remains silent for more than | |
4566 | @var{seconds}, terminate it and report a build failure. | |
4567 | ||
4568 | @item --timeout=@var{seconds} | |
4569 | Likewise, when the build or substitution process lasts for more than | |
4570 | @var{seconds}, terminate it and report a build failure. | |
4571 | ||
4572 | By default there is no timeout. This behavior can be restored with | |
4573 | @code{--timeout=0}. | |
4574 | ||
4575 | @item --verbosity=@var{level} | |
4576 | Use the given verbosity level. @var{level} must be an integer between 0 | |
4577 | and 5; higher means more verbose output. Setting a level of 4 or more | |
4578 | may be helpful when debugging setup issues with the build daemon. | |
4579 | ||
4580 | @item --cores=@var{n} | |
4581 | @itemx -c @var{n} | |
4582 | Allow the use of up to @var{n} CPU cores for the build. The special | |
4583 | value @code{0} means to use as many CPU cores as available. | |
4584 | ||
4585 | @item --max-jobs=@var{n} | |
4586 | @itemx -M @var{n} | |
4587 | Allow at most @var{n} build jobs in parallel. @xref{Invoking | |
4588 | guix-daemon, @code{--max-jobs}}, for details about this option and the | |
4589 | equivalent @command{guix-daemon} option. | |
4590 | ||
4591 | @end table | |
4592 | ||
4593 | Behind the scenes, @command{guix build} is essentially an interface to | |
4594 | the @code{package-derivation} procedure of the @code{(guix packages)} | |
4595 | module, and to the @code{build-derivations} procedure of the @code{(guix | |
4596 | derivations)} module. | |
4597 | ||
4598 | In addition to options explicitly passed on the command line, | |
4599 | @command{guix build} and other @command{guix} commands that support | |
4600 | building honor the @code{GUIX_BUILD_OPTIONS} environment variable. | |
4601 | ||
4602 | @defvr {Environment Variable} GUIX_BUILD_OPTIONS | |
4603 | Users can define this variable to a list of command line options that | |
4604 | will automatically be used by @command{guix build} and other | |
4605 | @command{guix} commands that can perform builds, as in the example | |
4606 | below: | |
4607 | ||
4608 | @example | |
4609 | $ export GUIX_BUILD_OPTIONS="--no-substitutes -c 2 -L /foo/bar" | |
4610 | @end example | |
4611 | ||
4612 | These options are parsed independently, and the result is appended to | |
4613 | the parsed command-line options. | |
4614 | @end defvr | |
4615 | ||
88ad6ded LC |
4616 | |
4617 | @node Package Transformation Options | |
4618 | @subsection Package Transformation Options | |
4619 | ||
4620 | @cindex package variants | |
4621 | Another set of command-line options supported by @command{guix build} | |
b8638f03 | 4622 | and also @command{guix package} are @dfn{package transformation |
f97c9175 | 4623 | options}. These are options that make it possible to define @dfn{package |
b8638f03 LC |
4624 | variants}---for instance, packages built from different source code. |
4625 | This is a convenient way to create customized packages on the fly | |
4626 | without having to type in the definitions of package variants | |
4627 | (@pxref{Defining Packages}). | |
88ad6ded LC |
4628 | |
4629 | @table @code | |
4630 | ||
4631 | @item --with-source=@var{source} | |
4632 | Use @var{source} as the source of the corresponding package. | |
4633 | @var{source} must be a file name or a URL, as for @command{guix | |
4634 | download} (@pxref{Invoking guix download}). | |
4635 | ||
f97c9175 AE |
4636 | The ``corresponding package'' is taken to be the one specified on the |
4637 | command line the name of which matches the base of @var{source}---e.g., | |
4638 | if @var{source} is @code{/src/guile-2.0.10.tar.gz}, the corresponding | |
88ad6ded | 4639 | package is @code{guile}. Likewise, the version string is inferred from |
f97c9175 | 4640 | @var{source}; in the previous example, it is @code{2.0.10}. |
88ad6ded LC |
4641 | |
4642 | This option allows users to try out versions of packages other than the | |
4643 | one provided by the distribution. The example below downloads | |
4644 | @file{ed-1.7.tar.gz} from a GNU mirror and uses that as the source for | |
4645 | the @code{ed} package: | |
4646 | ||
4647 | @example | |
4648 | guix build ed --with-source=mirror://gnu/ed/ed-1.7.tar.gz | |
4649 | @end example | |
4650 | ||
4651 | As a developer, @code{--with-source} makes it easy to test release | |
4652 | candidates: | |
4653 | ||
4654 | @example | |
4655 | guix build guile --with-source=../guile-2.0.9.219-e1bb7.tar.xz | |
4656 | @end example | |
4657 | ||
4658 | @dots{} or to build from a checkout in a pristine environment: | |
4659 | ||
4660 | @example | |
4661 | $ git clone git://git.sv.gnu.org/guix.git | |
4662 | $ guix build guix --with-source=./guix | |
4663 | @end example | |
4664 | ||
47c0f92c LC |
4665 | @item --with-input=@var{package}=@var{replacement} |
4666 | Replace dependency on @var{package} by a dependency on | |
4667 | @var{replacement}. @var{package} must be a package name, and | |
4668 | @var{replacement} must be a package specification such as @code{guile} | |
4669 | or @code{guile@@1.8}. | |
4670 | ||
f97c9175 | 4671 | For instance, the following command builds Guix, but replaces its |
47c0f92c LC |
4672 | dependency on the current stable version of Guile with a dependency on |
4673 | the development version of Guile, @code{guile-next}: | |
4674 | ||
4675 | @example | |
4676 | guix build --with-input=guile=guile-next guix | |
4677 | @end example | |
4678 | ||
4679 | This is a recursive, deep replacement. So in this example, both | |
4680 | @code{guix} and its dependency @code{guile-json} (which also depends on | |
4681 | @code{guile}) get rebuilt against @code{guile-next}. | |
4682 | ||
2a75b0b6 LC |
4683 | This is implemented using the @code{package-input-rewriting} Scheme |
4684 | procedure (@pxref{Defining Packages, @code{package-input-rewriting}}). | |
645b9df8 LC |
4685 | |
4686 | @item --with-graft=@var{package}=@var{replacement} | |
4687 | This is similar to @code{--with-input} but with an important difference: | |
4688 | instead of rebuilding all the dependency chain, @var{replacement} is | |
4689 | built and then @dfn{grafted} onto the binaries that were initially | |
4690 | referring to @var{package}. @xref{Security Updates}, for more | |
4691 | information on grafts. | |
4692 | ||
4693 | For example, the command below grafts version 3.5.4 of GnuTLS onto Wget | |
4694 | and all its dependencies, replacing references to the version of GnuTLS | |
4695 | they currently refer to: | |
4696 | ||
4697 | @example | |
4698 | guix build --with-graft=gnutls=gnutls@@3.5.4 wget | |
4699 | @end example | |
4700 | ||
4701 | This has the advantage of being much faster than rebuilding everything. | |
4702 | But there is a caveat: it works if and only if @var{package} and | |
4703 | @var{replacement} are strictly compatible---for example, if they provide | |
4704 | a library, the application binary interface (ABI) of those libraries | |
4705 | must be compatible. If @var{replacement} is somehow incompatible with | |
4706 | @var{package}, then the resulting package may be unusable. Use with | |
4707 | care! | |
4708 | ||
88ad6ded LC |
4709 | @end table |
4710 | ||
ccd7158d LC |
4711 | @node Additional Build Options |
4712 | @subsection Additional Build Options | |
4713 | ||
4714 | The command-line options presented below are specific to @command{guix | |
4715 | build}. | |
c78bd12b LC |
4716 | |
4717 | @table @code | |
4718 | ||
5284339d LC |
4719 | @item --quiet |
4720 | @itemx -q | |
4721 | Build quietly, without displaying the build log. Upon completion, the | |
4722 | build log is kept in @file{/var} (or similar) and can always be | |
4723 | retrieved using the @option{--log-file} option. | |
4724 | ||
34a1783f DT |
4725 | @item --file=@var{file} |
4726 | @itemx -f @var{file} | |
4727 | ||
4728 | Build the package or derivation that the code within @var{file} | |
4729 | evaluates to. | |
4730 | ||
4731 | As an example, @var{file} might contain a package definition like this | |
4732 | (@pxref{Defining Packages}): | |
4733 | ||
4734 | @example | |
4735 | @verbatiminclude package-hello.scm | |
4736 | @end example | |
4737 | ||
c78bd12b LC |
4738 | @item --expression=@var{expr} |
4739 | @itemx -e @var{expr} | |
ac5de156 | 4740 | Build the package or derivation @var{expr} evaluates to. |
c78bd12b | 4741 | |
5401dd75 | 4742 | For example, @var{expr} may be @code{(@@ (gnu packages guile) |
c78bd12b LC |
4743 | guile-1.8)}, which unambiguously designates this specific variant of |
4744 | version 1.8 of Guile. | |
4745 | ||
f97c9175 | 4746 | Alternatively, @var{expr} may be a G-expression, in which case it is used |
56b82106 LC |
4747 | as a build program passed to @code{gexp->derivation} |
4748 | (@pxref{G-Expressions}). | |
4749 | ||
4750 | Lastly, @var{expr} may refer to a zero-argument monadic procedure | |
ac5de156 LC |
4751 | (@pxref{The Store Monad}). The procedure must return a derivation as a |
4752 | monadic value, which is then passed through @code{run-with-store}. | |
4753 | ||
c78bd12b LC |
4754 | @item --source |
4755 | @itemx -S | |
f97c9175 | 4756 | Build the source derivations of the packages, rather than the packages |
c78bd12b LC |
4757 | themselves. |
4758 | ||
e49951eb | 4759 | For instance, @code{guix build -S gcc} returns something like |
f97c9175 AE |
4760 | @file{/gnu/store/@dots{}-gcc-4.7.2.tar.bz2}, which is the GCC |
4761 | source tarball. | |
c78bd12b | 4762 | |
f9cc8971 | 4763 | The returned source tarball is the result of applying any patches and |
f97c9175 | 4764 | code snippets specified in the package @code{origin} (@pxref{Defining |
f9cc8971 LC |
4765 | Packages}). |
4766 | ||
2cdfe13d EB |
4767 | @item --sources |
4768 | Fetch and return the source of @var{package-or-derivation} and all their | |
4769 | dependencies, recursively. This is a handy way to obtain a local copy | |
4770 | of all the source code needed to build @var{packages}, allowing you to | |
4771 | eventually build them even without network access. It is an extension | |
4772 | of the @code{--source} option and can accept one of the following | |
4773 | optional argument values: | |
4774 | ||
4775 | @table @code | |
4776 | @item package | |
4777 | This value causes the @code{--sources} option to behave in the same way | |
4778 | as the @code{--source} option. | |
4779 | ||
4780 | @item all | |
f97c9175 AE |
4781 | Build the source derivations of all packages, including any source that |
4782 | might be listed as @code{inputs}. This is the default value. | |
2cdfe13d EB |
4783 | |
4784 | @example | |
4785 | $ guix build --sources tzdata | |
4786 | The following derivations will be built: | |
4787 | /gnu/store/@dots{}-tzdata2015b.tar.gz.drv | |
4788 | /gnu/store/@dots{}-tzcode2015b.tar.gz.drv | |
4789 | @end example | |
4790 | ||
4791 | @item transitive | |
f97c9175 AE |
4792 | Build the source derivations of all packages, as well of all transitive |
4793 | inputs to the packages. This can be used e.g. to | |
2cdfe13d EB |
4794 | prefetch package source for later offline building. |
4795 | ||
4796 | @example | |
4797 | $ guix build --sources=transitive tzdata | |
4798 | The following derivations will be built: | |
4799 | /gnu/store/@dots{}-tzcode2015b.tar.gz.drv | |
4800 | /gnu/store/@dots{}-findutils-4.4.2.tar.xz.drv | |
4801 | /gnu/store/@dots{}-grep-2.21.tar.xz.drv | |
4802 | /gnu/store/@dots{}-coreutils-8.23.tar.xz.drv | |
4803 | /gnu/store/@dots{}-make-4.1.tar.xz.drv | |
4804 | /gnu/store/@dots{}-bash-4.3.tar.xz.drv | |
4805 | @dots{} | |
4806 | @end example | |
4807 | ||
4808 | @end table | |
4809 | ||
c78bd12b LC |
4810 | @item --system=@var{system} |
4811 | @itemx -s @var{system} | |
4812 | Attempt to build for @var{system}---e.g., @code{i686-linux}---instead of | |
f97c9175 | 4813 | the system type of the build host. |
c78bd12b LC |
4814 | |
4815 | An example use of this is on Linux-based systems, which can emulate | |
4816 | different personalities. For instance, passing | |
4817 | @code{--system=i686-linux} on an @code{x86_64-linux} system allows users | |
4818 | to build packages in a complete 32-bit environment. | |
4819 | ||
e55ec43d LC |
4820 | @item --target=@var{triplet} |
4821 | @cindex cross-compilation | |
4822 | Cross-build for @var{triplet}, which must be a valid GNU triplet, such | |
4823 | as @code{"mips64el-linux-gnu"} (@pxref{Configuration Names, GNU | |
4824 | configuration triplets,, configure, GNU Configure and Build System}). | |
4825 | ||
a8d65643 LC |
4826 | @anchor{build-check} |
4827 | @item --check | |
4828 | @cindex determinism, checking | |
4829 | @cindex reproducibility, checking | |
4830 | Rebuild @var{package-or-derivation}, which are already available in the | |
4831 | store, and raise an error if the build results are not bit-for-bit | |
4832 | identical. | |
4833 | ||
f97c9175 AE |
4834 | This mechanism allows you to check whether previously installed |
4835 | substitutes are genuine (@pxref{Substitutes}), or whether the build result | |
4836 | of a package is deterministic. @xref{Invoking guix challenge}, for more | |
a8d65643 LC |
4837 | background information and tools. |
4838 | ||
7f3b2510 ED |
4839 | When used in conjunction with @option{--keep-failed}, the differing |
4840 | output is kept in the store, under @file{/gnu/store/@dots{}-check}. | |
4841 | This makes it easy to look for differences between the two results. | |
4842 | ||
c78bd12b LC |
4843 | @item --derivations |
4844 | @itemx -d | |
4845 | Return the derivation paths, not the output paths, of the given | |
4846 | packages. | |
4847 | ||
70ee5642 LC |
4848 | @item --root=@var{file} |
4849 | @itemx -r @var{file} | |
4850 | Make @var{file} a symlink to the result, and register it as a garbage | |
4851 | collector root. | |
4852 | ||
4853 | @item --log-file | |
3f208ad7 | 4854 | Return the build log file names or URLs for the given |
f97c9175 | 4855 | @var{package-or-derivation}, or raise an error if build logs are |
70ee5642 LC |
4856 | missing. |
4857 | ||
4858 | This works regardless of how packages or derivations are specified. For | |
4859 | instance, the following invocations are equivalent: | |
4860 | ||
4861 | @example | |
4862 | guix build --log-file `guix build -d guile` | |
4863 | guix build --log-file `guix build guile` | |
4864 | guix build --log-file guile | |
4865 | guix build --log-file -e '(@@ (gnu packages guile) guile-2.0)' | |
4866 | @end example | |
4867 | ||
3f208ad7 LC |
4868 | If a log is unavailable locally, and unless @code{--no-substitutes} is |
4869 | passed, the command looks for a corresponding log on one of the | |
4870 | substitute servers (as specified with @code{--substitute-urls}.) | |
70ee5642 | 4871 | |
f97c9175 AE |
4872 | So for instance, imagine you want to see the build log of GDB on MIPS, |
4873 | but you are actually on an @code{x86_64} machine: | |
3f208ad7 LC |
4874 | |
4875 | @example | |
a01ad638 | 4876 | $ guix build --log-file gdb -s mips64el-linux |
df061d07 | 4877 | https://hydra.gnu.org/log/@dots{}-gdb-7.10 |
3f208ad7 LC |
4878 | @end example |
4879 | ||
4880 | You can freely access a huge library of build logs! | |
70ee5642 LC |
4881 | @end table |
4882 | ||
16eb115e | 4883 | |
39bee8a2 LC |
4884 | @node Invoking guix edit |
4885 | @section Invoking @command{guix edit} | |
4886 | ||
e32171ee | 4887 | @cindex @command{guix edit} |
39bee8a2 LC |
4888 | @cindex package definition, editing |
4889 | So many packages, so many source files! The @command{guix edit} command | |
424a323e GC |
4890 | facilitates the life of users and packagers by pointing their editor at |
4891 | the source file containing the definition of the specified packages. | |
4892 | For instance: | |
39bee8a2 LC |
4893 | |
4894 | @example | |
7b9a66e5 | 4895 | guix edit gcc@@4.9 vim |
39bee8a2 LC |
4896 | @end example |
4897 | ||
4898 | @noindent | |
6237b9fa | 4899 | launches the program specified in the @code{VISUAL} or in the |
424a323e | 4900 | @code{EDITOR} environment variable to view the recipe of GCC@tie{}4.9.3 |
6237b9fa | 4901 | and that of Vim. |
39bee8a2 | 4902 | |
424a323e GC |
4903 | If you are using a Guix Git checkout (@pxref{Building from Git}), or |
4904 | have created your own packages on @code{GUIX_PACKAGE_PATH} | |
4905 | (@pxref{Defining Packages}), you will be able to edit the package | |
4906 | recipes. Otherwise, you will be able to examine the read-only recipes | |
4907 | for packages currently in the store. | |
4908 | ||
39bee8a2 | 4909 | |
210cc920 LC |
4910 | @node Invoking guix download |
4911 | @section Invoking @command{guix download} | |
4912 | ||
e32171ee JD |
4913 | @cindex @command{guix download} |
4914 | @cindex downloading package sources | |
210cc920 | 4915 | When writing a package definition, developers typically need to download |
f97c9175 | 4916 | a source tarball, compute its SHA256 hash, and write that |
210cc920 LC |
4917 | hash in the package definition (@pxref{Defining Packages}). The |
4918 | @command{guix download} tool helps with this task: it downloads a file | |
4919 | from the given URI, adds it to the store, and prints both its file name | |
4920 | in the store and its SHA256 hash. | |
4921 | ||
4922 | The fact that the downloaded file is added to the store saves bandwidth: | |
4923 | when the developer eventually tries to build the newly defined package | |
4924 | with @command{guix build}, the source tarball will not have to be | |
4925 | downloaded again because it is already in the store. It is also a | |
4926 | convenient way to temporarily stash files, which may be deleted | |
4927 | eventually (@pxref{Invoking guix gc}). | |
4928 | ||
4929 | The @command{guix download} command supports the same URIs as used in | |
4930 | package definitions. In particular, it supports @code{mirror://} URIs. | |
4931 | @code{https} URIs (HTTP over TLS) are supported @emph{provided} the | |
4932 | Guile bindings for GnuTLS are available in the user's environment; when | |
537c8bb3 LC |
4933 | they are not available, an error is raised. @xref{Guile Preparations, |
4934 | how to install the GnuTLS bindings for Guile,, gnutls-guile, | |
4935 | GnuTLS-Guile}, for more information. | |
210cc920 | 4936 | |
bc3c41ce LC |
4937 | @command{guix download} verifies HTTPS server certificates by loading |
4938 | the certificates of X.509 authorities from the directory pointed to by | |
4939 | the @code{SSL_CERT_DIR} environment variable (@pxref{X.509 | |
64b8695c | 4940 | Certificates}), unless @option{--no-check-certificate} is used. |
bc3c41ce | 4941 | |
64b8695c | 4942 | The following options are available: |
210cc920 LC |
4943 | |
4944 | @table @code | |
4945 | @item --format=@var{fmt} | |
4946 | @itemx -f @var{fmt} | |
4947 | Write the hash in the format specified by @var{fmt}. For more | |
081145cf | 4948 | information on the valid values for @var{fmt}, @pxref{Invoking guix hash}. |
64b8695c LC |
4949 | |
4950 | @item --no-check-certificate | |
4951 | Do not validate the X.509 certificates of HTTPS servers. | |
4952 | ||
4953 | When using this option, you have @emph{absolutely no guarantee} that you | |
4954 | are communicating with the authentic server responsible for the given | |
4955 | URL, which makes you vulnerable to ``man-in-the-middle'' attacks. | |
4956 | ||
1bcc87bb LC |
4957 | @item --output=@var{file} |
4958 | @itemx -o @var{file} | |
4959 | Save the downloaded file to @var{file} instead of adding it to the | |
4960 | store. | |
210cc920 LC |
4961 | @end table |
4962 | ||
6c365eca NK |
4963 | @node Invoking guix hash |
4964 | @section Invoking @command{guix hash} | |
4965 | ||
e32171ee | 4966 | @cindex @command{guix hash} |
210cc920 | 4967 | The @command{guix hash} command computes the SHA256 hash of a file. |
6c365eca NK |
4968 | It is primarily a convenience tool for anyone contributing to the |
4969 | distribution: it computes the cryptographic hash of a file, which can be | |
4970 | used in the definition of a package (@pxref{Defining Packages}). | |
4971 | ||
4972 | The general syntax is: | |
4973 | ||
4974 | @example | |
4975 | guix hash @var{option} @var{file} | |
4976 | @end example | |
4977 | ||
343dc117 LC |
4978 | When @var{file} is @code{-} (a hyphen), @command{guix hash} computes the |
4979 | hash of data read from standard input. @command{guix hash} has the | |
4980 | following options: | |
6c365eca NK |
4981 | |
4982 | @table @code | |
4983 | ||
4984 | @item --format=@var{fmt} | |
4985 | @itemx -f @var{fmt} | |
210cc920 | 4986 | Write the hash in the format specified by @var{fmt}. |
6c365eca NK |
4987 | |
4988 | Supported formats: @code{nix-base32}, @code{base32}, @code{base16} | |
4989 | (@code{hex} and @code{hexadecimal} can be used as well). | |
4990 | ||
4991 | If the @option{--format} option is not specified, @command{guix hash} | |
4992 | will output the hash in @code{nix-base32}. This representation is used | |
4993 | in the definitions of packages. | |
4994 | ||
3140f2df LC |
4995 | @item --recursive |
4996 | @itemx -r | |
4997 | Compute the hash on @var{file} recursively. | |
4998 | ||
4999 | In this case, the hash is computed on an archive containing @var{file}, | |
f97c9175 AE |
5000 | including its children if it is a directory. Some of the metadata of |
5001 | @var{file} is part of the archive; for instance, when @var{file} is a | |
3140f2df | 5002 | regular file, the hash is different depending on whether @var{file} is |
f97c9175 | 5003 | executable or not. Metadata such as time stamps has no impact on the |
3140f2df LC |
5004 | hash (@pxref{Invoking guix archive}). |
5005 | @c FIXME: Replace xref above with xref to an ``Archive'' section when | |
5006 | @c it exists. | |
5007 | ||
392a4e12 JN |
5008 | @item --exclude-vcs |
5009 | @itemx -x | |
5010 | When combined with @option{--recursive}, exclude version control system | |
5011 | directories (@file{.bzr}, @file{.git}, @file{.hg}, etc.) | |
5012 | ||
db97a03a LC |
5013 | @vindex git-fetch |
5014 | As an example, here is how you would compute the hash of a Git checkout, | |
5015 | which is useful when using the @code{git-fetch} method (@pxref{origin | |
5016 | Reference}): | |
5017 | ||
5018 | @example | |
5019 | $ git clone http://example.org/foo.git | |
5020 | $ cd foo | |
392a4e12 | 5021 | $ guix hash -rx . |
db97a03a | 5022 | @end example |
6c365eca NK |
5023 | @end table |
5024 | ||
2f7d2d91 LC |
5025 | @node Invoking guix import |
5026 | @section Invoking @command{guix import} | |
5027 | ||
5028 | @cindex importing packages | |
5029 | @cindex package import | |
5030 | @cindex package conversion | |
e32171ee | 5031 | @cindex Invoking @command{guix import} |
f97c9175 AE |
5032 | The @command{guix import} command is useful for people who would like to |
5033 | add a package to the distribution with as little work as | |
5034 | possible---a legitimate demand. The command knows of a few | |
5035 | repositories from which it can ``import'' package metadata. The result | |
2f7d2d91 LC |
5036 | is a package definition, or a template thereof, in the format we know |
5037 | (@pxref{Defining Packages}). | |
5038 | ||
5039 | The general syntax is: | |
5040 | ||
5041 | @example | |
5042 | guix import @var{importer} @var{options}@dots{} | |
5043 | @end example | |
5044 | ||
5045 | @var{importer} specifies the source from which to import package | |
f97c9175 | 5046 | metadata, and @var{options} specifies a package identifier and other |
2f7d2d91 LC |
5047 | options specific to @var{importer}. Currently, the available |
5048 | ``importers'' are: | |
5049 | ||
5050 | @table @code | |
5051 | @item gnu | |
f97c9175 | 5052 | Import metadata for the given GNU package. This provides a template |
2f7d2d91 LC |
5053 | for the latest version of that GNU package, including the hash of its |
5054 | source tarball, and its canonical synopsis and description. | |
5055 | ||
f97c9175 | 5056 | Additional information such as the package dependencies and its |
2f7d2d91 LC |
5057 | license needs to be figured out manually. |
5058 | ||
5059 | For example, the following command returns a package definition for | |
5060 | GNU@tie{}Hello: | |
5061 | ||
5062 | @example | |
5063 | guix import gnu hello | |
5064 | @end example | |
5065 | ||
5066 | Specific command-line options are: | |
5067 | ||
5068 | @table @code | |
5069 | @item --key-download=@var{policy} | |
5070 | As for @code{guix refresh}, specify the policy to handle missing OpenPGP | |
f97c9175 | 5071 | keys when verifying the package signature. @xref{Invoking guix |
2f7d2d91 LC |
5072 | refresh, @code{--key-download}}. |
5073 | @end table | |
5074 | ||
5075 | @item pypi | |
5076 | @cindex pypi | |
f97c9175 | 5077 | Import metadata from the @uref{https://pypi.python.org/, Python Package |
2f7d2d91 LC |
5078 | Index}@footnote{This functionality requires Guile-JSON to be installed. |
5079 | @xref{Requirements}.}. Information is taken from the JSON-formatted | |
5080 | description available at @code{pypi.python.org} and usually includes all | |
266785d2 CR |
5081 | the relevant information, including package dependencies. For maximum |
5082 | efficiency, it is recommended to install the @command{unzip} utility, so | |
5083 | that the importer can unzip Python wheels and gather data from them. | |
2f7d2d91 | 5084 | |
f97c9175 | 5085 | The command below imports metadata for the @code{itsdangerous} Python |
2f7d2d91 LC |
5086 | package: |
5087 | ||
5088 | @example | |
5089 | guix import pypi itsdangerous | |
5090 | @end example | |
5091 | ||
3aae8145 DT |
5092 | @item gem |
5093 | @cindex gem | |
f97c9175 | 5094 | Import metadata from @uref{https://rubygems.org/, |
3aae8145 DT |
5095 | RubyGems}@footnote{This functionality requires Guile-JSON to be |
5096 | installed. @xref{Requirements}.}. Information is taken from the | |
5097 | JSON-formatted description available at @code{rubygems.org} and includes | |
5098 | most relevant information, including runtime dependencies. There are | |
f97c9175 | 5099 | some caveats, however. The metadata doesn't distinguish between |
3aae8145 DT |
5100 | synopses and descriptions, so the same string is used for both fields. |
5101 | Additionally, the details of non-Ruby dependencies required to build | |
5102 | native extensions is unavailable and left as an exercise to the | |
5103 | packager. | |
5104 | ||
f97c9175 | 5105 | The command below imports metadata for the @code{rails} Ruby package: |
3aae8145 DT |
5106 | |
5107 | @example | |
5108 | guix import gem rails | |
5109 | @end example | |
5110 | ||
d45dc6da EB |
5111 | @item cpan |
5112 | @cindex CPAN | |
3c192e4e AE |
5113 | Import metadata from @uref{https://www.metacpan.org/, MetaCPAN}@footnote{This |
5114 | functionality requires Guile-JSON to be installed. | |
5115 | @xref{Requirements}.}. | |
f97c9175 | 5116 | Information is taken from the JSON-formatted metadata provided through |
d45dc6da | 5117 | @uref{https://api.metacpan.org/, MetaCPAN's API} and includes most |
66392e47 EB |
5118 | relevant information, such as module dependencies. License information |
5119 | should be checked closely. If Perl is available in the store, then the | |
5120 | @code{corelist} utility will be used to filter core modules out of the | |
5121 | list of dependencies. | |
d45dc6da | 5122 | |
f97c9175 | 5123 | The command command below imports metadata for the @code{Acme::Boolean} |
d45dc6da EB |
5124 | Perl module: |
5125 | ||
5126 | @example | |
5127 | guix import cpan Acme::Boolean | |
5128 | @end example | |
5129 | ||
e1248602 RW |
5130 | @item cran |
5131 | @cindex CRAN | |
d0bd632f | 5132 | @cindex Bioconductor |
f97c9175 | 5133 | Import metadata from @uref{http://cran.r-project.org/, CRAN}, the |
e1248602 RW |
5134 | central repository for the @uref{http://r-project.org, GNU@tie{}R |
5135 | statistical and graphical environment}. | |
5136 | ||
f97c9175 | 5137 | Information is extracted from the @code{DESCRIPTION} file of the package. |
e1248602 | 5138 | |
f97c9175 | 5139 | The command command below imports metadata for the @code{Cairo} |
e1248602 RW |
5140 | R package: |
5141 | ||
5142 | @example | |
5143 | guix import cran Cairo | |
5144 | @end example | |
5145 | ||
64ce53eb RW |
5146 | When @code{--recursive} is added, the importer will traverse the |
5147 | dependency graph of the given upstream package recursively and generate | |
5148 | package expressions for all those packages that are not yet in Guix. | |
5149 | ||
f97c9175 | 5150 | When @code{--archive=bioconductor} is added, metadata is imported from |
d0bd632f RW |
5151 | @uref{http://www.bioconductor.org/, Bioconductor}, a repository of R |
5152 | packages for for the analysis and comprehension of high-throughput | |
5153 | genomic data in bioinformatics. | |
5154 | ||
f97c9175 | 5155 | Information is extracted from the @code{DESCRIPTION} file of a package |
d0bd632f RW |
5156 | published on the web interface of the Bioconductor SVN repository. |
5157 | ||
f97c9175 | 5158 | The command below imports metadata for the @code{GenomicRanges} |
d0bd632f RW |
5159 | R package: |
5160 | ||
5161 | @example | |
5162 | guix import cran --archive=bioconductor GenomicRanges | |
5163 | @end example | |
5164 | ||
2f7d2d91 | 5165 | @item nix |
f97c9175 | 5166 | Import metadata from a local copy of the source of the |
2f7d2d91 LC |
5167 | @uref{http://nixos.org/nixpkgs/, Nixpkgs distribution}@footnote{This |
5168 | relies on the @command{nix-instantiate} command of | |
5169 | @uref{http://nixos.org/nix/, Nix}.}. Package definitions in Nixpkgs are | |
5170 | typically written in a mixture of Nix-language and Bash code. This | |
5171 | command only imports the high-level package structure that is written in | |
5172 | the Nix language. It normally includes all the basic fields of a | |
5173 | package definition. | |
5174 | ||
5175 | When importing a GNU package, the synopsis and descriptions are replaced | |
5176 | by their canonical upstream variant. | |
5177 | ||
961d0d2d LC |
5178 | Usually, you will first need to do: |
5179 | ||
5180 | @example | |
5181 | export NIX_REMOTE=daemon | |
5182 | @end example | |
5183 | ||
5184 | @noindent | |
5185 | so that @command{nix-instantiate} does not try to open the Nix database. | |
5186 | ||
2f7d2d91 LC |
5187 | As an example, the command below imports the package definition of |
5188 | LibreOffice (more precisely, it imports the definition of the package | |
5189 | bound to the @code{libreoffice} top-level attribute): | |
5190 | ||
5191 | @example | |
5192 | guix import nix ~/path/to/nixpkgs libreoffice | |
5193 | @end example | |
863af4e1 FB |
5194 | |
5195 | @item hackage | |
5196 | @cindex hackage | |
f97c9175 | 5197 | Import metadata from the Haskell community's central package archive |
863af4e1 FB |
5198 | @uref{https://hackage.haskell.org/, Hackage}. Information is taken from |
5199 | Cabal files and includes all the relevant information, including package | |
5200 | dependencies. | |
5201 | ||
5202 | Specific command-line options are: | |
5203 | ||
5204 | @table @code | |
a4154748 FB |
5205 | @item --stdin |
5206 | @itemx -s | |
f97c9175 | 5207 | Read a Cabal file from standard input. |
863af4e1 FB |
5208 | @item --no-test-dependencies |
5209 | @itemx -t | |
f97c9175 | 5210 | Do not include dependencies required only by the test suites. |
a4154748 FB |
5211 | @item --cabal-environment=@var{alist} |
5212 | @itemx -e @var{alist} | |
5213 | @var{alist} is a Scheme alist defining the environment in which the | |
5214 | Cabal conditionals are evaluated. The accepted keys are: @code{os}, | |
5215 | @code{arch}, @code{impl} and a string representing the name of a flag. | |
5216 | The value associated with a flag has to be either the symbol | |
5217 | @code{true} or @code{false}. The value associated with other keys | |
5218 | has to conform to the Cabal file format definition. The default value | |
5219 | associated with the keys @code{os}, @code{arch} and @code{impl} is | |
f97c9175 | 5220 | @samp{linux}, @samp{x86_64} and @samp{ghc}, respectively. |
863af4e1 FB |
5221 | @end table |
5222 | ||
f97c9175 | 5223 | The command below imports metadata for the latest version of the |
a4154748 FB |
5224 | @code{HTTP} Haskell package without including test dependencies and |
5225 | specifying the value of the flag @samp{network-uri} as @code{false}: | |
863af4e1 FB |
5226 | |
5227 | @example | |
a4154748 | 5228 | guix import hackage -t -e "'((\"network-uri\" . false))" HTTP |
863af4e1 FB |
5229 | @end example |
5230 | ||
5231 | A specific package version may optionally be specified by following the | |
1b846da8 | 5232 | package name by an at-sign and a version number as in the following example: |
863af4e1 FB |
5233 | |
5234 | @example | |
1b846da8 | 5235 | guix import hackage mtl@@2.1.3.1 |
863af4e1 | 5236 | @end example |
7f74a931 FB |
5237 | |
5238 | @item elpa | |
5239 | @cindex elpa | |
f97c9175 | 5240 | Import metadata from an Emacs Lisp Package Archive (ELPA) package |
7f74a931 FB |
5241 | repository (@pxref{Packages,,, emacs, The GNU Emacs Manual}). |
5242 | ||
5243 | Specific command-line options are: | |
5244 | ||
5245 | @table @code | |
5246 | @item --archive=@var{repo} | |
5247 | @itemx -a @var{repo} | |
5248 | @var{repo} identifies the archive repository from which to retrieve the | |
5249 | information. Currently the supported repositories and their identifiers | |
5250 | are: | |
5251 | @itemize - | |
5252 | @item | |
840bd1d3 | 5253 | @uref{http://elpa.gnu.org/packages, GNU}, selected by the @code{gnu} |
7f74a931 FB |
5254 | identifier. This is the default. |
5255 | ||
624144e0 LC |
5256 | Packages from @code{elpa.gnu.org} are signed with one of the keys |
5257 | contained in the GnuPG keyring at | |
5258 | @file{share/emacs/25.1/etc/package-keyring.gpg} (or similar) in the | |
5259 | @code{emacs} package (@pxref{Package Installation, ELPA package | |
5260 | signatures,, emacs, The GNU Emacs Manual}). | |
5261 | ||
7f74a931 | 5262 | @item |
840bd1d3 | 5263 | @uref{http://stable.melpa.org/packages, MELPA-Stable}, selected by the |
7f74a931 FB |
5264 | @code{melpa-stable} identifier. |
5265 | ||
5266 | @item | |
840bd1d3 | 5267 | @uref{http://melpa.org/packages, MELPA}, selected by the @code{melpa} |
7f74a931 FB |
5268 | identifier. |
5269 | @end itemize | |
5270 | @end table | |
3e0c0365 DC |
5271 | |
5272 | @item crate | |
5273 | @cindex crate | |
5274 | Import metadata from the crates.io Rust package repository | |
5275 | @uref{https://crates.io, crates.io}. | |
2f7d2d91 LC |
5276 | @end table |
5277 | ||
5278 | The structure of the @command{guix import} code is modular. It would be | |
5279 | useful to have more importers for other package formats, and your help | |
5280 | is welcome here (@pxref{Contributing}). | |
5281 | ||
37166310 LC |
5282 | @node Invoking guix refresh |
5283 | @section Invoking @command{guix refresh} | |
5284 | ||
e32171ee | 5285 | @cindex @command {guix refresh} |
37166310 LC |
5286 | The primary audience of the @command{guix refresh} command is developers |
5287 | of the GNU software distribution. By default, it reports any packages | |
5288 | provided by the distribution that are outdated compared to the latest | |
5289 | upstream version, like this: | |
5290 | ||
5291 | @example | |
5292 | $ guix refresh | |
5293 | gnu/packages/gettext.scm:29:13: gettext would be upgraded from 0.18.1.1 to 0.18.2.1 | |
5294 | gnu/packages/glib.scm:77:12: glib would be upgraded from 2.34.3 to 2.37.0 | |
5295 | @end example | |
5296 | ||
e9c72306 LC |
5297 | Alternately, one can specify packages to consider, in which case a |
5298 | warning is emitted for packages that lack an updater: | |
5299 | ||
5300 | @example | |
5301 | $ guix refresh coreutils guile guile-ssh | |
5302 | gnu/packages/ssh.scm:205:2: warning: no updater for guile-ssh | |
5303 | gnu/packages/guile.scm:136:12: guile would be upgraded from 2.0.12 to 2.0.13 | |
5304 | @end example | |
5305 | ||
5306 | @command{guix refresh} browses the upstream repository of each package and determines | |
5307 | the highest version number of the releases therein. The command | |
bcb571cb | 5308 | knows how to update specific types of packages: GNU packages, ELPA |
e9c72306 | 5309 | packages, etc.---see the documentation for @option{--type} below. There |
bcb571cb LC |
5310 | are many packages, though, for which it lacks a method to determine |
5311 | whether a new upstream release is available. However, the mechanism is | |
5312 | extensible, so feel free to get in touch with us to add a new method! | |
37166310 LC |
5313 | |
5314 | When passed @code{--update}, it modifies distribution source files to | |
f97c9175 | 5315 | update the version numbers and source tarball hashes of those package |
37166310 LC |
5316 | recipes (@pxref{Defining Packages}). This is achieved by downloading |
5317 | each package's latest source tarball and its associated OpenPGP | |
5318 | signature, authenticating the downloaded tarball against its signature | |
5319 | using @command{gpg}, and finally computing its hash. When the public | |
5320 | key used to sign the tarball is missing from the user's keyring, an | |
5321 | attempt is made to automatically retrieve it from a public key server; | |
f97c9175 | 5322 | when this is successful, the key is added to the user's keyring; otherwise, |
37166310 LC |
5323 | @command{guix refresh} reports an error. |
5324 | ||
5325 | The following options are supported: | |
5326 | ||
5327 | @table @code | |
5328 | ||
2d7fc7da LC |
5329 | @item --expression=@var{expr} |
5330 | @itemx -e @var{expr} | |
5331 | Consider the package @var{expr} evaluates to. | |
5332 | ||
5333 | This is useful to precisely refer to a package, as in this example: | |
5334 | ||
5335 | @example | |
5336 | guix refresh -l -e '(@@@@ (gnu packages commencement) glibc-final)' | |
5337 | @end example | |
5338 | ||
5339 | This command lists the dependents of the ``final'' libc (essentially all | |
5340 | the packages.) | |
5341 | ||
37166310 LC |
5342 | @item --update |
5343 | @itemx -u | |
38e16b49 LC |
5344 | Update distribution source files (package recipes) in place. This is |
5345 | usually run from a checkout of the Guix source tree (@pxref{Running | |
5346 | Guix Before It Is Installed}): | |
5347 | ||
5348 | @example | |
e9c72306 | 5349 | $ ./pre-inst-env guix refresh -s non-core -u |
38e16b49 LC |
5350 | @end example |
5351 | ||
081145cf | 5352 | @xref{Defining Packages}, for more information on package definitions. |
37166310 LC |
5353 | |
5354 | @item --select=[@var{subset}] | |
5355 | @itemx -s @var{subset} | |
5356 | Select all the packages in @var{subset}, one of @code{core} or | |
5357 | @code{non-core}. | |
5358 | ||
5359 | The @code{core} subset refers to all the packages at the core of the | |
5360 | distribution---i.e., packages that are used to build ``everything | |
5361 | else''. This includes GCC, libc, Binutils, Bash, etc. Usually, | |
5362 | changing one of these packages in the distribution entails a rebuild of | |
5363 | all the others. Thus, such updates are an inconvenience to users in | |
5364 | terms of build time or bandwidth used to achieve the upgrade. | |
5365 | ||
5366 | The @code{non-core} subset refers to the remaining packages. It is | |
5367 | typically useful in cases where an update of the core packages would be | |
5368 | inconvenient. | |
5369 | ||
bcb571cb LC |
5370 | @item --type=@var{updater} |
5371 | @itemx -t @var{updater} | |
7191adc5 AK |
5372 | Select only packages handled by @var{updater} (may be a comma-separated |
5373 | list of updaters). Currently, @var{updater} may be one of: | |
bcb571cb LC |
5374 | |
5375 | @table @code | |
5376 | @item gnu | |
5377 | the updater for GNU packages; | |
e80c0f85 LC |
5378 | @item gnome |
5379 | the updater for GNOME packages; | |
9c97afe8 DC |
5380 | @item kde |
5381 | the updater for KDE packages; | |
62061d6b AW |
5382 | @item xorg |
5383 | the updater for X.org packages; | |
2fd370e8 LC |
5384 | @item kernel.org |
5385 | the updater for packages hosted on kernel.org; | |
bcb571cb | 5386 | @item elpa |
d882c235 LC |
5387 | the updater for @uref{http://elpa.gnu.org/, ELPA} packages; |
5388 | @item cran | |
b9d044ef | 5389 | the updater for @uref{http://cran.r-project.org/, CRAN} packages; |
d0bd632f RW |
5390 | @item bioconductor |
5391 | the updater for @uref{http://www.bioconductor.org/, Bioconductor} R packages; | |
200cdf81 EB |
5392 | @item cpan |
5393 | the updater for @uref{http://www.cpan.org/, CPAN} packages; | |
bab020d7 | 5394 | @item pypi |
b9d044ef | 5395 | the updater for @uref{https://pypi.python.org, PyPI} packages. |
fbc5b815 BW |
5396 | @item gem |
5397 | the updater for @uref{https://rubygems.org, RubyGems} packages. | |
917a2a58 BW |
5398 | @item github |
5399 | the updater for @uref{https://github.com, GitHub} packages. | |
42efe27a EB |
5400 | @item hackage |
5401 | the updater for @uref{https://hackage.haskell.org, Hackage} packages. | |
8ac52987 DC |
5402 | @item crate |
5403 | the updater for @uref{https://crates.io, Crates} packages. | |
bcb571cb LC |
5404 | @end table |
5405 | ||
f97c9175 AE |
5406 | For instance, the following command only checks for updates of Emacs |
5407 | packages hosted at @code{elpa.gnu.org} and for updates of CRAN packages: | |
bcb571cb LC |
5408 | |
5409 | @example | |
7191adc5 | 5410 | $ guix refresh --type=elpa,cran |
d882c235 | 5411 | gnu/packages/statistics.scm:819:13: r-testthat would be upgraded from 0.10.0 to 0.11.0 |
bcb571cb LC |
5412 | gnu/packages/emacs.scm:856:13: emacs-auctex would be upgraded from 11.88.6 to 11.88.9 |
5413 | @end example | |
5414 | ||
37166310 LC |
5415 | @end table |
5416 | ||
5417 | In addition, @command{guix refresh} can be passed one or more package | |
5418 | names, as in this example: | |
5419 | ||
5420 | @example | |
e9c72306 | 5421 | $ ./pre-inst-env guix refresh -u emacs idutils gcc@@4.8 |
37166310 LC |
5422 | @end example |
5423 | ||
5424 | @noindent | |
5425 | The command above specifically updates the @code{emacs} and | |
5426 | @code{idutils} packages. The @code{--select} option would have no | |
5427 | effect in this case. | |
5428 | ||
7d193ec3 EB |
5429 | When considering whether to upgrade a package, it is sometimes |
5430 | convenient to know which packages would be affected by the upgrade and | |
5431 | should be checked for compatibility. For this the following option may | |
5432 | be used when passing @command{guix refresh} one or more package names: | |
5433 | ||
5434 | @table @code | |
5435 | ||
6ffa706b AK |
5436 | @item --list-updaters |
5437 | @itemx -L | |
5438 | List available updaters and exit (see @option{--type} above.) | |
5439 | ||
3676f892 LC |
5440 | For each updater, display the fraction of packages it covers; at the |
5441 | end, display the fraction of packages covered by all these updaters. | |
5442 | ||
7d193ec3 EB |
5443 | @item --list-dependent |
5444 | @itemx -l | |
5445 | List top-level dependent packages that would need to be rebuilt as a | |
5446 | result of upgrading one or more packages. | |
5447 | ||
5448 | @end table | |
5449 | ||
5450 | Be aware that the @code{--list-dependent} option only | |
5451 | @emph{approximates} the rebuilds that would be required as a result of | |
5452 | an upgrade. More rebuilds might be required under some circumstances. | |
5453 | ||
5454 | @example | |
7779ab61 LC |
5455 | $ guix refresh --list-dependent flex |
5456 | Building the following 120 packages would ensure 213 dependent packages are rebuilt: | |
5457 | hop-2.4.0 geiser-0.4 notmuch-0.18 mu-0.9.9.5 cflow-1.4 idutils-4.6 @dots{} | |
7d193ec3 EB |
5458 | @end example |
5459 | ||
5460 | The command above lists a set of packages that could be built to check | |
5461 | for compatibility with an upgraded @code{flex} package. | |
5462 | ||
f9230085 LC |
5463 | The following options can be used to customize GnuPG operation: |
5464 | ||
5465 | @table @code | |
5466 | ||
f9230085 LC |
5467 | @item --gpg=@var{command} |
5468 | Use @var{command} as the GnuPG 2.x command. @var{command} is searched | |
5469 | for in @code{$PATH}. | |
5470 | ||
2bc53ba9 LC |
5471 | @item --key-download=@var{policy} |
5472 | Handle missing OpenPGP keys according to @var{policy}, which may be one | |
5473 | of: | |
5474 | ||
5475 | @table @code | |
5476 | @item always | |
5477 | Always download missing OpenPGP keys from the key server, and add them | |
5478 | to the user's GnuPG keyring. | |
5479 | ||
5480 | @item never | |
5481 | Never try to download missing OpenPGP keys. Instead just bail out. | |
5482 | ||
5483 | @item interactive | |
5484 | When a package signed with an unknown OpenPGP key is encountered, ask | |
5485 | the user whether to download it or not. This is the default behavior. | |
5486 | @end table | |
5487 | ||
5488 | @item --key-server=@var{host} | |
5489 | Use @var{host} as the OpenPGP key server when importing a public key. | |
5490 | ||
f9230085 LC |
5491 | @end table |
5492 | ||
917a2a58 BW |
5493 | The @code{github} updater uses the |
5494 | @uref{https://developer.github.com/v3/, GitHub API} to query for new | |
5495 | releases. When used repeatedly e.g. when refreshing all packages, | |
5496 | GitHub will eventually refuse to answer any further API requests. By | |
5497 | default 60 API requests per hour are allowed, and a full refresh on all | |
5498 | GitHub packages in Guix requires more than this. Authentication with | |
5499 | GitHub through the use of an API token alleviates these limits. To use | |
5500 | an API token, set the environment variable @code{GUIX_GITHUB_TOKEN} to a | |
5501 | token procured from @uref{https://github.com/settings/tokens} or | |
5502 | otherwise. | |
5503 | ||
5504 | ||
b4f5e0e8 CR |
5505 | @node Invoking guix lint |
5506 | @section Invoking @command{guix lint} | |
e32171ee JD |
5507 | |
5508 | @cindex @command{guix lint} | |
5509 | @cindex package, checking for errors | |
f97c9175 AE |
5510 | The @command{guix lint} command is meant to help package developers avoid |
5511 | common errors and use a consistent style. It runs a number of checks on | |
5512 | a given set of packages in order to find common mistakes in their | |
873c4085 LC |
5513 | definitions. Available @dfn{checkers} include (see |
5514 | @code{--list-checkers} for a complete list): | |
5515 | ||
5516 | @table @code | |
5517 | @item synopsis | |
5518 | @itemx description | |
5519 | Validate certain typographical and stylistic rules about package | |
5520 | descriptions and synopses. | |
5521 | ||
5522 | @item inputs-should-be-native | |
5523 | Identify inputs that should most likely be native inputs. | |
5524 | ||
5525 | @item source | |
5526 | @itemx home-page | |
fac46e3f | 5527 | @itemx mirror-url |
50f5c46d | 5528 | @itemx source-file-name |
873c4085 | 5529 | Probe @code{home-page} and @code{source} URLs and report those that are |
fac46e3f LC |
5530 | invalid. Suggest a @code{mirror://} URL when applicable. Check that |
5531 | the source file name is meaningful, e.g. is not | |
f97c9175 AE |
5532 | just a version number or ``git-checkout'', without a declared |
5533 | @code{file-name} (@pxref{origin Reference}). | |
40a7d4e5 | 5534 | |
5432734b | 5535 | @item cve |
09866b39 LC |
5536 | @cindex security vulnerabilities |
5537 | @cindex CVE, Common Vulnerabilities and Exposures | |
5432734b | 5538 | Report known vulnerabilities found in the Common Vulnerabilities and |
09866b39 | 5539 | Exposures (CVE) databases of the current and past year |
5432734b LC |
5540 | @uref{https://nvd.nist.gov/download.cfm#CVE_FEED, published by the US |
5541 | NIST}. | |
5542 | ||
09866b39 LC |
5543 | To view information about a particular vulnerability, visit pages such as: |
5544 | ||
5545 | @itemize | |
5546 | @item | |
5547 | @indicateurl{https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-YYYY-ABCD} | |
5548 | @item | |
5549 | @indicateurl{https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-YYYY-ABCD} | |
5550 | @end itemize | |
5551 | ||
5552 | @noindent | |
5553 | where @code{CVE-YYYY-ABCD} is the CVE identifier---e.g., | |
5554 | @code{CVE-2015-7554}. | |
5555 | ||
99effc8f LC |
5556 | Package developers can specify in package recipes the |
5557 | @uref{https://nvd.nist.gov/cpe.cfm,Common Platform Enumeration (CPE)} | |
5558 | name and version of the package when they differ from the name that Guix | |
5559 | uses, as in this example: | |
5560 | ||
5561 | @example | |
5562 | (package | |
5563 | (name "grub") | |
5564 | ;; @dots{} | |
5565 | ;; CPE calls this package "grub2". | |
5566 | (properties '((cpe-name . "grub2")))) | |
5567 | @end example | |
5568 | ||
40a7d4e5 LC |
5569 | @item formatting |
5570 | Warn about obvious source code formatting issues: trailing white space, | |
5571 | use of tabulations, etc. | |
873c4085 | 5572 | @end table |
b4f5e0e8 CR |
5573 | |
5574 | The general syntax is: | |
5575 | ||
5576 | @example | |
5577 | guix lint @var{options} @var{package}@dots{} | |
5578 | @end example | |
5579 | ||
5580 | If no package is given on the command line, then all packages are checked. | |
5581 | The @var{options} may be zero or more of the following: | |
5582 | ||
5583 | @table @code | |
f97c9175 AE |
5584 | @item --list-checkers |
5585 | @itemx -l | |
5586 | List and describe all the available checkers that will be run on packages | |
5587 | and exit. | |
b4f5e0e8 | 5588 | |
dd7c013d CR |
5589 | @item --checkers |
5590 | @itemx -c | |
5591 | Only enable the checkers specified in a comma-separated list using the | |
5592 | names returned by @code{--list-checkers}. | |
5593 | ||
b4f5e0e8 | 5594 | @end table |
37166310 | 5595 | |
fcc58db6 LC |
5596 | @node Invoking guix size |
5597 | @section Invoking @command{guix size} | |
5598 | ||
e32171ee JD |
5599 | @cindex size |
5600 | @cindex package size | |
5601 | @cindex closure | |
5602 | @cindex @command{guix size} | |
fcc58db6 LC |
5603 | The @command{guix size} command helps package developers profile the |
5604 | disk usage of packages. It is easy to overlook the impact of an | |
5605 | additional dependency added to a package, or the impact of using a | |
5606 | single output for a package that could easily be split (@pxref{Packages | |
f97c9175 | 5607 | with Multiple Outputs}). Such are the typical issues that |
fcc58db6 LC |
5608 | @command{guix size} can highlight. |
5609 | ||
5610 | The command can be passed a package specification such as @code{gcc-4.8} | |
5611 | or @code{guile:debug}, or a file name in the store. Consider this | |
5612 | example: | |
5613 | ||
5614 | @example | |
5615 | $ guix size coreutils | |
5616 | store item total self | |
5617 | /gnu/store/@dots{}-coreutils-8.23 70.0 13.9 19.8% | |
5618 | /gnu/store/@dots{}-gmp-6.0.0a 55.3 2.5 3.6% | |
5619 | /gnu/store/@dots{}-acl-2.2.52 53.7 0.5 0.7% | |
5620 | /gnu/store/@dots{}-attr-2.4.46 53.2 0.3 0.5% | |
5621 | /gnu/store/@dots{}-gcc-4.8.4-lib 52.9 15.7 22.4% | |
5622 | /gnu/store/@dots{}-glibc-2.21 37.2 37.2 53.1% | |
5623 | @end example | |
5624 | ||
5625 | @cindex closure | |
5626 | The store items listed here constitute the @dfn{transitive closure} of | |
5627 | Coreutils---i.e., Coreutils and all its dependencies, recursively---as | |
5628 | would be returned by: | |
5629 | ||
5630 | @example | |
5631 | $ guix gc -R /gnu/store/@dots{}-coreutils-8.23 | |
5632 | @end example | |
5633 | ||
f97c9175 | 5634 | Here the output shows three columns next to store items. The first column, |
fcc58db6 LC |
5635 | labeled ``total'', shows the size in mebibytes (MiB) of the closure of |
5636 | the store item---that is, its own size plus the size of all its | |
5637 | dependencies. The next column, labeled ``self'', shows the size of the | |
f97c9175 AE |
5638 | item itself. The last column shows the ratio of the size of the item |
5639 | itself to the space occupied by all the items listed here. | |
fcc58db6 LC |
5640 | |
5641 | In this example, we see that the closure of Coreutils weighs in at | |
5642 | 70@tie{}MiB, half of which is taken by libc. (That libc represents a | |
5643 | large fraction of the closure is not a problem @i{per se} because it is | |
5644 | always available on the system anyway.) | |
5645 | ||
5646 | When the package passed to @command{guix size} is available in the | |
5647 | store, @command{guix size} queries the daemon to determine its | |
5648 | dependencies, and measures its size in the store, similar to @command{du | |
5649 | -ms --apparent-size} (@pxref{du invocation,,, coreutils, GNU | |
5650 | Coreutils}). | |
5651 | ||
5652 | When the given package is @emph{not} in the store, @command{guix size} | |
f97c9175 AE |
5653 | reports information based on the available substitutes |
5654 | (@pxref{Substitutes}). This makes it possible it to profile disk usage of | |
5655 | store items that are not even on disk, only available remotely. | |
fcc58db6 | 5656 | |
db761534 LC |
5657 | You can also specify several package names: |
5658 | ||
5659 | @example | |
5660 | $ guix size coreutils grep sed bash | |
5661 | store item total self | |
5662 | /gnu/store/@dots{}-coreutils-8.24 77.8 13.8 13.4% | |
5663 | /gnu/store/@dots{}-grep-2.22 73.1 0.8 0.8% | |
5664 | /gnu/store/@dots{}-bash-4.3.42 72.3 4.7 4.6% | |
5665 | /gnu/store/@dots{}-readline-6.3 67.6 1.2 1.2% | |
5666 | @dots{} | |
5667 | total: 102.3 MiB | |
5668 | @end example | |
5669 | ||
5670 | @noindent | |
5671 | In this example we see that the combination of the four packages takes | |
5672 | 102.3@tie{}MiB in total, which is much less than the sum of each closure | |
5673 | since they have a lot of dependencies in common. | |
5674 | ||
a8f996c6 | 5675 | The available options are: |
fcc58db6 LC |
5676 | |
5677 | @table @option | |
5678 | ||
d490d06e LC |
5679 | @item --substitute-urls=@var{urls} |
5680 | Use substitute information from @var{urls}. | |
5681 | @xref{client-substitute-urls, the same option for @code{guix build}}. | |
5682 | ||
a8f996c6 | 5683 | @item --map-file=@var{file} |
f97c9175 | 5684 | Write a graphical map of disk usage in PNG format to @var{file}. |
a8f996c6 LC |
5685 | |
5686 | For the example above, the map looks like this: | |
5687 | ||
5688 | @image{images/coreutils-size-map,5in,, map of Coreutils disk usage | |
5689 | produced by @command{guix size}} | |
5690 | ||
5691 | This option requires that | |
5692 | @uref{http://wingolog.org/software/guile-charting/, Guile-Charting} be | |
5693 | installed and visible in Guile's module search path. When that is not | |
5694 | the case, @command{guix size} fails as it tries to load it. | |
5695 | ||
fcc58db6 LC |
5696 | @item --system=@var{system} |
5697 | @itemx -s @var{system} | |
5698 | Consider packages for @var{system}---e.g., @code{x86_64-linux}. | |
5699 | ||
5700 | @end table | |
5701 | ||
88856916 LC |
5702 | @node Invoking guix graph |
5703 | @section Invoking @command{guix graph} | |
5704 | ||
5705 | @cindex DAG | |
e32171ee JD |
5706 | @cindex @command{guix graph} |
5707 | @cindex package dependencies | |
88856916 LC |
5708 | Packages and their dependencies form a @dfn{graph}, specifically a |
5709 | directed acyclic graph (DAG). It can quickly become difficult to have a | |
f97c9175 | 5710 | mental model of the package DAG, so the @command{guix graph} command |
9ea36197 LC |
5711 | provides a visual representation of the DAG. By default, |
5712 | @command{guix graph} emits a DAG representation in the input format of | |
88856916 | 5713 | @uref{http://www.graphviz.org/, Graphviz}, so its output can be passed |
9ea36197 LC |
5714 | directly to the @command{dot} command of Graphviz. It can also emit an |
5715 | HTML page with embedded JavaScript code to display a ``chord diagram'' | |
5716 | in a Web browser, using the @uref{https://d3js.org/, d3.js} library. | |
5717 | The general syntax is: | |
88856916 LC |
5718 | |
5719 | @example | |
5720 | guix graph @var{options} @var{package}@dots{} | |
5721 | @end example | |
5722 | ||
5723 | For example, the following command generates a PDF file representing the | |
5724 | package DAG for the GNU@tie{}Core Utilities, showing its build-time | |
5725 | dependencies: | |
5726 | ||
5727 | @example | |
5728 | guix graph coreutils | dot -Tpdf > dag.pdf | |
5729 | @end example | |
5730 | ||
5731 | The output looks like this: | |
5732 | ||
5733 | @image{images/coreutils-graph,2in,,Dependency graph of the GNU Coreutils} | |
5734 | ||
5735 | Nice little graph, no? | |
5736 | ||
f97c9175 | 5737 | But there is more than one graph! The one above is concise: it is the |
88856916 | 5738 | graph of package objects, omitting implicit inputs such as GCC, libc, |
f97c9175 AE |
5739 | grep, etc. It is often useful to have such a concise graph, but |
5740 | sometimes one may want to see more details. @command{guix graph} supports | |
5741 | several types of graphs, allowing you to choose the level of detail: | |
88856916 LC |
5742 | |
5743 | @table @code | |
5744 | @item package | |
f97c9175 | 5745 | This is the default type used in the example above. It shows the DAG of |
88856916 LC |
5746 | package objects, excluding implicit dependencies. It is concise, but |
5747 | filters out many details. | |
5748 | ||
5749 | @item bag-emerged | |
5750 | This is the package DAG, @emph{including} implicit inputs. | |
5751 | ||
5752 | For instance, the following command: | |
5753 | ||
5754 | @example | |
5755 | guix graph --type=bag-emerged coreutils | dot -Tpdf > dag.pdf | |
5756 | @end example | |
5757 | ||
5758 | ... yields this bigger graph: | |
5759 | ||
5760 | @image{images/coreutils-bag-graph,,5in,Detailed dependency graph of the GNU Coreutils} | |
5761 | ||
5762 | At the bottom of the graph, we see all the implicit inputs of | |
5763 | @var{gnu-build-system} (@pxref{Build Systems, @code{gnu-build-system}}). | |
5764 | ||
f97c9175 | 5765 | Now, note that the dependencies of these implicit inputs---that is, the |
88856916 LC |
5766 | @dfn{bootstrap dependencies} (@pxref{Bootstrapping})---are not shown |
5767 | here, for conciseness. | |
5768 | ||
5769 | @item bag | |
5770 | Similar to @code{bag-emerged}, but this time including all the bootstrap | |
5771 | dependencies. | |
5772 | ||
38b92daa LC |
5773 | @item bag-with-origins |
5774 | Similar to @code{bag}, but also showing origins and their dependencies. | |
5775 | ||
88856916 LC |
5776 | @item derivations |
5777 | This is the most detailed representation: It shows the DAG of | |
5778 | derivations (@pxref{Derivations}) and plain store items. Compared to | |
5779 | the above representation, many additional nodes are visible, including | |
f97c9175 | 5780 | build scripts, patches, Guile modules, etc. |
88856916 | 5781 | |
a773c314 LC |
5782 | For this type of graph, it is also possible to pass a @file{.drv} file |
5783 | name instead of a package name, as in: | |
5784 | ||
5785 | @example | |
5786 | guix graph -t derivation `guix system build -d my-config.scm` | |
5787 | @end example | |
88856916 LC |
5788 | @end table |
5789 | ||
f97c9175 | 5790 | All the types above correspond to @emph{build-time dependencies}. The |
88856916 LC |
5791 | following graph type represents the @emph{run-time dependencies}: |
5792 | ||
5793 | @table @code | |
5794 | @item references | |
5795 | This is the graph of @dfn{references} of a package output, as returned | |
5796 | by @command{guix gc --references} (@pxref{Invoking guix gc}). | |
5797 | ||
5798 | If the given package output is not available in the store, @command{guix | |
5799 | graph} attempts to obtain dependency information from substitutes. | |
a773c314 LC |
5800 | |
5801 | Here you can also pass a store file name instead of a package name. For | |
5802 | example, the command below produces the reference graph of your profile | |
5803 | (which can be big!): | |
5804 | ||
5805 | @example | |
5806 | guix graph -t references `readlink -f ~/.guix-profile` | |
5807 | @end example | |
7f8fec0f LC |
5808 | |
5809 | @item referrers | |
5810 | This is the graph of the @dfn{referrers} of a store item, as returned by | |
5811 | @command{guix gc --referrers} (@pxref{Invoking guix gc}). | |
5812 | ||
5813 | This relies exclusively on local information from your store. For | |
5814 | instance, let us suppose that the current Inkscape is available in 10 | |
5815 | profiles on your machine; @command{guix graph -t referrers inkscape} | |
5816 | will show a graph rooted at Inkscape and with those 10 profiles linked | |
5817 | to it. | |
5818 | ||
5819 | It can help determine what is preventing a store item from being garbage | |
5820 | collected. | |
5821 | ||
88856916 LC |
5822 | @end table |
5823 | ||
5824 | The available options are the following: | |
5825 | ||
5826 | @table @option | |
5827 | @item --type=@var{type} | |
5828 | @itemx -t @var{type} | |
5829 | Produce a graph output of @var{type}, where @var{type} must be one of | |
5830 | the values listed above. | |
5831 | ||
5832 | @item --list-types | |
5833 | List the supported graph types. | |
4c8f997a | 5834 | |
642339dc RW |
5835 | @item --backend=@var{backend} |
5836 | @itemx -b @var{backend} | |
5837 | Produce a graph using the selected @var{backend}. | |
5838 | ||
5839 | @item --list-backends | |
5840 | List the supported graph backends. | |
5841 | ||
9ea36197 LC |
5842 | Currently, the available backends are Graphviz and d3.js. |
5843 | ||
4c8f997a LC |
5844 | @item --expression=@var{expr} |
5845 | @itemx -e @var{expr} | |
5846 | Consider the package @var{expr} evaluates to. | |
5847 | ||
5848 | This is useful to precisely refer to a package, as in this example: | |
5849 | ||
5850 | @example | |
5851 | guix graph -e '(@@@@ (gnu packages commencement) gnu-make-final)' | |
5852 | @end example | |
88856916 LC |
5853 | @end table |
5854 | ||
5855 | ||
372c4bbc DT |
5856 | @node Invoking guix environment |
5857 | @section Invoking @command{guix environment} | |
5858 | ||
f5fd4fd2 | 5859 | @cindex reproducible build environments |
fe36d84e | 5860 | @cindex development environments |
e32171ee JD |
5861 | @cindex @command{guix environment} |
5862 | @cindex environment, package build environment | |
372c4bbc DT |
5863 | The purpose of @command{guix environment} is to assist hackers in |
5864 | creating reproducible development environments without polluting their | |
5865 | package profile. The @command{guix environment} tool takes one or more | |
f97c9175 | 5866 | packages, builds all of their inputs, and creates a shell |
372c4bbc DT |
5867 | environment to use them. |
5868 | ||
5869 | The general syntax is: | |
5870 | ||
5871 | @example | |
5872 | guix environment @var{options} @var{package}@dots{} | |
5873 | @end example | |
5874 | ||
fe36d84e LC |
5875 | The following example spawns a new shell set up for the development of |
5876 | GNU@tie{}Guile: | |
372c4bbc DT |
5877 | |
5878 | @example | |
5879 | guix environment guile | |
5880 | @end example | |
5881 | ||
f97c9175 AE |
5882 | If the needed dependencies are not built yet, @command{guix environment} |
5883 | automatically builds them. The environment of the new shell is an augmented | |
372c4bbc DT |
5884 | version of the environment that @command{guix environment} was run in. |
5885 | It contains the necessary search paths for building the given package | |
5886 | added to the existing environment variables. To create a ``pure'' | |
f97c9175 | 5887 | environment, in which the original environment variables have been unset, |
50500f7c LC |
5888 | use the @code{--pure} option@footnote{Users sometimes wrongfully augment |
5889 | environment variables such as @code{PATH} in their @file{~/.bashrc} | |
5890 | file. As a consequence, when @code{guix environment} launches it, Bash | |
5891 | may read @file{~/.bashrc}, thereby introducing ``impurities'' in these | |
5892 | environment variables. It is an error to define such environment | |
5893 | variables in @file{.bashrc}; instead, they should be defined in | |
5894 | @file{.bash_profile}, which is sourced only by log-in shells. | |
5895 | @xref{Bash Startup Files,,, bash, The GNU Bash Reference Manual}, for | |
5896 | details on Bash start-up files.}. | |
372c4bbc | 5897 | |
28de8d25 LC |
5898 | @vindex GUIX_ENVIRONMENT |
5899 | @command{guix environment} defines the @code{GUIX_ENVIRONMENT} | |
20185522 LC |
5900 | variable in the shell it spawns; its value is the file name of the |
5901 | profile of this environment. This allows users to, say, define a | |
28de8d25 LC |
5902 | specific prompt for development environments in their @file{.bashrc} |
5903 | (@pxref{Bash Startup Files,,, bash, The GNU Bash Reference Manual}): | |
5904 | ||
5905 | @example | |
5906 | if [ -n "$GUIX_ENVIRONMENT" ] | |
5907 | then | |
5908 | export PS1="\u@@\h \w [dev]\$ " | |
5909 | fi | |
5910 | @end example | |
5911 | ||
20185522 LC |
5912 | @noindent |
5913 | ... or to browse the profile: | |
5914 | ||
5915 | @example | |
5916 | $ ls "$GUIX_ENVIRONMENT/bin" | |
5917 | @end example | |
5918 | ||
372c4bbc DT |
5919 | Additionally, more than one package may be specified, in which case the |
5920 | union of the inputs for the given packages are used. For example, the | |
5921 | command below spawns a shell where all of the dependencies of both Guile | |
5922 | and Emacs are available: | |
5923 | ||
5924 | @example | |
5925 | guix environment guile emacs | |
5926 | @end example | |
5927 | ||
1de2fe95 DT |
5928 | Sometimes an interactive shell session is not desired. An arbitrary |
5929 | command may be invoked by placing the @code{--} token to separate the | |
5930 | command from the rest of the arguments: | |
372c4bbc DT |
5931 | |
5932 | @example | |
1de2fe95 | 5933 | guix environment guile -- make -j4 |
372c4bbc DT |
5934 | @end example |
5935 | ||
fe36d84e LC |
5936 | In other situations, it is more convenient to specify the list of |
5937 | packages needed in the environment. For example, the following command | |
5938 | runs @command{python} from an environment containing Python@tie{}2.7 and | |
5939 | NumPy: | |
5940 | ||
5941 | @example | |
1de2fe95 | 5942 | guix environment --ad-hoc python2-numpy python-2.7 -- python |
fe36d84e LC |
5943 | @end example |
5944 | ||
cc90fbbf DT |
5945 | Furthermore, one might want the dependencies of a package and also some |
5946 | additional packages that are not build-time or runtime dependencies, but | |
5947 | are useful when developing nonetheless. Because of this, the | |
5948 | @code{--ad-hoc} flag is positional. Packages appearing before | |
5949 | @code{--ad-hoc} are interpreted as packages whose dependencies will be | |
5950 | added to the environment. Packages appearing after are interpreted as | |
5951 | packages that will be added to the environment directly. For example, | |
5952 | the following command creates a Guix development environment that | |
5953 | additionally includes Git and strace: | |
5954 | ||
5955 | @example | |
5956 | guix environment guix --ad-hoc git strace | |
5957 | @end example | |
5958 | ||
f535dcbe DT |
5959 | Sometimes it is desirable to isolate the environment as much as |
5960 | possible, for maximal purity and reproducibility. In particular, when | |
5961 | using Guix on a host distro that is not GuixSD, it is desirable to | |
5962 | prevent access to @file{/usr/bin} and other system-wide resources from | |
5963 | the development environment. For example, the following command spawns | |
5964 | a Guile REPL in a ``container'' where only the store and the current | |
5965 | working directory are mounted: | |
5966 | ||
5967 | @example | |
5968 | guix environment --ad-hoc --container guile -- guile | |
5969 | @end example | |
5970 | ||
0f252e26 | 5971 | @quotation Note |
cfd35b4e | 5972 | The @code{--container} option requires Linux-libre 3.19 or newer. |
0f252e26 DT |
5973 | @end quotation |
5974 | ||
fe36d84e | 5975 | The available options are summarized below. |
372c4bbc DT |
5976 | |
5977 | @table @code | |
f943c317 LC |
5978 | @item --root=@var{file} |
5979 | @itemx -r @var{file} | |
5980 | @cindex persistent environment | |
5981 | @cindex garbage collector root, for environments | |
5982 | Make @var{file} a symlink to the profile for this environment, and | |
5983 | register it as a garbage collector root. | |
5984 | ||
5985 | This is useful if you want to protect your environment from garbage | |
5986 | collection, to make it ``persistent''. | |
5987 | ||
5988 | When this option is omitted, the environment is protected from garbage | |
5989 | collection only for the duration of the @command{guix environment} | |
5990 | session. This means that next time you recreate the same environment, | |
5991 | you could have to rebuild or re-download packages. | |
5992 | ||
372c4bbc DT |
5993 | @item --expression=@var{expr} |
5994 | @itemx -e @var{expr} | |
c9c282ce DT |
5995 | Create an environment for the package or list of packages that |
5996 | @var{expr} evaluates to. | |
372c4bbc | 5997 | |
fe36d84e LC |
5998 | For example, running: |
5999 | ||
6000 | @example | |
6001 | guix environment -e '(@@ (gnu packages maths) petsc-openmpi)' | |
6002 | @end example | |
6003 | ||
6004 | starts a shell with the environment for this specific variant of the | |
6005 | PETSc package. | |
6006 | ||
c9c282ce DT |
6007 | Running: |
6008 | ||
6009 | @example | |
5c2b2f00 | 6010 | guix environment --ad-hoc -e '(@@ (gnu) %base-packages)' |
c9c282ce DT |
6011 | @end example |
6012 | ||
6013 | starts a shell with all the GuixSD base packages available. | |
6014 | ||
779aa003 DT |
6015 | The above commands only the use default output of the given packages. |
6016 | To select other outputs, two element tuples can be specified: | |
6017 | ||
6018 | @example | |
6019 | guix environment --ad-hoc -e '(list (@ (gnu packages bash) bash) "include")' | |
6020 | @end example | |
6021 | ||
372c4bbc DT |
6022 | @item --load=@var{file} |
6023 | @itemx -l @var{file} | |
c9c282ce DT |
6024 | Create an environment for the package or list of packages that the code |
6025 | within @var{file} evaluates to. | |
372c4bbc | 6026 | |
fe36d84e LC |
6027 | As an example, @var{file} might contain a definition like this |
6028 | (@pxref{Defining Packages}): | |
6029 | ||
6030 | @example | |
6031 | @verbatiminclude environment-gdb.scm | |
6032 | @end example | |
6033 | ||
a54bd6d7 DT |
6034 | @item --ad-hoc |
6035 | Include all specified packages in the resulting environment, as if an | |
6036 | @i{ad hoc} package were defined with them as inputs. This option is | |
6037 | useful for quickly creating an environment without having to write a | |
6038 | package expression to contain the desired inputs. | |
6039 | ||
6040 | For instance, the command: | |
6041 | ||
6042 | @example | |
1de2fe95 | 6043 | guix environment --ad-hoc guile guile-sdl -- guile |
a54bd6d7 DT |
6044 | @end example |
6045 | ||
6046 | runs @command{guile} in an environment where Guile and Guile-SDL are | |
6047 | available. | |
6048 | ||
417c39f1 | 6049 | Note that this example implicitly asks for the default output of |
f97c9175 | 6050 | @code{guile} and @code{guile-sdl}, but it is possible to ask for a |
417c39f1 LC |
6051 | specific output---e.g., @code{glib:bin} asks for the @code{bin} output |
6052 | of @code{glib} (@pxref{Packages with Multiple Outputs}). | |
6053 | ||
cc90fbbf DT |
6054 | This option may be composed with the default behavior of @command{guix |
6055 | environment}. Packages appearing before @code{--ad-hoc} are interpreted | |
6056 | as packages whose dependencies will be added to the environment, the | |
6057 | default behavior. Packages appearing after are interpreted as packages | |
6058 | that will be added to the environment directly. | |
6059 | ||
372c4bbc DT |
6060 | @item --pure |
6061 | Unset existing environment variables when building the new environment. | |
6062 | This has the effect of creating an environment in which search paths | |
6063 | only contain package inputs. | |
6064 | ||
6065 | @item --search-paths | |
6066 | Display the environment variable definitions that make up the | |
6067 | environment. | |
ce367ef3 LC |
6068 | |
6069 | @item --system=@var{system} | |
6070 | @itemx -s @var{system} | |
6071 | Attempt to build for @var{system}---e.g., @code{i686-linux}. | |
f535dcbe DT |
6072 | |
6073 | @item --container | |
6074 | @itemx -C | |
6075 | @cindex container | |
6076 | Run @var{command} within an isolated container. The current working | |
a01ad638 DT |
6077 | directory outside the container is mapped inside the container. |
6078 | Additionally, a dummy home directory is created that matches the current | |
6079 | user's home directory, and @file{/etc/passwd} is configured accordingly. | |
6080 | The spawned process runs as the current user outside the container, but | |
6081 | has root privileges in the context of the container. | |
f535dcbe DT |
6082 | |
6083 | @item --network | |
6084 | @itemx -N | |
6085 | For containers, share the network namespace with the host system. | |
6086 | Containers created without this flag only have access to the loopback | |
6087 | device. | |
6088 | ||
6089 | @item --expose=@var{source}[=@var{target}] | |
6090 | For containers, expose the file system @var{source} from the host system | |
6091 | as the read-only file system @var{target} within the container. If | |
6092 | @var{target} is not specified, @var{source} is used as the target mount | |
6093 | point in the container. | |
6094 | ||
6095 | The example below spawns a Guile REPL in a container in which the user's | |
6096 | home directory is accessible read-only via the @file{/exchange} | |
6097 | directory: | |
6098 | ||
6099 | @example | |
6100 | guix environment --container --expose=$HOME=/exchange guile -- guile | |
6101 | @end example | |
6102 | ||
5c2b2f00 | 6103 | @item --share=@var{source}[=@var{target}] |
f535dcbe DT |
6104 | For containers, share the file system @var{source} from the host system |
6105 | as the writable file system @var{target} within the container. If | |
6106 | @var{target} is not specified, @var{source} is used as the target mount | |
6107 | point in the container. | |
6108 | ||
6109 | The example below spawns a Guile REPL in a container in which the user's | |
6110 | home directory is accessible for both reading and writing via the | |
6111 | @file{/exchange} directory: | |
6112 | ||
6113 | @example | |
6114 | guix environment --container --share=$HOME=/exchange guile -- guile | |
6115 | @end example | |
372c4bbc DT |
6116 | @end table |
6117 | ||
6118 | It also supports all of the common build options that @command{guix | |
ccd7158d | 6119 | build} supports (@pxref{Common Build Options}). |
372c4bbc | 6120 | |
aff8ce7c DT |
6121 | @node Invoking guix publish |
6122 | @section Invoking @command{guix publish} | |
6123 | ||
e32171ee | 6124 | @cindex @command{guix publish} |
aff8ce7c | 6125 | The purpose of @command{guix publish} is to enable users to easily share |
f97c9175 | 6126 | their store with others, who can then use it as a substitute server |
8ce229fc LC |
6127 | (@pxref{Substitutes}). |
6128 | ||
6129 | When @command{guix publish} runs, it spawns an HTTP server which allows | |
6130 | anyone with network access to obtain substitutes from it. This means | |
6131 | that any machine running Guix can also act as if it were a build farm, | |
6132 | since the HTTP interface is compatible with Hydra, the software behind | |
6133 | the @code{hydra.gnu.org} build farm. | |
aff8ce7c DT |
6134 | |
6135 | For security, each substitute is signed, allowing recipients to check | |
6136 | their authenticity and integrity (@pxref{Substitutes}). Because | |
f97c9175 | 6137 | @command{guix publish} uses the signing key of the system, which is only |
5463fe51 LC |
6138 | readable by the system administrator, it must be started as root; the |
6139 | @code{--user} option makes it drop root privileges early on. | |
aff8ce7c | 6140 | |
b18812b6 LC |
6141 | The signing key pair must be generated before @command{guix publish} is |
6142 | launched, using @command{guix archive --generate-key} (@pxref{Invoking | |
6143 | guix archive}). | |
6144 | ||
aff8ce7c DT |
6145 | The general syntax is: |
6146 | ||
6147 | @example | |
6148 | guix publish @var{options}@dots{} | |
6149 | @end example | |
6150 | ||
6151 | Running @command{guix publish} without any additional arguments will | |
6152 | spawn an HTTP server on port 8080: | |
6153 | ||
6154 | @example | |
6155 | guix publish | |
6156 | @end example | |
6157 | ||
6158 | Once a publishing server has been authorized (@pxref{Invoking guix | |
6159 | archive}), the daemon may download substitutes from it: | |
6160 | ||
6161 | @example | |
6162 | guix-daemon --substitute-urls=http://example.org:8080 | |
6163 | @end example | |
6164 | ||
ff6638d1 LC |
6165 | As a bonus, @command{guix publish} also serves as a content-addressed |
6166 | mirror for source files referenced in @code{origin} records | |
6167 | (@pxref{origin Reference}). For instance, assuming @command{guix | |
6168 | publish} is running on @code{example.org}, the following URL returns the | |
6169 | raw @file{hello-2.10.tar.gz} file with the given SHA256 hash | |
6170 | (represented in @code{nix-base32} format, @pxref{Invoking guix hash}): | |
6171 | ||
6172 | @example | |
6173 | http://example.org/file/hello-2.10.tar.gz/sha256/0ssi1@dots{}ndq1i | |
6174 | @end example | |
6175 | ||
6176 | Obviously, these URLs only work for files that are in the store; in | |
6177 | other cases, they return 404 (``Not Found''). | |
6178 | ||
aff8ce7c DT |
6179 | The following options are available: |
6180 | ||
6181 | @table @code | |
6182 | @item --port=@var{port} | |
6183 | @itemx -p @var{port} | |
6184 | Listen for HTTP requests on @var{port}. | |
6185 | ||
9e2292ef LC |
6186 | @item --listen=@var{host} |
6187 | Listen on the network interface for @var{host}. The default is to | |
6188 | accept connections from any interface. | |
6189 | ||
5463fe51 LC |
6190 | @item --user=@var{user} |
6191 | @itemx -u @var{user} | |
6192 | Change privileges to @var{user} as soon as possible---i.e., once the | |
6193 | server socket is open and the signing key has been read. | |
6194 | ||
4a1fc562 LC |
6195 | @item --compression[=@var{level}] |
6196 | @itemx -C [@var{level}] | |
6197 | Compress data using the given @var{level}. When @var{level} is zero, | |
6198 | disable compression. The range 1 to 9 corresponds to different gzip | |
6199 | compression levels: 1 is the fastest, and 9 is the best (CPU-intensive). | |
6200 | The default is 3. | |
6201 | ||
4591c02e | 6202 | Compression occurs on the fly and the compressed streams are not |
4a1fc562 LC |
6203 | cached. Thus, to reduce load on the machine that runs @command{guix |
6204 | publish}, it may be a good idea to choose a low compression level, or to | |
6205 | run @command{guix publish} behind a caching proxy. | |
6206 | ||
e4c7a5f7 LC |
6207 | @item --ttl=@var{ttl} |
6208 | Produce @code{Cache-Control} HTTP headers that advertise a time-to-live | |
6209 | (TTL) of @var{ttl}. @var{ttl} must denote a duration: @code{5d} means 5 | |
6210 | days, @code{1m} means 1 month, and so on. | |
6211 | ||
6212 | This allows the user's Guix to keep substitute information in cache for | |
6213 | @var{ttl}. However, note that @code{guix publish} does not itself | |
6214 | guarantee that the store items it provides will indeed remain available | |
6215 | for as long as @var{ttl}. | |
6216 | ||
aff8ce7c DT |
6217 | @item --repl[=@var{port}] |
6218 | @itemx -r [@var{port}] | |
6219 | Spawn a Guile REPL server (@pxref{REPL Servers,,, guile, GNU Guile | |
8ce229fc LC |
6220 | Reference Manual}) on @var{port} (37146 by default). This is used |
6221 | primarily for debugging a running @command{guix publish} server. | |
aff8ce7c DT |
6222 | @end table |
6223 | ||
1c52181f LC |
6224 | Enabling @command{guix publish} on a GuixSD system is a one-liner: just |
6225 | add a call to @code{guix-publish-service} in the @code{services} field | |
6226 | of the @code{operating-system} declaration (@pxref{guix-publish-service, | |
6227 | @code{guix-publish-service}}). | |
6228 | ||
332d7903 HG |
6229 | If you are instead running Guix on a ``foreign distro'', follow these |
6230 | instructions:” | |
6231 | ||
6232 | @itemize | |
6233 | @item | |
6234 | If your host distro uses the systemd init system: | |
6235 | ||
6236 | @example | |
6237 | # ln -s ~root/.guix-profile/lib/systemd/system/guix-publish.service \ | |
6238 | /etc/systemd/system/ | |
6239 | # systemctl start guix-publish && systemctl enable guix-publish | |
6240 | @end example | |
6241 | ||
6242 | @item | |
6243 | If your host distro uses the Upstart init system: | |
6244 | ||
6245 | @example | |
6246 | # ln -s ~root/.guix-profile/lib/upstart/system/guix-publish.conf /etc/init/ | |
6247 | # start guix-publish | |
6248 | @end example | |
6249 | ||
6250 | @item | |
6251 | Otherwise, proceed similarly with your distro's init system. | |
6252 | @end itemize | |
d23c20f1 LC |
6253 | |
6254 | @node Invoking guix challenge | |
6255 | @section Invoking @command{guix challenge} | |
6256 | ||
6257 | @cindex reproducible builds | |
6258 | @cindex verifiable builds | |
e32171ee JD |
6259 | @cindex @command{guix challenge} |
6260 | @cindex challenge | |
d23c20f1 | 6261 | Do the binaries provided by this server really correspond to the source |
f97c9175 | 6262 | code it claims to build? Is a package build process deterministic? |
d23c20f1 LC |
6263 | These are the questions the @command{guix challenge} command attempts to |
6264 | answer. | |
6265 | ||
6266 | The former is obviously an important question: Before using a substitute | |
f97c9175 | 6267 | server (@pxref{Substitutes}), one had better @emph{verify} that it |
d23c20f1 LC |
6268 | provides the right binaries, and thus @emph{challenge} it. The latter |
6269 | is what enables the former: If package builds are deterministic, then | |
6270 | independent builds of the package should yield the exact same result, | |
6271 | bit for bit; if a server provides a binary different from the one | |
6272 | obtained locally, it may be either corrupt or malicious. | |
6273 | ||
6274 | We know that the hash that shows up in @file{/gnu/store} file names is | |
6275 | the hash of all the inputs of the process that built the file or | |
6276 | directory---compilers, libraries, build scripts, | |
6277 | etc. (@pxref{Introduction}). Assuming deterministic build processes, | |
6278 | one store file name should map to exactly one build output. | |
6279 | @command{guix challenge} checks whether there is, indeed, a single | |
6280 | mapping by comparing the build outputs of several independent builds of | |
6281 | any given store item. | |
6282 | ||
f97c9175 | 6283 | The command output looks like this: |
d23c20f1 LC |
6284 | |
6285 | @smallexample | |
ddbc7f7d LC |
6286 | $ guix challenge --substitute-urls="https://hydra.gnu.org https://guix.example.org" |
6287 | updating list of substitutes from 'https://hydra.gnu.org'... 100.0% | |
6288 | updating list of substitutes from 'https://guix.example.org'... 100.0% | |
d23c20f1 LC |
6289 | /gnu/store/@dots{}-openssl-1.0.2d contents differ: |
6290 | local hash: 0725l22r5jnzazaacncwsvp9kgf42266ayyp814v7djxs7nk963q | |
ddbc7f7d LC |
6291 | https://hydra.gnu.org/nar/@dots{}-openssl-1.0.2d: 0725l22r5jnzazaacncwsvp9kgf42266ayyp814v7djxs7nk963q |
6292 | https://guix.example.org/nar/@dots{}-openssl-1.0.2d: 1zy4fmaaqcnjrzzajkdn3f5gmjk754b43qkq47llbyak9z0qjyim | |
d23c20f1 LC |
6293 | /gnu/store/@dots{}-git-2.5.0 contents differ: |
6294 | local hash: 00p3bmryhjxrhpn2gxs2fy0a15lnip05l97205pgbk5ra395hyha | |
ddbc7f7d LC |
6295 | https://hydra.gnu.org/nar/@dots{}-git-2.5.0: 069nb85bv4d4a6slrwjdy8v1cn4cwspm3kdbmyb81d6zckj3nq9f |
6296 | https://guix.example.org/nar/@dots{}-git-2.5.0: 0mdqa9w1p6cmli6976v4wi0sw9r4p5prkj7lzfd1877wk11c9c73 | |
d23c20f1 LC |
6297 | /gnu/store/@dots{}-pius-2.1.1 contents differ: |
6298 | local hash: 0k4v3m9z1zp8xzzizb7d8kjj72f9172xv078sq4wl73vnq9ig3ax | |
ddbc7f7d LC |
6299 | https://hydra.gnu.org/nar/@dots{}-pius-2.1.1: 0k4v3m9z1zp8xzzizb7d8kjj72f9172xv078sq4wl73vnq9ig3ax |
6300 | https://guix.example.org/nar/@dots{}-pius-2.1.1: 1cy25x1a4fzq5rk0pmvc8xhwyffnqz95h2bpvqsz2mpvlbccy0gs | |
d23c20f1 LC |
6301 | @end smallexample |
6302 | ||
6303 | @noindent | |
6304 | In this example, @command{guix challenge} first scans the store to | |
6305 | determine the set of locally-built derivations---as opposed to store | |
6306 | items that were downloaded from a substitute server---and then queries | |
6307 | all the substitute servers. It then reports those store items for which | |
6308 | the servers obtained a result different from the local build. | |
6309 | ||
6310 | @cindex non-determinism, in package builds | |
6311 | As an example, @code{guix.example.org} always gets a different answer. | |
6312 | Conversely, @code{hydra.gnu.org} agrees with local builds, except in the | |
6313 | case of Git. This might indicate that the build process of Git is | |
6314 | non-deterministic, meaning that its output varies as a function of | |
6315 | various things that Guix does not fully control, in spite of building | |
6316 | packages in isolated environments (@pxref{Features}). Most common | |
6317 | sources of non-determinism include the addition of timestamps in build | |
6318 | results, the inclusion of random numbers, and directory listings sorted | |
a70a5004 | 6319 | by inode number. See @uref{https://reproducible-builds.org/docs/}, for |
d23c20f1 LC |
6320 | more information. |
6321 | ||
f97c9175 | 6322 | To find out what is wrong with this Git binary, we can do something along |
d23c20f1 LC |
6323 | these lines (@pxref{Invoking guix archive}): |
6324 | ||
6325 | @example | |
ddbc7f7d | 6326 | $ wget -q -O - https://hydra.gnu.org/nar/@dots{}-git-2.5.0 \ |
d23c20f1 | 6327 | | guix archive -x /tmp/git |
043f4698 | 6328 | $ diff -ur --no-dereference /gnu/store/@dots{}-git.2.5.0 /tmp/git |
d23c20f1 LC |
6329 | @end example |
6330 | ||
6331 | This command shows the difference between the files resulting from the | |
6332 | local build, and the files resulting from the build on | |
6333 | @code{hydra.gnu.org} (@pxref{Overview, Comparing and Merging Files,, | |
6334 | diffutils, Comparing and Merging Files}). The @command{diff} command | |
6335 | works great for text files. When binary files differ, a better option | |
ddbc7f7d | 6336 | is @uref{https://diffoscope.org/, Diffoscope}, a tool that helps |
d23c20f1 LC |
6337 | visualize differences for all kinds of files. |
6338 | ||
f97c9175 | 6339 | Once you have done that work, you can tell whether the differences are due |
d23c20f1 LC |
6340 | to a non-deterministic build process or to a malicious server. We try |
6341 | hard to remove sources of non-determinism in packages to make it easier | |
f97c9175 AE |
6342 | to verify substitutes, but of course, this is a process that |
6343 | involves not just Guix, but a large part of the free software community. | |
d23c20f1 LC |
6344 | In the meantime, @command{guix challenge} is one tool to help address |
6345 | the problem. | |
6346 | ||
6347 | If you are writing packages for Guix, you are encouraged to check | |
6348 | whether @code{hydra.gnu.org} and other substitute servers obtain the | |
6349 | same build result as you did with: | |
6350 | ||
6351 | @example | |
6352 | $ guix challenge @var{package} | |
6353 | @end example | |
6354 | ||
6355 | @noindent | |
f97c9175 | 6356 | where @var{package} is a package specification such as |
7cffaeb6 | 6357 | @code{guile@@2.0} or @code{glibc:debug}. |
d23c20f1 LC |
6358 | |
6359 | The general syntax is: | |
6360 | ||
6361 | @example | |
6362 | guix challenge @var{options} [@var{packages}@dots{}] | |
6363 | @end example | |
6364 | ||
7cffaeb6 LC |
6365 | When a difference is found between the hash of a locally-built item and |
6366 | that of a server-provided substitute, or among substitutes provided by | |
6367 | different servers, the command displays it as in the example above and | |
a17417a8 LC |
6368 | its exit code is 2 (other non-zero exit codes denote other kinds of |
6369 | errors.) | |
7cffaeb6 | 6370 | |
d23c20f1 LC |
6371 | The one option that matters is: |
6372 | ||
6373 | @table @code | |
6374 | ||
6375 | @item --substitute-urls=@var{urls} | |
6376 | Consider @var{urls} the whitespace-separated list of substitute source | |
6377 | URLs to compare to. | |
6378 | ||
6379 | @end table | |
6380 | ||
f11c444d LC |
6381 | @node Invoking guix copy |
6382 | @section Invoking @command{guix copy} | |
6383 | ||
6384 | @cindex copy, of store items, over SSH | |
6385 | @cindex SSH, copy of store items | |
6386 | @cindex sharing store items across machines | |
6387 | @cindex transferring store items across machines | |
6388 | The @command{guix copy} command copies items from the store of one | |
6389 | machine to that of another machine over a secure shell (SSH) | |
6390 | connection@footnote{This command is available only when Guile-SSH was | |
6391 | found. @xref{Requirements}, for details.}. For example, the following | |
6392 | command copies the @code{coreutils} package, the user's profile, and all | |
6393 | their dependencies over to @var{host}, logged in as @var{user}: | |
6394 | ||
6395 | @example | |
6396 | guix copy --to=@var{user}@@@var{host} \ | |
6397 | coreutils `readlink -f ~/.guix-profile` | |
6398 | @end example | |
6399 | ||
6400 | If some of the items to be copied are already present on @var{host}, | |
6401 | they are not actually sent. | |
6402 | ||
6403 | The command below retrieves @code{libreoffice} and @code{gimp} from | |
6404 | @var{host}, assuming they are available there: | |
6405 | ||
6406 | @example | |
6407 | guix copy --from=@var{host} libreoffice gimp | |
6408 | @end example | |
6409 | ||
6410 | The SSH connection is established using the Guile-SSH client, which is | |
6411 | compatible with OpenSSH: it honors @file{~/.ssh/known_hosts} and | |
6412 | @file{~/.ssh/config}, and uses the SSH agent for authentication. | |
6413 | ||
6414 | The key used to sign items that are sent must be accepted by the remote | |
6415 | machine. Likewise, the key used by the remote machine to sign items you | |
6416 | are retrieving must be in @file{/etc/guix/acl} so it is accepted by your | |
6417 | own daemon. @xref{Invoking guix archive}, for more information about | |
6418 | store item authentication. | |
6419 | ||
6420 | The general syntax is: | |
6421 | ||
6422 | @example | |
6423 | guix copy [--to=@var{spec}|--from=@var{spec}] @var{items}@dots{} | |
6424 | @end example | |
6425 | ||
6426 | You must always specify one of the following options: | |
6427 | ||
6428 | @table @code | |
6429 | @item --to=@var{spec} | |
6430 | @itemx --from=@var{spec} | |
6431 | Specify the host to send to or receive from. @var{spec} must be an SSH | |
6432 | spec such as @code{example.org}, @code{charlie@@example.org}, or | |
6433 | @code{charlie@@example.org:2222}. | |
6434 | @end table | |
6435 | ||
6436 | The @var{items} can be either package names, such as @code{gimp}, or | |
6437 | store items, such as @file{/gnu/store/@dots{}-idutils-4.6}. | |
6438 | ||
6439 | When specifying the name of a package to send, it is first built if | |
6440 | needed, unless @option{--dry-run} was specified. Common build options | |
6441 | are supported (@pxref{Common Build Options}). | |
6442 | ||
d23c20f1 | 6443 | |
32efa254 DT |
6444 | @node Invoking guix container |
6445 | @section Invoking @command{guix container} | |
6446 | @cindex container | |
e32171ee | 6447 | @cindex @command{guix container} |
32efa254 DT |
6448 | @quotation Note |
6449 | As of version @value{VERSION}, this tool is experimental. The interface | |
6450 | is subject to radical change in the future. | |
6451 | @end quotation | |
6452 | ||
6453 | The purpose of @command{guix container} is to manipulate processes | |
6454 | running within an isolated environment, commonly known as a | |
46c36586 | 6455 | ``container'', typically created by the @command{guix environment} |
32efa254 DT |
6456 | (@pxref{Invoking guix environment}) and @command{guix system container} |
6457 | (@pxref{Invoking guix system}) commands. | |
6458 | ||
6459 | The general syntax is: | |
6460 | ||
6461 | @example | |
6462 | guix container @var{action} @var{options}@dots{} | |
6463 | @end example | |
6464 | ||
6465 | @var{action} specifies the operation to perform with a container, and | |
6466 | @var{options} specifies the context-specific arguments for the action. | |
6467 | ||
6468 | The following actions are available: | |
6469 | ||
6470 | @table @code | |
6471 | @item exec | |
6472 | Execute a command within the context of a running container. | |
6473 | ||
6474 | The syntax is: | |
6475 | ||
6476 | @example | |
6477 | guix container exec @var{pid} @var{program} @var{arguments}@dots{} | |
6478 | @end example | |
6479 | ||
6480 | @var{pid} specifies the process ID of the running container. | |
f97c9175 AE |
6481 | @var{program} specifies an executable file name within the root file |
6482 | system of the container. @var{arguments} are the additional options that | |
6483 | will be passed to @var{program}. | |
32efa254 DT |
6484 | |
6485 | The following command launches an interactive login shell inside a | |
6486 | GuixSD container, started by @command{guix system container}, and whose | |
6487 | process ID is 9001: | |
6488 | ||
6489 | @example | |
6490 | guix container exec 9001 /run/current-system/profile/bin/bash --login | |
6491 | @end example | |
6492 | ||
6493 | Note that the @var{pid} cannot be the parent process of a container. It | |
f97c9175 | 6494 | must be PID 1 of the container or one of its child processes. |
32efa254 DT |
6495 | |
6496 | @end table | |
6497 | ||
a1ba8475 LC |
6498 | @c ********************************************************************* |
6499 | @node GNU Distribution | |
6500 | @chapter GNU Distribution | |
6501 | ||
3ca2731c | 6502 | @cindex Guix System Distribution |
4705641f | 6503 | @cindex GuixSD |
3ca2731c LC |
6504 | Guix comes with a distribution of the GNU system consisting entirely of |
6505 | free software@footnote{The term ``free'' here refers to the | |
a1ba8475 | 6506 | @url{http://www.gnu.org/philosophy/free-sw.html,freedom provided to |
3ca2731c | 6507 | users of that software}.}. The |
35ed9306 LC |
6508 | distribution can be installed on its own (@pxref{System Installation}), |
6509 | but it is also possible to install Guix as a package manager on top of | |
6510 | an installed GNU/Linux system (@pxref{Installation}). To distinguish | |
3ca2731c | 6511 | between the two, we refer to the standalone distribution as the Guix |
4705641f | 6512 | System Distribution, or GuixSD. |
35ed9306 LC |
6513 | |
6514 | The distribution provides core GNU packages such as GNU libc, GCC, and | |
6515 | Binutils, as well as many GNU and non-GNU applications. The complete | |
6516 | list of available packages can be browsed | |
093ae1be | 6517 | @url{http://www.gnu.org/software/guix/packages,on-line} or by |
d03bb653 | 6518 | running @command{guix package} (@pxref{Invoking guix package}): |
a1ba8475 LC |
6519 | |
6520 | @example | |
e49951eb | 6521 | guix package --list-available |
a1ba8475 LC |
6522 | @end example |
6523 | ||
f97c9175 | 6524 | Our goal is to provide a practical 100% free software distribution of |
401c53c4 LC |
6525 | Linux-based and other variants of GNU, with a focus on the promotion and |
6526 | tight integration of GNU components, and an emphasis on programs and | |
6527 | tools that help users exert that freedom. | |
6528 | ||
3ca2731c | 6529 | Packages are currently available on the following platforms: |
c320011d LC |
6530 | |
6531 | @table @code | |
6532 | ||
6533 | @item x86_64-linux | |
6534 | Intel/AMD @code{x86_64} architecture, Linux-Libre kernel; | |
6535 | ||
6536 | @item i686-linux | |
6537 | Intel 32-bit architecture (IA32), Linux-Libre kernel; | |
6538 | ||
aa1e1947 | 6539 | @item armhf-linux |
aa725117 | 6540 | ARMv7-A architecture with hard float, Thumb-2 and NEON, |
f97c9175 AE |
6541 | using the EABI hard-float application binary interface (ABI), |
6542 | and Linux-Libre kernel. | |
aa1e1947 | 6543 | |
c320011d LC |
6544 | @item mips64el-linux |
6545 | little-endian 64-bit MIPS processors, specifically the Loongson series, | |
f97c9175 | 6546 | n32 ABI, and Linux-Libre kernel. |
c320011d LC |
6547 | |
6548 | @end table | |
6549 | ||
4705641f | 6550 | GuixSD itself is currently only available on @code{i686} and @code{x86_64}. |
3ca2731c | 6551 | |
c320011d LC |
6552 | @noindent |
6553 | For information on porting to other architectures or kernels, | |
f97c9175 | 6554 | @pxref{Porting}. |
c320011d | 6555 | |
401c53c4 | 6556 | @menu |
5af6de3e | 6557 | * System Installation:: Installing the whole operating system. |
35ed9306 | 6558 | * System Configuration:: Configuring the operating system. |
91ef73d4 | 6559 | * Installing Debugging Files:: Feeding the debugger. |
05962f29 | 6560 | * Security Updates:: Deploying security fixes quickly. |
401c53c4 | 6561 | * Package Modules:: Packages from the programmer's viewpoint. |
da7cabd4 | 6562 | * Packaging Guidelines:: Growing the distribution. |
401c53c4 | 6563 | * Bootstrapping:: GNU/Linux built from scratch. |
8b315a6d | 6564 | * Porting:: Targeting another platform or kernel. |
401c53c4 LC |
6565 | @end menu |
6566 | ||
6567 | Building this distribution is a cooperative effort, and you are invited | |
081145cf | 6568 | to join! @xref{Contributing}, for information about how you can help. |
401c53c4 | 6569 | |
5af6de3e LC |
6570 | @node System Installation |
6571 | @section System Installation | |
6572 | ||
e32171ee | 6573 | @cindex installing GuixSD |
3ca2731c | 6574 | @cindex Guix System Distribution |
c8b54374 | 6575 | This section explains how to install the Guix System Distribution (GuixSD) |
3ca2731c | 6576 | on a machine. The Guix package manager can |
35ed9306 LC |
6577 | also be installed on top of a running GNU/Linux system, |
6578 | @pxref{Installation}. | |
5af6de3e LC |
6579 | |
6580 | @ifinfo | |
9c18cf9b | 6581 | @quotation Note |
5af6de3e LC |
6582 | @c This paragraph is for people reading this from tty2 of the |
6583 | @c installation image. | |
1068f26b | 6584 | You are reading this documentation with an Info reader. For details on |
5af6de3e | 6585 | how to use it, hit the @key{RET} key (``return'' or ``enter'') on the |
de341e7c LC |
6586 | link that follows: @pxref{Top, Info reader,, info-stnd, Stand-alone GNU |
6587 | Info}. Hit @kbd{l} afterwards to come back here. | |
9c18cf9b LC |
6588 | |
6589 | Alternately, run @command{info info} in another tty to keep the manual | |
6590 | available. | |
6591 | @end quotation | |
5af6de3e LC |
6592 | @end ifinfo |
6593 | ||
dedb8d5e | 6594 | @menu |
e3009f60 LC |
6595 | * Limitations:: What you can expect. |
6596 | * Hardware Considerations:: Supported hardware. | |
6597 | * USB Stick Installation:: Preparing the installation medium. | |
6598 | * Preparing for Installation:: Networking, partitioning, etc. | |
6599 | * Proceeding with the Installation:: The real thing. | |
c8b54374 | 6600 | * Installing GuixSD in a VM:: GuixSD playground. |
e3009f60 | 6601 | * Building the Installation Image:: How this comes to be. |
dedb8d5e LC |
6602 | @end menu |
6603 | ||
6604 | @node Limitations | |
8aaaae38 LC |
6605 | @subsection Limitations |
6606 | ||
4705641f | 6607 | As of version @value{VERSION}, the Guix System Distribution (GuixSD) is |
3ca2731c | 6608 | not production-ready. It may contain bugs and lack important |
8aaaae38 LC |
6609 | features. Thus, if you are looking for a stable production system that |
6610 | respects your freedom as a computer user, a good solution at this point | |
6611 | is to consider @url{http://www.gnu.org/distros/free-distros.html, one of | |
f97c9175 | 6612 | the more established GNU/Linux distributions}. We hope you can soon switch |
4705641f | 6613 | to the GuixSD without fear, of course. In the meantime, you can |
8aaaae38 LC |
6614 | also keep using your distribution and try out the package manager on top |
6615 | of it (@pxref{Installation}). | |
6616 | ||
6617 | Before you proceed with the installation, be aware of the following | |
6618 | noteworthy limitations applicable to version @value{VERSION}: | |
6619 | ||
6620 | @itemize | |
6621 | @item | |
6622 | The installation process does not include a graphical user interface and | |
6623 | requires familiarity with GNU/Linux (see the following subsections to | |
6624 | get a feel of what that means.) | |
6625 | ||
8aaaae38 | 6626 | @item |
dbcb0ab1 | 6627 | Support for the Logical Volume Manager (LVM) is missing. |
8aaaae38 LC |
6628 | |
6629 | @item | |
6630 | Few system services are currently supported out-of-the-box | |
6631 | (@pxref{Services}). | |
6632 | ||
6633 | @item | |
29e53b95 | 6634 | More than 4,000 packages are available, but you may |
8aaaae38 | 6635 | occasionally find that a useful package is missing. |
5fe01c2d LC |
6636 | |
6637 | @item | |
6638 | GNOME, Xfce, and Enlightenment are available (@pxref{Desktop Services}), | |
6639 | as well as a number of X11 window managers. However, some graphical | |
6640 | applications may be missing, as well as KDE. | |
8aaaae38 LC |
6641 | @end itemize |
6642 | ||
f97c9175 AE |
6643 | You have been warned! But more than a disclaimer, this is an invitation |
6644 | to report issues (and success stories!), and to join us in improving it. | |
8aaaae38 | 6645 | @xref{Contributing}, for more info. |
5af6de3e | 6646 | |
e3009f60 LC |
6647 | |
6648 | @node Hardware Considerations | |
6649 | @subsection Hardware Considerations | |
6650 | ||
6651 | @cindex hardware support on GuixSD | |
6652 | GNU@tie{}GuixSD focuses on respecting the user's computing freedom. It | |
6653 | builds around the kernel Linux-libre, which means that only hardware for | |
e0b3f97e | 6654 | which free software drivers and firmware exist is supported. Nowadays, |
e3009f60 LC |
6655 | a wide range of off-the-shelf hardware is supported on |
6656 | GNU/Linux-libre---from keyboards to graphics cards to scanners and | |
6657 | Ethernet controllers. Unfortunately, there are still areas where | |
6658 | hardware vendors deny users control over their own computing, and such | |
6659 | hardware is not supported on GuixSD. | |
6660 | ||
6661 | @cindex WiFi, hardware support | |
e0b3f97e | 6662 | One of the main areas where free drivers or firmware are lacking is WiFi |
e3009f60 LC |
6663 | devices. WiFi devices known to work include those using Atheros chips |
6664 | (AR9271 and AR7010), which corresponds to the @code{ath9k} Linux-libre | |
52db41af EB |
6665 | driver, and those using Broadcom/AirForce chips (BCM43xx with |
6666 | Wireless-Core Revision 5), which corresponds to the @code{b43-open} | |
6667 | Linux-libre driver. Free firmware exists for both and is available | |
e3009f60 LC |
6668 | out-of-the-box on GuixSD, as part of @var{%base-firmware} |
6669 | (@pxref{operating-system Reference, @code{firmware}}). | |
6670 | ||
6671 | @cindex RYF, Respects Your Freedom | |
6672 | The @uref{https://www.fsf.org/, Free Software Foundation} runs | |
e0b3f97e | 6673 | @uref{https://www.fsf.org/ryf, @dfn{Respects Your Freedom}} (RYF), a |
e3009f60 LC |
6674 | certification program for hardware products that respect your freedom |
6675 | and your privacy and ensure that you have control over your device. We | |
e0b3f97e | 6676 | encourage you to check the list of RYF-certified devices. |
e3009f60 LC |
6677 | |
6678 | Another useful resource is the @uref{https://www.h-node.org/, H-Node} | |
6679 | web site. It contains a catalog of hardware devices with information | |
6680 | about their support in GNU/Linux. | |
6681 | ||
6682 | ||
dedb8d5e | 6683 | @node USB Stick Installation |
5af6de3e LC |
6684 | @subsection USB Stick Installation |
6685 | ||
6686 | An installation image for USB sticks can be downloaded from | |
4705641f | 6687 | @indicateurl{ftp://alpha.gnu.org/gnu/guix/guixsd-usb-install-@value{VERSION}.@var{system}.xz}, |
5af6de3e LC |
6688 | where @var{system} is one of: |
6689 | ||
6690 | @table @code | |
6691 | @item x86_64-linux | |
6692 | for a GNU/Linux system on Intel/AMD-compatible 64-bit CPUs; | |
6693 | ||
6694 | @item i686-linux | |
6695 | for a 32-bit GNU/Linux system on Intel-compatible CPUs. | |
6696 | @end table | |
6697 | ||
debc6360 LC |
6698 | @c start duplication of authentication part from ``Binary Installation'' |
6699 | Make sure to download the associated @file{.sig} file and to verify the | |
6700 | authenticity of the image against it, along these lines: | |
6701 | ||
6702 | @example | |
6703 | $ wget ftp://alpha.gnu.org/gnu/guix/guixsd-usb-install-@value{VERSION}.@var{system}.xz.sig | |
6704 | $ gpg --verify guixsd-usb-install-@value{VERSION}.@var{system}.xz.sig | |
6705 | @end example | |
6706 | ||
6707 | If that command fails because you do not have the required public key, | |
6708 | then run this command to import it: | |
6709 | ||
6710 | @example | |
6711 | $ gpg --keyserver pgp.mit.edu --recv-keys @value{OPENPGP-SIGNING-KEY-ID} | |
6712 | @end example | |
6713 | ||
6714 | @noindent | |
6715 | and rerun the @code{gpg --verify} command. | |
6716 | @c end duplication | |
6717 | ||
5af6de3e LC |
6718 | This image contains a single partition with the tools necessary for an |
6719 | installation. It is meant to be copied @emph{as is} to a large-enough | |
6720 | USB stick. | |
6721 | ||
6722 | To copy the image to a USB stick, follow these steps: | |
6723 | ||
6724 | @enumerate | |
6725 | @item | |
6726 | Decompress the image using the @command{xz} command: | |
6727 | ||
6728 | @example | |
4705641f | 6729 | xz -d guixsd-usb-install-@value{VERSION}.@var{system}.xz |
5af6de3e LC |
6730 | @end example |
6731 | ||
6732 | @item | |
f97c9175 AE |
6733 | Insert a USB stick of 1@tie{}GiB or more into your machine, and determine |
6734 | its device name. Assuming that the USB stick is known as @file{/dev/sdX}, | |
5af6de3e LC |
6735 | copy the image with: |
6736 | ||
6737 | @example | |
4705641f | 6738 | dd if=guixsd-usb-install-@value{VERSION}.x86_64 of=/dev/sdX |
5af6de3e LC |
6739 | @end example |
6740 | ||
6741 | Access to @file{/dev/sdX} usually requires root privileges. | |
6742 | @end enumerate | |
6743 | ||
6744 | Once this is done, you should be able to reboot the system and boot from | |
6745 | the USB stick. The latter usually requires you to get in the BIOS' boot | |
6746 | menu, where you can choose to boot from the USB stick. | |
6747 | ||
c8b54374 VL |
6748 | @xref{Installing GuixSD in a VM}, if, instead, you would like to install |
6749 | GuixSD in a virtual machine (VM). | |
6750 | ||
dedb8d5e | 6751 | @node Preparing for Installation |
5af6de3e LC |
6752 | @subsection Preparing for Installation |
6753 | ||
6754 | Once you have successfully booted the image on the USB stick, you should | |
6755 | end up with a root prompt. Several console TTYs are configured and can | |
6756 | be used to run commands as root. TTY2 shows this documentation, | |
de341e7c LC |
6757 | browsable using the Info reader commands (@pxref{Top,,, info-stnd, |
6758 | Stand-alone GNU Info}). The installation system runs the GPM mouse | |
6759 | daemon, which allows you to select text with the left mouse button and | |
6760 | to paste it with the middle button. | |
5af6de3e | 6761 | |
ff925d37 LC |
6762 | @quotation Note |
6763 | Installation requires access to the Internet so that any missing | |
6764 | dependencies of your system configuration can be downloaded. See the | |
6765 | ``Networking'' section below. | |
6766 | @end quotation | |
6767 | ||
0e69cf67 LC |
6768 | The installation system includes many common tools needed for this task. |
6769 | But it is also a full-blown GuixSD system, which means that you can | |
6770 | install additional packages, should you need it, using @command{guix | |
6771 | package} (@pxref{Invoking guix package}). | |
6772 | ||
dedb8d5e | 6773 | @subsubsection Keyboard Layout |
5af6de3e | 6774 | |
dedb8d5e LC |
6775 | @cindex keyboard layout |
6776 | The installation image uses the US qwerty keyboard layout. If you want | |
6777 | to change it, you can use the @command{loadkeys} command. For example, | |
6778 | the following command selects the Dvorak keyboard layout: | |
5af6de3e | 6779 | |
dedb8d5e LC |
6780 | @example |
6781 | loadkeys dvorak | |
6782 | @end example | |
6783 | ||
6784 | See the files under @file{/run/current-system/profile/share/keymaps} for | |
6785 | a list of available keyboard layouts. Run @command{man loadkeys} for | |
6786 | more information. | |
6787 | ||
6788 | @subsubsection Networking | |
6789 | ||
6790 | Run the following command see what your network interfaces are called: | |
235cba85 LC |
6791 | |
6792 | @example | |
dedb8d5e | 6793 | ifconfig -a |
235cba85 LC |
6794 | @end example |
6795 | ||
1713c37f LC |
6796 | @noindent |
6797 | @dots{} or, using the GNU/Linux-specific @command{ip} command: | |
6798 | ||
6799 | @example | |
6800 | ip a | |
6801 | @end example | |
6802 | ||
95c559c1 | 6803 | @c http://cgit.freedesktop.org/systemd/systemd/tree/src/udev/udev-builtin-net_id.c#n20 |
dedb8d5e LC |
6804 | Wired interfaces have a name starting with @samp{e}; for example, the |
6805 | interface corresponding to the first on-board Ethernet controller is | |
6806 | called @samp{eno1}. Wireless interfaces have a name starting with | |
6807 | @samp{w}, like @samp{w1p2s0}. | |
6808 | ||
6809 | @table @asis | |
6810 | @item Wired connection | |
6811 | To configure a wired network run the following command, substituting | |
6812 | @var{interface} with the name of the wired interface you want to use. | |
6813 | ||
6814 | @example | |
6815 | ifconfig @var{interface} up | |
6816 | @end example | |
6817 | ||
6818 | @item Wireless connection | |
e32171ee JD |
6819 | @cindex wireless |
6820 | @cindex WiFi | |
dedb8d5e LC |
6821 | To configure wireless networking, you can create a configuration file |
6822 | for the @command{wpa_supplicant} configuration tool (its location is not | |
6823 | important) using one of the available text editors such as | |
6824 | @command{zile}: | |
6825 | ||
6826 | @example | |
6827 | zile wpa_supplicant.conf | |
6828 | @end example | |
6829 | ||
6830 | As an example, the following stanza can go to this file and will work | |
6831 | for many wireless networks, provided you give the actual SSID and | |
6832 | passphrase for the network you are connecting to: | |
6833 | ||
6834 | @example | |
6835 | network=@{ | |
ae768308 | 6836 | ssid="@var{my-ssid}" |
dedb8d5e LC |
6837 | key_mgmt=WPA-PSK |
6838 | psk="the network's secret passphrase" | |
6839 | @} | |
6840 | @end example | |
6841 | ||
6842 | Start the wireless service and run it in the background with the | |
6843 | following command (substitute @var{interface} with the name of the | |
6844 | network interface you want to use): | |
6845 | ||
6846 | @example | |
6847 | wpa_supplicant -c wpa_supplicant.conf -i @var{interface} -B | |
6848 | @end example | |
6849 | ||
641d0518 | 6850 | Run @command{man wpa_supplicant} for more information. |
dedb8d5e LC |
6851 | @end table |
6852 | ||
e32171ee | 6853 | @cindex DHCP |
dedb8d5e LC |
6854 | At this point, you need to acquire an IP address. On a network where IP |
6855 | addresses are automatically assigned @i{via} DHCP, you can run: | |
6856 | ||
6857 | @example | |
15650ac2 | 6858 | dhclient -v @var{interface} |
dedb8d5e | 6859 | @end example |
5af6de3e | 6860 | |
dedb8d5e LC |
6861 | Try to ping a server to see if networking is up and running: |
6862 | ||
6863 | @example | |
6864 | ping -c 3 gnu.org | |
6865 | @end example | |
5af6de3e LC |
6866 | |
6867 | Setting up network access is almost always a requirement because the | |
6868 | image does not contain all the software and tools that may be needed. | |
6869 | ||
dedb8d5e LC |
6870 | @subsubsection Disk Partitioning |
6871 | ||
6872 | Unless this has already been done, the next step is to partition, and | |
6873 | then format the target partition(s). | |
6874 | ||
6875 | The installation image includes several partitioning tools, including | |
6876 | Parted (@pxref{Overview,,, parted, GNU Parted User Manual}), | |
6877 | @command{fdisk}, and @command{cfdisk}. Run it and set up your disk with | |
6878 | the partition layout you want: | |
6879 | ||
6880 | @example | |
6881 | cfdisk | |
6882 | @end example | |
6883 | ||
6884 | Once you are done partitioning the target hard disk drive, you have to | |
6885 | create a file system on the relevant partition(s)@footnote{Currently | |
6886 | GuixSD pretty much assumes an ext4 file system. In particular, code | |
6887 | that reads partition UUIDs and labels only works with ext4. This will | |
6888 | be fixed in the future.}. | |
5af6de3e | 6889 | |
7ab44369 LC |
6890 | Preferably, assign partitions a label so that you can easily and |
6891 | reliably refer to them in @code{file-system} declarations (@pxref{File | |
6892 | Systems}). This is typically done using the @code{-L} option of | |
dedb8d5e LC |
6893 | @command{mkfs.ext4} and related commands. So, assuming the target root |
6894 | partition lives at @file{/dev/sda1}, a file system with the label | |
6895 | @code{my-root} can be created with: | |
7ab44369 | 6896 | |
dedb8d5e LC |
6897 | @example |
6898 | mkfs.ext4 -L my-root /dev/sda1 | |
6899 | @end example | |
dd816355 | 6900 | |
13fb1bd9 LC |
6901 | @cindex encrypted disk |
6902 | If you are instead planning to encrypt the root partition, you can use | |
6903 | the Cryptsetup/LUKS utilities to do that (see @inlinefmtifelse{html, | |
6904 | @uref{https://linux.die.net/man/8/cryptsetup, @code{man cryptsetup}}, | |
6905 | @code{man cryptsetup}} for more information.) Assuming you want to | |
6906 | store the root partition on @file{/dev/sda1}, the command sequence would | |
6907 | be along these lines: | |
6d6e6281 | 6908 | |
13fb1bd9 LC |
6909 | @example |
6910 | cryptsetup luksFormat /dev/sda1 | |
6911 | cryptsetup open --type luks /dev/sda1 my-partition | |
6912 | mkfs.ext4 -L my-root /dev/mapper/my-partition | |
6913 | @end example | |
5af6de3e | 6914 | |
dedb8d5e | 6915 | Once that is done, mount the target root partition under @file{/mnt} |
13fb1bd9 LC |
6916 | with a command like (again, assuming @code{my-root} is the label of the |
6917 | root partition): | |
83a17b62 | 6918 | |
dedb8d5e | 6919 | @example |
13fb1bd9 | 6920 | mount LABEL=my-root /mnt |
dedb8d5e | 6921 | @end example |
83a17b62 | 6922 | |
31b6cdf8 LC |
6923 | Finally, if you plan to use one or more swap partitions (@pxref{Memory |
6924 | Concepts, swap space,, libc, The GNU C Library Reference Manual}), make | |
6925 | sure to initialize them with @command{mkswap}. Assuming you have one | |
6926 | swap partition on @file{/dev/sda2}, you would run: | |
6927 | ||
6928 | @example | |
6929 | mkswap /dev/sda2 | |
b2ff76a0 | 6930 | swapon /dev/sda2 |
31b6cdf8 LC |
6931 | @end example |
6932 | ||
dedb8d5e LC |
6933 | @node Proceeding with the Installation |
6934 | @subsection Proceeding with the Installation | |
83a17b62 | 6935 | |
dedb8d5e LC |
6936 | With the target partitions ready and the target root mounted on |
6937 | @file{/mnt}, we're ready to go. First, run: | |
5af6de3e | 6938 | |
dedb8d5e LC |
6939 | @example |
6940 | herd start cow-store /mnt | |
6941 | @end example | |
5af6de3e | 6942 | |
b397c0d5 LC |
6943 | This makes @file{/gnu/store} copy-on-write, such that packages added to it |
6944 | during the installation phase are written to the target disk on @file{/mnt} | |
6945 | rather than kept in memory. This is necessary because the first phase of | |
6946 | the @command{guix system init} command (see below) entails downloads or | |
6947 | builds to @file{/gnu/store} which, initially, is an in-memory file system. | |
5af6de3e | 6948 | |
dedb8d5e | 6949 | Next, you have to edit a file and |
5af6de3e | 6950 | provide the declaration of the operating system to be installed. To |
a8cb87ab LC |
6951 | that end, the installation system comes with three text editors: GNU nano |
6952 | (@pxref{Top,,, nano, GNU nano Manual}), GNU Zile (an Emacs clone), and | |
6953 | nvi (a clone of the original BSD @command{vi} editor). | |
efa77c6c LC |
6954 | We strongly recommend storing that file on the target root file system, say, |
6955 | as @file{/mnt/etc/config.scm}. Failing to do that, you will have lost your | |
6956 | configuration file once you have rebooted into the newly-installed system. | |
5af6de3e | 6957 | |
dedb8d5e LC |
6958 | @xref{Using the Configuration System}, for an overview of the |
6959 | configuration file. The example configurations discussed in that | |
6960 | section are available under @file{/etc/configuration} in the | |
6961 | installation image. Thus, to get started with a system configuration | |
6962 | providing a graphical display server (a ``desktop'' system), you can run | |
6963 | something along these lines: | |
6964 | ||
6965 | @example | |
6966 | # mkdir /mnt/etc | |
6967 | # cp /etc/configuration/desktop.scm /mnt/etc/config.scm | |
6968 | # zile /mnt/etc/config.scm | |
6969 | @end example | |
6970 | ||
6971 | You should pay attention to what your configuration file contains, and | |
6972 | in particular: | |
6973 | ||
6974 | @itemize | |
6975 | @item | |
6976 | Make sure the @code{grub-configuration} form refers to the device you | |
6977 | want to install GRUB on. | |
6978 | ||
6979 | @item | |
6980 | Be sure that your partition labels match the value of their respective | |
6981 | @code{device} fields in your @code{file-system} configuration, assuming | |
6982 | your @code{file-system} configuration sets the value of @code{title} to | |
6983 | @code{'label}. | |
13fb1bd9 LC |
6984 | |
6985 | @item | |
6986 | If there are encrypted or RAID partitions, make sure to add a | |
6987 | @code{mapped-devices} field to describe them (@pxref{Mapped Devices}). | |
dedb8d5e | 6988 | @end itemize |
5af6de3e | 6989 | |
dd51caac LC |
6990 | Once you are done preparing the configuration file, the new system must |
6991 | be initialized (remember that the target root file system is mounted | |
6992 | under @file{/mnt}): | |
5af6de3e LC |
6993 | |
6994 | @example | |
6995 | guix system init /mnt/etc/config.scm /mnt | |
6996 | @end example | |
6997 | ||
6998 | @noindent | |
dedb8d5e | 6999 | This copies all the necessary files and installs GRUB on |
5af6de3e | 7000 | @file{/dev/sdX}, unless you pass the @option{--no-grub} option. For |
6621cdb6 | 7001 | more information, @pxref{Invoking guix system}. This command may trigger |
5af6de3e LC |
7002 | downloads or builds of missing packages, which can take some time. |
7003 | ||
1bd4e6db LC |
7004 | Once that command has completed---and hopefully succeeded!---you can run |
7005 | @command{reboot} and boot into the new system. The @code{root} password | |
7006 | in the new system is initially empty; other users' passwords need to be | |
7007 | initialized by running the @command{passwd} command as @code{root}, | |
7008 | unless your configuration specifies otherwise | |
7009 | (@pxref{user-account-password, user account passwords}). | |
7010 | ||
7fcf2a0b LC |
7011 | @cindex upgrading GuixSD |
7012 | From then on, you can update GuixSD whenever you want by running | |
7013 | @command{guix pull} as @code{root} (@pxref{Invoking guix pull}), and | |
7014 | then running @command{guix system reconfigure} to build a new system | |
7015 | generation with the latest packages and services (@pxref{Invoking guix | |
7016 | system}). We recommend doing that regularly so that your system | |
7017 | includes the latest security updates (@pxref{Security Updates}). | |
7018 | ||
1bd4e6db | 7019 | Join us on @code{#guix} on the Freenode IRC network or on |
5af6de3e LC |
7020 | @file{guix-devel@@gnu.org} to share your experience---good or not so |
7021 | good. | |
7022 | ||
c8b54374 VL |
7023 | @node Installing GuixSD in a VM |
7024 | @subsection Installing GuixSD in a Virtual Machine | |
7025 | ||
7026 | @cindex virtual machine, GuixSD installation | |
7027 | If you'd like to install GuixSD in a virtual machine (VM) rather than on | |
7028 | your beloved machine, this section is for you. | |
7029 | ||
7030 | To boot a @uref{http://qemu.org/,QEMU} VM for installing GuixSD in a | |
7031 | disk image, follow these steps: | |
7032 | ||
7033 | @enumerate | |
7034 | @item | |
7035 | First, retrieve the GuixSD installation image as described previously | |
7036 | (@pxref{USB Stick Installation}). | |
7037 | ||
7038 | @item | |
7039 | Create a disk image that will hold the installed system. To make a | |
7040 | qcow2-formatted disk image, use the @command{qemu-img} command: | |
7041 | ||
7042 | @example | |
7043 | qemu-img create -f qcow2 guixsd.img 5G | |
7044 | @end example | |
7045 | ||
7046 | This will create a 5GB file. | |
7047 | ||
7048 | @item | |
7049 | Boot the USB installation image in an VM: | |
7050 | ||
7051 | @example | |
7052 | qemu-system-x86_64 -m 1024 -smp 1 \ | |
7053 | -net default -net nic,model=virtio -boot menu=on \ | |
7054 | -drive file=guixsd.img \ | |
7055 | -drive file=guixsd-usb-install-@value{VERSION}.@var{system} | |
7056 | @end example | |
7057 | ||
7058 | In the VM console, quickly press the @kbd{F12} key to enter the boot | |
7059 | menu. Then press the @kbd{2} key and the @kbd{RET} key to validate your | |
7060 | selection. | |
7061 | ||
7062 | @item | |
7063 | You're now root in the VM, proceed with the installation process. | |
7064 | @xref{Preparing for Installation}, and follow the instructions. | |
7065 | @end enumerate | |
7066 | ||
7067 | Once installation is complete, you can boot the system that's on your | |
7068 | @file{guixsd.img} image. @xref{Running GuixSD in a VM}, for how to do | |
7069 | that. | |
7070 | ||
dedb8d5e | 7071 | @node Building the Installation Image |
5af6de3e LC |
7072 | @subsection Building the Installation Image |
7073 | ||
e32171ee | 7074 | @cindex installation image |
5af6de3e LC |
7075 | The installation image described above was built using the @command{guix |
7076 | system} command, specifically: | |
7077 | ||
622b2304 | 7078 | @c FIXME: 1G is too much; see <http://bugs.gnu.org/23077>. |
5af6de3e | 7079 | @example |
622b2304 | 7080 | guix system disk-image --image-size=1G gnu/system/install.scm |
5af6de3e LC |
7081 | @end example |
7082 | ||
6e6a0401 AE |
7083 | Have a look at @file{gnu/system/install.scm} in the source tree, |
7084 | and see also @ref{Invoking guix system} for more information | |
5af6de3e LC |
7085 | about the installation image. |
7086 | ||
cf4a9129 LC |
7087 | @node System Configuration |
7088 | @section System Configuration | |
b208a005 | 7089 | |
cf4a9129 | 7090 | @cindex system configuration |
3ca2731c | 7091 | The Guix System Distribution supports a consistent whole-system configuration |
cf4a9129 LC |
7092 | mechanism. By that we mean that all aspects of the global system |
7093 | configuration---such as the available system services, timezone and | |
7094 | locale settings, user accounts---are declared in a single place. Such | |
7095 | a @dfn{system configuration} can be @dfn{instantiated}---i.e., effected. | |
91ef73d4 | 7096 | |
cf4a9129 LC |
7097 | One of the advantages of putting all the system configuration under the |
7098 | control of Guix is that it supports transactional system upgrades, and | |
1068f26b | 7099 | makes it possible to roll back to a previous system instantiation, |
cf4a9129 | 7100 | should something go wrong with the new one (@pxref{Features}). Another |
1068f26b | 7101 | advantage is that it makes it easy to replicate the exact same configuration |
cf4a9129 LC |
7102 | across different machines, or at different points in time, without |
7103 | having to resort to additional administration tools layered on top of | |
1068f26b | 7104 | the own tools of the system. |
cf4a9129 | 7105 | @c Yes, we're talking of Puppet, Chef, & co. here. ↑ |
91ef73d4 | 7106 | |
cf4a9129 LC |
7107 | This section describes this mechanism. First we focus on the system |
7108 | administrator's viewpoint---explaining how the system is configured and | |
7109 | instantiated. Then we show how this mechanism can be extended, for | |
7110 | instance to support new system services. | |
91ef73d4 | 7111 | |
cf4a9129 LC |
7112 | @menu |
7113 | * Using the Configuration System:: Customizing your GNU system. | |
7313a52e | 7114 | * operating-system Reference:: Detail of operating-system declarations. |
cf4a9129 | 7115 | * File Systems:: Configuring file system mounts. |
510f9d86 | 7116 | * Mapped Devices:: Block device extra processing. |
cf4a9129 | 7117 | * User Accounts:: Specifying user accounts. |
598e19dc | 7118 | * Locales:: Language and cultural convention settings. |
cf4a9129 | 7119 | * Services:: Specifying system services. |
0ae8c15a | 7120 | * Setuid Programs:: Programs running with root privileges. |
efb5e833 | 7121 | * X.509 Certificates:: Authenticating HTTPS servers. |
996ed739 | 7122 | * Name Service Switch:: Configuring libc's name service switch. |
fd1b1fa2 | 7123 | * Initial RAM Disk:: Linux-Libre bootstrapping. |
88faf933 | 7124 | * GRUB Configuration:: Configuring the boot loader. |
cf4a9129 | 7125 | * Invoking guix system:: Instantiating a system configuration. |
97d76250 | 7126 | * Running GuixSD in a VM:: How to run GuixSD in a virtual machine. |
cf4a9129 LC |
7127 | * Defining Services:: Adding new service definitions. |
7128 | @end menu | |
91ef73d4 | 7129 | |
cf4a9129 LC |
7130 | @node Using the Configuration System |
7131 | @subsection Using the Configuration System | |
64d76fa6 | 7132 | |
cf4a9129 LC |
7133 | The operating system is configured by providing an |
7134 | @code{operating-system} declaration in a file that can then be passed to | |
7135 | the @command{guix system} command (@pxref{Invoking guix system}). A | |
7136 | simple setup, with the default system services, the default Linux-Libre | |
7137 | kernel, initial RAM disk, and boot loader looks like this: | |
91ef73d4 | 7138 | |
cf4a9129 LC |
7139 | @findex operating-system |
7140 | @lisp | |
dd51caac | 7141 | @include os-config-bare-bones.texi |
cf4a9129 | 7142 | @end lisp |
401c53c4 | 7143 | |
cf4a9129 LC |
7144 | This example should be self-describing. Some of the fields defined |
7145 | above, such as @code{host-name} and @code{bootloader}, are mandatory. | |
7146 | Others, such as @code{packages} and @code{services}, can be omitted, in | |
7147 | which case they get a default value. | |
e7f34eb0 | 7148 | |
5d94ac51 LC |
7149 | Below we discuss the effect of some of the most important fields |
7150 | (@pxref{operating-system Reference}, for details about all the available | |
7151 | fields), and how to @dfn{instantiate} the operating system using | |
7152 | @command{guix system}. | |
7153 | ||
7154 | @unnumberedsubsubsec Globally-Visible Packages | |
7155 | ||
cf4a9129 | 7156 | @vindex %base-packages |
5d94ac51 LC |
7157 | The @code{packages} field lists packages that will be globally visible |
7158 | on the system, for all user accounts---i.e., in every user's @code{PATH} | |
7159 | environment variable---in addition to the per-user profiles | |
7160 | (@pxref{Invoking guix package}). The @var{%base-packages} variable | |
7161 | provides all the tools one would expect for basic user and administrator | |
7162 | tasks---including the GNU Core Utilities, the GNU Networking Utilities, | |
7163 | the GNU Zile lightweight text editor, @command{find}, @command{grep}, | |
7164 | etc. The example above adds tcpdump to those, taken from the @code{(gnu | |
7165 | packages admin)} module (@pxref{Package Modules}). | |
e7f34eb0 | 7166 | |
f6c9fb1b LC |
7167 | @findex specification->package |
7168 | Referring to packages by variable name, like @var{tcpdump} above, has | |
7169 | the advantage of being unambiguous; it also allows typos and such to be | |
7170 | diagnosed right away as ``unbound variables''. The downside is that one | |
7171 | needs to know which module defines which package, and to augment the | |
7172 | @code{use-package-modules} line accordingly. To avoid that, one can use | |
7173 | the @code{specification->package} procedure of the @code{(gnu packages)} | |
7174 | module, which returns the best package for a given name or name and | |
7175 | version: | |
7176 | ||
7177 | @lisp | |
7178 | (use-modules (gnu packages)) | |
7179 | ||
7180 | (operating-system | |
7181 | ;; ... | |
7182 | (packages (append (map specification->package | |
d5e59248 | 7183 | '("tcpdump" "htop" "gnupg@@2.0")) |
f6c9fb1b LC |
7184 | %base-packages))) |
7185 | @end lisp | |
7186 | ||
5d94ac51 LC |
7187 | @unnumberedsubsubsec System Services |
7188 | ||
e32171ee | 7189 | @cindex services |
cf4a9129 LC |
7190 | @vindex %base-services |
7191 | The @code{services} field lists @dfn{system services} to be made | |
7192 | available when the system starts (@pxref{Services}). | |
7193 | The @code{operating-system} declaration above specifies that, in | |
7194 | addition to the basic services, we want the @command{lshd} secure shell | |
cd6f6c22 LC |
7195 | daemon listening on port 2222 (@pxref{Networking Services, |
7196 | @code{lsh-service}}). Under the hood, | |
cf4a9129 LC |
7197 | @code{lsh-service} arranges so that @code{lshd} is started with the |
7198 | right command-line options, possibly with supporting configuration files | |
cd6f6c22 LC |
7199 | generated as needed (@pxref{Defining Services}). |
7200 | ||
7201 | @cindex customization, of services | |
7202 | @findex modify-services | |
7203 | Occasionally, instead of using the base services as is, you will want to | |
4d343a14 CM |
7204 | customize them. To do this, use @code{modify-services} (@pxref{Service |
7205 | Reference, @code{modify-services}}) to modify the list. | |
7206 | ||
7207 | For example, suppose you want to modify @code{guix-daemon} and Mingetty | |
7208 | (the console log-in) in the @var{%base-services} list (@pxref{Base | |
7209 | Services, @code{%base-services}}). To do that, you can write the | |
7210 | following in your operating system declaration: | |
cd6f6c22 LC |
7211 | |
7212 | @lisp | |
4d343a14 CM |
7213 | (define %my-services |
7214 | ;; My very own list of services. | |
7215 | (modify-services %base-services | |
7216 | (guix-service-type config => | |
7217 | (guix-configuration | |
7218 | (inherit config) | |
7219 | (use-substitutes? #f) | |
7220 | (extra-options '("--gc-keep-derivations")))) | |
7221 | (mingetty-service-type config => | |
7222 | (mingetty-configuration | |
317d3b47 | 7223 | (inherit config))))) |
4d343a14 CM |
7224 | |
7225 | (operating-system | |
7226 | ;; @dots{} | |
7227 | (services %my-services)) | |
cd6f6c22 LC |
7228 | @end lisp |
7229 | ||
4d343a14 CM |
7230 | This changes the configuration---i.e., the service parameters---of the |
7231 | @code{guix-service-type} instance, and that of all the | |
7232 | @code{mingetty-service-type} instances in the @var{%base-services} list. | |
7233 | Observe how this is accomplished: first, we arrange for the original | |
7234 | configuration to be bound to the identifier @code{config} in the | |
7235 | @var{body}, and then we write the @var{body} so that it evaluates to the | |
7236 | desired configuration. In particular, notice how we use @code{inherit} | |
7237 | to create a new configuration which has the same values as the old | |
7238 | configuration, but with a few modifications. | |
a1ba8475 | 7239 | |
13fb1bd9 LC |
7240 | @cindex encrypted disk |
7241 | The configuration for a typical ``desktop'' usage, with an encrypted | |
7242 | root partition, the X11 display | |
d038b674 LC |
7243 | server, GNOME and Xfce (users can choose which of these desktop |
7244 | environments to use at the log-in screen by pressing @kbd{F1}), network | |
7245 | management, power management, and more, would look like this: | |
dd51caac LC |
7246 | |
7247 | @lisp | |
7248 | @include os-config-desktop.texi | |
7249 | @end lisp | |
7250 | ||
d038b674 LC |
7251 | A graphical environment with a choice of lightweight window managers |
7252 | instead of full-blown desktop environments would look like this: | |
7253 | ||
7254 | @lisp | |
7255 | @include os-config-lightweight-desktop.texi | |
7256 | @end lisp | |
7257 | ||
dd51caac | 7258 | @xref{Desktop Services}, for the exact list of services provided by |
efb5e833 LC |
7259 | @var{%desktop-services}. @xref{X.509 Certificates}, for background |
7260 | information about the @code{nss-certs} package that is used here. | |
dd51caac | 7261 | |
5d94ac51 LC |
7262 | Again, @var{%desktop-services} is just a list of service objects. If |
7263 | you want to remove services from there, you can do so using the | |
7264 | procedures for list filtering (@pxref{SRFI-1 Filtering and | |
7265 | Partitioning,,, guile, GNU Guile Reference Manual}). For instance, the | |
7266 | following expression returns a list that contains all the services in | |
7267 | @var{%desktop-services} minus the Avahi service: | |
7268 | ||
7269 | @example | |
7270 | (remove (lambda (service) | |
7271 | (eq? (service-kind service) avahi-service-type)) | |
7272 | %desktop-services) | |
7273 | @end example | |
7274 | ||
7275 | @unnumberedsubsubsec Instantiating the System | |
7276 | ||
7277 | Assuming the @code{operating-system} declaration | |
7278 | is stored in the @file{my-system-config.scm} | |
cf4a9129 LC |
7279 | file, the @command{guix system reconfigure my-system-config.scm} command |
7280 | instantiates that configuration, and makes it the default GRUB boot | |
65797bff LC |
7281 | entry (@pxref{Invoking guix system}). |
7282 | ||
1068f26b | 7283 | The normal way to change the system configuration is by updating this |
65797bff | 7284 | file and re-running @command{guix system reconfigure}. One should never |
8b499030 | 7285 | have to touch files in @file{/etc} or to run commands that modify the |
65797bff LC |
7286 | system state such as @command{useradd} or @command{grub-install}. In |
7287 | fact, you must avoid that since that would not only void your warranty | |
7288 | but also prevent you from rolling back to previous versions of your | |
7289 | system, should you ever need to. | |
7290 | ||
7291 | @cindex roll-back, of the operating system | |
7292 | Speaking of roll-back, each time you run @command{guix system | |
7293 | reconfigure}, a new @dfn{generation} of the system is created---without | |
7294 | modifying or deleting previous generations. Old system generations get | |
7295 | an entry in the GRUB boot menu, allowing you to boot them in case | |
7296 | something went wrong with the latest generation. Reassuring, no? The | |
7297 | @command{guix system list-generations} command lists the system | |
067a2e2d CM |
7298 | generations available on disk. It is also possible to roll back the |
7299 | system via the commands @command{guix system roll-back} and | |
7300 | @command{guix system switch-generation}. | |
7301 | ||
7302 | Although the command @command{guix system reconfigure} will not modify | |
7303 | previous generations, must take care when the current generation is not | |
7304 | the latest (e.g., after invoking @command{guix system roll-back}), since | |
7305 | the operation might overwrite a later generation (@pxref{Invoking guix | |
7306 | system}). | |
b81e1947 | 7307 | |
5d94ac51 LC |
7308 | @unnumberedsubsubsec The Programming Interface |
7309 | ||
cf4a9129 LC |
7310 | At the Scheme level, the bulk of an @code{operating-system} declaration |
7311 | is instantiated with the following monadic procedure (@pxref{The Store | |
7312 | Monad}): | |
b81e1947 | 7313 | |
cf4a9129 LC |
7314 | @deffn {Monadic Procedure} operating-system-derivation os |
7315 | Return a derivation that builds @var{os}, an @code{operating-system} | |
7316 | object (@pxref{Derivations}). | |
b81e1947 | 7317 | |
cf4a9129 LC |
7318 | The output of the derivation is a single directory that refers to all |
7319 | the packages, configuration files, and other supporting files needed to | |
7320 | instantiate @var{os}. | |
7321 | @end deffn | |
b81e1947 | 7322 | |
5d94ac51 LC |
7323 | This procedure is provided by the @code{(gnu system)} module. Along |
7324 | with @code{(gnu services)} (@pxref{Services}), this module contains the | |
7325 | guts of GuixSD. Make sure to visit it! | |
7326 | ||
7327 | ||
7313a52e LC |
7328 | @node operating-system Reference |
7329 | @subsection @code{operating-system} Reference | |
7330 | ||
7331 | This section summarizes all the options available in | |
7332 | @code{operating-system} declarations (@pxref{Using the Configuration | |
7333 | System}). | |
7334 | ||
7335 | @deftp {Data Type} operating-system | |
7336 | This is the data type representing an operating system configuration. | |
7337 | By that, we mean all the global system configuration, not per-user | |
7338 | configuration (@pxref{Using the Configuration System}). | |
7339 | ||
7340 | @table @asis | |
7341 | @item @code{kernel} (default: @var{linux-libre}) | |
fbb25e56 | 7342 | The package object of the operating system kernel to use@footnote{Currently |
7313a52e LC |
7343 | only the Linux-libre kernel is supported. In the future, it will be |
7344 | possible to use the GNU@tie{}Hurd.}. | |
7345 | ||
ee2a6304 LC |
7346 | @item @code{kernel-arguments} (default: @code{'()}) |
7347 | List of strings or gexps representing additional arguments to pass on | |
1068f26b | 7348 | the command-line of the kernel---e.g., @code{("console=ttyS0")}. |
ee2a6304 | 7349 | |
7313a52e | 7350 | @item @code{bootloader} |
88faf933 | 7351 | The system bootloader configuration object. @xref{GRUB Configuration}. |
7313a52e LC |
7352 | |
7353 | @item @code{initrd} (default: @code{base-initrd}) | |
e32171ee JD |
7354 | @cindex initrd |
7355 | @cindex initial RAM disk | |
7313a52e LC |
7356 | A two-argument monadic procedure that returns an initial RAM disk for |
7357 | the Linux kernel. @xref{Initial RAM Disk}. | |
7358 | ||
f34c56be LC |
7359 | @item @code{firmware} (default: @var{%base-firmware}) |
7360 | @cindex firmware | |
7361 | List of firmware packages loadable by the operating system kernel. | |
7362 | ||
52db41af EB |
7363 | The default includes firmware needed for Atheros- and Broadcom-based |
7364 | WiFi devices (Linux-libre modules @code{ath9k} and @code{b43-open}, | |
7365 | respectively). @xref{Hardware Considerations}, for more info on | |
7366 | supported hardware. | |
f34c56be | 7367 | |
7313a52e LC |
7368 | @item @code{host-name} |
7369 | The host name. | |
7370 | ||
7371 | @item @code{hosts-file} | |
7372 | @cindex hosts file | |
24e02c28 | 7373 | A file-like object (@pxref{G-Expressions, file-like objects}) for use as |
7313a52e | 7374 | @file{/etc/hosts} (@pxref{Host Names,,, libc, The GNU C Library |
24e02c28 | 7375 | Reference Manual}). The default is a file with entries for |
7313a52e LC |
7376 | @code{localhost} and @var{host-name}. |
7377 | ||
7378 | @item @code{mapped-devices} (default: @code{'()}) | |
7379 | A list of mapped devices. @xref{Mapped Devices}. | |
7380 | ||
7381 | @item @code{file-systems} | |
7382 | A list of file systems. @xref{File Systems}. | |
7383 | ||
7384 | @item @code{swap-devices} (default: @code{'()}) | |
7385 | @cindex swap devices | |
7386 | A list of strings identifying devices to be used for ``swap space'' | |
7387 | (@pxref{Memory Concepts,,, libc, The GNU C Library Reference Manual}). | |
7388 | For example, @code{'("/dev/sda3")}. | |
7389 | ||
bf87f38a | 7390 | @item @code{users} (default: @code{%base-user-accounts}) |
7313a52e LC |
7391 | @itemx @code{groups} (default: @var{%base-groups}) |
7392 | List of user accounts and groups. @xref{User Accounts}. | |
7393 | ||
7394 | @item @code{skeletons} (default: @code{(default-skeletons)}) | |
e9dffec1 LC |
7395 | A list target file name/file-like object tuples (@pxref{G-Expressions, |
7396 | file-like objects}). These are the skeleton files that will be added to | |
7397 | the home directory of newly-created user accounts. | |
7313a52e LC |
7398 | |
7399 | For instance, a valid value may look like this: | |
7400 | ||
7401 | @example | |
e9dffec1 LC |
7402 | `((".bashrc" ,(plain-file "bashrc" "echo Hello\n")) |
7403 | (".guile" ,(plain-file "guile" | |
7404 | "(use-modules (ice-9 readline)) | |
7405 | (activate-readline)"))) | |
7313a52e LC |
7406 | @end example |
7407 | ||
7408 | @item @code{issue} (default: @var{%default-issue}) | |
7409 | A string denoting the contents of the @file{/etc/issue} file, which is | |
1068f26b | 7410 | displayed when users log in on a text console. |
7313a52e LC |
7411 | |
7412 | @item @code{packages} (default: @var{%base-packages}) | |
7413 | The set of packages installed in the global profile, which is accessible | |
7414 | at @file{/run/current-system/profile}. | |
7415 | ||
1068f26b | 7416 | The default set includes core utilities and it is good practice to |
7313a52e LC |
7417 | install non-core utilities in user profiles (@pxref{Invoking guix |
7418 | package}). | |
7419 | ||
7420 | @item @code{timezone} | |
7421 | A timezone identifying string---e.g., @code{"Europe/Paris"}. | |
7422 | ||
17c20385 LC |
7423 | You can run the @command{tzselect} command to find out which timezone |
7424 | string corresponds to your region. Choosing an invalid timezone name | |
7425 | causes @command{guix system} to fail. | |
7426 | ||
598e19dc LC |
7427 | @item @code{locale} (default: @code{"en_US.utf8"}) |
7428 | The name of the default locale (@pxref{Locale Names,,, libc, The GNU C | |
7429 | Library Reference Manual}). @xref{Locales}, for more information. | |
7430 | ||
7431 | @item @code{locale-definitions} (default: @var{%default-locale-definitions}) | |
7432 | The list of locale definitions to be compiled and that may be used at | |
7433 | run time. @xref{Locales}. | |
7313a52e | 7434 | |
34760ae7 LC |
7435 | @item @code{locale-libcs} (default: @code{(list @var{glibc})}) |
7436 | The list of GNU@tie{}libc packages whose locale data and tools are used | |
7437 | to build the locale definitions. @xref{Locales}, for compatibility | |
7438 | considerations that justify this option. | |
7439 | ||
996ed739 | 7440 | @item @code{name-service-switch} (default: @var{%default-nss}) |
1068f26b | 7441 | Configuration of the libc name service switch (NSS)---a |
996ed739 LC |
7442 | @code{<name-service-switch>} object. @xref{Name Service Switch}, for |
7443 | details. | |
7444 | ||
7313a52e | 7445 | @item @code{services} (default: @var{%base-services}) |
28d939af | 7446 | A list of service objects denoting system services. @xref{Services}. |
7313a52e LC |
7447 | |
7448 | @item @code{pam-services} (default: @code{(base-pam-services)}) | |
7449 | @cindex PAM | |
7450 | @cindex pluggable authentication modules | |
7451 | Linux @dfn{pluggable authentication module} (PAM) services. | |
7452 | @c FIXME: Add xref to PAM services section. | |
7453 | ||
7454 | @item @code{setuid-programs} (default: @var{%setuid-programs}) | |
7455 | List of string-valued G-expressions denoting setuid programs. | |
7456 | @xref{Setuid Programs}. | |
7457 | ||
f5a9ffa0 AK |
7458 | @item @code{sudoers-file} (default: @var{%sudoers-specification}) |
7459 | @cindex sudoers file | |
84765839 LC |
7460 | The contents of the @file{/etc/sudoers} file as a file-like object |
7461 | (@pxref{G-Expressions, @code{local-file} and @code{plain-file}}). | |
7313a52e LC |
7462 | |
7463 | This file specifies which users can use the @command{sudo} command, what | |
7464 | they are allowed to do, and what privileges they may gain. The default | |
7465 | is that only @code{root} and members of the @code{wheel} group may use | |
7466 | @code{sudo}. | |
7467 | ||
7468 | @end table | |
7469 | @end deftp | |
7470 | ||
cf4a9129 LC |
7471 | @node File Systems |
7472 | @subsection File Systems | |
b81e1947 | 7473 | |
cf4a9129 | 7474 | The list of file systems to be mounted is specified in the |
1068f26b | 7475 | @code{file-systems} field of the operating system declaration |
cf4a9129 LC |
7476 | (@pxref{Using the Configuration System}). Each file system is declared |
7477 | using the @code{file-system} form, like this: | |
b81e1947 LC |
7478 | |
7479 | @example | |
cf4a9129 LC |
7480 | (file-system |
7481 | (mount-point "/home") | |
7482 | (device "/dev/sda3") | |
7483 | (type "ext4")) | |
b81e1947 LC |
7484 | @end example |
7485 | ||
cf4a9129 LC |
7486 | As usual, some of the fields are mandatory---those shown in the example |
7487 | above---while others can be omitted. These are described below. | |
b81e1947 | 7488 | |
cf4a9129 LC |
7489 | @deftp {Data Type} file-system |
7490 | Objects of this type represent file systems to be mounted. They | |
7491 | contain the following members: | |
5ff3c4b8 | 7492 | |
cf4a9129 LC |
7493 | @table @asis |
7494 | @item @code{type} | |
7495 | This is a string specifying the type of the file system---e.g., | |
7496 | @code{"ext4"}. | |
5ff3c4b8 | 7497 | |
cf4a9129 LC |
7498 | @item @code{mount-point} |
7499 | This designates the place where the file system is to be mounted. | |
b81e1947 | 7500 | |
cf4a9129 LC |
7501 | @item @code{device} |
7502 | This names the ``source'' of the file system. By default it is the name | |
7503 | of a node under @file{/dev}, but its meaning depends on the @code{title} | |
7504 | field described below. | |
401c53c4 | 7505 | |
cf4a9129 LC |
7506 | @item @code{title} (default: @code{'device}) |
7507 | This is a symbol that specifies how the @code{device} field is to be | |
7508 | interpreted. | |
401c53c4 | 7509 | |
cf4a9129 LC |
7510 | When it is the symbol @code{device}, then the @code{device} field is |
7511 | interpreted as a file name; when it is @code{label}, then @code{device} | |
7512 | is interpreted as a partition label name; when it is @code{uuid}, | |
7513 | @code{device} is interpreted as a partition unique identifier (UUID). | |
da7cabd4 | 7514 | |
661a1d79 | 7515 | UUIDs may be converted from their string representation (as shown by the |
0767f6a6 LC |
7516 | @command{tune2fs -l} command) using the @code{uuid} form@footnote{The |
7517 | @code{uuid} form expects 16-byte UUIDs as defined in | |
7518 | @uref{https://tools.ietf.org/html/rfc4122, RFC@tie{}4122}. This is the | |
7519 | form of UUID used by the ext2 family of file systems and others, but it | |
7520 | is different from ``UUIDs'' found in FAT file systems, for instance.}, | |
7521 | like this: | |
661a1d79 LC |
7522 | |
7523 | @example | |
7524 | (file-system | |
7525 | (mount-point "/home") | |
7526 | (type "ext4") | |
7527 | (title 'uuid) | |
7528 | (device (uuid "4dab5feb-d176-45de-b287-9b0a6e4c01cb"))) | |
7529 | @end example | |
7530 | ||
cf4a9129 | 7531 | The @code{label} and @code{uuid} options offer a way to refer to disk |
661a1d79 LC |
7532 | partitions without having to hard-code their actual device |
7533 | name@footnote{Note that, while it is tempting to use | |
7534 | @file{/dev/disk/by-uuid} and similar device names to achieve the same | |
7535 | result, this is not recommended: These special device nodes are created | |
7536 | by the udev daemon and may be unavailable at the time the device is | |
7537 | mounted.}. | |
da7cabd4 | 7538 | |
1068f26b | 7539 | However, when the source of a file system is a mapped device (@pxref{Mapped |
5f86a66e LC |
7540 | Devices}), its @code{device} field @emph{must} refer to the mapped |
7541 | device name---e.g., @file{/dev/mapper/root-partition}---and consequently | |
7542 | @code{title} must be set to @code{'device}. This is required so that | |
7543 | the system knows that mounting the file system depends on having the | |
7544 | corresponding device mapping established. | |
7545 | ||
cf4a9129 LC |
7546 | @item @code{flags} (default: @code{'()}) |
7547 | This is a list of symbols denoting mount flags. Recognized flags | |
2c071ce9 LC |
7548 | include @code{read-only}, @code{bind-mount}, @code{no-dev} (disallow |
7549 | access to special files), @code{no-suid} (ignore setuid and setgid | |
7550 | bits), and @code{no-exec} (disallow program execution.) | |
da7cabd4 | 7551 | |
cf4a9129 LC |
7552 | @item @code{options} (default: @code{#f}) |
7553 | This is either @code{#f}, or a string denoting mount options. | |
da7cabd4 | 7554 | |
be21979d LC |
7555 | @item @code{mount?} (default: @code{#t}) |
7556 | This value indicates whether to automatically mount the file system when | |
7557 | the system is brought up. When set to @code{#f}, the file system gets | |
7558 | an entry in @file{/etc/fstab} (read by the @command{mount} command) but | |
7559 | is not automatically mounted. | |
7560 | ||
cf4a9129 LC |
7561 | @item @code{needed-for-boot?} (default: @code{#f}) |
7562 | This Boolean value indicates whether the file system is needed when | |
7563 | booting. If that is true, then the file system is mounted when the | |
7564 | initial RAM disk (initrd) is loaded. This is always the case, for | |
7565 | instance, for the root file system. | |
da7cabd4 | 7566 | |
cf4a9129 LC |
7567 | @item @code{check?} (default: @code{#t}) |
7568 | This Boolean indicates whether the file system needs to be checked for | |
7569 | errors before being mounted. | |
f9cc8971 | 7570 | |
4e469051 LC |
7571 | @item @code{create-mount-point?} (default: @code{#f}) |
7572 | When true, the mount point is created if it does not exist yet. | |
7573 | ||
e51710d1 | 7574 | @item @code{dependencies} (default: @code{'()}) |
13fb1bd9 LC |
7575 | This is a list of @code{<file-system>} or @code{<mapped-device>} objects |
7576 | representing file systems that must be mounted or mapped devices that | |
7577 | must be opened before (and unmounted or closed after) this one. | |
e51710d1 LC |
7578 | |
7579 | As an example, consider a hierarchy of mounts: @file{/sys/fs/cgroup} is | |
7580 | a dependency of @file{/sys/fs/cgroup/cpu} and | |
7581 | @file{/sys/fs/cgroup/memory}. | |
7582 | ||
13fb1bd9 LC |
7583 | Another example is a file system that depends on a mapped device, for |
7584 | example for an encrypted partition (@pxref{Mapped Devices}). | |
cf4a9129 LC |
7585 | @end table |
7586 | @end deftp | |
da7cabd4 | 7587 | |
a69576ea LC |
7588 | The @code{(gnu system file-systems)} exports the following useful |
7589 | variables. | |
7590 | ||
7591 | @defvr {Scheme Variable} %base-file-systems | |
7592 | These are essential file systems that are required on normal systems, | |
cc0e575a | 7593 | such as @var{%pseudo-terminal-file-system} and @var{%immutable-store} (see |
3392ce5d LC |
7594 | below.) Operating system declarations should always contain at least |
7595 | these. | |
a69576ea LC |
7596 | @end defvr |
7597 | ||
7f239fd3 LC |
7598 | @defvr {Scheme Variable} %pseudo-terminal-file-system |
7599 | This is the file system to be mounted as @file{/dev/pts}. It supports | |
7600 | @dfn{pseudo-terminals} created @i{via} @code{openpty} and similar | |
7601 | functions (@pxref{Pseudo-Terminals,,, libc, The GNU C Library Reference | |
7602 | Manual}). Pseudo-terminals are used by terminal emulators such as | |
7603 | @command{xterm}. | |
7604 | @end defvr | |
7605 | ||
db17ae5c LC |
7606 | @defvr {Scheme Variable} %shared-memory-file-system |
7607 | This file system is mounted as @file{/dev/shm} and is used to support | |
7608 | memory sharing across processes (@pxref{Memory-mapped I/O, | |
7609 | @code{shm_open},, libc, The GNU C Library Reference Manual}). | |
7610 | @end defvr | |
7611 | ||
3392ce5d LC |
7612 | @defvr {Scheme Variable} %immutable-store |
7613 | This file system performs a read-only ``bind mount'' of | |
7614 | @file{/gnu/store}, making it read-only for all the users including | |
7615 | @code{root}. This prevents against accidental modification by software | |
7616 | running as @code{root} or by system administrators. | |
7617 | ||
7618 | The daemon itself is still able to write to the store: it remounts it | |
7619 | read-write in its own ``name space.'' | |
7620 | @end defvr | |
7621 | ||
a69576ea LC |
7622 | @defvr {Scheme Variable} %binary-format-file-system |
7623 | The @code{binfmt_misc} file system, which allows handling of arbitrary | |
7624 | executable file types to be delegated to user space. This requires the | |
7625 | @code{binfmt.ko} kernel module to be loaded. | |
7626 | @end defvr | |
7627 | ||
7628 | @defvr {Scheme Variable} %fuse-control-file-system | |
7629 | The @code{fusectl} file system, which allows unprivileged users to mount | |
7630 | and unmount user-space FUSE file systems. This requires the | |
7631 | @code{fuse.ko} kernel module to be loaded. | |
7632 | @end defvr | |
7633 | ||
510f9d86 LC |
7634 | @node Mapped Devices |
7635 | @subsection Mapped Devices | |
7636 | ||
7637 | @cindex device mapping | |
7638 | @cindex mapped devices | |
7639 | The Linux kernel has a notion of @dfn{device mapping}: a block device, | |
7640 | such as a hard disk partition, can be @dfn{mapped} into another device, | |
97c8aef1 | 7641 | usually in @code{/dev/mapper/}, |
510f9d86 LC |
7642 | with additional processing over the data that flows through |
7643 | it@footnote{Note that the GNU@tie{}Hurd makes no difference between the | |
7644 | concept of a ``mapped device'' and that of a file system: both boil down | |
7645 | to @emph{translating} input/output operations made on a file to | |
7646 | operations on its backing store. Thus, the Hurd implements mapped | |
7647 | devices, like file systems, using the generic @dfn{translator} mechanism | |
7648 | (@pxref{Translators,,, hurd, The GNU Hurd Reference Manual}).}. A | |
7649 | typical example is encryption device mapping: all writes to the mapped | |
7650 | device are encrypted, and all reads are deciphered, transparently. | |
97c8aef1 AE |
7651 | Guix extends this notion by considering any device or set of devices that |
7652 | are @dfn{transformed} in some way to create a new device; for instance, | |
7653 | RAID devices are obtained by @dfn{assembling} several other devices, such | |
7654 | as hard disks or partitions, into a new one that behaves as one partition. | |
7655 | Other examples, not yet implemented, are LVM logical volumes. | |
510f9d86 | 7656 | |
97c8aef1 AE |
7657 | Mapped devices are declared using the @code{mapped-device} form, |
7658 | defined as follows; for examples, see below. | |
510f9d86 LC |
7659 | |
7660 | @deftp {Data Type} mapped-device | |
7661 | Objects of this type represent device mappings that will be made when | |
7662 | the system boots up. | |
7663 | ||
9cb426b8 LC |
7664 | @table @code |
7665 | @item source | |
97c8aef1 AE |
7666 | This is either a string specifying the name of the block device to be mapped, |
7667 | such as @code{"/dev/sda3"}, or a list of such strings when several devices | |
7668 | need to be assembled for creating a new one. | |
510f9d86 | 7669 | |
9cb426b8 | 7670 | @item target |
97c8aef1 AE |
7671 | This string specifies the name of the resulting mapped device. For |
7672 | kernel mappers such as encrypted devices of type @code{luks-device-mapping}, | |
7673 | specifying @code{"my-partition"} leads to the creation of | |
510f9d86 | 7674 | the @code{"/dev/mapper/my-partition"} device. |
97c8aef1 AE |
7675 | For RAID devices of type @code{raid-device-mapping}, the full device name |
7676 | such as @code{"/dev/md0"} needs to be given. | |
510f9d86 | 7677 | |
9cb426b8 | 7678 | @item type |
510f9d86 LC |
7679 | This must be a @code{mapped-device-kind} object, which specifies how |
7680 | @var{source} is mapped to @var{target}. | |
7681 | @end table | |
7682 | @end deftp | |
7683 | ||
7684 | @defvr {Scheme Variable} luks-device-mapping | |
7685 | This defines LUKS block device encryption using the @command{cryptsetup} | |
1068f26b | 7686 | command from the package with the same name. It relies on the |
510f9d86 LC |
7687 | @code{dm-crypt} Linux kernel module. |
7688 | @end defvr | |
7689 | ||
97c8aef1 AE |
7690 | @defvr {Scheme Variable} raid-device-mapping |
7691 | This defines a RAID device, which is assembled using the @code{mdadm} | |
7692 | command from the package with the same name. It requires a Linux kernel | |
7693 | module for the appropriate RAID level to be loaded, such as @code{raid456} | |
7694 | for RAID-4, RAID-5 or RAID-6, or @code{raid10} for RAID-10. | |
7695 | @end defvr | |
7696 | ||
7697 | @cindex disk encryption | |
7698 | @cindex LUKS | |
7699 | The following example specifies a mapping from @file{/dev/sda3} to | |
7700 | @file{/dev/mapper/home} using LUKS---the | |
ddf1cd51 | 7701 | @url{https://gitlab.com/cryptsetup/cryptsetup,Linux Unified Key Setup}, a |
97c8aef1 AE |
7702 | standard mechanism for disk encryption. |
7703 | The @file{/dev/mapper/home} | |
7704 | device can then be used as the @code{device} of a @code{file-system} | |
7705 | declaration (@pxref{File Systems}). | |
7706 | ||
7707 | @example | |
7708 | (mapped-device | |
7709 | (source "/dev/sda3") | |
7710 | (target "home") | |
7711 | (type luks-device-mapping)) | |
7712 | @end example | |
7713 | ||
7714 | Alternatively, to become independent of device numbering, one may obtain | |
7715 | the LUKS UUID (@dfn{unique identifier}) of the source device by a | |
7716 | command like: | |
7717 | ||
7718 | @example | |
7719 | cryptsetup luksUUID /dev/sda3 | |
7720 | @end example | |
7721 | ||
7722 | and use it as follows: | |
7723 | ||
7724 | @example | |
7725 | (mapped-device | |
7726 | (source (uuid "cb67fc72-0d54-4c88-9d4b-b225f30b0f44")) | |
7727 | (target "home") | |
7728 | (type luks-device-mapping)) | |
7729 | @end example | |
7730 | ||
7731 | A RAID device formed of the partitions @file{/dev/sda1} and @file{/dev/sdb1} | |
7732 | may be declared as follows: | |
7733 | ||
7734 | @example | |
7735 | (mapped-device | |
7736 | (source (list "/dev/sda1" "/dev/sdb1")) | |
7737 | (target "/dev/md0") | |
7738 | (type raid-device-mapping)) | |
7739 | @end example | |
7740 | ||
7741 | The @file{/dev/md0} device can then be used as the @code{device} of a | |
7742 | @code{file-system} declaration (@pxref{File Systems}). | |
7743 | Note that the RAID level need not be given; it is chosen during the | |
7744 | initial creation and formatting of the RAID device and is determined | |
7745 | automatically later. | |
7746 | ||
7747 | ||
cf4a9129 LC |
7748 | @node User Accounts |
7749 | @subsection User Accounts | |
ee85f3db | 7750 | |
e32171ee JD |
7751 | @cindex users |
7752 | @cindex accounts | |
7753 | @cindex user accounts | |
9bea87a5 LC |
7754 | User accounts and groups are entirely managed through the |
7755 | @code{operating-system} declaration. They are specified with the | |
7756 | @code{user-account} and @code{user-group} forms: | |
ee85f3db | 7757 | |
cf4a9129 LC |
7758 | @example |
7759 | (user-account | |
7760 | (name "alice") | |
7761 | (group "users") | |
24e752c0 LC |
7762 | (supplementary-groups '("wheel" ;allow use of sudo, etc. |
7763 | "audio" ;sound card | |
7764 | "video" ;video devices such as webcams | |
7765 | "cdrom")) ;the good ol' CD-ROM | |
cf4a9129 LC |
7766 | (comment "Bob's sister") |
7767 | (home-directory "/home/alice")) | |
7768 | @end example | |
25083588 | 7769 | |
9bea87a5 LC |
7770 | When booting or upon completion of @command{guix system reconfigure}, |
7771 | the system ensures that only the user accounts and groups specified in | |
7772 | the @code{operating-system} declaration exist, and with the specified | |
7773 | properties. Thus, account or group creations or modifications made by | |
7774 | directly invoking commands such as @command{useradd} are lost upon | |
7775 | reconfiguration or reboot. This ensures that the system remains exactly | |
7776 | as declared. | |
7777 | ||
cf4a9129 LC |
7778 | @deftp {Data Type} user-account |
7779 | Objects of this type represent user accounts. The following members may | |
7780 | be specified: | |
ee85f3db | 7781 | |
cf4a9129 LC |
7782 | @table @asis |
7783 | @item @code{name} | |
7784 | The name of the user account. | |
ee85f3db | 7785 | |
cf4a9129 | 7786 | @item @code{group} |
e32171ee | 7787 | @cindex groups |
cf4a9129 LC |
7788 | This is the name (a string) or identifier (a number) of the user group |
7789 | this account belongs to. | |
ee85f3db | 7790 | |
cf4a9129 LC |
7791 | @item @code{supplementary-groups} (default: @code{'()}) |
7792 | Optionally, this can be defined as a list of group names that this | |
7793 | account belongs to. | |
ee85f3db | 7794 | |
cf4a9129 LC |
7795 | @item @code{uid} (default: @code{#f}) |
7796 | This is the user ID for this account (a number), or @code{#f}. In the | |
7797 | latter case, a number is automatically chosen by the system when the | |
7798 | account is created. | |
ee85f3db | 7799 | |
cf4a9129 | 7800 | @item @code{comment} (default: @code{""}) |
1068f26b | 7801 | A comment about the account, such as the account owner's full name. |
c8c871d1 | 7802 | |
cf4a9129 LC |
7803 | @item @code{home-directory} |
7804 | This is the name of the home directory for the account. | |
ee85f3db | 7805 | |
eb56ee02 LC |
7806 | @item @code{create-home-directory?} (default: @code{#t}) |
7807 | Indicates whether the home directory of this account should be created | |
7808 | if it does not exist yet. | |
7809 | ||
cf4a9129 LC |
7810 | @item @code{shell} (default: Bash) |
7811 | This is a G-expression denoting the file name of a program to be used as | |
7812 | the shell (@pxref{G-Expressions}). | |
ee85f3db | 7813 | |
cf4a9129 LC |
7814 | @item @code{system?} (default: @code{#f}) |
7815 | This Boolean value indicates whether the account is a ``system'' | |
7816 | account. System accounts are sometimes treated specially; for instance, | |
7817 | graphical login managers do not list them. | |
ee85f3db | 7818 | |
1bd4e6db | 7819 | @anchor{user-account-password} |
cf4a9129 | 7820 | @item @code{password} (default: @code{#f}) |
eb59595c LC |
7821 | You would normally leave this field to @code{#f}, initialize user |
7822 | passwords as @code{root} with the @command{passwd} command, and then let | |
9bea87a5 LC |
7823 | users change it with @command{passwd}. Passwords set with |
7824 | @command{passwd} are of course preserved across reboot and | |
7825 | reconfiguration. | |
eb59595c LC |
7826 | |
7827 | If you @emph{do} want to have a preset password for an account, then | |
7828 | this field must contain the encrypted password, as a string. | |
5d1f1177 LC |
7829 | @xref{crypt,,, libc, The GNU C Library Reference Manual}, for more information |
7830 | on password encryption, and @ref{Encryption,,, guile, GNU Guile Reference | |
eb59595c | 7831 | Manual}, for information on Guile's @code{crypt} procedure. |
c8c871d1 | 7832 | |
cf4a9129 LC |
7833 | @end table |
7834 | @end deftp | |
ee85f3db | 7835 | |
e32171ee | 7836 | @cindex groups |
cf4a9129 | 7837 | User group declarations are even simpler: |
ee85f3db | 7838 | |
cf4a9129 LC |
7839 | @example |
7840 | (user-group (name "students")) | |
7841 | @end example | |
ee85f3db | 7842 | |
cf4a9129 LC |
7843 | @deftp {Data Type} user-group |
7844 | This type is for, well, user groups. There are just a few fields: | |
af8a56b8 | 7845 | |
cf4a9129 LC |
7846 | @table @asis |
7847 | @item @code{name} | |
1068f26b | 7848 | The name of the group. |
ee85f3db | 7849 | |
cf4a9129 LC |
7850 | @item @code{id} (default: @code{#f}) |
7851 | The group identifier (a number). If @code{#f}, a new number is | |
7852 | automatically allocated when the group is created. | |
ee85f3db | 7853 | |
c8fa3426 LC |
7854 | @item @code{system?} (default: @code{#f}) |
7855 | This Boolean value indicates whether the group is a ``system'' group. | |
7856 | System groups have low numerical IDs. | |
7857 | ||
cf4a9129 LC |
7858 | @item @code{password} (default: @code{#f}) |
7859 | What, user groups can have a password? Well, apparently yes. Unless | |
1068f26b | 7860 | @code{#f}, this field specifies the password of the group. |
ee85f3db | 7861 | |
cf4a9129 LC |
7862 | @end table |
7863 | @end deftp | |
401c53c4 | 7864 | |
cf4a9129 LC |
7865 | For convenience, a variable lists all the basic user groups one may |
7866 | expect: | |
401c53c4 | 7867 | |
cf4a9129 LC |
7868 | @defvr {Scheme Variable} %base-groups |
7869 | This is the list of basic user groups that users and/or packages expect | |
7870 | to be present on the system. This includes groups such as ``root'', | |
7871 | ``wheel'', and ``users'', as well as groups used to control access to | |
7872 | specific devices such as ``audio'', ``disk'', and ``cdrom''. | |
7873 | @end defvr | |
401c53c4 | 7874 | |
bf87f38a LC |
7875 | @defvr {Scheme Variable} %base-user-accounts |
7876 | This is the list of basic system accounts that programs may expect to | |
7877 | find on a GNU/Linux system, such as the ``nobody'' account. | |
7878 | ||
7879 | Note that the ``root'' account is not included here. It is a | |
7880 | special-case and is automatically added whether or not it is specified. | |
7881 | @end defvr | |
7882 | ||
598e19dc LC |
7883 | @node Locales |
7884 | @subsection Locales | |
7885 | ||
7886 | @cindex locale | |
7887 | A @dfn{locale} defines cultural conventions for a particular language | |
7888 | and region of the world (@pxref{Locales,,, libc, The GNU C Library | |
7889 | Reference Manual}). Each locale has a name that typically has the form | |
b2636518 | 7890 | @code{@var{language}_@var{territory}.@var{codeset}}---e.g., |
598e19dc LC |
7891 | @code{fr_LU.utf8} designates the locale for the French language, with |
7892 | cultural conventions from Luxembourg, and using the UTF-8 encoding. | |
7893 | ||
7894 | @cindex locale definition | |
7895 | Usually, you will want to specify the default locale for the machine | |
7896 | using the @code{locale} field of the @code{operating-system} declaration | |
7897 | (@pxref{operating-system Reference, @code{locale}}). | |
7898 | ||
f5582b2c LC |
7899 | The selected locale is automatically added to the @dfn{locale |
7900 | definitions} known to the system if needed, with its codeset inferred | |
7901 | from its name---e.g., @code{bo_CN.utf8} will be assumed to use the | |
7902 | @code{UTF-8} codeset. Additional locale definitions can be specified in | |
7903 | the @code{locale-definitions} slot of @code{operating-system}---this is | |
7904 | useful, for instance, if the codeset could not be inferred from the | |
7905 | locale name. The default set of locale definitions includes some widely | |
7906 | used locales, but not all the available locales, in order to save space. | |
7907 | ||
7908 | For instance, to add the North Frisian locale for Germany, the value of | |
7909 | that field may be: | |
598e19dc LC |
7910 | |
7911 | @example | |
7912 | (cons (locale-definition | |
7913 | (name "fy_DE.utf8") (source "fy_DE")) | |
7914 | %default-locale-definitions) | |
7915 | @end example | |
7916 | ||
7917 | Likewise, to save space, one might want @code{locale-definitions} to | |
7918 | list only the locales that are actually used, as in: | |
7919 | ||
7920 | @example | |
7921 | (list (locale-definition | |
7922 | (name "ja_JP.eucjp") (source "ja_JP") | |
7923 | (charset "EUC-JP"))) | |
7924 | @end example | |
7925 | ||
5c3c1427 LC |
7926 | @vindex LOCPATH |
7927 | The compiled locale definitions are available at | |
46bd6edd LC |
7928 | @file{/run/current-system/locale/X.Y}, where @code{X.Y} is the libc |
7929 | version, which is the default location where the GNU@tie{}libc provided | |
7930 | by Guix looks for locale data. This can be overridden using the | |
7931 | @code{LOCPATH} environment variable (@pxref{locales-and-locpath, | |
5c3c1427 LC |
7932 | @code{LOCPATH} and locale packages}). |
7933 | ||
598e19dc LC |
7934 | The @code{locale-definition} form is provided by the @code{(gnu system |
7935 | locale)} module. Details are given below. | |
7936 | ||
7937 | @deftp {Data Type} locale-definition | |
7938 | This is the data type of a locale definition. | |
7939 | ||
7940 | @table @asis | |
7941 | ||
7942 | @item @code{name} | |
7943 | The name of the locale. @xref{Locale Names,,, libc, The GNU C Library | |
7944 | Reference Manual}, for more information on locale names. | |
7945 | ||
7946 | @item @code{source} | |
7947 | The name of the source for that locale. This is typically the | |
7948 | @code{@var{language}_@var{territory}} part of the locale name. | |
7949 | ||
7950 | @item @code{charset} (default: @code{"UTF-8"}) | |
7951 | The ``character set'' or ``code set'' for that locale, | |
7952 | @uref{http://www.iana.org/assignments/character-sets, as defined by | |
7953 | IANA}. | |
7954 | ||
7955 | @end table | |
7956 | @end deftp | |
7957 | ||
7958 | @defvr {Scheme Variable} %default-locale-definitions | |
1068f26b | 7959 | A list of commonly used UTF-8 locales, used as the default |
b2636518 | 7960 | value of the @code{locale-definitions} field of @code{operating-system} |
598e19dc | 7961 | declarations. |
b2636518 LC |
7962 | |
7963 | @cindex locale name | |
7964 | @cindex normalized codeset in locale names | |
7965 | These locale definitions use the @dfn{normalized codeset} for the part | |
7966 | that follows the dot in the name (@pxref{Using gettextized software, | |
7967 | normalized codeset,, libc, The GNU C Library Reference Manual}). So for | |
7968 | instance it has @code{uk_UA.utf8} but @emph{not}, say, | |
7969 | @code{uk_UA.UTF-8}. | |
598e19dc | 7970 | @end defvr |
401c53c4 | 7971 | |
34760ae7 LC |
7972 | @subsubsection Locale Data Compatibility Considerations |
7973 | ||
7974 | @cindex incompatibility, of locale data | |
7975 | @code{operating-system} declarations provide a @code{locale-libcs} field | |
7976 | to specify the GNU@tie{}libc packages that are used to compile locale | |
7977 | declarations (@pxref{operating-system Reference}). ``Why would I | |
7978 | care?'', you may ask. Well, it turns out that the binary format of | |
7979 | locale data is occasionally incompatible from one libc version to | |
7980 | another. | |
7981 | ||
7982 | @c See <https://sourceware.org/ml/libc-alpha/2015-09/msg00575.html> | |
7983 | @c and <https://lists.gnu.org/archive/html/guix-devel/2015-08/msg00737.html>. | |
7984 | For instance, a program linked against libc version 2.21 is unable to | |
7985 | read locale data produced with libc 2.22; worse, that program | |
7986 | @emph{aborts} instead of simply ignoring the incompatible locale | |
7987 | data@footnote{Versions 2.23 and later of GNU@tie{}libc will simply skip | |
7988 | the incompatible locale data, which is already an improvement.}. | |
7989 | Similarly, a program linked against libc 2.22 can read most, but not | |
201fff9e | 7990 | all, of the locale data from libc 2.21 (specifically, @code{LC_COLLATE} |
34760ae7 LC |
7991 | data is incompatible); thus calls to @code{setlocale} may fail, but |
7992 | programs will not abort. | |
7993 | ||
7994 | The ``problem'' in GuixSD is that users have a lot of freedom: They can | |
7995 | choose whether and when to upgrade software in their profiles, and might | |
7996 | be using a libc version different from the one the system administrator | |
7997 | used to build the system-wide locale data. | |
7998 | ||
7999 | Fortunately, unprivileged users can also install their own locale data | |
8000 | and define @var{GUIX_LOCPATH} accordingly (@pxref{locales-and-locpath, | |
8001 | @code{GUIX_LOCPATH} and locale packages}). | |
8002 | ||
8003 | Still, it is best if the system-wide locale data at | |
8004 | @file{/run/current-system/locale} is built for all the libc versions | |
8005 | actually in use on the system, so that all the programs can access | |
8006 | it---this is especially crucial on a multi-user system. To do that, the | |
8007 | administrator can specify several libc packages in the | |
8008 | @code{locale-libcs} field of @code{operating-system}: | |
8009 | ||
8010 | @example | |
8011 | (use-package-modules base) | |
8012 | ||
8013 | (operating-system | |
8014 | ;; @dots{} | |
8015 | (locale-libcs (list glibc-2.21 (canonical-package glibc)))) | |
8016 | @end example | |
8017 | ||
8018 | This example would lead to a system containing locale definitions for | |
8019 | both libc 2.21 and the current version of libc in | |
8020 | @file{/run/current-system/locale}. | |
8021 | ||
8022 | ||
cf4a9129 LC |
8023 | @node Services |
8024 | @subsection Services | |
401c53c4 | 8025 | |
cf4a9129 LC |
8026 | @cindex system services |
8027 | An important part of preparing an @code{operating-system} declaration is | |
8028 | listing @dfn{system services} and their configuration (@pxref{Using the | |
8029 | Configuration System}). System services are typically daemons launched | |
8030 | when the system boots, or other actions needed at that time---e.g., | |
d8b94dbd LC |
8031 | configuring network access. |
8032 | ||
e8b652d4 LC |
8033 | GuixSD has a broad definition of ``service'' (@pxref{Service |
8034 | Composition}), but many services are managed by the GNU@tie{}Shepherd | |
8035 | (@pxref{Shepherd Services}). On a running system, the @command{herd} | |
8036 | command allows you to list the available services, show their status, | |
8037 | start and stop them, or do other specific operations (@pxref{Jump | |
8038 | Start,,, shepherd, The GNU Shepherd Manual}). For example: | |
d8b94dbd LC |
8039 | |
8040 | @example | |
dd17bc38 | 8041 | # herd status |
d8b94dbd LC |
8042 | @end example |
8043 | ||
8044 | The above command, run as @code{root}, lists the currently defined | |
dd17bc38 | 8045 | services. The @command{herd doc} command shows a synopsis of the given |
d8b94dbd LC |
8046 | service: |
8047 | ||
8048 | @example | |
dd17bc38 | 8049 | # herd doc nscd |
d8b94dbd LC |
8050 | Run libc's name service cache daemon (nscd). |
8051 | @end example | |
8052 | ||
8053 | The @command{start}, @command{stop}, and @command{restart} sub-commands | |
8054 | have the effect you would expect. For instance, the commands below stop | |
8055 | the nscd service and restart the Xorg display server: | |
8056 | ||
8057 | @example | |
dd17bc38 | 8058 | # herd stop nscd |
d8b94dbd | 8059 | Service nscd has been stopped. |
dd17bc38 | 8060 | # herd restart xorg-server |
d8b94dbd LC |
8061 | Service xorg-server has been stopped. |
8062 | Service xorg-server has been started. | |
8063 | @end example | |
401c53c4 | 8064 | |
cf4a9129 | 8065 | The following sections document the available services, starting with |
d8b94dbd LC |
8066 | the core services, that may be used in an @code{operating-system} |
8067 | declaration. | |
401c53c4 | 8068 | |
cf4a9129 LC |
8069 | @menu |
8070 | * Base Services:: Essential system services. | |
c311089b | 8071 | * Scheduled Job Execution:: The mcron service. |
92c03a87 | 8072 | * Log Rotation:: The rottlog service. |
cf4a9129 LC |
8073 | * Networking Services:: Network setup, SSH daemon, etc. |
8074 | * X Window:: Graphical display. | |
f2ec23d1 | 8075 | * Printing Services:: Local and remote printer support. |
fe1a39d3 | 8076 | * Desktop Services:: D-Bus and desktop services. |
105369a4 | 8077 | * Database Services:: SQL databases. |
d8c18af8 | 8078 | * Mail Services:: IMAP, POP3, SMTP, and all that. |
859e367d | 8079 | * Kerberos Services:: Kerberos services. |
58724c48 | 8080 | * Web Services:: Web servers. |
eb419bc9 | 8081 | * Network File System:: NFS related services. |
a7cf4eb6 | 8082 | * Continuous Integration:: The Cuirass service. |
dbc6d370 | 8083 | * Miscellaneous Services:: Other services. |
cf4a9129 | 8084 | @end menu |
401c53c4 | 8085 | |
cf4a9129 LC |
8086 | @node Base Services |
8087 | @subsubsection Base Services | |
a1ba8475 | 8088 | |
cf4a9129 LC |
8089 | The @code{(gnu services base)} module provides definitions for the basic |
8090 | services that one expects from the system. The services exported by | |
8091 | this module are listed below. | |
401c53c4 | 8092 | |
cf4a9129 | 8093 | @defvr {Scheme Variable} %base-services |
31771497 LC |
8094 | This variable contains a list of basic services (@pxref{Service Types |
8095 | and Services}, for more information on service objects) one would | |
cf4a9129 | 8096 | expect from the system: a login service (mingetty) on each tty, syslogd, |
1068f26b | 8097 | the libc name service cache daemon (nscd), the udev device manager, and |
cf4a9129 | 8098 | more. |
401c53c4 | 8099 | |
cf4a9129 LC |
8100 | This is the default value of the @code{services} field of |
8101 | @code{operating-system} declarations. Usually, when customizing a | |
8102 | system, you will want to append services to @var{%base-services}, like | |
8103 | this: | |
401c53c4 | 8104 | |
cf4a9129 | 8105 | @example |
fa1e31b8 | 8106 | (cons* (avahi-service) (lsh-service) %base-services) |
cf4a9129 LC |
8107 | @end example |
8108 | @end defvr | |
401c53c4 | 8109 | |
be1c2c54 | 8110 | @deffn {Scheme Procedure} host-name-service @var{name} |
cf4a9129 LC |
8111 | Return a service that sets the host name to @var{name}. |
8112 | @end deffn | |
401c53c4 | 8113 | |
317d3b47 DC |
8114 | @deffn {Scheme Procedure} login-service @var{config} |
8115 | Return a service to run login according to @var{config}, a | |
8116 | @code{<login-configuration>} object, which specifies the message of the day, | |
8117 | among other things. | |
8118 | @end deffn | |
8119 | ||
8120 | @deftp {Data Type} login-configuration | |
8121 | This is the data type representing the configuration of login. | |
8122 | ||
8123 | @table @asis | |
8124 | ||
8125 | @item @code{motd} | |
e32171ee | 8126 | @cindex message of the day |
317d3b47 DC |
8127 | A file-like object containing the ``message of the day''. |
8128 | ||
8129 | @item @code{allow-empty-passwords?} (default: @code{#t}) | |
8130 | Allow empty passwords by default so that first-time users can log in when | |
8131 | the 'root' account has just been created. | |
8132 | ||
8133 | @end table | |
8134 | @end deftp | |
8135 | ||
66e4f01c LC |
8136 | @deffn {Scheme Procedure} mingetty-service @var{config} |
8137 | Return a service to run mingetty according to @var{config}, a | |
8138 | @code{<mingetty-configuration>} object, which specifies the tty to run, among | |
8139 | other things. | |
cf4a9129 | 8140 | @end deffn |
401c53c4 | 8141 | |
66e4f01c LC |
8142 | @deftp {Data Type} mingetty-configuration |
8143 | This is the data type representing the configuration of Mingetty, which | |
8144 | implements console log-in. | |
8145 | ||
8146 | @table @asis | |
8147 | ||
8148 | @item @code{tty} | |
8149 | The name of the console this Mingetty runs on---e.g., @code{"tty1"}. | |
8150 | ||
66e4f01c LC |
8151 | @item @code{auto-login} (default: @code{#f}) |
8152 | When true, this field must be a string denoting the user name under | |
f9b9a033 | 8153 | which the system automatically logs in. When it is @code{#f}, a |
66e4f01c LC |
8154 | user name and password must be entered to log in. |
8155 | ||
8156 | @item @code{login-program} (default: @code{#f}) | |
8157 | This must be either @code{#f}, in which case the default log-in program | |
8158 | is used (@command{login} from the Shadow tool suite), or a gexp denoting | |
8159 | the name of the log-in program. | |
8160 | ||
8161 | @item @code{login-pause?} (default: @code{#f}) | |
8162 | When set to @code{#t} in conjunction with @var{auto-login}, the user | |
8163 | will have to press a key before the log-in shell is launched. | |
8164 | ||
8165 | @item @code{mingetty} (default: @var{mingetty}) | |
8166 | The Mingetty package to use. | |
8167 | ||
8168 | @end table | |
8169 | @end deftp | |
8170 | ||
46ec2707 DC |
8171 | @deffn {Scheme Procedure} kmscon-service-type @var{config} |
8172 | Return a service to run @uref{https://www.freedesktop.org/wiki/Software/kmscon,kmscon} | |
8173 | according to @var{config}, a @code{<kmscon-configuration>} object, which | |
8174 | specifies the tty to run, among other things. | |
8175 | @end deffn | |
8176 | ||
8177 | @deftp {Data Type} kmscon-configuration | |
8178 | This is the data type representing the configuration of Kmscon, which | |
8179 | implements console log-in. | |
8180 | ||
8181 | @table @asis | |
8182 | ||
8183 | @item @code{virtual-terminal} | |
8184 | The name of the console this Kmscon runs on---e.g., @code{"tty1"}. | |
8185 | ||
8186 | @item @code{login-program} (default: @code{#~(string-append #$shadow "/bin/login")}) | |
8187 | A gexp denoting the name of the log-in program. The default log-in program is | |
8188 | @command{login} from the Shadow tool suite. | |
8189 | ||
8190 | @item @code{login-arguments} (default: @code{'("-p")}) | |
8191 | A list of arguments to pass to @command{login}. | |
8192 | ||
8193 | @item @code{hardware-acceleration?} (default: #f) | |
8194 | Whether to use hardware acceleration. | |
8195 | ||
8196 | @item @code{kmscon} (default: @var{kmscon}) | |
8197 | The Kmscon package to use. | |
8198 | ||
8199 | @end table | |
8200 | @end deftp | |
8201 | ||
6454b333 LC |
8202 | @cindex name service cache daemon |
8203 | @cindex nscd | |
be1c2c54 | 8204 | @deffn {Scheme Procedure} nscd-service [@var{config}] [#:glibc glibc] @ |
4aee6e60 | 8205 | [#:name-services '()] |
1068f26b | 8206 | Return a service that runs the libc name service cache daemon (nscd) with the |
b893f1ae LC |
8207 | given @var{config}---an @code{<nscd-configuration>} object. @xref{Name |
8208 | Service Switch}, for an example. | |
cf4a9129 | 8209 | @end deffn |
401c53c4 | 8210 | |
6454b333 LC |
8211 | @defvr {Scheme Variable} %nscd-default-configuration |
8212 | This is the default @code{<nscd-configuration>} value (see below) used | |
1068f26b | 8213 | by @code{nscd-service}. It uses the caches defined by |
6454b333 LC |
8214 | @var{%nscd-default-caches}; see below. |
8215 | @end defvr | |
8216 | ||
8217 | @deftp {Data Type} nscd-configuration | |
1068f26b | 8218 | This is the data type representing the name service cache daemon (nscd) |
6454b333 LC |
8219 | configuration. |
8220 | ||
8221 | @table @asis | |
8222 | ||
b893f1ae LC |
8223 | @item @code{name-services} (default: @code{'()}) |
8224 | List of packages denoting @dfn{name services} that must be visible to | |
8225 | the nscd---e.g., @code{(list @var{nss-mdns})}. | |
8226 | ||
8227 | @item @code{glibc} (default: @var{glibc}) | |
8228 | Package object denoting the GNU C Library providing the @command{nscd} | |
8229 | command. | |
8230 | ||
6454b333 | 8231 | @item @code{log-file} (default: @code{"/var/log/nscd.log"}) |
1068f26b | 8232 | Name of the nscd log file. This is where debugging output goes when |
6454b333 LC |
8233 | @code{debug-level} is strictly positive. |
8234 | ||
8235 | @item @code{debug-level} (default: @code{0}) | |
1068f26b | 8236 | Integer denoting the debugging levels. Higher numbers mean that more |
6454b333 LC |
8237 | debugging output is logged. |
8238 | ||
8239 | @item @code{caches} (default: @var{%nscd-default-caches}) | |
8240 | List of @code{<nscd-cache>} objects denoting things to be cached; see | |
8241 | below. | |
8242 | ||
8243 | @end table | |
8244 | @end deftp | |
8245 | ||
8246 | @deftp {Data Type} nscd-cache | |
8247 | Data type representing a cache database of nscd and its parameters. | |
8248 | ||
8249 | @table @asis | |
8250 | ||
8251 | @item @code{database} | |
8252 | This is a symbol representing the name of the database to be cached. | |
8253 | Valid values are @code{passwd}, @code{group}, @code{hosts}, and | |
8254 | @code{services}, which designate the corresponding NSS database | |
8255 | (@pxref{NSS Basics,,, libc, The GNU C Library Reference Manual}). | |
8256 | ||
8257 | @item @code{positive-time-to-live} | |
8258 | @itemx @code{negative-time-to-live} (default: @code{20}) | |
8259 | A number representing the number of seconds during which a positive or | |
8260 | negative lookup result remains in cache. | |
8261 | ||
8262 | @item @code{check-files?} (default: @code{#t}) | |
8263 | Whether to check for updates of the files corresponding to | |
8264 | @var{database}. | |
8265 | ||
8266 | For instance, when @var{database} is @code{hosts}, setting this flag | |
8267 | instructs nscd to check for updates in @file{/etc/hosts} and to take | |
8268 | them into account. | |
8269 | ||
8270 | @item @code{persistent?} (default: @code{#t}) | |
8271 | Whether the cache should be stored persistently on disk. | |
8272 | ||
8273 | @item @code{shared?} (default: @code{#t}) | |
8274 | Whether the cache should be shared among users. | |
8275 | ||
8276 | @item @code{max-database-size} (default: 32@tie{}MiB) | |
8277 | Maximum size in bytes of the database cache. | |
8278 | ||
8279 | @c XXX: 'suggested-size' and 'auto-propagate?' seem to be expert | |
8280 | @c settings, so leave them out. | |
8281 | ||
8282 | @end table | |
8283 | @end deftp | |
8284 | ||
8285 | @defvr {Scheme Variable} %nscd-default-caches | |
8286 | List of @code{<nscd-cache>} objects used by default by | |
1068f26b | 8287 | @code{nscd-configuration} (see above). |
6454b333 LC |
8288 | |
8289 | It enables persistent and aggressive caching of service and host name | |
8290 | lookups. The latter provides better host name lookup performance, | |
8291 | resilience in the face of unreliable name servers, and also better | |
8292 | privacy---often the result of host name lookups is in local cache, so | |
8293 | external name servers do not even need to be queried. | |
8294 | @end defvr | |
8295 | ||
ec2e2f6c | 8296 | @anchor{syslog-configuration-type} |
e32171ee JD |
8297 | @cindex syslog |
8298 | @cindex logging | |
ec2e2f6c DC |
8299 | @deftp {Data Type} syslog-configuration |
8300 | This data type represents the configuration of the syslog daemon. | |
6454b333 | 8301 | |
ec2e2f6c DC |
8302 | @table @asis |
8303 | @item @code{syslogd} (default: @code{#~(string-append #$inetutils "/libexec/syslogd")}) | |
8304 | The syslog daemon to use. | |
8305 | ||
8306 | @item @code{config-file} (default: @code{%default-syslog.conf}) | |
8307 | The syslog configuration file to use. | |
8308 | ||
8309 | @end table | |
8310 | @end deftp | |
8311 | ||
8312 | @anchor{syslog-service} | |
e32171ee | 8313 | @cindex syslog |
ec2e2f6c DC |
8314 | @deffn {Scheme Procedure} syslog-service @var{config} |
8315 | Return a service that runs a syslog daemon according to @var{config}. | |
44abcb28 LC |
8316 | |
8317 | @xref{syslogd invocation,,, inetutils, GNU Inetutils}, for more | |
8318 | information on the configuration file syntax. | |
cf4a9129 | 8319 | @end deffn |
401c53c4 | 8320 | |
0adfe95a LC |
8321 | @anchor{guix-configuration-type} |
8322 | @deftp {Data Type} guix-configuration | |
8323 | This data type represents the configuration of the Guix build daemon. | |
8324 | @xref{Invoking guix-daemon}, for more information. | |
8325 | ||
8326 | @table @asis | |
8327 | @item @code{guix} (default: @var{guix}) | |
8328 | The Guix package to use. | |
401c53c4 | 8329 | |
0adfe95a LC |
8330 | @item @code{build-group} (default: @code{"guixbuild"}) |
8331 | Name of the group for build user accounts. | |
401c53c4 | 8332 | |
0adfe95a LC |
8333 | @item @code{build-accounts} (default: @code{10}) |
8334 | Number of build user accounts to create. | |
401c53c4 | 8335 | |
0adfe95a | 8336 | @item @code{authorize-key?} (default: @code{#t}) |
e32171ee | 8337 | @cindex substitutes, authorization thereof |
5b58c28b LC |
8338 | Whether to authorize the substitute keys listed in |
8339 | @code{authorized-keys}---by default that of @code{hydra.gnu.org} | |
0adfe95a LC |
8340 | (@pxref{Substitutes}). |
8341 | ||
5b58c28b LC |
8342 | @vindex %default-authorized-guix-keys |
8343 | @item @code{authorized-keys} (default: @var{%default-authorized-guix-keys}) | |
8344 | The list of authorized key files for archive imports, as a list of | |
8345 | string-valued gexps (@pxref{Invoking guix archive}). By default, it | |
8346 | contains that of @code{hydra.gnu.org} (@pxref{Substitutes}). | |
8347 | ||
0adfe95a LC |
8348 | @item @code{use-substitutes?} (default: @code{#t}) |
8349 | Whether to use substitutes. | |
8350 | ||
b0b9f6e0 LC |
8351 | @item @code{substitute-urls} (default: @var{%default-substitute-urls}) |
8352 | The list of URLs where to look for substitutes by default. | |
8353 | ||
0adfe95a LC |
8354 | @item @code{extra-options} (default: @code{'()}) |
8355 | List of extra command-line options for @command{guix-daemon}. | |
8356 | ||
dc0ef095 LC |
8357 | @item @code{log-file} (default: @code{"/var/log/guix-daemon.log"}) |
8358 | File where @command{guix-daemon}'s standard output and standard error | |
8359 | are written. | |
8360 | ||
0adfe95a | 8361 | @item @code{lsof} (default: @var{lsof}) |
f78903f3 | 8362 | The lsof package to use. |
0adfe95a LC |
8363 | |
8364 | @end table | |
8365 | @end deftp | |
8366 | ||
8367 | @deffn {Scheme Procedure} guix-service @var{config} | |
8368 | Return a service that runs the Guix build daemon according to | |
8369 | @var{config}. | |
cf4a9129 | 8370 | @end deffn |
a1ba8475 | 8371 | |
be1c2c54 | 8372 | @deffn {Scheme Procedure} udev-service [#:udev udev] |
cf4a9129 LC |
8373 | Run @var{udev}, which populates the @file{/dev} directory dynamically. |
8374 | @end deffn | |
401c53c4 | 8375 | |
a535e122 LF |
8376 | @deffn {Scheme Procedure} urandom-seed-service @var{#f} |
8377 | Save some entropy in @var{%random-seed-file} to seed @file{/dev/urandom} | |
8378 | when rebooting. | |
8379 | @end deffn | |
8380 | ||
8381 | @defvr {Scheme Variable} %random-seed-file | |
8382 | This is the name of the file where some random bytes are saved by | |
8383 | @var{urandom-seed-service} to seed @file{/dev/urandom} when rebooting. | |
8384 | It defaults to @file{/var/lib/random-seed}. | |
8385 | @end defvr | |
8386 | ||
e32171ee JD |
8387 | @cindex keymap |
8388 | @cindex keyboard | |
b3d05f48 | 8389 | @deffn {Scheme Procedure} console-keymap-service @var{files} ... |
dedb8d5e | 8390 | @cindex keyboard layout |
b3d05f48 AK |
8391 | Return a service to load console keymaps from @var{files} using |
8392 | @command{loadkeys} command. Most likely, you want to load some default | |
8393 | keymap, which can be done like this: | |
8394 | ||
8395 | @example | |
8396 | (console-keymap-service "dvorak") | |
8397 | @end example | |
8398 | ||
8399 | Or, for example, for a Swedish keyboard, you may need to combine | |
8400 | the following keymaps: | |
8401 | @example | |
8402 | (console-keymap-service "se-lat6" "se-fi-lat6") | |
8403 | @end example | |
8404 | ||
8405 | Also you can specify a full file name (or file names) of your keymap(s). | |
8406 | See @code{man loadkeys} for details. | |
8407 | ||
5eca9459 AK |
8408 | @end deffn |
8409 | ||
e32171ee JD |
8410 | @cindex mouse |
8411 | @cindex gpm | |
1aaf116d | 8412 | @deffn {Scheme Procedure} gpm-service [#:gpm @var{gpm}] @ |
8664cc88 LC |
8413 | [#:options] |
8414 | Run @var{gpm}, the general-purpose mouse daemon, with the given | |
8415 | command-line @var{options}. GPM allows users to use the mouse in the console, | |
8416 | notably to select, copy, and paste text. The default value of @var{options} | |
8417 | uses the @code{ps2} protocol, which works for both USB and PS/2 mice. | |
8418 | ||
8419 | This service is not part of @var{%base-services}. | |
8420 | @end deffn | |
8421 | ||
1c52181f LC |
8422 | @anchor{guix-publish-service} |
8423 | @deffn {Scheme Procedure} guix-publish-service [#:guix @var{guix}] @ | |
8424 | [#:port 80] [#:host "localhost"] | |
8425 | Return a service that runs @command{guix publish} listening on @var{host} | |
8426 | and @var{port} (@pxref{Invoking guix publish}). | |
8427 | ||
8428 | This assumes that @file{/etc/guix} already contains a signing key pair as | |
8429 | created by @command{guix archive --generate-key} (@pxref{Invoking guix | |
8430 | archive}). If that is not the case, the service will fail to start. | |
8431 | @end deffn | |
8432 | ||
b58cbf9a DC |
8433 | @anchor{rngd-service} |
8434 | @deffn {Scheme Procedure} rngd-service [#:rng-tools @var{rng-tools}] @ | |
8435 | [#:device "/dev/hwrng"] | |
8436 | Return a service that runs the @command{rngd} program from @var{rng-tools} | |
8437 | to add @var{device} to the kernel's entropy pool. The service will fail if | |
8438 | @var{device} does not exist. | |
8439 | @end deffn | |
a69576ea | 8440 | |
909147e4 RW |
8441 | @anchor{pam-limits-service} |
8442 | @cindex session limits | |
8443 | @cindex ulimit | |
8444 | @cindex priority | |
8445 | @deffn {Scheme Procedure} pam-limits-service [#:limits @var{limits}] | |
8446 | ||
8447 | Return a service that installs a configuration file for the | |
8448 | @uref{http://linux-pam.org/Linux-PAM-html/sag-pam_limits.html, | |
8449 | @code{pam_limits} module}. The procedure optionally takes a list of | |
8450 | @code{pam-limits-entry} values, which can be used to specify | |
8451 | @code{ulimit} limits and nice priority limits to user sessions. | |
8452 | ||
8453 | The following limits definition sets two hard and soft limits for all | |
8454 | login sessions of users in the @code{realtime} group: | |
8455 | ||
8456 | @example | |
8457 | (pam-limits-service | |
8458 | (list | |
8459 | (pam-limits-entry "@@realtime" 'both 'rtprio 99) | |
8460 | (pam-limits-entry "@@realtime" 'both 'memlock 'unlimited))) | |
8461 | @end example | |
8462 | ||
8463 | The first entry increases the maximum realtime priority for | |
8464 | non-privileged processes; the second entry lifts any restriction of the | |
8465 | maximum address space that can be locked in memory. These settings are | |
8466 | commonly used for real-time audio systems. | |
8467 | @end deffn | |
8468 | ||
c311089b LC |
8469 | @node Scheduled Job Execution |
8470 | @subsubsection Scheduled Job Execution | |
8471 | ||
8472 | @cindex cron | |
e32171ee | 8473 | @cindex mcron |
c311089b LC |
8474 | @cindex scheduling jobs |
8475 | The @code{(gnu services mcron)} module provides an interface to | |
8476 | GNU@tie{}mcron, a daemon to run jobs at scheduled times (@pxref{Top,,, | |
8477 | mcron, GNU@tie{}mcron}). GNU@tie{}mcron is similar to the traditional | |
8478 | Unix @command{cron} daemon; the main difference is that it is | |
8479 | implemented in Guile Scheme, which provides a lot of flexibility when | |
8480 | specifying the scheduling of jobs and their actions. | |
8481 | ||
8ac6282c | 8482 | The example below defines an operating system that runs the |
c311089b | 8483 | @command{updatedb} (@pxref{Invoking updatedb,,, find, Finding Files}) |
8ac6282c LC |
8484 | and the @command{guix gc} commands (@pxref{Invoking guix gc}) daily, as |
8485 | well as the @command{mkid} command on behalf of an unprivileged user | |
8486 | (@pxref{mkid invocation,,, idutils, ID Database Utilities}). It uses | |
8487 | gexps to introduce job definitions that are passed to mcron | |
8488 | (@pxref{G-Expressions}). | |
c311089b LC |
8489 | |
8490 | @lisp | |
8491 | (use-modules (guix) (gnu) (gnu services mcron)) | |
8ac6282c | 8492 | (use-package-modules base idutils) |
c311089b LC |
8493 | |
8494 | (define updatedb-job | |
8ac6282c LC |
8495 | ;; Run 'updatedb' at 3AM every day. Here we write the |
8496 | ;; job's action as a Scheme procedure. | |
c311089b | 8497 | #~(job '(next-hour '(3)) |
8ac6282c LC |
8498 | (lambda () |
8499 | (execl (string-append #$findutils "/bin/updatedb") | |
8500 | "updatedb" | |
8501 | "--prunepaths=/tmp /var/tmp /gnu/store")))) | |
c311089b LC |
8502 | |
8503 | (define garbage-collector-job | |
8504 | ;; Collect garbage 5 minutes after midnight every day. | |
8ac6282c | 8505 | ;; The job's action is a shell command. |
c311089b LC |
8506 | #~(job "5 0 * * *" ;Vixie cron syntax |
8507 | "guix gc -F 1G")) | |
8508 | ||
80d944b7 | 8509 | (define idutils-job |
8ac6282c LC |
8510 | ;; Update the index database as user "charlie" at 12:15PM |
8511 | ;; and 19:15PM. This runs from the user's home directory. | |
8512 | #~(job '(next-minute-from (next-hour '(12 19)) '(15)) | |
8513 | (string-append #$idutils "/bin/mkid src") | |
8514 | #:user "charlie")) | |
8515 | ||
c311089b LC |
8516 | (operating-system |
8517 | ;; @dots{} | |
8518 | (services (cons (mcron-service (list garbage-collector-job | |
8ac6282c LC |
8519 | updatedb-job |
8520 | idutils-job)) | |
c311089b LC |
8521 | %base-services))) |
8522 | @end lisp | |
8523 | ||
8524 | @xref{Guile Syntax, mcron job specifications,, mcron, GNU@tie{}mcron}, | |
8525 | for more information on mcron job specifications. Below is the | |
8526 | reference of the mcron service. | |
8527 | ||
8528 | @deffn {Scheme Procedure} mcron-service @var{jobs} [#:mcron @var{mcron2}] | |
8529 | Return an mcron service running @var{mcron} that schedules @var{jobs}, a | |
8530 | list of gexps denoting mcron job specifications. | |
8531 | ||
8532 | This is a shorthand for: | |
8533 | @example | |
80d944b7 LC |
8534 | (service mcron-service-type |
8535 | (mcron-configuration (mcron mcron) (jobs jobs))) | |
c311089b LC |
8536 | @end example |
8537 | @end deffn | |
8538 | ||
8539 | @defvr {Scheme Variable} mcron-service-type | |
8540 | This is the type of the @code{mcron} service, whose value is an | |
8541 | @code{mcron-configuration} object. | |
8542 | ||
8543 | This service type can be the target of a service extension that provides | |
8544 | it additional job specifications (@pxref{Service Composition}). In | |
80d944b7 | 8545 | other words, it is possible to define services that provide additional |
c311089b LC |
8546 | mcron jobs to run. |
8547 | @end defvr | |
8548 | ||
8549 | @deftp {Data Type} mcron-configuration | |
8550 | Data type representing the configuration of mcron. | |
8551 | ||
8552 | @table @asis | |
8553 | @item @code{mcron} (default: @var{mcron2}) | |
8554 | The mcron package to use. | |
8555 | ||
8556 | @item @code{jobs} | |
8557 | This is a list of gexps (@pxref{G-Expressions}), where each gexp | |
8558 | corresponds to an mcron job specification (@pxref{Syntax, mcron job | |
8559 | specifications,, mcron, GNU@tie{}mcron}). | |
8560 | @end table | |
8561 | @end deftp | |
8562 | ||
8563 | ||
92c03a87 JN |
8564 | @node Log Rotation |
8565 | @subsubsection Log Rotation | |
8566 | ||
8567 | @cindex rottlog | |
8568 | @cindex log rotation | |
e32171ee | 8569 | @cindex logging |
92c03a87 JN |
8570 | Log files such as those found in @file{/var/log} tend to grow endlessly, |
8571 | so it's a good idea to @dfn{rotate} them once in a while---i.e., archive | |
8572 | their contents in separate files, possibly compressed. The @code{(gnu | |
8573 | services admin)} module provides an interface to GNU@tie{}Rot[t]log, a | |
8574 | log rotation tool (@pxref{Top,,, rottlog, GNU Rot[t]log Manual}). | |
8575 | ||
8576 | The example below defines an operating system that provides log rotation | |
8577 | with the default settings. | |
8578 | ||
8579 | @lisp | |
8580 | (use-modules (guix) (gnu)) | |
8581 | (use-service-modules admin mcron) | |
8582 | (use-package-modules base idutils) | |
8583 | ||
8584 | (operating-system | |
8585 | ;; @dots{} | |
8586 | (services (cons* (mcron-service) | |
8587 | (service rottlog-service-type (rottlog-configuration)) | |
8588 | %base-services))) | |
8589 | @end lisp | |
8590 | ||
8591 | @defvr {Scheme Variable} rottlog-service-type | |
8592 | This is the type of the Rottlog service, whose value is a | |
8593 | @code{rottlog-configuration} object. | |
8594 | ||
8595 | This service type can define mcron jobs (@pxref{Scheduled Job | |
8596 | Execution}) to run the rottlog service. | |
8597 | @end defvr | |
8598 | ||
8599 | @deftp {Data Type} rottlog-configuration | |
8600 | Data type representing the configuration of rottlog. | |
8601 | ||
8602 | @table @asis | |
8603 | @item @code{rottlog} (default: @code{rottlog}) | |
8604 | The Rottlog package to use. | |
8605 | ||
8606 | @item @code{rc-file} (default: @code{(file-append rottlog "/etc/rc")}) | |
8607 | The Rottlog configuration file to use (@pxref{Mandatory RC Variables,,, | |
8608 | rottlog, GNU Rot[t]log Manual}). | |
8609 | ||
8610 | @item @code{periodic-rotations} (default: @code{`(("weekly" %default-rotatations))}) | |
8611 | A list of Rottlog period-name/period-config tuples. | |
8612 | ||
8613 | For example, taking an example from the Rottlog manual (@pxref{Period | |
8614 | Related File Examples,,, rottlog, GNU Rot[t]log Manual}), a valid tuple | |
8615 | might be: | |
8616 | ||
8617 | @example | |
8618 | ("daily" ,(plain-file "daily" | |
8619 | "\ | |
8620 | /var/log/apache/* @{ | |
8621 | storedir apache-archives | |
8622 | rotate 6 | |
8623 | notifempty | |
8624 | nocompress | |
8625 | @}")) | |
8626 | @end example | |
8627 | ||
8628 | @item @code{jobs} | |
8629 | This is a list of gexps where each gexp corresponds to an mcron job | |
8630 | specification (@pxref{Scheduled Job Execution}). | |
8631 | @end table | |
8632 | @end deftp | |
8633 | ||
8634 | @defvr {Scheme Variable} %default-rotations | |
8635 | Specifies weekly rotation of @var{%rotated-files} and | |
8636 | @code{"/var/log/shepherd.log"}. | |
8637 | @end defvr | |
8638 | ||
8639 | @defvr {Scheme Variable} %rotated-files | |
8640 | The list of syslog-controlled files to be rotated. By default it is: | |
8641 | @code{'("/var/log/messages" "/var/log/secure")}. | |
8642 | @end defvr | |
8643 | ||
cf4a9129 LC |
8644 | @node Networking Services |
8645 | @subsubsection Networking Services | |
401c53c4 | 8646 | |
fa1e31b8 | 8647 | The @code{(gnu services networking)} module provides services to configure |
cf4a9129 | 8648 | the network interface. |
a1ba8475 | 8649 | |
a023cca8 | 8650 | @cindex DHCP, networking service |
be1c2c54 | 8651 | @deffn {Scheme Procedure} dhcp-client-service [#:dhcp @var{isc-dhcp}] |
a023cca8 LC |
8652 | Return a service that runs @var{dhcp}, a Dynamic Host Configuration |
8653 | Protocol (DHCP) client, on all the non-loopback network interfaces. | |
8654 | @end deffn | |
8655 | ||
be1c2c54 | 8656 | @deffn {Scheme Procedure} static-networking-service @var{interface} @var{ip} @ |
1f9803c2 | 8657 | [#:netmask #f] [#:gateway #f] [#:name-servers @code{'()}] |
cf4a9129 | 8658 | Return a service that starts @var{interface} with address @var{ip}. If |
1f9803c2 LC |
8659 | @var{netmask} is true, use it as the network mask. If @var{gateway} is true, |
8660 | it must be a string specifying the default network gateway. | |
cf4a9129 | 8661 | @end deffn |
8b315a6d | 8662 | |
b7d0c494 | 8663 | @cindex wicd |
e32171ee JD |
8664 | @cindex wireless |
8665 | @cindex WiFi | |
87f40011 | 8666 | @cindex network management |
be1c2c54 | 8667 | @deffn {Scheme Procedure} wicd-service [#:wicd @var{wicd}] |
87f40011 LC |
8668 | Return a service that runs @url{https://launchpad.net/wicd,Wicd}, a network |
8669 | management daemon that aims to simplify wired and wireless networking. | |
8670 | ||
8671 | This service adds the @var{wicd} package to the global profile, providing | |
8672 | several commands to interact with the daemon and configure networking: | |
8673 | @command{wicd-client}, a graphical user interface, and the @command{wicd-cli} | |
8674 | and @command{wicd-curses} user interfaces. | |
b7d0c494 MW |
8675 | @end deffn |
8676 | ||
c0a9589d SB |
8677 | @cindex NetworkManager |
8678 | @deffn {Scheme Procedure} network-manager-service @ | |
8679 | [#:network-manager @var{network-manager}] | |
8680 | Return a service that runs NetworkManager, a network connection manager | |
1068f26b | 8681 | attempting to keep network connectivity active when available. |
c0a9589d SB |
8682 | @end deffn |
8683 | ||
76192896 EF |
8684 | @cindex Connman |
8685 | @deffn {Scheme Procedure} connman-service @ | |
8686 | [#:connman @var{connman}] | |
8687 | Return a service that runs @url{https://01.org/connman,Connman}, a network | |
8688 | connection manager. | |
8689 | ||
8690 | This service adds the @var{connman} package to the global profile, providing | |
8691 | several the @command{connmanctl} command to interact with the daemon and | |
8692 | configure networking." | |
8693 | @end deffn | |
8694 | ||
2cccbc2a | 8695 | @cindex WPA Supplicant |
cbf1024e LC |
8696 | @defvr {Scheme Variable} wpa-supplicant-service-type |
8697 | This is the service type to run @url{https://w1.fi/wpa_supplicant/,WPA | |
2cccbc2a | 8698 | supplicant}, an authentication daemon required to authenticate against |
cbf1024e | 8699 | encrypted WiFi or ethernet networks. It is configured to listen for |
2cccbc2a | 8700 | requests on D-Bus. |
cbf1024e LC |
8701 | |
8702 | The value of this service is the @code{wpa-supplicant} package to use. | |
8703 | Thus, it can be instantiated like this: | |
8704 | ||
8705 | @lisp | |
8706 | (use-modules (gnu services networking) | |
8707 | (gnu packages admin)) | |
8708 | ||
9747d189 | 8709 | (service wpa-supplicant-service-type wpa-supplicant) |
cbf1024e LC |
8710 | @end lisp |
8711 | @end defvr | |
2cccbc2a | 8712 | |
e32171ee JD |
8713 | @cindex NTP |
8714 | @cindex real time clock | |
be1c2c54 | 8715 | @deffn {Scheme Procedure} ntp-service [#:ntp @var{ntp}] @ |
dc0322b5 LC |
8716 | [#:servers @var{%ntp-servers}] @ |
8717 | [#:allow-large-adjustment? #f] | |
63854bcb LC |
8718 | Return a service that runs the daemon from @var{ntp}, the |
8719 | @uref{http://www.ntp.org, Network Time Protocol package}. The daemon will | |
8720 | keep the system clock synchronized with that of @var{servers}. | |
dc0322b5 LC |
8721 | @var{allow-large-adjustment?} determines whether @command{ntpd} is allowed to |
8722 | make an initial adjustment of more than 1,000 seconds. | |
63854bcb LC |
8723 | @end deffn |
8724 | ||
8725 | @defvr {Scheme Variable} %ntp-servers | |
8726 | List of host names used as the default NTP servers. | |
8727 | @end defvr | |
8728 | ||
e32171ee | 8729 | @cindex Tor |
375c6108 LC |
8730 | @deffn {Scheme Procedure} tor-service [@var{config-file}] [#:tor @var{tor}] |
8731 | Return a service to run the @uref{https://torproject.org, Tor} anonymous | |
8732 | networking daemon. | |
8b315a6d | 8733 | |
375c6108 | 8734 | The daemon runs as the @code{tor} unprivileged user. It is passed |
6331bde7 LC |
8735 | @var{config-file}, a file-like object, with an additional @code{User tor} line |
8736 | and lines for hidden services added via @code{tor-hidden-service}. Run | |
8737 | @command{man tor} for information about the configuration file. | |
8738 | @end deffn | |
8739 | ||
24a8ef3b | 8740 | @cindex hidden service |
6331bde7 LC |
8741 | @deffn {Scheme Procedure} tor-hidden-service @var{name} @var{mapping} |
8742 | Define a new Tor @dfn{hidden service} called @var{name} and implementing | |
8743 | @var{mapping}. @var{mapping} is a list of port/host tuples, such as: | |
8744 | ||
8745 | @example | |
24a8ef3b LC |
8746 | '((22 "127.0.0.1:22") |
8747 | (80 "127.0.0.1:8080")) | |
6331bde7 LC |
8748 | @end example |
8749 | ||
8750 | In this example, port 22 of the hidden service is mapped to local port 22, and | |
8751 | port 80 is mapped to local port 8080. | |
8752 | ||
6629099a LC |
8753 | This creates a @file{/var/lib/tor/hidden-services/@var{name}} directory, where |
8754 | the @file{hostname} file contains the @code{.onion} host name for the hidden | |
6331bde7 LC |
8755 | service. |
8756 | ||
8757 | See @uref{https://www.torproject.org/docs/tor-hidden-service.html.en, the Tor | |
8758 | project's documentation} for more information. | |
cf4a9129 | 8759 | @end deffn |
8b315a6d | 8760 | |
be1c2c54 | 8761 | @deffn {Scheme Procedure} bitlbee-service [#:bitlbee bitlbee] @ |
4627a464 LC |
8762 | [#:interface "127.0.0.1"] [#:port 6667] @ |
8763 | [#:extra-settings ""] | |
8764 | Return a service that runs @url{http://bitlbee.org,BitlBee}, a daemon that | |
8765 | acts as a gateway between IRC and chat networks. | |
8766 | ||
8767 | The daemon will listen to the interface corresponding to the IP address | |
8768 | specified in @var{interface}, on @var{port}. @code{127.0.0.1} means that only | |
8769 | local clients can connect, whereas @code{0.0.0.0} means that connections can | |
8770 | come from any networking interface. | |
8771 | ||
8772 | In addition, @var{extra-settings} specifies a string to append to the | |
8773 | configuration file. | |
8774 | @end deffn | |
8775 | ||
71b0601a | 8776 | Furthermore, @code{(gnu services ssh)} provides the following services. |
e32171ee JD |
8777 | @cindex SSH |
8778 | @cindex SSH server | |
8b315a6d | 8779 | |
be1c2c54 | 8780 | @deffn {Scheme Procedure} lsh-service [#:host-key "/etc/lsh/host-key"] @ |
5833bf33 | 8781 | [#:daemonic? #t] [#:interfaces '()] [#:port-number 22] @ |
cf4a9129 LC |
8782 | [#:allow-empty-passwords? #f] [#:root-login? #f] @ |
8783 | [#:syslog-output? #t] [#:x11-forwarding? #t] @ | |
8784 | [#:tcp/ip-forwarding? #t] [#:password-authentication? #t] @ | |
21cc905a | 8785 | [#:public-key-authentication? #t] [#:initialize? #t] |
cf4a9129 LC |
8786 | Run the @command{lshd} program from @var{lsh} to listen on port @var{port-number}. |
8787 | @var{host-key} must designate a file containing the host key, and readable | |
8788 | only by root. | |
72e25e35 | 8789 | |
5833bf33 DP |
8790 | When @var{daemonic?} is true, @command{lshd} will detach from the |
8791 | controlling terminal and log its output to syslogd, unless one sets | |
8792 | @var{syslog-output?} to false. Obviously, it also makes lsh-service | |
8793 | depend on existence of syslogd service. When @var{pid-file?} is true, | |
8794 | @command{lshd} writes its PID to the file called @var{pid-file}. | |
8795 | ||
cf4a9129 LC |
8796 | When @var{initialize?} is true, automatically create the seed and host key |
8797 | upon service activation if they do not exist yet. This may take long and | |
8798 | require interaction. | |
8b315a6d | 8799 | |
20dd519c LC |
8800 | When @var{initialize?} is false, it is up to the user to initialize the |
8801 | randomness generator (@pxref{lsh-make-seed,,, lsh, LSH Manual}), and to create | |
8802 | a key pair with the private key stored in file @var{host-key} (@pxref{lshd | |
8803 | basics,,, lsh, LSH Manual}). | |
8804 | ||
cf4a9129 LC |
8805 | When @var{interfaces} is empty, lshd listens for connections on all the |
8806 | network interfaces; otherwise, @var{interfaces} must be a list of host names | |
8807 | or addresses. | |
9bf3c1a7 | 8808 | |
20dd519c LC |
8809 | @var{allow-empty-passwords?} specifies whether to accept log-ins with empty |
8810 | passwords, and @var{root-login?} specifies whether to accept log-ins as | |
cf4a9129 | 8811 | root. |
4af2447e | 8812 | |
cf4a9129 LC |
8813 | The other options should be self-descriptive. |
8814 | @end deffn | |
4af2447e | 8815 | |
e32171ee JD |
8816 | @cindex SSH |
8817 | @cindex SSH server | |
d8f31281 LC |
8818 | @deffn {Scheme Variable} openssh-service-type |
8819 | This is the type for the @uref{http://www.openssh.org, OpenSSH} secure | |
8820 | shell daemon, @command{sshd}. Its value must be an | |
8821 | @code{openssh-configuration} record as in this example: | |
8822 | ||
8823 | @example | |
8824 | (service openssh-service-type | |
8825 | (openssh-configuration | |
8826 | (x11-forwarding? #t) | |
8827 | (permit-root-login 'without-password))) | |
8828 | @end example | |
8829 | ||
8830 | See below for details about @code{openssh-configuration}. | |
86d8f6d3 JL |
8831 | @end deffn |
8832 | ||
d8f31281 LC |
8833 | @deftp {Data Type} openssh-configuration |
8834 | This is the configuration record for OpenSSH's @command{sshd}. | |
8835 | ||
8836 | @table @asis | |
8837 | @item @code{pid-file} (default: @code{"/var/run/sshd.pid"}) | |
8838 | Name of the file where @command{sshd} writes its PID. | |
8839 | ||
8840 | @item @code{port-number} (default: @code{22}) | |
8841 | TCP port on which @command{sshd} listens for incoming connections. | |
8842 | ||
8843 | @item @code{permit-root-login} (default: @code{#f}) | |
8844 | This field determines whether and when to allow logins as root. If | |
8845 | @code{#f}, root logins are disallowed; if @code{#t}, they are allowed. | |
8846 | If it's the symbol @code{'without-password}, then root logins are | |
8847 | permitted but not with password-based authentication. | |
8848 | ||
8849 | @item @code{allow-empty-passwords?} (default: @code{#f}) | |
8850 | When true, users with empty passwords may log in. When false, they may | |
8851 | not. | |
8852 | ||
8853 | @item @code{password-authentication?} (default: @code{#t}) | |
8854 | When true, users may log in with their password. When false, they have | |
8855 | other authentication methods. | |
8856 | ||
8857 | @item @code{public-key-authentication?} (default: @code{#t}) | |
8858 | When true, users may log in using public key authentication. When | |
8859 | false, users have to use other authentication method. | |
8860 | ||
8861 | Authorized public keys are stored in @file{~/.ssh/authorized_keys}. | |
8862 | This is used only by protocol version 2. | |
8863 | ||
8864 | @item @code{rsa-authentication?} (default: @code{#t}) | |
8865 | When true, users may log in using pure RSA authentication. When false, | |
8866 | users have to use other means of authentication. This is used only by | |
8867 | protocol 1. | |
8868 | ||
8869 | @item @code{x11-forwarding?} (default: @code{#f}) | |
8870 | When true, forwarding of X11 graphical client connections is | |
8871 | enabled---in other words, @command{ssh} options @option{-X} and | |
8872 | @option{-Y} will work. | |
8873 | ||
8874 | @item @code{protocol-number} (default: @code{2}) | |
8875 | The SSH protocol number to use. | |
8876 | @end table | |
8877 | @end deftp | |
8878 | ||
71b0601a DC |
8879 | @deffn {Scheme Procedure} dropbear-service [@var{config}] |
8880 | Run the @uref{https://matt.ucc.asn.au/dropbear/dropbear.html,Dropbear SSH | |
8881 | daemon} with the given @var{config}, a @code{<dropbear-configuration>} | |
8882 | object. | |
8883 | ||
8884 | For example, to specify a Dropbear service listening on port 1234, add | |
8885 | this call to the operating system's @code{services} field: | |
8886 | ||
8887 | @example | |
8888 | (dropbear-service (dropbear-configuration | |
8889 | (port-number 1234))) | |
8890 | @end example | |
8891 | @end deffn | |
8892 | ||
8893 | @deftp {Data Type} dropbear-configuration | |
8894 | This data type represents the configuration of a Dropbear SSH daemon. | |
8895 | ||
8896 | @table @asis | |
8897 | @item @code{dropbear} (default: @var{dropbear}) | |
8898 | The Dropbear package to use. | |
8899 | ||
8900 | @item @code{port-number} (default: 22) | |
8901 | The TCP port where the daemon waits for incoming connections. | |
8902 | ||
8903 | @item @code{syslog-output?} (default: @code{#t}) | |
8904 | Whether to enable syslog output. | |
8905 | ||
8906 | @item @code{pid-file} (default: @code{"/var/run/dropbear.pid"}) | |
8907 | File name of the daemon's PID file. | |
8908 | ||
8909 | @item @code{root-login?} (default: @code{#f}) | |
8910 | Whether to allow @code{root} logins. | |
8911 | ||
8912 | @item @code{allow-empty-passwords?} (default: @code{#f}) | |
8913 | Whether to allow empty passwords. | |
8914 | ||
8915 | @item @code{password-authentication?} (default: @code{#t}) | |
8916 | Whether to enable password-based authentication. | |
8917 | @end table | |
8918 | @end deftp | |
8919 | ||
fa0c1d61 LC |
8920 | @defvr {Scheme Variable} %facebook-host-aliases |
8921 | This variable contains a string for use in @file{/etc/hosts} | |
8922 | (@pxref{Host Names,,, libc, The GNU C Library Reference Manual}). Each | |
8923 | line contains a entry that maps a known server name of the Facebook | |
8924 | on-line service---e.g., @code{www.facebook.com}---to the local | |
8925 | host---@code{127.0.0.1} or its IPv6 equivalent, @code{::1}. | |
8926 | ||
8927 | This variable is typically used in the @code{hosts-file} field of an | |
7313a52e LC |
8928 | @code{operating-system} declaration (@pxref{operating-system Reference, |
8929 | @file{/etc/hosts}}): | |
fa0c1d61 LC |
8930 | |
8931 | @example | |
8932 | (use-modules (gnu) (guix)) | |
8933 | ||
8934 | (operating-system | |
8935 | (host-name "mymachine") | |
8936 | ;; ... | |
8937 | (hosts-file | |
8938 | ;; Create a /etc/hosts file with aliases for "localhost" | |
8939 | ;; and "mymachine", as well as for Facebook servers. | |
24e02c28 LC |
8940 | (plain-file "hosts" |
8941 | (string-append (local-host-aliases host-name) | |
8942 | %facebook-host-aliases)))) | |
fa0c1d61 LC |
8943 | @end example |
8944 | ||
8945 | This mechanism can prevent programs running locally, such as Web | |
8946 | browsers, from accessing Facebook. | |
8947 | @end defvr | |
8948 | ||
965a7332 LC |
8949 | The @code{(gnu services avahi)} provides the following definition. |
8950 | ||
be1c2c54 | 8951 | @deffn {Scheme Procedure} avahi-service [#:avahi @var{avahi}] @ |
965a7332 LC |
8952 | [#:host-name #f] [#:publish? #t] [#:ipv4? #t] @ |
8953 | [#:ipv6? #t] [#:wide-area? #f] @ | |
c8695f32 | 8954 | [#:domains-to-browse '()] [#:debug? #f] |
965a7332 LC |
8955 | Return a service that runs @command{avahi-daemon}, a system-wide |
8956 | mDNS/DNS-SD responder that allows for service discovery and | |
cc9c1f39 LC |
8957 | "zero-configuration" host name lookups (see @uref{http://avahi.org/}), and |
8958 | extends the name service cache daemon (nscd) so that it can resolve | |
8959 | @code{.local} host names using | |
1065bed9 LC |
8960 | @uref{http://0pointer.de/lennart/projects/nss-mdns/, nss-mdns}. Additionally, |
8961 | add the @var{avahi} package to the system profile so that commands such as | |
8962 | @command{avahi-browse} are directly usable. | |
965a7332 LC |
8963 | |
8964 | If @var{host-name} is different from @code{#f}, use that as the host name to | |
8965 | publish for this machine; otherwise, use the machine's actual host name. | |
8966 | ||
8967 | When @var{publish?} is true, publishing of host names and services is allowed; | |
8968 | in particular, avahi-daemon will publish the machine's host name and IP | |
8969 | address via mDNS on the local network. | |
8970 | ||
8971 | When @var{wide-area?} is true, DNS-SD over unicast DNS is enabled. | |
8972 | ||
8973 | Boolean values @var{ipv4?} and @var{ipv6?} determine whether to use IPv4/IPv6 | |
8974 | sockets. | |
8975 | @end deffn | |
8976 | ||
8977 | ||
cf4a9129 LC |
8978 | @node X Window |
8979 | @subsubsection X Window | |
68ad877c | 8980 | |
e32171ee JD |
8981 | @cindex X11 |
8982 | @cindex X Window System | |
cf4a9129 LC |
8983 | Support for the X Window graphical display system---specifically |
8984 | Xorg---is provided by the @code{(gnu services xorg)} module. Note that | |
8985 | there is no @code{xorg-service} procedure. Instead, the X server is | |
8986 | started by the @dfn{login manager}, currently SLiM. | |
4af2447e | 8987 | |
935644c0 DC |
8988 | @deftp {Data Type} sddm-configuration |
8989 | This is the data type representing the sddm service configuration. | |
8990 | ||
8991 | @table @asis | |
8992 | @item @code{display-server} (default: "x11") | |
8993 | Select display server to use for the greeter. Valid values are "x11" | |
8994 | or "wayland". | |
8995 | ||
8996 | @item @code{numlock} (default: "on") | |
8997 | Valid values are "on", "off" or "none". | |
8998 | ||
8999 | @item @code{halt-command} (default @code{#~(string-apppend #$shepherd "/sbin/halt")}) | |
9000 | Command to run when halting. | |
9001 | ||
9002 | @item @code{reboot-command} (default @code{#~(string-append #$shepherd "/sbin/reboot")}) | |
9003 | Command to run when rebooting. | |
9004 | ||
9005 | @item @code{theme} (default "maldives") | |
9006 | Theme to use. Default themes provided by SDDM are "elarun" or "maldives". | |
9007 | ||
9008 | @item @code{themes-directory} (default "/run/current-system/profile/share/sddm/themes") | |
9009 | Directory to look for themes. | |
9010 | ||
9011 | @item @code{faces-directory} (default "/run/current-system/profile/share/sddm/faces") | |
9012 | Directory to look for faces. | |
9013 | ||
9014 | @item @code{default-path} (default "/run/current-system/profile/bin") | |
9015 | Default PATH to use. | |
9016 | ||
9017 | @item @code{minimum-uid} (default 1000) | |
9018 | Minimum UID to display in SDDM. | |
9019 | ||
9020 | @item @code{maximum-uid} (default 2000) | |
9021 | Maximum UID to display in SDDM | |
9022 | ||
9023 | @item @code{remember-last-user?} (default #t) | |
9024 | Remember last user. | |
9025 | ||
9026 | @item @code{remember-last-session?} (default #t) | |
9027 | Remember last session. | |
9028 | ||
9029 | @item @code{hide-users} (default "") | |
9030 | Usernames to hide from SDDM greeter. | |
9031 | ||
9032 | @item @code{hide-shells} (default @code{#~(string-append #$shadow "/sbin/nologin")}) | |
9033 | Users with shells listed will be hidden from the SDDM greeter. | |
9034 | ||
9035 | @item @code{session-command} (default @code{#~(string-append #$sddm "/share/sddm/scripts/wayland-session")}) | |
9036 | Script to run before starting a wayland session. | |
9037 | ||
9038 | @item @code{sessions-directory} (default "/run/current-system/profile/share/wayland-sessions") | |
9039 | Directory to look for desktop files starting wayland sessions. | |
9040 | ||
9041 | @item @code{xorg-server-path} (default @code{xorg-start-command}) | |
9042 | Path to xorg-server. | |
9043 | ||
9044 | @item @code{xauth-path} (default @code{#~(string-append #$xauth "/bin/xauth")}) | |
9045 | Path to xauth. | |
9046 | ||
9047 | @item @code{xephyr-path} (default @code{#~(string-append #$xorg-server "/bin/Xephyr")}) | |
9048 | Path to Xephyr. | |
9049 | ||
9050 | @item @code{xdisplay-start} (default @code{#~(string-append #$sddm "/share/sddm/scripts/Xsetup")}) | |
9051 | Script to run after starting xorg-server. | |
9052 | ||
9053 | @item @code{xdisplay-stop} (default @code{#~(string-append #$sddm "/share/sddm/scripts/Xstop")}) | |
9054 | Script to run before stopping xorg-server. | |
9055 | ||
9056 | @item @code{xsession-command} (default: @code{xinitr }) | |
9057 | Script to run before starting a X session. | |
9058 | ||
9059 | @item @code{xsessions-directory} (default: "/run/current-system/profile/share/xsessions") | |
9060 | Directory to look for desktop files starting X sessions. | |
9061 | ||
9062 | @item @code{minimum-vt} (default: 7) | |
9063 | Minimum VT to use. | |
9064 | ||
9065 | @item @code{xserver-arguments} (default "-nolisten tcp") | |
9066 | Arguments to pass to xorg-server. | |
9067 | ||
9068 | @item @code{auto-login-user} (default "") | |
9069 | User to use for auto-login. | |
9070 | ||
9071 | @item @code{auto-login-session} (default "") | |
9072 | Desktop file to use for auto-login. | |
9073 | ||
9074 | @item @code{relogin?} (default #f) | |
9075 | Relogin after logout. | |
9076 | ||
9077 | @end table | |
9078 | @end deftp | |
9079 | ||
e32171ee | 9080 | @cindex login manager |
935644c0 DC |
9081 | @deffn {Scheme Procedure} sddm-service config |
9082 | Return a service that spawns the SDDM graphical login manager for config of | |
9083 | type @code{<sddm-configuration>}. | |
9084 | ||
9085 | @example | |
9086 | (sddm-service (sddm-configuration | |
9087 | (auto-login-user "Alice") | |
9088 | (auto-login-session "xfce.desktop"))) | |
9089 | @end example | |
9090 | @end deffn | |
9091 | ||
be1c2c54 | 9092 | @deffn {Scheme Procedure} slim-service [#:allow-empty-passwords? #f] @ |
0ecc3bf3 LC |
9093 | [#:auto-login? #f] [#:default-user ""] [#:startx] @ |
9094 | [#:theme @var{%default-slim-theme}] @ | |
4bd43bbe | 9095 | [#:theme-name @var{%default-slim-theme-name}] |
cf4a9129 LC |
9096 | Return a service that spawns the SLiM graphical login manager, which in |
9097 | turn starts the X display server with @var{startx}, a command as returned by | |
9098 | @code{xorg-start-command}. | |
4af2447e | 9099 | |
04e4e6ab LC |
9100 | @cindex X session |
9101 | ||
9102 | SLiM automatically looks for session types described by the @file{.desktop} | |
9103 | files in @file{/run/current-system/profile/share/xsessions} and allows users | |
9104 | to choose a session from the log-in screen using @kbd{F1}. Packages such as | |
9105 | @var{xfce}, @var{sawfish}, and @var{ratpoison} provide @file{.desktop} files; | |
9106 | adding them to the system-wide set of packages automatically makes them | |
9107 | available at the log-in screen. | |
9108 | ||
9109 | In addition, @file{~/.xsession} files are honored. When available, | |
9110 | @file{~/.xsession} must be an executable that starts a window manager | |
9111 | and/or other X clients. | |
9112 | ||
cf4a9129 LC |
9113 | When @var{allow-empty-passwords?} is true, allow logins with an empty |
9114 | password. When @var{auto-login?} is true, log in automatically as | |
9115 | @var{default-user}. | |
0ecc3bf3 | 9116 | |
1068f26b | 9117 | If @var{theme} is @code{#f}, use the default log-in theme; otherwise |
0ecc3bf3 LC |
9118 | @var{theme} must be a gexp denoting the name of a directory containing the |
9119 | theme to use. In that case, @var{theme-name} specifies the name of the | |
9120 | theme. | |
cf4a9129 | 9121 | @end deffn |
4af2447e | 9122 | |
0ecc3bf3 LC |
9123 | @defvr {Scheme Variable} %default-theme |
9124 | @defvrx {Scheme Variable} %default-theme-name | |
9125 | The G-Expression denoting the default SLiM theme and its name. | |
9126 | @end defvr | |
9127 | ||
be1c2c54 | 9128 | @deffn {Scheme Procedure} xorg-start-command [#:guile] @ |
d1cdd7ba | 9129 | [#:configuration-file #f] [#:xorg-server @var{xorg-server}] |
f703413e | 9130 | Return a derivation that builds a @var{guile} script to start the X server |
d1cdd7ba LC |
9131 | from @var{xorg-server}. @var{configuration-file} is the server configuration |
9132 | file or a derivation that builds it; when omitted, the result of | |
9133 | @code{xorg-configuration-file} is used. | |
9134 | ||
9135 | Usually the X server is started by a login manager. | |
9136 | @end deffn | |
9137 | ||
be1c2c54 | 9138 | @deffn {Scheme Procedure} xorg-configuration-file @ |
12422c9d | 9139 | [#:drivers '()] [#:resolutions '()] [#:extra-config '()] |
d1cdd7ba LC |
9140 | Return a configuration file for the Xorg server containing search paths for |
9141 | all the common drivers. | |
f703413e LC |
9142 | |
9143 | @var{drivers} must be either the empty list, in which case Xorg chooses a | |
9144 | graphics driver automatically, or a list of driver names that will be tried in | |
d1cdd7ba | 9145 | this order---e.g., @code{(\"modesetting\" \"vesa\")}. |
d2e59637 LC |
9146 | |
9147 | Likewise, when @var{resolutions} is the empty list, Xorg chooses an | |
9148 | appropriate screen resolution; otherwise, it must be a list of | |
9149 | resolutions---e.g., @code{((1024 768) (640 480))}. | |
12422c9d LC |
9150 | |
9151 | Last, @var{extra-config} is a list of strings or objects appended to the | |
9152 | @code{text-file*} argument list. It is used to pass extra text to be added | |
9153 | verbatim to the configuration file. | |
f703413e | 9154 | @end deffn |
4af2447e | 9155 | |
6726282b LC |
9156 | @deffn {Scheme Procedure} screen-locker-service @var{package} [@var{name}] |
9157 | Add @var{package}, a package for a screen-locker or screen-saver whose | |
9158 | command is @var{program}, to the set of setuid programs and add a PAM entry | |
9159 | for it. For example: | |
9160 | ||
9161 | @lisp | |
9162 | (screen-locker-service xlockmore "xlock") | |
9163 | @end lisp | |
9164 | ||
9165 | makes the good ol' XlockMore usable. | |
9166 | @end deffn | |
9167 | ||
9168 | ||
f2ec23d1 AW |
9169 | @node Printing Services |
9170 | @subsubsection Printing Services | |
9171 | ||
9172 | The @code{(gnu services cups)} module provides a Guix service definition | |
9173 | for the CUPS printing service. To add printer support to a GuixSD | |
9174 | system, add a @code{cups-service} to the operating system definition: | |
9175 | ||
9176 | @deffn {Scheme Variable} cups-service-type | |
9177 | The service type for the CUPS print server. Its value should be a valid | |
9178 | CUPS configuration (see below). For example: | |
9179 | @example | |
9180 | (service cups-service-type (cups-configuration)) | |
9181 | @end example | |
9182 | @end deffn | |
9183 | ||
9184 | The CUPS configuration controls the basic things about your CUPS | |
9185 | installation: what interfaces it listens on, what to do if a print job | |
9186 | fails, how much logging to do, and so on. To actually add a printer, | |
9187 | you have to visit the @url{http://localhost:631} URL, or use a tool such | |
9188 | as GNOME's printer configuration services. By default, configuring a | |
9189 | CUPS service will generate a self-signed certificate if needed, for | |
9190 | secure connections to the print server. | |
9191 | ||
9192 | One way you might want to customize CUPS is to enable or disable the web | |
9193 | interface. You can do that directly, like this: | |
9194 | ||
9195 | @example | |
9196 | (service cups-service-type | |
9197 | (cups-configuration | |
9198 | (web-interface? #f))) | |
9199 | @end example | |
9200 | ||
9201 | The available configuration parameters follow. Each parameter | |
9202 | definition is preceded by its type; for example, @samp{string-list foo} | |
9203 | indicates that the @code{foo} parameter should be specified as a list of | |
9204 | strings. There is also a way to specify the configuration as a string, | |
9205 | if you have an old @code{cupsd.conf} file that you want to port over | |
9206 | from some other system; see the end for more details. | |
9207 | ||
9208 | @c The following documentation was initially generated by | |
9209 | @c (generate-documentation) in (gnu services cups). Manually maintained | |
9210 | @c documentation is better, so we shouldn't hesitate to edit below as | |
9211 | @c needed. However if the change you want to make to this documentation | |
9212 | @c can be done in an automated way, it's probably easier to change | |
9213 | @c (generate-documentation) than to make it below and have to deal with | |
9214 | @c the churn as CUPS updates. | |
9215 | ||
9216 | ||
9217 | Available @code{cups-configuration} fields are: | |
9218 | ||
9219 | @deftypevr {@code{cups-configuration} parameter} package cups | |
9220 | The CUPS package. | |
9221 | @end deftypevr | |
9222 | ||
9223 | @deftypevr {@code{cups-configuration} parameter} package-list extensions | |
9224 | Drivers and other extensions to the CUPS package. | |
9225 | @end deftypevr | |
9226 | ||
9227 | @deftypevr {@code{cups-configuration} parameter} files-configuration files-configuration | |
9228 | Configuration of where to write logs, what directories to use for print | |
9229 | spools, and related privileged configuration parameters. | |
9230 | ||
9231 | Available @code{files-configuration} fields are: | |
9232 | ||
9233 | @deftypevr {@code{files-configuration} parameter} log-location access-log | |
9234 | Defines the access log filename. Specifying a blank filename disables | |
9235 | access log generation. The value @code{stderr} causes log entries to be | |
9236 | sent to the standard error file when the scheduler is running in the | |
9237 | foreground, or to the system log daemon when run in the background. The | |
9238 | value @code{syslog} causes log entries to be sent to the system log | |
9239 | daemon. The server name may be included in filenames using the string | |
9240 | @code{%s}, as in @code{/var/log/cups/%s-access_log}. | |
9241 | ||
9242 | Defaults to @samp{"/var/log/cups/access_log"}. | |
9243 | @end deftypevr | |
9244 | ||
9245 | @deftypevr {@code{files-configuration} parameter} file-name cache-dir | |
9246 | Where CUPS should cache data. | |
9247 | ||
9248 | Defaults to @samp{"/var/cache/cups"}. | |
9249 | @end deftypevr | |
9250 | ||
9251 | @deftypevr {@code{files-configuration} parameter} string config-file-perm | |
9252 | Specifies the permissions for all configuration files that the scheduler | |
9253 | writes. | |
9254 | ||
9255 | Note that the permissions for the printers.conf file are currently | |
9256 | masked to only allow access from the scheduler user (typically root). | |
9257 | This is done because printer device URIs sometimes contain sensitive | |
9258 | authentication information that should not be generally known on the | |
9259 | system. There is no way to disable this security feature. | |
9260 | ||
9261 | Defaults to @samp{"0640"}. | |
9262 | @end deftypevr | |
9263 | ||
9264 | @deftypevr {@code{files-configuration} parameter} log-location error-log | |
9265 | Defines the error log filename. Specifying a blank filename disables | |
9266 | access log generation. The value @code{stderr} causes log entries to be | |
9267 | sent to the standard error file when the scheduler is running in the | |
9268 | foreground, or to the system log daemon when run in the background. The | |
9269 | value @code{syslog} causes log entries to be sent to the system log | |
9270 | daemon. The server name may be included in filenames using the string | |
9271 | @code{%s}, as in @code{/var/log/cups/%s-error_log}. | |
9272 | ||
9273 | Defaults to @samp{"/var/log/cups/error_log"}. | |
9274 | @end deftypevr | |
9275 | ||
9276 | @deftypevr {@code{files-configuration} parameter} string fatal-errors | |
9277 | Specifies which errors are fatal, causing the scheduler to exit. The | |
9278 | kind strings are: | |
9279 | ||
9280 | @table @code | |
9281 | @item none | |
9282 | No errors are fatal. | |
9283 | ||
9284 | @item all | |
9285 | All of the errors below are fatal. | |
9286 | ||
9287 | @item browse | |
9288 | Browsing initialization errors are fatal, for example failed connections | |
9289 | to the DNS-SD daemon. | |
9290 | ||
9291 | @item config | |
9292 | Configuration file syntax errors are fatal. | |
9293 | ||
9294 | @item listen | |
9295 | Listen or Port errors are fatal, except for IPv6 failures on the | |
9296 | loopback or @code{any} addresses. | |
9297 | ||
9298 | @item log | |
9299 | Log file creation or write errors are fatal. | |
9300 | ||
9301 | @item permissions | |
9302 | Bad startup file permissions are fatal, for example shared TLS | |
9303 | certificate and key files with world-read permissions. | |
9304 | @end table | |
9305 | ||
9306 | Defaults to @samp{"all -browse"}. | |
9307 | @end deftypevr | |
9308 | ||
9309 | @deftypevr {@code{files-configuration} parameter} boolean file-device? | |
9310 | Specifies whether the file pseudo-device can be used for new printer | |
9311 | queues. The URI @uref{file:///dev/null} is always allowed. | |
9312 | ||
9313 | Defaults to @samp{#f}. | |
9314 | @end deftypevr | |
9315 | ||
9316 | @deftypevr {@code{files-configuration} parameter} string group | |
9317 | Specifies the group name or ID that will be used when executing external | |
9318 | programs. | |
9319 | ||
9320 | Defaults to @samp{"lp"}. | |
9321 | @end deftypevr | |
9322 | ||
9323 | @deftypevr {@code{files-configuration} parameter} string log-file-perm | |
9324 | Specifies the permissions for all log files that the scheduler writes. | |
9325 | ||
9326 | Defaults to @samp{"0644"}. | |
9327 | @end deftypevr | |
9328 | ||
9329 | @deftypevr {@code{files-configuration} parameter} log-location page-log | |
9330 | Defines the page log filename. Specifying a blank filename disables | |
9331 | access log generation. The value @code{stderr} causes log entries to be | |
9332 | sent to the standard error file when the scheduler is running in the | |
9333 | foreground, or to the system log daemon when run in the background. The | |
9334 | value @code{syslog} causes log entries to be sent to the system log | |
9335 | daemon. The server name may be included in filenames using the string | |
9336 | @code{%s}, as in @code{/var/log/cups/%s-page_log}. | |
9337 | ||
9338 | Defaults to @samp{"/var/log/cups/page_log"}. | |
9339 | @end deftypevr | |
9340 | ||
9341 | @deftypevr {@code{files-configuration} parameter} string remote-root | |
9342 | Specifies the username that is associated with unauthenticated accesses | |
9343 | by clients claiming to be the root user. The default is @code{remroot}. | |
9344 | ||
9345 | Defaults to @samp{"remroot"}. | |
9346 | @end deftypevr | |
9347 | ||
9348 | @deftypevr {@code{files-configuration} parameter} file-name request-root | |
9349 | Specifies the directory that contains print jobs and other HTTP request | |
9350 | data. | |
9351 | ||
9352 | Defaults to @samp{"/var/spool/cups"}. | |
9353 | @end deftypevr | |
9354 | ||
9355 | @deftypevr {@code{files-configuration} parameter} sandboxing sandboxing | |
9356 | Specifies the level of security sandboxing that is applied to print | |
9357 | filters, backends, and other child processes of the scheduler; either | |
9358 | @code{relaxed} or @code{strict}. This directive is currently only | |
9359 | used/supported on macOS. | |
9360 | ||
9361 | Defaults to @samp{strict}. | |
9362 | @end deftypevr | |
9363 | ||
9364 | @deftypevr {@code{files-configuration} parameter} file-name server-keychain | |
9365 | Specifies the location of TLS certificates and private keys. CUPS will | |
9366 | look for public and private keys in this directory: a @code{.crt} files | |
9367 | for PEM-encoded certificates and corresponding @code{.key} files for | |
9368 | PEM-encoded private keys. | |
9369 | ||
9370 | Defaults to @samp{"/etc/cups/ssl"}. | |
9371 | @end deftypevr | |
9372 | ||
9373 | @deftypevr {@code{files-configuration} parameter} file-name server-root | |
9374 | Specifies the directory containing the server configuration files. | |
9375 | ||
9376 | Defaults to @samp{"/etc/cups"}. | |
9377 | @end deftypevr | |
9378 | ||
9379 | @deftypevr {@code{files-configuration} parameter} boolean sync-on-close? | |
9380 | Specifies whether the scheduler calls fsync(2) after writing | |
9381 | configuration or state files. | |
9382 | ||
9383 | Defaults to @samp{#f}. | |
9384 | @end deftypevr | |
9385 | ||
9386 | @deftypevr {@code{files-configuration} parameter} space-separated-string-list system-group | |
9387 | Specifies the group(s) to use for @code{@@SYSTEM} group authentication. | |
9388 | @end deftypevr | |
9389 | ||
9390 | @deftypevr {@code{files-configuration} parameter} file-name temp-dir | |
9391 | Specifies the directory where temporary files are stored. | |
9392 | ||
9393 | Defaults to @samp{"/var/spool/cups/tmp"}. | |
9394 | @end deftypevr | |
9395 | ||
9396 | @deftypevr {@code{files-configuration} parameter} string user | |
9397 | Specifies the user name or ID that is used when running external | |
9398 | programs. | |
9399 | ||
9400 | Defaults to @samp{"lp"}. | |
9401 | @end deftypevr | |
9402 | @end deftypevr | |
9403 | ||
9404 | @deftypevr {@code{cups-configuration} parameter} access-log-level access-log-level | |
9405 | Specifies the logging level for the AccessLog file. The @code{config} | |
9406 | level logs when printers and classes are added, deleted, or modified and | |
9407 | when configuration files are accessed or updated. The @code{actions} | |
9408 | level logs when print jobs are submitted, held, released, modified, or | |
9409 | canceled, and any of the conditions for @code{config}. The @code{all} | |
9410 | level logs all requests. | |
9411 | ||
9412 | Defaults to @samp{actions}. | |
9413 | @end deftypevr | |
9414 | ||
9415 | @deftypevr {@code{cups-configuration} parameter} boolean auto-purge-jobs? | |
9416 | Specifies whether to purge job history data automatically when it is no | |
9417 | longer required for quotas. | |
9418 | ||
9419 | Defaults to @samp{#f}. | |
9420 | @end deftypevr | |
9421 | ||
9422 | @deftypevr {@code{cups-configuration} parameter} browse-local-protocols browse-local-protocols | |
9423 | Specifies which protocols to use for local printer sharing. | |
9424 | ||
9425 | Defaults to @samp{dnssd}. | |
9426 | @end deftypevr | |
9427 | ||
9428 | @deftypevr {@code{cups-configuration} parameter} boolean browse-web-if? | |
9429 | Specifies whether the CUPS web interface is advertised. | |
9430 | ||
9431 | Defaults to @samp{#f}. | |
9432 | @end deftypevr | |
9433 | ||
9434 | @deftypevr {@code{cups-configuration} parameter} boolean browsing? | |
9435 | Specifies whether shared printers are advertised. | |
9436 | ||
9437 | Defaults to @samp{#f}. | |
9438 | @end deftypevr | |
9439 | ||
9440 | @deftypevr {@code{cups-configuration} parameter} string classification | |
9441 | Specifies the security classification of the server. Any valid banner | |
9442 | name can be used, including "classified", "confidential", "secret", | |
9443 | "topsecret", and "unclassified", or the banner can be omitted to disable | |
9444 | secure printing functions. | |
9445 | ||
9446 | Defaults to @samp{""}. | |
9447 | @end deftypevr | |
9448 | ||
9449 | @deftypevr {@code{cups-configuration} parameter} boolean classify-override? | |
9450 | Specifies whether users may override the classification (cover page) of | |
9451 | individual print jobs using the @code{job-sheets} option. | |
9452 | ||
9453 | Defaults to @samp{#f}. | |
9454 | @end deftypevr | |
9455 | ||
9456 | @deftypevr {@code{cups-configuration} parameter} default-auth-type default-auth-type | |
9457 | Specifies the default type of authentication to use. | |
9458 | ||
9459 | Defaults to @samp{Basic}. | |
9460 | @end deftypevr | |
9461 | ||
9462 | @deftypevr {@code{cups-configuration} parameter} default-encryption default-encryption | |
9463 | Specifies whether encryption will be used for authenticated requests. | |
9464 | ||
9465 | Defaults to @samp{Required}. | |
9466 | @end deftypevr | |
9467 | ||
9468 | @deftypevr {@code{cups-configuration} parameter} string default-language | |
9469 | Specifies the default language to use for text and web content. | |
9470 | ||
9471 | Defaults to @samp{"en"}. | |
9472 | @end deftypevr | |
9473 | ||
9474 | @deftypevr {@code{cups-configuration} parameter} string default-paper-size | |
9475 | Specifies the default paper size for new print queues. @samp{"Auto"} | |
9476 | uses a locale-specific default, while @samp{"None"} specifies there is | |
9477 | no default paper size. Specific size names are typically | |
9478 | @samp{"Letter"} or @samp{"A4"}. | |
9479 | ||
9480 | Defaults to @samp{"Auto"}. | |
9481 | @end deftypevr | |
9482 | ||
9483 | @deftypevr {@code{cups-configuration} parameter} string default-policy | |
9484 | Specifies the default access policy to use. | |
9485 | ||
9486 | Defaults to @samp{"default"}. | |
9487 | @end deftypevr | |
9488 | ||
9489 | @deftypevr {@code{cups-configuration} parameter} boolean default-shared? | |
9490 | Specifies whether local printers are shared by default. | |
9491 | ||
9492 | Defaults to @samp{#t}. | |
9493 | @end deftypevr | |
9494 | ||
9495 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer dirty-clean-interval | |
9496 | Specifies the delay for updating of configuration and state files, in | |
9497 | seconds. A value of 0 causes the update to happen as soon as possible, | |
9498 | typically within a few milliseconds. | |
9499 | ||
9500 | Defaults to @samp{30}. | |
9501 | @end deftypevr | |
9502 | ||
9503 | @deftypevr {@code{cups-configuration} parameter} error-policy error-policy | |
9504 | Specifies what to do when an error occurs. Possible values are | |
9505 | @code{abort-job}, which will discard the failed print job; | |
9506 | @code{retry-job}, which will retry the job at a later time; | |
9507 | @code{retry-this-job}, which retries the failed job immediately; and | |
9508 | @code{stop-printer}, which stops the printer. | |
9509 | ||
9510 | Defaults to @samp{stop-printer}. | |
9511 | @end deftypevr | |
9512 | ||
9513 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer filter-limit | |
9514 | Specifies the maximum cost of filters that are run concurrently, which | |
9515 | can be used to minimize disk, memory, and CPU resource problems. A | |
9516 | limit of 0 disables filter limiting. An average print to a | |
9517 | non-PostScript printer needs a filter limit of about 200. A PostScript | |
9518 | printer needs about half that (100). Setting the limit below these | |
9519 | thresholds will effectively limit the scheduler to printing a single job | |
9520 | at any time. | |
9521 | ||
9522 | Defaults to @samp{0}. | |
9523 | @end deftypevr | |
9524 | ||
9525 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer filter-nice | |
9526 | Specifies the scheduling priority of filters that are run to print a | |
9527 | job. The nice value ranges from 0, the highest priority, to 19, the | |
9528 | lowest priority. | |
9529 | ||
9530 | Defaults to @samp{0}. | |
9531 | @end deftypevr | |
9532 | ||
9533 | @deftypevr {@code{cups-configuration} parameter} host-name-lookups host-name-lookups | |
9534 | Specifies whether to do reverse lookups on connecting clients. The | |
9535 | @code{double} setting causes @code{cupsd} to verify that the hostname | |
9536 | resolved from the address matches one of the addresses returned for that | |
9537 | hostname. Double lookups also prevent clients with unregistered | |
9538 | addresses from connecting to your server. Only set this option to | |
9539 | @code{#t} or @code{double} if absolutely required. | |
9540 | ||
9541 | Defaults to @samp{#f}. | |
9542 | @end deftypevr | |
9543 | ||
9544 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer job-kill-delay | |
9545 | Specifies the number of seconds to wait before killing the filters and | |
9546 | backend associated with a canceled or held job. | |
9547 | ||
9548 | Defaults to @samp{30}. | |
9549 | @end deftypevr | |
9550 | ||
9551 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer job-retry-interval | |
9552 | Specifies the interval between retries of jobs in seconds. This is | |
9553 | typically used for fax queues but can also be used with normal print | |
9554 | queues whose error policy is @code{retry-job} or | |
9555 | @code{retry-current-job}. | |
9556 | ||
9557 | Defaults to @samp{30}. | |
9558 | @end deftypevr | |
9559 | ||
9560 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer job-retry-limit | |
9561 | Specifies the number of retries that are done for jobs. This is | |
9562 | typically used for fax queues but can also be used with normal print | |
9563 | queues whose error policy is @code{retry-job} or | |
9564 | @code{retry-current-job}. | |
9565 | ||
9566 | Defaults to @samp{5}. | |
9567 | @end deftypevr | |
9568 | ||
9569 | @deftypevr {@code{cups-configuration} parameter} boolean keep-alive? | |
9570 | Specifies whether to support HTTP keep-alive connections. | |
9571 | ||
9572 | Defaults to @samp{#t}. | |
9573 | @end deftypevr | |
9574 | ||
9575 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer keep-alive-timeout | |
9576 | Specifies how long an idle client connection remains open, in seconds. | |
9577 | ||
9578 | Defaults to @samp{30}. | |
9579 | @end deftypevr | |
9580 | ||
9581 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer limit-request-body | |
9582 | Specifies the maximum size of print files, IPP requests, and HTML form | |
9583 | data. A limit of 0 disables the limit check. | |
9584 | ||
9585 | Defaults to @samp{0}. | |
9586 | @end deftypevr | |
9587 | ||
9588 | @deftypevr {@code{cups-configuration} parameter} multiline-string-list listen | |
9589 | Listens on the specified interfaces for connections. Valid values are | |
9590 | of the form @var{address}:@var{port}, where @var{address} is either an | |
9591 | IPv6 address enclosed in brackets, an IPv4 address, or @code{*} to | |
9592 | indicate all addresses. Values can also be file names of local UNIX | |
9593 | domain sockets. The Listen directive is similar to the Port directive | |
9594 | but allows you to restrict access to specific interfaces or networks. | |
9595 | @end deftypevr | |
9596 | ||
9597 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer listen-back-log | |
9598 | Specifies the number of pending connections that will be allowed. This | |
9599 | normally only affects very busy servers that have reached the MaxClients | |
9600 | limit, but can also be triggered by large numbers of simultaneous | |
9601 | connections. When the limit is reached, the operating system will | |
9602 | refuse additional connections until the scheduler can accept the pending | |
9603 | ones. | |
9604 | ||
9605 | Defaults to @samp{128}. | |
9606 | @end deftypevr | |
9607 | ||
9608 | @deftypevr {@code{cups-configuration} parameter} location-access-control-list location-access-controls | |
9609 | Specifies a set of additional access controls. | |
9610 | ||
9611 | Available @code{location-access-controls} fields are: | |
9612 | ||
9613 | @deftypevr {@code{location-access-controls} parameter} file-name path | |
9614 | Specifies the URI path to which the access control applies. | |
9615 | @end deftypevr | |
9616 | ||
9617 | @deftypevr {@code{location-access-controls} parameter} access-control-list access-controls | |
9618 | Access controls for all access to this path, in the same format as the | |
9619 | @code{access-controls} of @code{operation-access-control}. | |
9620 | ||
9621 | Defaults to @samp{()}. | |
9622 | @end deftypevr | |
9623 | ||
9624 | @deftypevr {@code{location-access-controls} parameter} method-access-control-list method-access-controls | |
9625 | Access controls for method-specific access to this path. | |
9626 | ||
9627 | Defaults to @samp{()}. | |
9628 | ||
9629 | Available @code{method-access-controls} fields are: | |
9630 | ||
9631 | @deftypevr {@code{method-access-controls} parameter} boolean reverse? | |
9632 | If @code{#t}, apply access controls to all methods except the listed | |
9633 | methods. Otherwise apply to only the listed methods. | |
9634 | ||
9635 | Defaults to @samp{#f}. | |
9636 | @end deftypevr | |
9637 | ||
9638 | @deftypevr {@code{method-access-controls} parameter} method-list methods | |
9639 | Methods to which this access control applies. | |
9640 | ||
9641 | Defaults to @samp{()}. | |
9642 | @end deftypevr | |
9643 | ||
9644 | @deftypevr {@code{method-access-controls} parameter} access-control-list access-controls | |
9645 | Access control directives, as a list of strings. Each string should be | |
9646 | one directive, such as "Order allow,deny". | |
9647 | ||
9648 | Defaults to @samp{()}. | |
9649 | @end deftypevr | |
9650 | @end deftypevr | |
9651 | @end deftypevr | |
9652 | ||
9653 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer log-debug-history | |
9654 | Specifies the number of debugging messages that are retained for logging | |
9655 | if an error occurs in a print job. Debug messages are logged regardless | |
9656 | of the LogLevel setting. | |
9657 | ||
9658 | Defaults to @samp{100}. | |
9659 | @end deftypevr | |
9660 | ||
9661 | @deftypevr {@code{cups-configuration} parameter} log-level log-level | |
9662 | Specifies the level of logging for the ErrorLog file. The value | |
9663 | @code{none} stops all logging while @code{debug2} logs everything. | |
9664 | ||
9665 | Defaults to @samp{info}. | |
9666 | @end deftypevr | |
9667 | ||
9668 | @deftypevr {@code{cups-configuration} parameter} log-time-format log-time-format | |
9669 | Specifies the format of the date and time in the log files. The value | |
9670 | @code{standard} logs whole seconds while @code{usecs} logs microseconds. | |
9671 | ||
9672 | Defaults to @samp{standard}. | |
9673 | @end deftypevr | |
9674 | ||
9675 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-clients | |
9676 | Specifies the maximum number of simultaneous clients that are allowed by | |
9677 | the scheduler. | |
9678 | ||
9679 | Defaults to @samp{100}. | |
9680 | @end deftypevr | |
9681 | ||
9682 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-clients-per-host | |
9683 | Specifies the maximum number of simultaneous clients that are allowed | |
9684 | from a single address. | |
9685 | ||
9686 | Defaults to @samp{100}. | |
9687 | @end deftypevr | |
9688 | ||
9689 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-copies | |
9690 | Specifies the maximum number of copies that a user can print of each | |
9691 | job. | |
9692 | ||
9693 | Defaults to @samp{9999}. | |
9694 | @end deftypevr | |
9695 | ||
9696 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-hold-time | |
9697 | Specifies the maximum time a job may remain in the @code{indefinite} | |
9698 | hold state before it is canceled. A value of 0 disables cancellation of | |
9699 | held jobs. | |
9700 | ||
9701 | Defaults to @samp{0}. | |
9702 | @end deftypevr | |
9703 | ||
9704 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-jobs | |
9705 | Specifies the maximum number of simultaneous jobs that are allowed. Set | |
9706 | to 0 to allow an unlimited number of jobs. | |
9707 | ||
9708 | Defaults to @samp{500}. | |
9709 | @end deftypevr | |
9710 | ||
9711 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-jobs-per-printer | |
9712 | Specifies the maximum number of simultaneous jobs that are allowed per | |
9713 | printer. A value of 0 allows up to MaxJobs jobs per printer. | |
9714 | ||
9715 | Defaults to @samp{0}. | |
9716 | @end deftypevr | |
9717 | ||
9718 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-jobs-per-user | |
9719 | Specifies the maximum number of simultaneous jobs that are allowed per | |
9720 | user. A value of 0 allows up to MaxJobs jobs per user. | |
9721 | ||
9722 | Defaults to @samp{0}. | |
9723 | @end deftypevr | |
9724 | ||
9725 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-job-time | |
9726 | Specifies the maximum time a job may take to print before it is | |
9727 | canceled, in seconds. Set to 0 to disable cancellation of "stuck" jobs. | |
9728 | ||
9729 | Defaults to @samp{10800}. | |
9730 | @end deftypevr | |
9731 | ||
9732 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-log-size | |
9733 | Specifies the maximum size of the log files before they are rotated, in | |
9734 | bytes. The value 0 disables log rotation. | |
9735 | ||
9736 | Defaults to @samp{1048576}. | |
9737 | @end deftypevr | |
9738 | ||
9739 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer multiple-operation-timeout | |
9740 | Specifies the maximum amount of time to allow between files in a | |
9741 | multiple file print job, in seconds. | |
9742 | ||
9743 | Defaults to @samp{300}. | |
9744 | @end deftypevr | |
9745 | ||
9746 | @deftypevr {@code{cups-configuration} parameter} string page-log-format | |
9747 | Specifies the format of PageLog lines. Sequences beginning with percent | |
9748 | (@samp{%}) characters are replaced with the corresponding information, | |
9749 | while all other characters are copied literally. The following percent | |
9750 | sequences are recognized: | |
9751 | ||
9752 | @table @samp | |
9753 | @item %% | |
9754 | insert a single percent character | |
9755 | ||
9756 | @item %@{name@} | |
9757 | insert the value of the specified IPP attribute | |
9758 | ||
9759 | @item %C | |
9760 | insert the number of copies for the current page | |
9761 | ||
9762 | @item %P | |
9763 | insert the current page number | |
9764 | ||
9765 | @item %T | |
9766 | insert the current date and time in common log format | |
9767 | ||
9768 | @item %j | |
9769 | insert the job ID | |
9770 | ||
9771 | @item %p | |
9772 | insert the printer name | |
9773 | ||
9774 | @item %u | |
9775 | insert the username | |
9776 | @end table | |
9777 | ||
9778 | A value of the empty string disables page logging. The string @code{%p | |
9779 | %u %j %T %P %C %@{job-billing@} %@{job-originating-host-name@} | |
9780 | %@{job-name@} %@{media@} %@{sides@}} creates a page log with the | |
9781 | standard items. | |
9782 | ||
9783 | Defaults to @samp{""}. | |
9784 | @end deftypevr | |
9785 | ||
9786 | @deftypevr {@code{cups-configuration} parameter} environment-variables environment-variables | |
9787 | Passes the specified environment variable(s) to child processes; a list | |
9788 | of strings. | |
9789 | ||
9790 | Defaults to @samp{()}. | |
9791 | @end deftypevr | |
9792 | ||
9793 | @deftypevr {@code{cups-configuration} parameter} policy-configuration-list policies | |
9794 | Specifies named access control policies. | |
9795 | ||
9796 | Available @code{policy-configuration} fields are: | |
9797 | ||
9798 | @deftypevr {@code{policy-configuration} parameter} string name | |
9799 | Name of the policy. | |
9800 | @end deftypevr | |
9801 | ||
9802 | @deftypevr {@code{policy-configuration} parameter} string job-private-access | |
9803 | Specifies an access list for a job's private values. @code{@@ACL} maps | |
9804 | to the printer's requesting-user-name-allowed or | |
9805 | requesting-user-name-denied values. @code{@@OWNER} maps to the job's | |
9806 | owner. @code{@@SYSTEM} maps to the groups listed for the | |
9807 | @code{system-group} field of the @code{files-config} configuration, | |
9808 | which is reified into the @code{cups-files.conf(5)} file. Other | |
9809 | possible elements of the access list include specific user names, and | |
9810 | @code{@@@var{group}} to indicate members of a specific group. The | |
9811 | access list may also be simply @code{all} or @code{default}. | |
9812 | ||
9813 | Defaults to @samp{"@@OWNER @@SYSTEM"}. | |
9814 | @end deftypevr | |
9815 | ||
9816 | @deftypevr {@code{policy-configuration} parameter} string job-private-values | |
9817 | Specifies the list of job values to make private, or @code{all}, | |
9818 | @code{default}, or @code{none}. | |
9819 | ||
9820 | Defaults to @samp{"job-name job-originating-host-name | |
9821 | job-originating-user-name phone"}. | |
9822 | @end deftypevr | |
9823 | ||
9824 | @deftypevr {@code{policy-configuration} parameter} string subscription-private-access | |
9825 | Specifies an access list for a subscription's private values. | |
9826 | @code{@@ACL} maps to the printer's requesting-user-name-allowed or | |
9827 | requesting-user-name-denied values. @code{@@OWNER} maps to the job's | |
9828 | owner. @code{@@SYSTEM} maps to the groups listed for the | |
9829 | @code{system-group} field of the @code{files-config} configuration, | |
9830 | which is reified into the @code{cups-files.conf(5)} file. Other | |
9831 | possible elements of the access list include specific user names, and | |
9832 | @code{@@@var{group}} to indicate members of a specific group. The | |
9833 | access list may also be simply @code{all} or @code{default}. | |
9834 | ||
9835 | Defaults to @samp{"@@OWNER @@SYSTEM"}. | |
9836 | @end deftypevr | |
9837 | ||
9838 | @deftypevr {@code{policy-configuration} parameter} string subscription-private-values | |
9839 | Specifies the list of job values to make private, or @code{all}, | |
9840 | @code{default}, or @code{none}. | |
9841 | ||
9842 | Defaults to @samp{"notify-events notify-pull-method notify-recipient-uri | |
9843 | notify-subscriber-user-name notify-user-data"}. | |
9844 | @end deftypevr | |
9845 | ||
9846 | @deftypevr {@code{policy-configuration} parameter} operation-access-control-list access-controls | |
9847 | Access control by IPP operation. | |
9848 | ||
9849 | Defaults to @samp{()}. | |
9850 | @end deftypevr | |
9851 | @end deftypevr | |
9852 | ||
9853 | @deftypevr {@code{cups-configuration} parameter} boolean-or-non-negative-integer preserve-job-files | |
9854 | Specifies whether job files (documents) are preserved after a job is | |
9855 | printed. If a numeric value is specified, job files are preserved for | |
9856 | the indicated number of seconds after printing. Otherwise a boolean | |
9857 | value applies indefinitely. | |
9858 | ||
9859 | Defaults to @samp{86400}. | |
9860 | @end deftypevr | |
9861 | ||
9862 | @deftypevr {@code{cups-configuration} parameter} boolean-or-non-negative-integer preserve-job-history | |
9863 | Specifies whether the job history is preserved after a job is printed. | |
9864 | If a numeric value is specified, the job history is preserved for the | |
9865 | indicated number of seconds after printing. If @code{#t}, the job | |
9866 | history is preserved until the MaxJobs limit is reached. | |
9867 | ||
9868 | Defaults to @samp{#t}. | |
9869 | @end deftypevr | |
9870 | ||
9871 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer reload-timeout | |
9872 | Specifies the amount of time to wait for job completion before | |
9873 | restarting the scheduler. | |
9874 | ||
9875 | Defaults to @samp{30}. | |
9876 | @end deftypevr | |
9877 | ||
9878 | @deftypevr {@code{cups-configuration} parameter} string rip-cache | |
9879 | Specifies the maximum amount of memory to use when converting documents | |
9880 | into bitmaps for a printer. | |
9881 | ||
9882 | Defaults to @samp{"128m"}. | |
9883 | @end deftypevr | |
9884 | ||
9885 | @deftypevr {@code{cups-configuration} parameter} string server-admin | |
9886 | Specifies the email address of the server administrator. | |
9887 | ||
9888 | Defaults to @samp{"root@@localhost.localdomain"}. | |
9889 | @end deftypevr | |
9890 | ||
9891 | @deftypevr {@code{cups-configuration} parameter} host-name-list-or-* server-alias | |
9892 | The ServerAlias directive is used for HTTP Host header validation when | |
9893 | clients connect to the scheduler from external interfaces. Using the | |
9894 | special name @code{*} can expose your system to known browser-based DNS | |
9895 | rebinding attacks, even when accessing sites through a firewall. If the | |
9896 | auto-discovery of alternate names does not work, we recommend listing | |
9897 | each alternate name with a ServerAlias directive instead of using | |
9898 | @code{*}. | |
9899 | ||
9900 | Defaults to @samp{*}. | |
9901 | @end deftypevr | |
9902 | ||
9903 | @deftypevr {@code{cups-configuration} parameter} string server-name | |
9904 | Specifies the fully-qualified host name of the server. | |
9905 | ||
9906 | Defaults to @samp{"localhost"}. | |
9907 | @end deftypevr | |
9908 | ||
9909 | @deftypevr {@code{cups-configuration} parameter} server-tokens server-tokens | |
9910 | Specifies what information is included in the Server header of HTTP | |
9911 | responses. @code{None} disables the Server header. @code{ProductOnly} | |
9912 | reports @code{CUPS}. @code{Major} reports @code{CUPS 2}. @code{Minor} | |
9913 | reports @code{CUPS 2.0}. @code{Minimal} reports @code{CUPS 2.0.0}. | |
9914 | @code{OS} reports @code{CUPS 2.0.0 (@var{uname})} where @var{uname} is | |
9915 | the output of the @code{uname} command. @code{Full} reports @code{CUPS | |
9916 | 2.0.0 (@var{uname}) IPP/2.0}. | |
9917 | ||
9918 | Defaults to @samp{Minimal}. | |
9919 | @end deftypevr | |
9920 | ||
9921 | @deftypevr {@code{cups-configuration} parameter} string set-env | |
9922 | Set the specified environment variable to be passed to child processes. | |
9923 | ||
9924 | Defaults to @samp{"variable value"}. | |
9925 | @end deftypevr | |
9926 | ||
9927 | @deftypevr {@code{cups-configuration} parameter} multiline-string-list ssl-listen | |
9928 | Listens on the specified interfaces for encrypted connections. Valid | |
9929 | values are of the form @var{address}:@var{port}, where @var{address} is | |
9930 | either an IPv6 address enclosed in brackets, an IPv4 address, or | |
9931 | @code{*} to indicate all addresses. | |
9932 | ||
9933 | Defaults to @samp{()}. | |
9934 | @end deftypevr | |
9935 | ||
9936 | @deftypevr {@code{cups-configuration} parameter} ssl-options ssl-options | |
9937 | Sets encryption options. By default, CUPS only supports encryption | |
9938 | using TLS v1.0 or higher using known secure cipher suites. The | |
9939 | @code{AllowRC4} option enables the 128-bit RC4 cipher suites, which are | |
9940 | required for some older clients that do not implement newer ones. The | |
9941 | @code{AllowSSL3} option enables SSL v3.0, which is required for some | |
9942 | older clients that do not support TLS v1.0. | |
9943 | ||
9944 | Defaults to @samp{()}. | |
9945 | @end deftypevr | |
9946 | ||
9947 | @deftypevr {@code{cups-configuration} parameter} boolean strict-conformance? | |
9948 | Specifies whether the scheduler requires clients to strictly adhere to | |
9949 | the IPP specifications. | |
9950 | ||
9951 | Defaults to @samp{#f}. | |
9952 | @end deftypevr | |
9953 | ||
9954 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer timeout | |
9955 | Specifies the HTTP request timeout, in seconds. | |
9956 | ||
9957 | Defaults to @samp{300}. | |
9958 | ||
9959 | @end deftypevr | |
9960 | ||
9961 | @deftypevr {@code{cups-configuration} parameter} boolean web-interface? | |
9962 | Specifies whether the web interface is enabled. | |
9963 | ||
9964 | Defaults to @samp{#f}. | |
9965 | @end deftypevr | |
9966 | ||
9967 | At this point you're probably thinking ``oh dear, Guix manual, I like | |
9968 | you but you can stop already with the configuration options''. Indeed. | |
9969 | However, one more point: it could be that you have an existing | |
9970 | @code{cupsd.conf} that you want to use. In that case, you can pass an | |
9971 | @code{opaque-cups-configuration} as the configuration of a | |
9972 | @code{cups-service-type}. | |
9973 | ||
9974 | Available @code{opaque-cups-configuration} fields are: | |
9975 | ||
9976 | @deftypevr {@code{opaque-cups-configuration} parameter} package cups | |
9977 | The CUPS package. | |
9978 | @end deftypevr | |
9979 | ||
9980 | @deftypevr {@code{opaque-cups-configuration} parameter} string cupsd.conf | |
9981 | The contents of the @code{cupsd.conf}, as a string. | |
9982 | @end deftypevr | |
9983 | ||
9984 | @deftypevr {@code{opaque-cups-configuration} parameter} string cups-files.conf | |
9985 | The contents of the @code{cups-files.conf} file, as a string. | |
9986 | @end deftypevr | |
9987 | ||
9988 | For example, if your @code{cupsd.conf} and @code{cups-files.conf} are in | |
9989 | strings of the same name, you could instantiate a CUPS service like | |
9990 | this: | |
9991 | ||
9992 | @example | |
9993 | (service cups-service-type | |
9994 | (opaque-cups-configuration | |
9995 | (cupsd.conf cupsd.conf) | |
9996 | (cups-files.conf cups-files.conf))) | |
9997 | @end example | |
9998 | ||
9999 | ||
fe1a39d3 LC |
10000 | @node Desktop Services |
10001 | @subsubsection Desktop Services | |
aa4ed923 | 10002 | |
fe1a39d3 LC |
10003 | The @code{(gnu services desktop)} module provides services that are |
10004 | usually useful in the context of a ``desktop'' setup---that is, on a | |
10005 | machine running a graphical display server, possibly with graphical user | |
7a2413e4 AW |
10006 | interfaces, etc. It also defines services that provide specific desktop |
10007 | environments like GNOME and XFCE. | |
aa4ed923 | 10008 | |
4467be21 LC |
10009 | To simplify things, the module defines a variable containing the set of |
10010 | services that users typically expect on a machine with a graphical | |
10011 | environment and networking: | |
10012 | ||
10013 | @defvr {Scheme Variable} %desktop-services | |
10014 | This is a list of services that builds upon @var{%base-services} and | |
1068f26b | 10015 | adds or adjusts services for a typical ``desktop'' setup. |
4467be21 LC |
10016 | |
10017 | In particular, it adds a graphical login manager (@pxref{X Window, | |
6726282b LC |
10018 | @code{slim-service}}), screen lockers, |
10019 | a network management tool (@pxref{Networking | |
4467be21 | 10020 | Services, @code{wicd-service}}), energy and color management services, |
4650a77e | 10021 | the @code{elogind} login and seat manager, the Polkit privilege service, |
cee32ee4 AW |
10022 | the GeoClue location service, an NTP client (@pxref{Networking |
10023 | Services}), the Avahi daemon, and has the name service switch service | |
10024 | configured to be able to use @code{nss-mdns} (@pxref{Name Service | |
10025 | Switch, mDNS}). | |
4467be21 LC |
10026 | @end defvr |
10027 | ||
10028 | The @var{%desktop-services} variable can be used as the @code{services} | |
10029 | field of an @code{operating-system} declaration (@pxref{operating-system | |
10030 | Reference, @code{services}}). | |
10031 | ||
7a2413e4 AW |
10032 | Additionally, the @code{gnome-desktop-service} and |
10033 | @code{xfce-desktop-service} procedures can add GNOME and/or XFCE to a | |
10034 | system. To ``add GNOME'' means that system-level services like the | |
10035 | backlight adjustment helpers and the power management utilities are | |
10036 | added to the system, extending @code{polkit} and @code{dbus} | |
10037 | appropriately, allowing GNOME to operate with elevated privileges on a | |
10038 | limited number of special-purpose system interfaces. Additionally, | |
10039 | adding a service made by @code{gnome-desktop-service} adds the GNOME | |
10040 | metapackage to the system profile. Likewise, adding the XFCE service | |
10041 | not only adds the @code{xfce} metapackage to the system profile, but it | |
10042 | also gives the Thunar file manager the ability to open a ``root-mode'' | |
10043 | file management window, if the user authenticates using the | |
10044 | administrator's password via the standard polkit graphical interface. | |
10045 | ||
10046 | @deffn {Scheme Procedure} gnome-desktop-service | |
10047 | Return a service that adds the @code{gnome} package to the system | |
10048 | profile, and extends polkit with the actions from | |
10049 | @code{gnome-settings-daemon}. | |
10050 | @end deffn | |
10051 | ||
10052 | @deffn {Scheme Procedure} xfce-desktop-service | |
10053 | Return a service that adds the @code{xfce} package to the system profile, | |
5741e3e5 | 10054 | and extends polkit with the ability for @code{thunar} to manipulate the |
7a2413e4 AW |
10055 | file system as root from within a user session, after the user has |
10056 | authenticated with the administrator's password. | |
10057 | @end deffn | |
10058 | ||
10059 | Because the GNOME and XFCE desktop services pull in so many packages, | |
10060 | the default @code{%desktop-services} variable doesn't include either of | |
10061 | them by default. To add GNOME or XFCE, just @code{cons} them onto | |
10062 | @code{%desktop-services} in the @code{services} field of your | |
10063 | @code{operating-system}: | |
10064 | ||
10065 | @example | |
10066 | (use-modules (gnu)) | |
10067 | (use-service-modules desktop) | |
10068 | (operating-system | |
10069 | ... | |
10070 | ;; cons* adds items to the list given as its last argument. | |
10071 | (services (cons* (gnome-desktop-service) | |
10072 | (xfce-desktop-service) | |
10073 | %desktop-services)) | |
10074 | ...) | |
10075 | @end example | |
10076 | ||
10077 | These desktop environments will then be available as options in the | |
10078 | graphical login window. | |
10079 | ||
10080 | The actual service definitions included in @code{%desktop-services} and | |
10081 | provided by @code{(gnu services dbus)} and @code{(gnu services desktop)} | |
10082 | are described below. | |
4467be21 | 10083 | |
0adfe95a | 10084 | @deffn {Scheme Procedure} dbus-service [#:dbus @var{dbus}] [#:services '()] |
fe1a39d3 LC |
10085 | Return a service that runs the ``system bus'', using @var{dbus}, with |
10086 | support for @var{services}. | |
aa4ed923 | 10087 | |
fe1a39d3 LC |
10088 | @uref{http://dbus.freedesktop.org/, D-Bus} is an inter-process communication |
10089 | facility. Its system bus is used to allow system services to communicate | |
1068f26b | 10090 | and to be notified of system-wide events. |
aa4ed923 | 10091 | |
fe1a39d3 LC |
10092 | @var{services} must be a list of packages that provide an |
10093 | @file{etc/dbus-1/system.d} directory containing additional D-Bus configuration | |
10094 | and policy files. For example, to allow avahi-daemon to use the system bus, | |
10095 | @var{services} must be equal to @code{(list avahi)}. | |
aa4ed923 AK |
10096 | @end deffn |
10097 | ||
0adfe95a | 10098 | @deffn {Scheme Procedure} elogind-service [#:config @var{config}] |
4650a77e AW |
10099 | Return a service that runs the @code{elogind} login and |
10100 | seat management daemon. @uref{https://github.com/andywingo/elogind, | |
10101 | Elogind} exposes a D-Bus interface that can be used to know which users | |
10102 | are logged in, know what kind of sessions they have open, suspend the | |
10103 | system, inhibit system suspend, reboot the system, and other tasks. | |
10104 | ||
10105 | Elogind handles most system-level power events for a computer, for | |
10106 | example suspending the system when a lid is closed, or shutting it down | |
10107 | when the power button is pressed. | |
10108 | ||
10109 | The @var{config} keyword argument specifies the configuration for | |
1068f26b | 10110 | elogind, and should be the result of an @code{(elogind-configuration |
4650a77e AW |
10111 | (@var{parameter} @var{value})...)} invocation. Available parameters and |
10112 | their default values are: | |
10113 | ||
10114 | @table @code | |
10115 | @item kill-user-processes? | |
10116 | @code{#f} | |
10117 | @item kill-only-users | |
10118 | @code{()} | |
10119 | @item kill-exclude-users | |
10120 | @code{("root")} | |
10121 | @item inhibit-delay-max-seconds | |
10122 | @code{5} | |
10123 | @item handle-power-key | |
10124 | @code{poweroff} | |
10125 | @item handle-suspend-key | |
10126 | @code{suspend} | |
10127 | @item handle-hibernate-key | |
10128 | @code{hibernate} | |
10129 | @item handle-lid-switch | |
10130 | @code{suspend} | |
10131 | @item handle-lid-switch-docked | |
10132 | @code{ignore} | |
10133 | @item power-key-ignore-inhibited? | |
10134 | @code{#f} | |
10135 | @item suspend-key-ignore-inhibited? | |
10136 | @code{#f} | |
10137 | @item hibernate-key-ignore-inhibited? | |
10138 | @code{#f} | |
10139 | @item lid-switch-ignore-inhibited? | |
10140 | @code{#t} | |
10141 | @item holdoff-timeout-seconds | |
10142 | @code{30} | |
10143 | @item idle-action | |
10144 | @code{ignore} | |
10145 | @item idle-action-seconds | |
10146 | @code{(* 30 60)} | |
10147 | @item runtime-directory-size-percent | |
10148 | @code{10} | |
10149 | @item runtime-directory-size | |
10150 | @code{#f} | |
10151 | @item remove-ipc? | |
10152 | @code{#t} | |
10153 | @item suspend-state | |
10154 | @code{("mem" "standby" "freeze")} | |
10155 | @item suspend-mode | |
10156 | @code{()} | |
10157 | @item hibernate-state | |
10158 | @code{("disk")} | |
10159 | @item hibernate-mode | |
10160 | @code{("platform" "shutdown")} | |
10161 | @item hybrid-sleep-state | |
10162 | @code{("disk")} | |
10163 | @item hybrid-sleep-mode | |
10164 | @code{("suspend" "platform" "shutdown")} | |
10165 | @end table | |
10166 | @end deffn | |
10167 | ||
be1c2c54 | 10168 | @deffn {Scheme Procedure} polkit-service @ |
4650a77e | 10169 | [#:polkit @var{polkit}] |
222e3319 LC |
10170 | Return a service that runs the |
10171 | @uref{http://www.freedesktop.org/wiki/Software/polkit/, Polkit privilege | |
10172 | management service}, which allows system administrators to grant access to | |
10173 | privileged operations in a structured way. By querying the Polkit service, a | |
10174 | privileged system component can know when it should grant additional | |
10175 | capabilities to ordinary users. For example, an ordinary user can be granted | |
10176 | the capability to suspend the system if the user is logged in locally. | |
4650a77e AW |
10177 | @end deffn |
10178 | ||
be1c2c54 | 10179 | @deffn {Scheme Procedure} upower-service [#:upower @var{upower}] @ |
be234128 AW |
10180 | [#:watts-up-pro? #f] @ |
10181 | [#:poll-batteries? #t] @ | |
10182 | [#:ignore-lid? #f] @ | |
10183 | [#:use-percentage-for-policy? #f] @ | |
10184 | [#:percentage-low 10] @ | |
10185 | [#:percentage-critical 3] @ | |
10186 | [#:percentage-action 2] @ | |
10187 | [#:time-low 1200] @ | |
10188 | [#:time-critical 300] @ | |
10189 | [#:time-action 120] @ | |
10190 | [#:critical-power-action 'hybrid-sleep] | |
10191 | Return a service that runs @uref{http://upower.freedesktop.org/, | |
10192 | @command{upowerd}}, a system-wide monitor for power consumption and battery | |
10193 | levels, with the given configuration settings. It implements the | |
10194 | @code{org.freedesktop.UPower} D-Bus interface, and is notably used by | |
10195 | GNOME. | |
10196 | @end deffn | |
10197 | ||
2b9e0a94 LC |
10198 | @deffn {Scheme Procedure} udisks-service [#:udisks @var{udisks}] |
10199 | Return a service for @uref{http://udisks.freedesktop.org/docs/latest/, | |
10200 | UDisks}, a @dfn{disk management} daemon that provides user interfaces with | |
10201 | notifications and ways to mount/unmount disks. Programs that talk to UDisks | |
10202 | include the @command{udisksctl} command, part of UDisks, and GNOME Disks. | |
10203 | @end deffn | |
10204 | ||
be1c2c54 | 10205 | @deffn {Scheme Procedure} colord-service [#:colord @var{colord}] |
7ce597ff AW |
10206 | Return a service that runs @command{colord}, a system service with a D-Bus |
10207 | interface to manage the color profiles of input and output devices such as | |
10208 | screens and scanners. It is notably used by the GNOME Color Manager graphical | |
10209 | tool. See @uref{http://www.freedesktop.org/software/colord/, the colord web | |
10210 | site} for more information. | |
10211 | @end deffn | |
10212 | ||
cee32ee4 | 10213 | @deffn {Scheme Procedure} geoclue-application name [#:allowed? #t] [#:system? #f] [#:users '()] |
1068f26b | 10214 | Return a configuration allowing an application to access GeoClue |
cee32ee4 AW |
10215 | location data. @var{name} is the Desktop ID of the application, without |
10216 | the @code{.desktop} part. If @var{allowed?} is true, the application | |
10217 | will have access to location information by default. The boolean | |
1068f26b | 10218 | @var{system?} value indicates whether an application is a system component |
cee32ee4 AW |
10219 | or not. Finally @var{users} is a list of UIDs of all users for which |
10220 | this application is allowed location info access. An empty users list | |
10221 | means that all users are allowed. | |
10222 | @end deffn | |
10223 | ||
10224 | @defvr {Scheme Variable} %standard-geoclue-applications | |
10225 | The standard list of well-known GeoClue application configurations, | |
1068f26b AE |
10226 | granting authority to the GNOME date-and-time utility to ask for the |
10227 | current location in order to set the time zone, and allowing the | |
10228 | IceCat and Epiphany web browsers to request location information. | |
10229 | IceCat and Epiphany both query the user before allowing a web page to | |
cee32ee4 AW |
10230 | know the user's location. |
10231 | @end defvr | |
10232 | ||
be1c2c54 | 10233 | @deffn {Scheme Procedure} geoclue-service [#:colord @var{colord}] @ |
cee32ee4 AW |
10234 | [#:whitelist '()] @ |
10235 | [#:wifi-geolocation-url "https://location.services.mozilla.com/v1/geolocate?key=geoclue"] @ | |
10236 | [#:submit-data? #f] | |
10237 | [#:wifi-submission-url "https://location.services.mozilla.com/v1/submit?key=geoclue"] @ | |
10238 | [#:submission-nick "geoclue"] @ | |
10239 | [#:applications %standard-geoclue-applications] | |
10240 | Return a service that runs the GeoClue location service. This service | |
10241 | provides a D-Bus interface to allow applications to request access to a | |
10242 | user's physical location, and optionally to add information to online | |
10243 | location databases. See | |
10244 | @uref{https://wiki.freedesktop.org/www/Software/GeoClue/, the GeoClue | |
10245 | web site} for more information. | |
10246 | @end deffn | |
10247 | ||
922e21f4 SB |
10248 | @deffn {Scheme Procedure} bluetooth-service [#:bluez @var{bluez}] |
10249 | Return a service that runs the @command{bluetoothd} daemon, which manages | |
10250 | all the Bluetooth devices and provides a number of D-Bus interfaces. | |
10251 | ||
10252 | Users need to be in the @code{lp} group to access the D-Bus service. | |
10253 | @end deffn | |
10254 | ||
105369a4 DT |
10255 | @node Database Services |
10256 | @subsubsection Database Services | |
10257 | ||
e32171ee JD |
10258 | @cindex database |
10259 | @cindex SQL | |
6575183b | 10260 | The @code{(gnu services databases)} module provides the following services. |
105369a4 | 10261 | |
be1c2c54 | 10262 | @deffn {Scheme Procedure} postgresql-service [#:postgresql postgresql] @ |
2d3d5cc5 | 10263 | [#:config-file] [#:data-directory ``/var/lib/postgresql/data''] @ |
e05b780a | 10264 | [#:port 5432] [#:locale ``en_US.utf8''] |
105369a4 DT |
10265 | Return a service that runs @var{postgresql}, the PostgreSQL database |
10266 | server. | |
10267 | ||
e05b780a CB |
10268 | The PostgreSQL daemon loads its runtime configuration from @var{config-file}, |
10269 | creates a database cluster with @var{locale} as the default | |
10270 | locale, stored in @var{data-directory}. It then listens on @var{port}. | |
105369a4 | 10271 | @end deffn |
fe1a39d3 | 10272 | |
6575183b SB |
10273 | @deffn {Scheme Procedure} mysql-service [#:config (mysql-configuration)] |
10274 | Return a service that runs @command{mysqld}, the MySQL or MariaDB | |
10275 | database server. | |
10276 | ||
10277 | The optional @var{config} argument specifies the configuration for | |
c940b8e6 | 10278 | @command{mysqld}, which should be a @code{<mysql-configuration>} object. |
6575183b SB |
10279 | @end deffn |
10280 | ||
10281 | @deftp {Data Type} mysql-configuration | |
10282 | Data type representing the configuration of @var{mysql-service}. | |
10283 | ||
10284 | @table @asis | |
10285 | @item @code{mysql} (default: @var{mariadb}) | |
10286 | Package object of the MySQL database server, can be either @var{mariadb} | |
10287 | or @var{mysql}. | |
10288 | ||
7414de0a | 10289 | For MySQL, a temporary root password will be displayed at activation time. |
6575183b | 10290 | For MariaDB, the root password is empty. |
4b41febf CB |
10291 | |
10292 | @item @code{port} (default: @code{3306}) | |
10293 | TCP port on which the database server listens for incoming connections. | |
6575183b SB |
10294 | @end table |
10295 | @end deftp | |
10296 | ||
d8c18af8 AW |
10297 | @node Mail Services |
10298 | @subsubsection Mail Services | |
10299 | ||
e32171ee JD |
10300 | @cindex mail |
10301 | @cindex email | |
d8c18af8 | 10302 | The @code{(gnu services mail)} module provides Guix service definitions |
f88371e8 SB |
10303 | for email services: IMAP, POP3, and LMTP servers, as well as mail |
10304 | transport agents (MTAs). Lots of acronyms! These services are detailed | |
10305 | in the subsections below. | |
d8c18af8 | 10306 | |
f88371e8 | 10307 | @subsubheading Dovecot Service |
d8c18af8 AW |
10308 | |
10309 | @deffn {Scheme Procedure} dovecot-service [#:config (dovecot-configuration)] | |
10310 | Return a service that runs the Dovecot IMAP/POP3/LMTP mail server. | |
10311 | @end deffn | |
10312 | ||
1068f26b | 10313 | By default, Dovecot does not need much configuration; the default |
d8c18af8 AW |
10314 | configuration object created by @code{(dovecot-configuration)} will |
10315 | suffice if your mail is delivered to @code{~/Maildir}. A self-signed | |
10316 | certificate will be generated for TLS-protected connections, though | |
10317 | Dovecot will also listen on cleartext ports by default. There are a | |
1068f26b | 10318 | number of options, though, which mail administrators might need to change, |
d8c18af8 AW |
10319 | and as is the case with other services, Guix allows the system |
10320 | administrator to specify these parameters via a uniform Scheme interface. | |
10321 | ||
10322 | For example, to specify that mail is located at @code{maildir~/.mail}, | |
10323 | one would instantiate the Dovecot service like this: | |
10324 | ||
10325 | @example | |
10326 | (dovecot-service #:config | |
10327 | (dovecot-configuration | |
10328 | (mail-location "maildir:~/.mail"))) | |
10329 | @end example | |
10330 | ||
10331 | The available configuration parameters follow. Each parameter | |
10332 | definition is preceded by its type; for example, @samp{string-list foo} | |
10333 | indicates that the @code{foo} parameter should be specified as a list of | |
10334 | strings. There is also a way to specify the configuration as a string, | |
10335 | if you have an old @code{dovecot.conf} file that you want to port over | |
10336 | from some other system; see the end for more details. | |
10337 | ||
10338 | @c The following documentation was initially generated by | |
10339 | @c (generate-documentation) in (gnu services mail). Manually maintained | |
10340 | @c documentation is better, so we shouldn't hesitate to edit below as | |
10341 | @c needed. However if the change you want to make to this documentation | |
10342 | @c can be done in an automated way, it's probably easier to change | |
10343 | @c (generate-documentation) than to make it below and have to deal with | |
10344 | @c the churn as dovecot updates. | |
10345 | ||
10346 | Available @code{dovecot-configuration} fields are: | |
10347 | ||
10348 | @deftypevr {@code{dovecot-configuration} parameter} package dovecot | |
10349 | The dovecot package. | |
10350 | @end deftypevr | |
10351 | ||
10352 | @deftypevr {@code{dovecot-configuration} parameter} comma-separated-string-list listen | |
1068f26b AE |
10353 | A list of IPs or hosts where to listen for connections. @samp{*} |
10354 | listens on all IPv4 interfaces, @samp{::} listens on all IPv6 | |
d8c18af8 AW |
10355 | interfaces. If you want to specify non-default ports or anything more |
10356 | complex, customize the address and port fields of the | |
10357 | @samp{inet-listener} of the specific services you are interested in. | |
10358 | @end deftypevr | |
10359 | ||
10360 | @deftypevr {@code{dovecot-configuration} parameter} protocol-configuration-list protocols | |
10361 | List of protocols we want to serve. Available protocols include | |
10362 | @samp{imap}, @samp{pop3}, and @samp{lmtp}. | |
10363 | ||
10364 | Available @code{protocol-configuration} fields are: | |
10365 | ||
10366 | @deftypevr {@code{protocol-configuration} parameter} string name | |
10367 | The name of the protocol. | |
10368 | @end deftypevr | |
10369 | ||
10370 | @deftypevr {@code{protocol-configuration} parameter} string auth-socket-path | |
1068f26b | 10371 | UNIX socket path to the master authentication server to find users. |
d8c18af8 | 10372 | This is used by imap (for shared users) and lda. |
1068f26b | 10373 | It defaults to @samp{"/var/run/dovecot/auth-userdb"}. |
d8c18af8 AW |
10374 | @end deftypevr |
10375 | ||
10376 | @deftypevr {@code{protocol-configuration} parameter} space-separated-string-list mail-plugins | |
10377 | Space separated list of plugins to load. | |
10378 | @end deftypevr | |
10379 | ||
10380 | @deftypevr {@code{protocol-configuration} parameter} non-negative-integer mail-max-userip-connections | |
10381 | Maximum number of IMAP connections allowed for a user from each IP | |
10382 | address. NOTE: The username is compared case-sensitively. | |
10383 | Defaults to @samp{10}. | |
10384 | @end deftypevr | |
10385 | ||
10386 | @end deftypevr | |
10387 | ||
10388 | @deftypevr {@code{dovecot-configuration} parameter} service-configuration-list services | |
10389 | List of services to enable. Available services include @samp{imap}, | |
10390 | @samp{imap-login}, @samp{pop3}, @samp{pop3-login}, @samp{auth}, and | |
10391 | @samp{lmtp}. | |
10392 | ||
10393 | Available @code{service-configuration} fields are: | |
10394 | ||
10395 | @deftypevr {@code{service-configuration} parameter} string kind | |
10396 | The service kind. Valid values include @code{director}, | |
10397 | @code{imap-login}, @code{pop3-login}, @code{lmtp}, @code{imap}, | |
10398 | @code{pop3}, @code{auth}, @code{auth-worker}, @code{dict}, | |
10399 | @code{tcpwrap}, @code{quota-warning}, or anything else. | |
10400 | @end deftypevr | |
10401 | ||
10402 | @deftypevr {@code{service-configuration} parameter} listener-configuration-list listeners | |
1068f26b | 10403 | Listeners for the service. A listener is either a |
d8c18af8 AW |
10404 | @code{unix-listener-configuration}, a @code{fifo-listener-configuration}, or |
10405 | an @code{inet-listener-configuration}. | |
10406 | Defaults to @samp{()}. | |
10407 | ||
10408 | Available @code{unix-listener-configuration} fields are: | |
10409 | ||
10410 | @deftypevr {@code{unix-listener-configuration} parameter} file-name path | |
10411 | The file name on which to listen. | |
10412 | @end deftypevr | |
10413 | ||
10414 | @deftypevr {@code{unix-listener-configuration} parameter} string mode | |
10415 | The access mode for the socket. | |
10416 | Defaults to @samp{"0600"}. | |
10417 | @end deftypevr | |
10418 | ||
10419 | @deftypevr {@code{unix-listener-configuration} parameter} string user | |
f9b9a033 | 10420 | The user to own the socket. |
d8c18af8 AW |
10421 | Defaults to @samp{""}. |
10422 | @end deftypevr | |
10423 | ||
10424 | @deftypevr {@code{unix-listener-configuration} parameter} string group | |
10425 | The group to own the socket. | |
10426 | Defaults to @samp{""}. | |
10427 | @end deftypevr | |
10428 | ||
10429 | ||
10430 | Available @code{fifo-listener-configuration} fields are: | |
10431 | ||
10432 | @deftypevr {@code{fifo-listener-configuration} parameter} file-name path | |
10433 | The file name on which to listen. | |
10434 | @end deftypevr | |
10435 | ||
10436 | @deftypevr {@code{fifo-listener-configuration} parameter} string mode | |
10437 | The access mode for the socket. | |
10438 | Defaults to @samp{"0600"}. | |
10439 | @end deftypevr | |
10440 | ||
10441 | @deftypevr {@code{fifo-listener-configuration} parameter} string user | |
f9b9a033 | 10442 | The user to own the socket. |
d8c18af8 AW |
10443 | Defaults to @samp{""}. |
10444 | @end deftypevr | |
10445 | ||
10446 | @deftypevr {@code{fifo-listener-configuration} parameter} string group | |
10447 | The group to own the socket. | |
10448 | Defaults to @samp{""}. | |
10449 | @end deftypevr | |
10450 | ||
10451 | ||
10452 | Available @code{inet-listener-configuration} fields are: | |
10453 | ||
10454 | @deftypevr {@code{inet-listener-configuration} parameter} string protocol | |
10455 | The protocol to listen for. | |
10456 | @end deftypevr | |
10457 | ||
10458 | @deftypevr {@code{inet-listener-configuration} parameter} string address | |
10459 | The address on which to listen, or empty for all addresses. | |
10460 | Defaults to @samp{""}. | |
10461 | @end deftypevr | |
10462 | ||
10463 | @deftypevr {@code{inet-listener-configuration} parameter} non-negative-integer port | |
10464 | The port on which to listen. | |
10465 | @end deftypevr | |
10466 | ||
10467 | @deftypevr {@code{inet-listener-configuration} parameter} boolean ssl? | |
10468 | Whether to use SSL for this service; @samp{yes}, @samp{no}, or | |
10469 | @samp{required}. | |
10470 | Defaults to @samp{#t}. | |
10471 | @end deftypevr | |
10472 | ||
10473 | @end deftypevr | |
10474 | ||
10475 | @deftypevr {@code{service-configuration} parameter} non-negative-integer service-count | |
10476 | Number of connections to handle before starting a new process. | |
10477 | Typically the only useful values are 0 (unlimited) or 1. 1 is more | |
10478 | secure, but 0 is faster. <doc/wiki/LoginProcess.txt>. | |
10479 | Defaults to @samp{1}. | |
10480 | @end deftypevr | |
10481 | ||
10482 | @deftypevr {@code{service-configuration} parameter} non-negative-integer process-min-avail | |
10483 | Number of processes to always keep waiting for more connections. | |
10484 | Defaults to @samp{0}. | |
10485 | @end deftypevr | |
10486 | ||
10487 | @deftypevr {@code{service-configuration} parameter} non-negative-integer vsz-limit | |
10488 | If you set @samp{service-count 0}, you probably need to grow | |
10489 | this. | |
10490 | Defaults to @samp{256000000}. | |
10491 | @end deftypevr | |
10492 | ||
10493 | @end deftypevr | |
10494 | ||
10495 | @deftypevr {@code{dovecot-configuration} parameter} dict-configuration dict | |
10496 | Dict configuration, as created by the @code{dict-configuration} | |
10497 | constructor. | |
10498 | ||
10499 | Available @code{dict-configuration} fields are: | |
10500 | ||
10501 | @deftypevr {@code{dict-configuration} parameter} free-form-fields entries | |
10502 | A list of key-value pairs that this dict should hold. | |
10503 | Defaults to @samp{()}. | |
10504 | @end deftypevr | |
10505 | ||
10506 | @end deftypevr | |
10507 | ||
10508 | @deftypevr {@code{dovecot-configuration} parameter} passdb-configuration-list passdbs | |
1068f26b | 10509 | A list of passdb configurations, each one created by the |
d8c18af8 AW |
10510 | @code{passdb-configuration} constructor. |
10511 | ||
10512 | Available @code{passdb-configuration} fields are: | |
10513 | ||
10514 | @deftypevr {@code{passdb-configuration} parameter} string driver | |
10515 | The driver that the passdb should use. Valid values include | |
10516 | @samp{pam}, @samp{passwd}, @samp{shadow}, @samp{bsdauth}, and | |
10517 | @samp{static}. | |
10518 | Defaults to @samp{"pam"}. | |
10519 | @end deftypevr | |
10520 | ||
10521 | @deftypevr {@code{passdb-configuration} parameter} free-form-args args | |
10522 | A list of key-value args to the passdb driver. | |
10523 | Defaults to @samp{()}. | |
10524 | @end deftypevr | |
10525 | ||
10526 | @end deftypevr | |
10527 | ||
10528 | @deftypevr {@code{dovecot-configuration} parameter} userdb-configuration-list userdbs | |
10529 | List of userdb configurations, each one created by the | |
10530 | @code{userdb-configuration} constructor. | |
10531 | ||
10532 | Available @code{userdb-configuration} fields are: | |
10533 | ||
10534 | @deftypevr {@code{userdb-configuration} parameter} string driver | |
10535 | The driver that the userdb should use. Valid values include | |
10536 | @samp{passwd} and @samp{static}. | |
10537 | Defaults to @samp{"passwd"}. | |
10538 | @end deftypevr | |
10539 | ||
10540 | @deftypevr {@code{userdb-configuration} parameter} free-form-args args | |
10541 | A list of key-value args to the userdb driver. | |
10542 | Defaults to @samp{()}. | |
10543 | @end deftypevr | |
10544 | ||
10545 | @deftypevr {@code{userdb-configuration} parameter} free-form-args override-fields | |
10546 | Override fields from passwd. | |
10547 | Defaults to @samp{()}. | |
10548 | @end deftypevr | |
10549 | ||
10550 | @end deftypevr | |
10551 | ||
10552 | @deftypevr {@code{dovecot-configuration} parameter} plugin-configuration plugin-configuration | |
10553 | Plug-in configuration, created by the @code{plugin-configuration} | |
10554 | constructor. | |
10555 | @end deftypevr | |
10556 | ||
10557 | @deftypevr {@code{dovecot-configuration} parameter} list-of-namespace-configuration namespaces | |
10558 | List of namespaces. Each item in the list is created by the | |
10559 | @code{namespace-configuration} constructor. | |
10560 | ||
10561 | Available @code{namespace-configuration} fields are: | |
10562 | ||
10563 | @deftypevr {@code{namespace-configuration} parameter} string name | |
10564 | Name for this namespace. | |
10565 | @end deftypevr | |
10566 | ||
10567 | @deftypevr {@code{namespace-configuration} parameter} string type | |
10568 | Namespace type: @samp{private}, @samp{shared} or @samp{public}. | |
10569 | Defaults to @samp{"private"}. | |
10570 | @end deftypevr | |
10571 | ||
10572 | @deftypevr {@code{namespace-configuration} parameter} string separator | |
10573 | Hierarchy separator to use. You should use the same separator for | |
10574 | all namespaces or some clients get confused. @samp{/} is usually a good | |
10575 | one. The default however depends on the underlying mail storage | |
10576 | format. | |
10577 | Defaults to @samp{""}. | |
10578 | @end deftypevr | |
10579 | ||
10580 | @deftypevr {@code{namespace-configuration} parameter} string prefix | |
10581 | Prefix required to access this namespace. This needs to be | |
10582 | different for all namespaces. For example @samp{Public/}. | |
10583 | Defaults to @samp{""}. | |
10584 | @end deftypevr | |
10585 | ||
10586 | @deftypevr {@code{namespace-configuration} parameter} string location | |
1068f26b | 10587 | Physical location of the mailbox. This is in the same format as |
d8c18af8 AW |
10588 | mail_location, which is also the default for it. |
10589 | Defaults to @samp{""}. | |
10590 | @end deftypevr | |
10591 | ||
10592 | @deftypevr {@code{namespace-configuration} parameter} boolean inbox? | |
10593 | There can be only one INBOX, and this setting defines which | |
10594 | namespace has it. | |
10595 | Defaults to @samp{#f}. | |
10596 | @end deftypevr | |
10597 | ||
10598 | @deftypevr {@code{namespace-configuration} parameter} boolean hidden? | |
10599 | If namespace is hidden, it's not advertised to clients via NAMESPACE | |
10600 | extension. You'll most likely also want to set @samp{list? #f}. This is mostly | |
10601 | useful when converting from another server with different namespaces | |
10602 | which you want to deprecate but still keep working. For example you can | |
10603 | create hidden namespaces with prefixes @samp{~/mail/}, @samp{~%u/mail/} | |
10604 | and @samp{mail/}. | |
10605 | Defaults to @samp{#f}. | |
10606 | @end deftypevr | |
10607 | ||
10608 | @deftypevr {@code{namespace-configuration} parameter} boolean list? | |
1068f26b AE |
10609 | Show the mailboxes under this namespace with the LIST command. This |
10610 | makes the namespace visible for clients that do not support the NAMESPACE | |
d8c18af8 AW |
10611 | extension. The special @code{children} value lists child mailboxes, but |
10612 | hides the namespace prefix. | |
10613 | Defaults to @samp{#t}. | |
10614 | @end deftypevr | |
10615 | ||
10616 | @deftypevr {@code{namespace-configuration} parameter} boolean subscriptions? | |
10617 | Namespace handles its own subscriptions. If set to @code{#f}, the | |
10618 | parent namespace handles them. The empty prefix should always have this | |
1068f26b | 10619 | as @code{#t}). |
d8c18af8 AW |
10620 | Defaults to @samp{#t}. |
10621 | @end deftypevr | |
10622 | ||
10623 | @deftypevr {@code{namespace-configuration} parameter} mailbox-configuration-list mailboxes | |
10624 | List of predefined mailboxes in this namespace. | |
10625 | Defaults to @samp{()}. | |
10626 | ||
10627 | Available @code{mailbox-configuration} fields are: | |
10628 | ||
10629 | @deftypevr {@code{mailbox-configuration} parameter} string name | |
10630 | Name for this mailbox. | |
10631 | @end deftypevr | |
10632 | ||
10633 | @deftypevr {@code{mailbox-configuration} parameter} string auto | |
10634 | @samp{create} will automatically create this mailbox. | |
10635 | @samp{subscribe} will both create and subscribe to the mailbox. | |
10636 | Defaults to @samp{"no"}. | |
10637 | @end deftypevr | |
10638 | ||
10639 | @deftypevr {@code{mailbox-configuration} parameter} space-separated-string-list special-use | |
10640 | List of IMAP @code{SPECIAL-USE} attributes as specified by RFC 6154. | |
10641 | Valid values are @code{\All}, @code{\Archive}, @code{\Drafts}, | |
10642 | @code{\Flagged}, @code{\Junk}, @code{\Sent}, and @code{\Trash}. | |
10643 | Defaults to @samp{()}. | |
10644 | @end deftypevr | |
10645 | ||
10646 | @end deftypevr | |
10647 | ||
10648 | @end deftypevr | |
10649 | ||
10650 | @deftypevr {@code{dovecot-configuration} parameter} file-name base-dir | |
10651 | Base directory where to store runtime data. | |
10652 | Defaults to @samp{"/var/run/dovecot/"}. | |
10653 | @end deftypevr | |
10654 | ||
10655 | @deftypevr {@code{dovecot-configuration} parameter} string login-greeting | |
10656 | Greeting message for clients. | |
10657 | Defaults to @samp{"Dovecot ready."}. | |
10658 | @end deftypevr | |
10659 | ||
10660 | @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list login-trusted-networks | |
10661 | List of trusted network ranges. Connections from these IPs are | |
10662 | allowed to override their IP addresses and ports (for logging and for | |
10663 | authentication checks). @samp{disable-plaintext-auth} is also ignored | |
1068f26b | 10664 | for these networks. Typically you would specify your IMAP proxy servers |
d8c18af8 AW |
10665 | here. |
10666 | Defaults to @samp{()}. | |
10667 | @end deftypevr | |
10668 | ||
10669 | @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list login-access-sockets | |
10670 | List of login access check sockets (e.g. tcpwrap). | |
10671 | Defaults to @samp{()}. | |
10672 | @end deftypevr | |
10673 | ||
10674 | @deftypevr {@code{dovecot-configuration} parameter} boolean verbose-proctitle? | |
10675 | Show more verbose process titles (in ps). Currently shows user name | |
1068f26b AE |
10676 | and IP address. Useful for seeing who is actually using the IMAP |
10677 | processes (e.g. shared mailboxes or if the same uid is used for multiple | |
d8c18af8 AW |
10678 | accounts). |
10679 | Defaults to @samp{#f}. | |
10680 | @end deftypevr | |
10681 | ||
10682 | @deftypevr {@code{dovecot-configuration} parameter} boolean shutdown-clients? | |
10683 | Should all processes be killed when Dovecot master process shuts down. | |
10684 | Setting this to @code{#f} means that Dovecot can be upgraded without | |
10685 | forcing existing client connections to close (although that could also | |
1068f26b | 10686 | be a problem if the upgrade is e.g. due to a security fix). |
d8c18af8 AW |
10687 | Defaults to @samp{#t}. |
10688 | @end deftypevr | |
10689 | ||
10690 | @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer doveadm-worker-count | |
10691 | If non-zero, run mail commands via this many connections to doveadm | |
10692 | server, instead of running them directly in the same process. | |
10693 | Defaults to @samp{0}. | |
10694 | @end deftypevr | |
10695 | ||
10696 | @deftypevr {@code{dovecot-configuration} parameter} string doveadm-socket-path | |
10697 | UNIX socket or host:port used for connecting to doveadm server. | |
10698 | Defaults to @samp{"doveadm-server"}. | |
10699 | @end deftypevr | |
10700 | ||
10701 | @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list import-environment | |
10702 | List of environment variables that are preserved on Dovecot startup | |
10703 | and passed down to all of its child processes. You can also give | |
10704 | key=value pairs to always set specific settings. | |
10705 | @end deftypevr | |
10706 | ||
10707 | @deftypevr {@code{dovecot-configuration} parameter} boolean disable-plaintext-auth? | |
10708 | Disable LOGIN command and all other plaintext authentications unless | |
10709 | SSL/TLS is used (LOGINDISABLED capability). Note that if the remote IP | |
10710 | matches the local IP (i.e. you're connecting from the same computer), | |
10711 | the connection is considered secure and plaintext authentication is | |
10712 | allowed. See also ssl=required setting. | |
10713 | Defaults to @samp{#t}. | |
10714 | @end deftypevr | |
10715 | ||
10716 | @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer auth-cache-size | |
10717 | Authentication cache size (e.g. @samp{#e10e6}). 0 means it's disabled. | |
10718 | Note that bsdauth, PAM and vpopmail require @samp{cache-key} to be set | |
10719 | for caching to be used. | |
10720 | Defaults to @samp{0}. | |
10721 | @end deftypevr | |
10722 | ||
10723 | @deftypevr {@code{dovecot-configuration} parameter} string auth-cache-ttl | |
10724 | Time to live for cached data. After TTL expires the cached record | |
10725 | is no longer used, *except* if the main database lookup returns internal | |
10726 | failure. We also try to handle password changes automatically: If | |
10727 | user's previous authentication was successful, but this one wasn't, the | |
10728 | cache isn't used. For now this works only with plaintext | |
10729 | authentication. | |
10730 | Defaults to @samp{"1 hour"}. | |
10731 | @end deftypevr | |
10732 | ||
10733 | @deftypevr {@code{dovecot-configuration} parameter} string auth-cache-negative-ttl | |
10734 | TTL for negative hits (user not found, password mismatch). | |
10735 | 0 disables caching them completely. | |
10736 | Defaults to @samp{"1 hour"}. | |
10737 | @end deftypevr | |
10738 | ||
10739 | @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list auth-realms | |
10740 | List of realms for SASL authentication mechanisms that need them. | |
10741 | You can leave it empty if you don't want to support multiple realms. | |
10742 | Many clients simply use the first one listed here, so keep the default | |
10743 | realm first. | |
10744 | Defaults to @samp{()}. | |
10745 | @end deftypevr | |
10746 | ||
10747 | @deftypevr {@code{dovecot-configuration} parameter} string auth-default-realm | |
10748 | Default realm/domain to use if none was specified. This is used for | |
10749 | both SASL realms and appending @@domain to username in plaintext | |
10750 | logins. | |
10751 | Defaults to @samp{""}. | |
10752 | @end deftypevr | |
10753 | ||
10754 | @deftypevr {@code{dovecot-configuration} parameter} string auth-username-chars | |
10755 | List of allowed characters in username. If the user-given username | |
10756 | contains a character not listed in here, the login automatically fails. | |
10757 | This is just an extra check to make sure user can't exploit any | |
10758 | potential quote escaping vulnerabilities with SQL/LDAP databases. If | |
10759 | you want to allow all characters, set this value to empty. | |
10760 | Defaults to @samp{"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890.-_@@"}. | |
10761 | @end deftypevr | |
10762 | ||
10763 | @deftypevr {@code{dovecot-configuration} parameter} string auth-username-translation | |
10764 | Username character translations before it's looked up from | |
10765 | databases. The value contains series of from -> to characters. For | |
10766 | example @samp{#@@/@@} means that @samp{#} and @samp{/} characters are | |
10767 | translated to @samp{@@}. | |
10768 | Defaults to @samp{""}. | |
10769 | @end deftypevr | |
10770 | ||
10771 | @deftypevr {@code{dovecot-configuration} parameter} string auth-username-format | |
10772 | Username formatting before it's looked up from databases. You can | |
10773 | use the standard variables here, e.g. %Lu would lowercase the username, | |
10774 | %n would drop away the domain if it was given, or @samp{%n-AT-%d} would | |
10775 | change the @samp{@@} into @samp{-AT-}. This translation is done after | |
10776 | @samp{auth-username-translation} changes. | |
10777 | Defaults to @samp{"%Lu"}. | |
10778 | @end deftypevr | |
10779 | ||
10780 | @deftypevr {@code{dovecot-configuration} parameter} string auth-master-user-separator | |
10781 | If you want to allow master users to log in by specifying the master | |
10782 | username within the normal username string (i.e. not using SASL | |
10783 | mechanism's support for it), you can specify the separator character | |
10784 | here. The format is then <username><separator><master username>. | |
10785 | UW-IMAP uses @samp{*} as the separator, so that could be a good | |
10786 | choice. | |
10787 | Defaults to @samp{""}. | |
10788 | @end deftypevr | |
10789 | ||
10790 | @deftypevr {@code{dovecot-configuration} parameter} string auth-anonymous-username | |
10791 | Username to use for users logging in with ANONYMOUS SASL | |
10792 | mechanism. | |
10793 | Defaults to @samp{"anonymous"}. | |
10794 | @end deftypevr | |
10795 | ||
10796 | @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer auth-worker-max-count | |
10797 | Maximum number of dovecot-auth worker processes. They're used to | |
10798 | execute blocking passdb and userdb queries (e.g. MySQL and PAM). | |
10799 | They're automatically created and destroyed as needed. | |
10800 | Defaults to @samp{30}. | |
10801 | @end deftypevr | |
10802 | ||
10803 | @deftypevr {@code{dovecot-configuration} parameter} string auth-gssapi-hostname | |
10804 | Host name to use in GSSAPI principal names. The default is to use | |
10805 | the name returned by gethostname(). Use @samp{$ALL} (with quotes) to | |
10806 | allow all keytab entries. | |
10807 | Defaults to @samp{""}. | |
10808 | @end deftypevr | |
10809 | ||
10810 | @deftypevr {@code{dovecot-configuration} parameter} string auth-krb5-keytab | |
10811 | Kerberos keytab to use for the GSSAPI mechanism. Will use the | |
8b499030 | 10812 | system default (usually @file{/etc/krb5.keytab}) if not specified. You may |
d8c18af8 AW |
10813 | need to change the auth service to run as root to be able to read this |
10814 | file. | |
10815 | Defaults to @samp{""}. | |
10816 | @end deftypevr | |
10817 | ||
10818 | @deftypevr {@code{dovecot-configuration} parameter} boolean auth-use-winbind? | |
10819 | Do NTLM and GSS-SPNEGO authentication using Samba's winbind daemon | |
10820 | and @samp{ntlm-auth} helper. | |
10821 | <doc/wiki/Authentication/Mechanisms/Winbind.txt>. | |
10822 | Defaults to @samp{#f}. | |
10823 | @end deftypevr | |
10824 | ||
10825 | @deftypevr {@code{dovecot-configuration} parameter} file-name auth-winbind-helper-path | |
10826 | Path for Samba's @samp{ntlm-auth} helper binary. | |
10827 | Defaults to @samp{"/usr/bin/ntlm_auth"}. | |
10828 | @end deftypevr | |
10829 | ||
10830 | @deftypevr {@code{dovecot-configuration} parameter} string auth-failure-delay | |
10831 | Time to delay before replying to failed authentications. | |
10832 | Defaults to @samp{"2 secs"}. | |
10833 | @end deftypevr | |
10834 | ||
10835 | @deftypevr {@code{dovecot-configuration} parameter} boolean auth-ssl-require-client-cert? | |
10836 | Require a valid SSL client certificate or the authentication | |
10837 | fails. | |
10838 | Defaults to @samp{#f}. | |
10839 | @end deftypevr | |
10840 | ||
10841 | @deftypevr {@code{dovecot-configuration} parameter} boolean auth-ssl-username-from-cert? | |
10842 | Take the username from client's SSL certificate, using | |
10843 | @code{X509_NAME_get_text_by_NID()} which returns the subject's DN's | |
10844 | CommonName. | |
10845 | Defaults to @samp{#f}. | |
10846 | @end deftypevr | |
10847 | ||
10848 | @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list auth-mechanisms | |
10849 | List of wanted authentication mechanisms. Supported mechanisms are: | |
10850 | @samp{plain}, @samp{login}, @samp{digest-md5}, @samp{cram-md5}, | |
10851 | @samp{ntlm}, @samp{rpa}, @samp{apop}, @samp{anonymous}, @samp{gssapi}, | |
10852 | @samp{otp}, @samp{skey}, and @samp{gss-spnego}. NOTE: See also | |
10853 | @samp{disable-plaintext-auth} setting. | |
10854 | @end deftypevr | |
10855 | ||
10856 | @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list director-servers | |
10857 | List of IPs or hostnames to all director servers, including ourself. | |
10858 | Ports can be specified as ip:port. The default port is the same as what | |
10859 | director service's @samp{inet-listener} is using. | |
10860 | Defaults to @samp{()}. | |
10861 | @end deftypevr | |
10862 | ||
10863 | @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list director-mail-servers | |
10864 | List of IPs or hostnames to all backend mail servers. Ranges are | |
10865 | allowed too, like 10.0.0.10-10.0.0.30. | |
10866 | Defaults to @samp{()}. | |
10867 | @end deftypevr | |
10868 | ||
10869 | @deftypevr {@code{dovecot-configuration} parameter} string director-user-expire | |
10870 | How long to redirect users to a specific server after it no longer | |
10871 | has any connections. | |
10872 | Defaults to @samp{"15 min"}. | |
10873 | @end deftypevr | |
10874 | ||
10875 | @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer director-doveadm-port | |
10876 | TCP/IP port that accepts doveadm connections (instead of director | |
10877 | connections) If you enable this, you'll also need to add | |
10878 | @samp{inet-listener} for the port. | |
10879 | Defaults to @samp{0}. | |
10880 | @end deftypevr | |
10881 | ||
10882 | @deftypevr {@code{dovecot-configuration} parameter} string director-username-hash | |
10883 | How the username is translated before being hashed. Useful values | |
10884 | include %Ln if user can log in with or without @@domain, %Ld if mailboxes | |
10885 | are shared within domain. | |
10886 | Defaults to @samp{"%Lu"}. | |
10887 | @end deftypevr | |
10888 | ||
10889 | @deftypevr {@code{dovecot-configuration} parameter} string log-path | |
10890 | Log file to use for error messages. @samp{syslog} logs to syslog, | |
10891 | @samp{/dev/stderr} logs to stderr. | |
10892 | Defaults to @samp{"syslog"}. | |
10893 | @end deftypevr | |
10894 | ||
10895 | @deftypevr {@code{dovecot-configuration} parameter} string info-log-path | |
10896 | Log file to use for informational messages. Defaults to | |
10897 | @samp{log-path}. | |
10898 | Defaults to @samp{""}. | |
10899 | @end deftypevr | |
10900 | ||
10901 | @deftypevr {@code{dovecot-configuration} parameter} string debug-log-path | |
10902 | Log file to use for debug messages. Defaults to | |
10903 | @samp{info-log-path}. | |
10904 | Defaults to @samp{""}. | |
10905 | @end deftypevr | |
10906 | ||
10907 | @deftypevr {@code{dovecot-configuration} parameter} string syslog-facility | |
10908 | Syslog facility to use if you're logging to syslog. Usually if you | |
10909 | don't want to use @samp{mail}, you'll use local0..local7. Also other | |
10910 | standard facilities are supported. | |
10911 | Defaults to @samp{"mail"}. | |
10912 | @end deftypevr | |
10913 | ||
10914 | @deftypevr {@code{dovecot-configuration} parameter} boolean auth-verbose? | |
10915 | Log unsuccessful authentication attempts and the reasons why they | |
10916 | failed. | |
10917 | Defaults to @samp{#f}. | |
10918 | @end deftypevr | |
10919 | ||
10920 | @deftypevr {@code{dovecot-configuration} parameter} boolean auth-verbose-passwords? | |
10921 | In case of password mismatches, log the attempted password. Valid | |
10922 | values are no, plain and sha1. sha1 can be useful for detecting brute | |
10923 | force password attempts vs. user simply trying the same password over | |
10924 | and over again. You can also truncate the value to n chars by appending | |
10925 | ":n" (e.g. sha1:6). | |
10926 | Defaults to @samp{#f}. | |
10927 | @end deftypevr | |
10928 | ||
10929 | @deftypevr {@code{dovecot-configuration} parameter} boolean auth-debug? | |
10930 | Even more verbose logging for debugging purposes. Shows for example | |
10931 | SQL queries. | |
10932 | Defaults to @samp{#f}. | |
10933 | @end deftypevr | |
10934 | ||
10935 | @deftypevr {@code{dovecot-configuration} parameter} boolean auth-debug-passwords? | |
10936 | In case of password mismatches, log the passwords and used scheme so | |
10937 | the problem can be debugged. Enabling this also enables | |
10938 | @samp{auth-debug}. | |
10939 | Defaults to @samp{#f}. | |
10940 | @end deftypevr | |
10941 | ||
10942 | @deftypevr {@code{dovecot-configuration} parameter} boolean mail-debug? | |
10943 | Enable mail process debugging. This can help you figure out why | |
10944 | Dovecot isn't finding your mails. | |
10945 | Defaults to @samp{#f}. | |
10946 | @end deftypevr | |
10947 | ||
10948 | @deftypevr {@code{dovecot-configuration} parameter} boolean verbose-ssl? | |
10949 | Show protocol level SSL errors. | |
10950 | Defaults to @samp{#f}. | |
10951 | @end deftypevr | |
10952 | ||
10953 | @deftypevr {@code{dovecot-configuration} parameter} string log-timestamp | |
10954 | Prefix for each line written to log file. % codes are in | |
10955 | strftime(3) format. | |
10956 | Defaults to @samp{"\"%b %d %H:%M:%S \""}. | |
10957 | @end deftypevr | |
10958 | ||
10959 | @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list login-log-format-elements | |
10960 | List of elements we want to log. The elements which have a | |
10961 | non-empty variable value are joined together to form a comma-separated | |
10962 | string. | |
10963 | @end deftypevr | |
10964 | ||
10965 | @deftypevr {@code{dovecot-configuration} parameter} string login-log-format | |
10966 | Login log format. %s contains @samp{login-log-format-elements} | |
10967 | string, %$ contains the data we want to log. | |
10968 | Defaults to @samp{"%$: %s"}. | |
10969 | @end deftypevr | |
10970 | ||
10971 | @deftypevr {@code{dovecot-configuration} parameter} string mail-log-prefix | |
10972 | Log prefix for mail processes. See doc/wiki/Variables.txt for list | |
10973 | of possible variables you can use. | |
10974 | Defaults to @samp{"\"%s(%u): \""}. | |
10975 | @end deftypevr | |
10976 | ||
10977 | @deftypevr {@code{dovecot-configuration} parameter} string deliver-log-format | |
10978 | Format to use for logging mail deliveries. You can use variables: | |
10979 | @table @code | |
10980 | @item %$ | |
10981 | Delivery status message (e.g. @samp{saved to INBOX}) | |
10982 | @item %m | |
10983 | Message-ID | |
10984 | @item %s | |
10985 | Subject | |
10986 | @item %f | |
10987 | From address | |
10988 | @item %p | |
10989 | Physical size | |
10990 | @item %w | |
10991 | Virtual size. | |
10992 | @end table | |
10993 | Defaults to @samp{"msgid=%m: %$"}. | |
10994 | @end deftypevr | |
10995 | ||
10996 | @deftypevr {@code{dovecot-configuration} parameter} string mail-location | |
10997 | Location for users' mailboxes. The default is empty, which means | |
10998 | that Dovecot tries to find the mailboxes automatically. This won't work | |
10999 | if the user doesn't yet have any mail, so you should explicitly tell | |
11000 | Dovecot the full location. | |
11001 | ||
11002 | If you're using mbox, giving a path to the INBOX | |
11003 | file (e.g. /var/mail/%u) isn't enough. You'll also need to tell Dovecot | |
11004 | where the other mailboxes are kept. This is called the "root mail | |
11005 | directory", and it must be the first path given in the | |
11006 | @samp{mail-location} setting. | |
11007 | ||
11008 | There are a few special variables you can use, eg.: | |
11009 | ||
11010 | @table @samp | |
11011 | @item %u | |
11012 | username | |
11013 | @item %n | |
11014 | user part in user@@domain, same as %u if there's no domain | |
11015 | @item %d | |
11016 | domain part in user@@domain, empty if there's no domain | |
11017 | @item %h | |
11018 | home director | |
11019 | @end table | |
11020 | ||
11021 | See doc/wiki/Variables.txt for full list. Some examples: | |
11022 | @table @samp | |
11023 | @item maildir:~/Maildir | |
11024 | @item mbox:~/mail:INBOX=/var/mail/%u | |
11025 | @item mbox:/var/mail/%d/%1n/%n:INDEX=/var/indexes/%d/%1n/% | |
11026 | @end table | |
11027 | Defaults to @samp{""}. | |
11028 | @end deftypevr | |
11029 | ||
11030 | @deftypevr {@code{dovecot-configuration} parameter} string mail-uid | |
11031 | System user and group used to access mails. If you use multiple, | |
11032 | userdb can override these by returning uid or gid fields. You can use | |
11033 | either numbers or names. <doc/wiki/UserIds.txt>. | |
11034 | Defaults to @samp{""}. | |
11035 | @end deftypevr | |
11036 | ||
11037 | @deftypevr {@code{dovecot-configuration} parameter} string mail-gid | |
11038 | ||
11039 | Defaults to @samp{""}. | |
11040 | @end deftypevr | |
11041 | ||
11042 | @deftypevr {@code{dovecot-configuration} parameter} string mail-privileged-group | |
11043 | Group to enable temporarily for privileged operations. Currently | |
11044 | this is used only with INBOX when either its initial creation or | |
11045 | dotlocking fails. Typically this is set to "mail" to give access to | |
11046 | /var/mail. | |
11047 | Defaults to @samp{""}. | |
11048 | @end deftypevr | |
11049 | ||
11050 | @deftypevr {@code{dovecot-configuration} parameter} string mail-access-groups | |
11051 | Grant access to these supplementary groups for mail processes. | |
11052 | Typically these are used to set up access to shared mailboxes. Note | |
11053 | that it may be dangerous to set these if users can create | |
11054 | symlinks (e.g. if "mail" group is set here, ln -s /var/mail ~/mail/var | |
11055 | could allow a user to delete others' mailboxes, or ln -s | |
11056 | /secret/shared/box ~/mail/mybox would allow reading it). | |
11057 | Defaults to @samp{""}. | |
11058 | @end deftypevr | |
11059 | ||
11060 | @deftypevr {@code{dovecot-configuration} parameter} boolean mail-full-filesystem-access? | |
8f65585b | 11061 | Allow full file system access to clients. There's no access checks |
d8c18af8 AW |
11062 | other than what the operating system does for the active UID/GID. It |
11063 | works with both maildir and mboxes, allowing you to prefix mailboxes | |
11064 | names with e.g. /path/ or ~user/. | |
11065 | Defaults to @samp{#f}. | |
11066 | @end deftypevr | |
11067 | ||
11068 | @deftypevr {@code{dovecot-configuration} parameter} boolean mmap-disable? | |
11069 | Don't use mmap() at all. This is required if you store indexes to | |
8f65585b | 11070 | shared file systems (NFS or clustered file system). |
d8c18af8 AW |
11071 | Defaults to @samp{#f}. |
11072 | @end deftypevr | |
11073 | ||
11074 | @deftypevr {@code{dovecot-configuration} parameter} boolean dotlock-use-excl? | |
11075 | Rely on @samp{O_EXCL} to work when creating dotlock files. NFS | |
11076 | supports @samp{O_EXCL} since version 3, so this should be safe to use | |
11077 | nowadays by default. | |
11078 | Defaults to @samp{#t}. | |
11079 | @end deftypevr | |
11080 | ||
11081 | @deftypevr {@code{dovecot-configuration} parameter} string mail-fsync | |
11082 | When to use fsync() or fdatasync() calls: | |
11083 | @table @code | |
11084 | @item optimized | |
11085 | Whenever necessary to avoid losing important data | |
11086 | @item always | |
11087 | Useful with e.g. NFS when write()s are delayed | |
11088 | @item never | |
11089 | Never use it (best performance, but crashes can lose data). | |
11090 | @end table | |
11091 | Defaults to @samp{"optimized"}. | |
11092 | @end deftypevr | |
11093 | ||
11094 | @deftypevr {@code{dovecot-configuration} parameter} boolean mail-nfs-storage? | |
11095 | Mail storage exists in NFS. Set this to yes to make Dovecot flush | |
11096 | NFS caches whenever needed. If you're using only a single mail server | |
11097 | this isn't needed. | |
11098 | Defaults to @samp{#f}. | |
11099 | @end deftypevr | |
11100 | ||
11101 | @deftypevr {@code{dovecot-configuration} parameter} boolean mail-nfs-index? | |
11102 | Mail index files also exist in NFS. Setting this to yes requires | |
11103 | @samp{mmap-disable? #t} and @samp{fsync-disable? #f}. | |
11104 | Defaults to @samp{#f}. | |
11105 | @end deftypevr | |
11106 | ||
11107 | @deftypevr {@code{dovecot-configuration} parameter} string lock-method | |
11108 | Locking method for index files. Alternatives are fcntl, flock and | |
11109 | dotlock. Dotlocking uses some tricks which may create more disk I/O | |
11110 | than other locking methods. NFS users: flock doesn't work, remember to | |
11111 | change @samp{mmap-disable}. | |
11112 | Defaults to @samp{"fcntl"}. | |
11113 | @end deftypevr | |
11114 | ||
11115 | @deftypevr {@code{dovecot-configuration} parameter} file-name mail-temp-dir | |
11116 | Directory in which LDA/LMTP temporarily stores incoming mails >128 | |
11117 | kB. | |
11118 | Defaults to @samp{"/tmp"}. | |
11119 | @end deftypevr | |
11120 | ||
11121 | @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer first-valid-uid | |
11122 | Valid UID range for users. This is mostly to make sure that users can't | |
11123 | log in as daemons or other system users. Note that denying root logins is | |
11124 | hardcoded to dovecot binary and can't be done even if @samp{first-valid-uid} | |
11125 | is set to 0. | |
11126 | Defaults to @samp{500}. | |
11127 | @end deftypevr | |
11128 | ||
11129 | @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer last-valid-uid | |
11130 | ||
11131 | Defaults to @samp{0}. | |
11132 | @end deftypevr | |
11133 | ||
11134 | @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer first-valid-gid | |
11135 | Valid GID range for users. Users having non-valid GID as primary group ID | |
11136 | aren't allowed to log in. If user belongs to supplementary groups with | |
11137 | non-valid GIDs, those groups are not set. | |
11138 | Defaults to @samp{1}. | |
11139 | @end deftypevr | |
11140 | ||
11141 | @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer last-valid-gid | |
11142 | ||
11143 | Defaults to @samp{0}. | |
11144 | @end deftypevr | |
11145 | ||
11146 | @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mail-max-keyword-length | |
11147 | Maximum allowed length for mail keyword name. It's only forced when | |
11148 | trying to create new keywords. | |
11149 | Defaults to @samp{50}. | |
11150 | @end deftypevr | |
11151 | ||
11152 | @deftypevr {@code{dovecot-configuration} parameter} colon-separated-file-name-list valid-chroot-dirs | |
11153 | List of directories under which chrooting is allowed for mail | |
11154 | processes (i.e. /var/mail will allow chrooting to /var/mail/foo/bar | |
11155 | too). This setting doesn't affect @samp{login-chroot} | |
11156 | @samp{mail-chroot} or auth chroot settings. If this setting is empty, | |
11157 | "/./" in home dirs are ignored. WARNING: Never add directories here | |
11158 | which local users can modify, that may lead to root exploit. Usually | |
11159 | this should be done only if you don't allow shell access for users. | |
11160 | <doc/wiki/Chrooting.txt>. | |
11161 | Defaults to @samp{()}. | |
11162 | @end deftypevr | |
11163 | ||
11164 | @deftypevr {@code{dovecot-configuration} parameter} string mail-chroot | |
11165 | Default chroot directory for mail processes. This can be overridden | |
11166 | for specific users in user database by giving /./ in user's home | |
11167 | directory (e.g. /home/./user chroots into /home). Note that usually | |
11168 | there is no real need to do chrooting, Dovecot doesn't allow users to | |
11169 | access files outside their mail directory anyway. If your home | |
11170 | directories are prefixed with the chroot directory, append "/." to | |
11171 | @samp{mail-chroot}. <doc/wiki/Chrooting.txt>. | |
11172 | Defaults to @samp{""}. | |
11173 | @end deftypevr | |
11174 | ||
11175 | @deftypevr {@code{dovecot-configuration} parameter} file-name auth-socket-path | |
11176 | UNIX socket path to master authentication server to find users. | |
11177 | This is used by imap (for shared users) and lda. | |
11178 | Defaults to @samp{"/var/run/dovecot/auth-userdb"}. | |
11179 | @end deftypevr | |
11180 | ||
11181 | @deftypevr {@code{dovecot-configuration} parameter} file-name mail-plugin-dir | |
11182 | Directory where to look up mail plugins. | |
11183 | Defaults to @samp{"/usr/lib/dovecot"}. | |
11184 | @end deftypevr | |
11185 | ||
11186 | @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list mail-plugins | |
11187 | List of plugins to load for all services. Plugins specific to IMAP, | |
11188 | LDA, etc. are added to this list in their own .conf files. | |
11189 | Defaults to @samp{()}. | |
11190 | @end deftypevr | |
11191 | ||
11192 | @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mail-cache-min-mail-count | |
11193 | The minimum number of mails in a mailbox before updates are done to | |
11194 | cache file. This allows optimizing Dovecot's behavior to do less disk | |
11195 | writes at the cost of more disk reads. | |
11196 | Defaults to @samp{0}. | |
11197 | @end deftypevr | |
11198 | ||
11199 | @deftypevr {@code{dovecot-configuration} parameter} string mailbox-idle-check-interval | |
11200 | When IDLE command is running, mailbox is checked once in a while to | |
11201 | see if there are any new mails or other changes. This setting defines | |
11202 | the minimum time to wait between those checks. Dovecot can also use | |
11203 | dnotify, inotify and kqueue to find out immediately when changes | |
11204 | occur. | |
11205 | Defaults to @samp{"30 secs"}. | |
11206 | @end deftypevr | |
11207 | ||
11208 | @deftypevr {@code{dovecot-configuration} parameter} boolean mail-save-crlf? | |
11209 | Save mails with CR+LF instead of plain LF. This makes sending those | |
11210 | mails take less CPU, especially with sendfile() syscall with Linux and | |
11211 | FreeBSD. But it also creates a bit more disk I/O which may just make it | |
11212 | slower. Also note that if other software reads the mboxes/maildirs, | |
11213 | they may handle the extra CRs wrong and cause problems. | |
11214 | Defaults to @samp{#f}. | |
11215 | @end deftypevr | |
11216 | ||
11217 | @deftypevr {@code{dovecot-configuration} parameter} boolean maildir-stat-dirs? | |
11218 | By default LIST command returns all entries in maildir beginning | |
11219 | with a dot. Enabling this option makes Dovecot return only entries | |
11220 | which are directories. This is done by stat()ing each entry, so it | |
11221 | causes more disk I/O. | |
11222 | (For systems setting struct @samp{dirent->d_type} this check is free | |
11223 | and it's done always regardless of this setting). | |
11224 | Defaults to @samp{#f}. | |
11225 | @end deftypevr | |
11226 | ||
11227 | @deftypevr {@code{dovecot-configuration} parameter} boolean maildir-copy-with-hardlinks? | |
11228 | When copying a message, do it with hard links whenever possible. | |
11229 | This makes the performance much better, and it's unlikely to have any | |
11230 | side effects. | |
11231 | Defaults to @samp{#t}. | |
11232 | @end deftypevr | |
11233 | ||
11234 | @deftypevr {@code{dovecot-configuration} parameter} boolean maildir-very-dirty-syncs? | |
11235 | Assume Dovecot is the only MUA accessing Maildir: Scan cur/ | |
11236 | directory only when its mtime changes unexpectedly or when we can't find | |
11237 | the mail otherwise. | |
11238 | Defaults to @samp{#f}. | |
11239 | @end deftypevr | |
11240 | ||
11241 | @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list mbox-read-locks | |
11242 | Which locking methods to use for locking mbox. There are four | |
11243 | available: | |
11244 | ||
11245 | @table @code | |
11246 | @item dotlock | |
11247 | Create <mailbox>.lock file. This is the oldest and most NFS-safe | |
11248 | solution. If you want to use /var/mail/ like directory, the users will | |
11249 | need write access to that directory. | |
11250 | @item dotlock-try | |
11251 | Same as dotlock, but if it fails because of permissions or because there | |
11252 | isn't enough disk space, just skip it. | |
11253 | @item fcntl | |
11254 | Use this if possible. Works with NFS too if lockd is used. | |
11255 | @item flock | |
a01ad638 | 11256 | May not exist in all systems. Doesn't work with NFS. |
d8c18af8 AW |
11257 | @item lockf |
11258 | May not exist in all systems. Doesn't work with NFS. | |
11259 | @end table | |
11260 | ||
11261 | You can use multiple locking methods; if you do the order they're declared | |
11262 | in is important to avoid deadlocks if other MTAs/MUAs are using multiple | |
11263 | locking methods as well. Some operating systems don't allow using some of | |
11264 | them simultaneously. | |
11265 | @end deftypevr | |
11266 | ||
11267 | @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list mbox-write-locks | |
11268 | ||
11269 | @end deftypevr | |
11270 | ||
11271 | @deftypevr {@code{dovecot-configuration} parameter} string mbox-lock-timeout | |
11272 | Maximum time to wait for lock (all of them) before aborting. | |
11273 | Defaults to @samp{"5 mins"}. | |
11274 | @end deftypevr | |
11275 | ||
11276 | @deftypevr {@code{dovecot-configuration} parameter} string mbox-dotlock-change-timeout | |
11277 | If dotlock exists but the mailbox isn't modified in any way, | |
11278 | override the lock file after this much time. | |
11279 | Defaults to @samp{"2 mins"}. | |
11280 | @end deftypevr | |
11281 | ||
11282 | @deftypevr {@code{dovecot-configuration} parameter} boolean mbox-dirty-syncs? | |
11283 | When mbox changes unexpectedly we have to fully read it to find out | |
11284 | what changed. If the mbox is large this can take a long time. Since | |
11285 | the change is usually just a newly appended mail, it'd be faster to | |
11286 | simply read the new mails. If this setting is enabled, Dovecot does | |
11287 | this but still safely fallbacks to re-reading the whole mbox file | |
11288 | whenever something in mbox isn't how it's expected to be. The only real | |
11289 | downside to this setting is that if some other MUA changes message | |
11290 | flags, Dovecot doesn't notice it immediately. Note that a full sync is | |
11291 | done with SELECT, EXAMINE, EXPUNGE and CHECK commands. | |
11292 | Defaults to @samp{#t}. | |
11293 | @end deftypevr | |
11294 | ||
11295 | @deftypevr {@code{dovecot-configuration} parameter} boolean mbox-very-dirty-syncs? | |
11296 | Like @samp{mbox-dirty-syncs}, but don't do full syncs even with SELECT, | |
11297 | EXAMINE, EXPUNGE or CHECK commands. If this is set, | |
11298 | @samp{mbox-dirty-syncs} is ignored. | |
11299 | Defaults to @samp{#f}. | |
11300 | @end deftypevr | |
11301 | ||
11302 | @deftypevr {@code{dovecot-configuration} parameter} boolean mbox-lazy-writes? | |
11303 | Delay writing mbox headers until doing a full write sync (EXPUNGE | |
11304 | and CHECK commands and when closing the mailbox). This is especially | |
11305 | useful for POP3 where clients often delete all mails. The downside is | |
11306 | that our changes aren't immediately visible to other MUAs. | |
11307 | Defaults to @samp{#t}. | |
11308 | @end deftypevr | |
11309 | ||
11310 | @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mbox-min-index-size | |
11311 | If mbox size is smaller than this (e.g. 100k), don't write index | |
11312 | files. If an index file already exists it's still read, just not | |
11313 | updated. | |
11314 | Defaults to @samp{0}. | |
11315 | @end deftypevr | |
11316 | ||
11317 | @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mdbox-rotate-size | |
11318 | Maximum dbox file size until it's rotated. | |
11319 | Defaults to @samp{2000000}. | |
11320 | @end deftypevr | |
11321 | ||
11322 | @deftypevr {@code{dovecot-configuration} parameter} string mdbox-rotate-interval | |
11323 | Maximum dbox file age until it's rotated. Typically in days. Day | |
11324 | begins from midnight, so 1d = today, 2d = yesterday, etc. 0 = check | |
11325 | disabled. | |
11326 | Defaults to @samp{"1d"}. | |
11327 | @end deftypevr | |
11328 | ||
11329 | @deftypevr {@code{dovecot-configuration} parameter} boolean mdbox-preallocate-space? | |
11330 | When creating new mdbox files, immediately preallocate their size to | |
11331 | @samp{mdbox-rotate-size}. This setting currently works only in Linux | |
8f65585b | 11332 | with some file systems (ext4, xfs). |
d8c18af8 AW |
11333 | Defaults to @samp{#f}. |
11334 | @end deftypevr | |
11335 | ||
11336 | @deftypevr {@code{dovecot-configuration} parameter} string mail-attachment-dir | |
11337 | sdbox and mdbox support saving mail attachments to external files, | |
11338 | which also allows single instance storage for them. Other backends | |
11339 | don't support this for now. | |
11340 | ||
11341 | WARNING: This feature hasn't been tested much yet. Use at your own risk. | |
11342 | ||
11343 | Directory root where to store mail attachments. Disabled, if empty. | |
11344 | Defaults to @samp{""}. | |
11345 | @end deftypevr | |
11346 | ||
11347 | @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mail-attachment-min-size | |
11348 | Attachments smaller than this aren't saved externally. It's also | |
11349 | possible to write a plugin to disable saving specific attachments | |
11350 | externally. | |
11351 | Defaults to @samp{128000}. | |
11352 | @end deftypevr | |
11353 | ||
11354 | @deftypevr {@code{dovecot-configuration} parameter} string mail-attachment-fs | |
8f65585b | 11355 | File system backend to use for saving attachments: |
d8c18af8 AW |
11356 | @table @code |
11357 | @item posix | |
11358 | No SiS done by Dovecot (but this might help FS's own deduplication) | |
11359 | @item sis posix | |
11360 | SiS with immediate byte-by-byte comparison during saving | |
11361 | @item sis-queue posix | |
11362 | SiS with delayed comparison and deduplication. | |
11363 | @end table | |
11364 | Defaults to @samp{"sis posix"}. | |
11365 | @end deftypevr | |
11366 | ||
11367 | @deftypevr {@code{dovecot-configuration} parameter} string mail-attachment-hash | |
11368 | Hash format to use in attachment filenames. You can add any text and | |
11369 | variables: @code{%@{md4@}}, @code{%@{md5@}}, @code{%@{sha1@}}, | |
11370 | @code{%@{sha256@}}, @code{%@{sha512@}}, @code{%@{size@}}. Variables can be | |
11371 | truncated, e.g. @code{%@{sha256:80@}} returns only first 80 bits. | |
11372 | Defaults to @samp{"%@{sha1@}"}. | |
11373 | @end deftypevr | |
11374 | ||
11375 | @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer default-process-limit | |
11376 | ||
11377 | Defaults to @samp{100}. | |
11378 | @end deftypevr | |
11379 | ||
11380 | @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer default-client-limit | |
11381 | ||
11382 | Defaults to @samp{1000}. | |
11383 | @end deftypevr | |
11384 | ||
11385 | @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer default-vsz-limit | |
11386 | Default VSZ (virtual memory size) limit for service processes. | |
11387 | This is mainly intended to catch and kill processes that leak memory | |
11388 | before they eat up everything. | |
11389 | Defaults to @samp{256000000}. | |
11390 | @end deftypevr | |
11391 | ||
11392 | @deftypevr {@code{dovecot-configuration} parameter} string default-login-user | |
11393 | Login user is internally used by login processes. This is the most | |
11394 | untrusted user in Dovecot system. It shouldn't have access to anything | |
11395 | at all. | |
11396 | Defaults to @samp{"dovenull"}. | |
11397 | @end deftypevr | |
11398 | ||
11399 | @deftypevr {@code{dovecot-configuration} parameter} string default-internal-user | |
11400 | Internal user is used by unprivileged processes. It should be | |
11401 | separate from login user, so that login processes can't disturb other | |
11402 | processes. | |
11403 | Defaults to @samp{"dovecot"}. | |
11404 | @end deftypevr | |
11405 | ||
11406 | @deftypevr {@code{dovecot-configuration} parameter} string ssl? | |
11407 | SSL/TLS support: yes, no, required. <doc/wiki/SSL.txt>. | |
11408 | Defaults to @samp{"required"}. | |
11409 | @end deftypevr | |
11410 | ||
11411 | @deftypevr {@code{dovecot-configuration} parameter} string ssl-cert | |
11412 | PEM encoded X.509 SSL/TLS certificate (public key). | |
11413 | Defaults to @samp{"</etc/dovecot/default.pem"}. | |
11414 | @end deftypevr | |
11415 | ||
11416 | @deftypevr {@code{dovecot-configuration} parameter} string ssl-key | |
11417 | PEM encoded SSL/TLS private key. The key is opened before | |
11418 | dropping root privileges, so keep the key file unreadable by anyone but | |
11419 | root. | |
11420 | Defaults to @samp{"</etc/dovecot/private/default.pem"}. | |
11421 | @end deftypevr | |
11422 | ||
11423 | @deftypevr {@code{dovecot-configuration} parameter} string ssl-key-password | |
11424 | If key file is password protected, give the password here. | |
11425 | Alternatively give it when starting dovecot with -p parameter. Since | |
11426 | this file is often world-readable, you may want to place this setting | |
11427 | instead to a different. | |
11428 | Defaults to @samp{""}. | |
11429 | @end deftypevr | |
11430 | ||
11431 | @deftypevr {@code{dovecot-configuration} parameter} string ssl-ca | |
11432 | PEM encoded trusted certificate authority. Set this only if you | |
11433 | intend to use @samp{ssl-verify-client-cert? #t}. The file should | |
11434 | contain the CA certificate(s) followed by the matching | |
11435 | CRL(s). (e.g. @samp{ssl-ca </etc/ssl/certs/ca.pem}). | |
11436 | Defaults to @samp{""}. | |
11437 | @end deftypevr | |
11438 | ||
11439 | @deftypevr {@code{dovecot-configuration} parameter} boolean ssl-require-crl? | |
11440 | Require that CRL check succeeds for client certificates. | |
11441 | Defaults to @samp{#t}. | |
11442 | @end deftypevr | |
11443 | ||
11444 | @deftypevr {@code{dovecot-configuration} parameter} boolean ssl-verify-client-cert? | |
11445 | Request client to send a certificate. If you also want to require | |
11446 | it, set @samp{auth-ssl-require-client-cert? #t} in auth section. | |
11447 | Defaults to @samp{#f}. | |
11448 | @end deftypevr | |
11449 | ||
11450 | @deftypevr {@code{dovecot-configuration} parameter} string ssl-cert-username-field | |
11451 | Which field from certificate to use for username. commonName and | |
11452 | x500UniqueIdentifier are the usual choices. You'll also need to set | |
11453 | @samp{auth-ssl-username-from-cert? #t}. | |
11454 | Defaults to @samp{"commonName"}. | |
11455 | @end deftypevr | |
11456 | ||
11457 | @deftypevr {@code{dovecot-configuration} parameter} hours ssl-parameters-regenerate | |
11458 | How often to regenerate the SSL parameters file. Generation is | |
11459 | quite CPU intensive operation. The value is in hours, 0 disables | |
11460 | regeneration entirely. | |
11461 | Defaults to @samp{168}. | |
11462 | @end deftypevr | |
11463 | ||
11464 | @deftypevr {@code{dovecot-configuration} parameter} string ssl-protocols | |
11465 | SSL protocols to use. | |
11466 | Defaults to @samp{"!SSLv2"}. | |
11467 | @end deftypevr | |
11468 | ||
11469 | @deftypevr {@code{dovecot-configuration} parameter} string ssl-cipher-list | |
11470 | SSL ciphers to use. | |
11471 | Defaults to @samp{"ALL:!LOW:!SSLv2:!EXP:!aNULL"}. | |
11472 | @end deftypevr | |
11473 | ||
11474 | @deftypevr {@code{dovecot-configuration} parameter} string ssl-crypto-device | |
11475 | SSL crypto device to use, for valid values run "openssl engine". | |
11476 | Defaults to @samp{""}. | |
11477 | @end deftypevr | |
11478 | ||
11479 | @deftypevr {@code{dovecot-configuration} parameter} string postmaster-address | |
11480 | Address to use when sending rejection mails. | |
66329c23 AW |
11481 | %d expands to recipient domain. |
11482 | Defaults to @samp{"postmaster@@%d"}. | |
d8c18af8 AW |
11483 | @end deftypevr |
11484 | ||
11485 | @deftypevr {@code{dovecot-configuration} parameter} string hostname | |
11486 | Hostname to use in various parts of sent mails (e.g. in Message-Id) | |
11487 | and in LMTP replies. Default is the system's real hostname@@domain. | |
11488 | Defaults to @samp{""}. | |
11489 | @end deftypevr | |
11490 | ||
11491 | @deftypevr {@code{dovecot-configuration} parameter} boolean quota-full-tempfail? | |
11492 | If user is over quota, return with temporary failure instead of | |
11493 | bouncing the mail. | |
11494 | Defaults to @samp{#f}. | |
11495 | @end deftypevr | |
11496 | ||
11497 | @deftypevr {@code{dovecot-configuration} parameter} file-name sendmail-path | |
11498 | Binary to use for sending mails. | |
11499 | Defaults to @samp{"/usr/sbin/sendmail"}. | |
11500 | @end deftypevr | |
11501 | ||
11502 | @deftypevr {@code{dovecot-configuration} parameter} string submission-host | |
11503 | If non-empty, send mails via this SMTP host[:port] instead of | |
11504 | sendmail. | |
11505 | Defaults to @samp{""}. | |
11506 | @end deftypevr | |
11507 | ||
11508 | @deftypevr {@code{dovecot-configuration} parameter} string rejection-subject | |
11509 | Subject: header to use for rejection mails. You can use the same | |
11510 | variables as for @samp{rejection-reason} below. | |
11511 | Defaults to @samp{"Rejected: %s"}. | |
11512 | @end deftypevr | |
11513 | ||
11514 | @deftypevr {@code{dovecot-configuration} parameter} string rejection-reason | |
11515 | Human readable error message for rejection mails. You can use | |
11516 | variables: | |
11517 | ||
11518 | @table @code | |
11519 | @item %n | |
11520 | CRLF | |
11521 | @item %r | |
11522 | reason | |
11523 | @item %s | |
11524 | original subject | |
11525 | @item %t | |
11526 | recipient | |
11527 | @end table | |
11528 | Defaults to @samp{"Your message to <%t> was automatically rejected:%n%r"}. | |
11529 | @end deftypevr | |
11530 | ||
11531 | @deftypevr {@code{dovecot-configuration} parameter} string recipient-delimiter | |
11532 | Delimiter character between local-part and detail in email | |
11533 | address. | |
11534 | Defaults to @samp{"+"}. | |
11535 | @end deftypevr | |
11536 | ||
11537 | @deftypevr {@code{dovecot-configuration} parameter} string lda-original-recipient-header | |
11538 | Header where the original recipient address (SMTP's RCPT TO: | |
11539 | address) is taken from if not available elsewhere. With dovecot-lda -a | |
11540 | parameter overrides this. A commonly used header for this is | |
11541 | X-Original-To. | |
11542 | Defaults to @samp{""}. | |
11543 | @end deftypevr | |
11544 | ||
11545 | @deftypevr {@code{dovecot-configuration} parameter} boolean lda-mailbox-autocreate? | |
11546 | Should saving a mail to a nonexistent mailbox automatically create | |
11547 | it?. | |
11548 | Defaults to @samp{#f}. | |
11549 | @end deftypevr | |
11550 | ||
11551 | @deftypevr {@code{dovecot-configuration} parameter} boolean lda-mailbox-autosubscribe? | |
11552 | Should automatically created mailboxes be also automatically | |
11553 | subscribed?. | |
11554 | Defaults to @samp{#f}. | |
11555 | @end deftypevr | |
11556 | ||
11557 | @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer imap-max-line-length | |
11558 | Maximum IMAP command line length. Some clients generate very long | |
11559 | command lines with huge mailboxes, so you may need to raise this if you | |
11560 | get "Too long argument" or "IMAP command line too large" errors | |
11561 | often. | |
11562 | Defaults to @samp{64000}. | |
11563 | @end deftypevr | |
11564 | ||
11565 | @deftypevr {@code{dovecot-configuration} parameter} string imap-logout-format | |
11566 | IMAP logout format string: | |
11567 | @table @code | |
11568 | @item %i | |
11569 | total number of bytes read from client | |
11570 | @item %o | |
11571 | total number of bytes sent to client. | |
11572 | @end table | |
11573 | Defaults to @samp{"in=%i out=%o"}. | |
11574 | @end deftypevr | |
11575 | ||
11576 | @deftypevr {@code{dovecot-configuration} parameter} string imap-capability | |
11577 | Override the IMAP CAPABILITY response. If the value begins with '+', | |
11578 | add the given capabilities on top of the defaults (e.g. +XFOO XBAR). | |
11579 | Defaults to @samp{""}. | |
11580 | @end deftypevr | |
11581 | ||
11582 | @deftypevr {@code{dovecot-configuration} parameter} string imap-idle-notify-interval | |
11583 | How long to wait between "OK Still here" notifications when client | |
11584 | is IDLEing. | |
11585 | Defaults to @samp{"2 mins"}. | |
11586 | @end deftypevr | |
11587 | ||
11588 | @deftypevr {@code{dovecot-configuration} parameter} string imap-id-send | |
11589 | ID field names and values to send to clients. Using * as the value | |
11590 | makes Dovecot use the default value. The following fields have default | |
11591 | values currently: name, version, os, os-version, support-url, | |
11592 | support-email. | |
11593 | Defaults to @samp{""}. | |
11594 | @end deftypevr | |
11595 | ||
11596 | @deftypevr {@code{dovecot-configuration} parameter} string imap-id-log | |
11597 | ID fields sent by client to log. * means everything. | |
11598 | Defaults to @samp{""}. | |
11599 | @end deftypevr | |
11600 | ||
11601 | @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list imap-client-workarounds | |
11602 | Workarounds for various client bugs: | |
11603 | ||
11604 | @table @code | |
11605 | @item delay-newmail | |
11606 | Send EXISTS/RECENT new mail notifications only when replying to NOOP and | |
11607 | CHECK commands. Some clients ignore them otherwise, for example OSX | |
11608 | Mail (<v2.1). Outlook Express breaks more badly though, without this it | |
11609 | may show user "Message no longer in server" errors. Note that OE6 | |
11610 | still breaks even with this workaround if synchronization is set to | |
11611 | "Headers Only". | |
11612 | ||
11613 | @item tb-extra-mailbox-sep | |
11614 | Thunderbird gets somehow confused with LAYOUT=fs (mbox and dbox) and | |
11615 | adds extra @samp{/} suffixes to mailbox names. This option causes Dovecot to | |
11616 | ignore the extra @samp{/} instead of treating it as invalid mailbox name. | |
11617 | ||
11618 | @item tb-lsub-flags | |
11619 | Show \Noselect flags for LSUB replies with LAYOUT=fs (e.g. mbox). | |
11620 | This makes Thunderbird realize they aren't selectable and show them | |
11621 | greyed out, instead of only later giving "not selectable" popup error. | |
11622 | @end table | |
11623 | Defaults to @samp{()}. | |
11624 | @end deftypevr | |
11625 | ||
11626 | @deftypevr {@code{dovecot-configuration} parameter} string imap-urlauth-host | |
11627 | Host allowed in URLAUTH URLs sent by client. "*" allows all. | |
11628 | Defaults to @samp{""}. | |
11629 | @end deftypevr | |
11630 | ||
11631 | ||
11632 | Whew! Lots of configuration options. The nice thing about it though is | |
11633 | that GuixSD has a complete interface to Dovecot's configuration | |
11634 | language. This allows not only a nice way to declare configurations, | |
11635 | but also offers reflective capabilities as well: users can write code to | |
11636 | inspect and transform configurations from within Scheme. | |
11637 | ||
11638 | However, it could be that you just want to get a @code{dovecot.conf} up | |
11639 | and running. In that case, you can pass an | |
7414de0a | 11640 | @code{opaque-dovecot-configuration} as the @code{#:config} parameter to |
d8c18af8 AW |
11641 | @code{dovecot-service}. As its name indicates, an opaque configuration |
11642 | does not have easy reflective capabilities. | |
11643 | ||
11644 | Available @code{opaque-dovecot-configuration} fields are: | |
11645 | ||
11646 | @deftypevr {@code{opaque-dovecot-configuration} parameter} package dovecot | |
11647 | The dovecot package. | |
11648 | @end deftypevr | |
11649 | ||
11650 | @deftypevr {@code{opaque-dovecot-configuration} parameter} string string | |
11651 | The contents of the @code{dovecot.conf}, as a string. | |
11652 | @end deftypevr | |
11653 | ||
11654 | For example, if your @code{dovecot.conf} is just the empty string, you | |
11655 | could instantiate a dovecot service like this: | |
11656 | ||
11657 | @example | |
11658 | (dovecot-service #:config | |
11659 | (opaque-dovecot-configuration | |
11660 | (string ""))) | |
11661 | @end example | |
11662 | ||
f88371e8 SB |
11663 | @subsubheading OpenSMTPD Service |
11664 | ||
11665 | @deffn {Scheme Variable} opensmtpd-service-type | |
11666 | This is the type of the @uref{https://www.opensmtpd.org, OpenSMTPD} | |
11667 | service, whose value should be an @code{opensmtpd-configuration} object | |
11668 | as in this example: | |
11669 | ||
11670 | @example | |
11671 | (service opensmtpd-service-type | |
11672 | (opensmtpd-configuration | |
11673 | (config-file (local-file "./my-smtpd.conf")))) | |
11674 | @end example | |
11675 | @end deffn | |
11676 | ||
11677 | @deftp {Data Type} opensmtpd-configuration | |
11678 | Data type regresenting the configuration of opensmtpd. | |
11679 | ||
11680 | @table @asis | |
11681 | @item @code{package} (default: @var{opensmtpd}) | |
11682 | Package object of the OpenSMTPD SMTP server. | |
11683 | ||
11684 | @item @code{config-file} (default: @var{%default-opensmtpd-file}) | |
11685 | File-like object of the OpenSMTPD configuration file to use. By default | |
11686 | it listens on the loopback network interface, and allows for mail from | |
11687 | users and daemons on the local machine, as well as permitting email to | |
11688 | remote servers. Run @command{man smtpd.conf} for more information. | |
11689 | ||
11690 | @end table | |
11691 | @end deftp | |
859e367d JD |
11692 | |
11693 | @node Kerberos Services | |
11694 | @subsubsection Kerberos Services | |
11695 | @cindex Kerberos | |
11696 | ||
df31e36a | 11697 | The @code{(gnu services kerberos)} module provides services relating to |
859e367d JD |
11698 | the authentication protocol @dfn{Kerberos}. |
11699 | ||
8e3f813f JD |
11700 | @subsubheading Krb5 Service |
11701 | ||
11702 | Programs using a Kerberos client library normally | |
11703 | expect a configuration file in @file{/etc/krb5.conf}. | |
11704 | This service generates such a file from a definition provided in the | |
11705 | operating system declaration. | |
11706 | It does not cause any daemon to be started. | |
11707 | ||
11708 | No ``keytab'' files are provided by this service---you must explicitly create them. | |
11709 | This service is known to work with the MIT client library, @code{mit-krb5}. | |
11710 | Other implementations have not been tested. | |
11711 | ||
11712 | @defvr {Scheme Variable} krb5-service-type | |
11713 | A service type for Kerberos 5 clients. | |
11714 | @end defvr | |
11715 | ||
11716 | @noindent | |
11717 | Here is an example of its use: | |
11718 | @lisp | |
11719 | (service krb5-service-type | |
11720 | (krb5-configuration | |
11721 | (default-realm "EXAMPLE.COM") | |
11722 | (allow-weak-crypto? #t) | |
11723 | (realms (list | |
11724 | (krb5-realm | |
11725 | (name "EXAMPLE.COM") | |
11726 | (admin-server "groucho.example.com") | |
11727 | (kdc "karl.example.com")) | |
11728 | (krb5-realm | |
11729 | (name "ARGRX.EDU") | |
11730 | (admin-server "kerb-admin.argrx.edu") | |
11731 | (kdc "keys.argrx.edu")))))) | |
11732 | @end lisp | |
11733 | ||
11734 | @noindent | |
11735 | This example provides a Kerberos@tie{}5 client configuration which: | |
11736 | @itemize | |
11737 | @item Recognizes two realms, @i{viz:} ``EXAMPLE.COM'' and ``ARGRX.EDU'', both | |
11738 | of which have distinct administration servers and key distribution centers; | |
11739 | @item Will default to the realm ``EXAMPLE.COM'' if the realm is not explicitly | |
11740 | specified by clients; | |
11741 | @item Accepts services which only support encryption types known to be weak. | |
11742 | @end itemize | |
11743 | ||
11744 | The @code{krb5-realm} and @code{krb5-configuration} types have many fields. | |
11745 | Only the most commonly used ones are described here. | |
11746 | For a full list, and more detailed explanation of each, see the MIT | |
11747 | @uref{http://web.mit.edu/kerberos/krb5-devel/doc/admin/conf_files/krb5_conf.html,,krb5.conf} | |
11748 | documentation. | |
11749 | ||
11750 | ||
11751 | @deftp {Data Type} krb5-realm | |
11752 | @cindex realm, kerberos | |
11753 | @table @asis | |
11754 | @item @code{name} | |
11755 | This field is a string identifying the name of the realm. | |
11756 | A common convention is to use the fully qualified DNS name of your organization, | |
11757 | converted to upper case. | |
11758 | ||
11759 | @item @code{admin-server} | |
11760 | This field is a string identifying the host where the administration server is | |
11761 | running. | |
11762 | ||
11763 | @item @code{kdc} | |
11764 | This field is a string identifying the key distribution center | |
11765 | for the realm. | |
11766 | @end table | |
11767 | @end deftp | |
11768 | ||
11769 | @deftp {Data Type} krb5-configuration | |
11770 | ||
11771 | @table @asis | |
11772 | @item @code{allow-weak-crypto?} (default: @code{#f}) | |
11773 | If this flag is @code{#t} then services which only offer encryption algorithms | |
11774 | known to be weak will be accepted. | |
11775 | ||
11776 | @item @code{default-realm} (default: @code{#f}) | |
11777 | This field should be a string identifying the default Kerberos | |
11778 | realm for the client. | |
11779 | You should set this field to the name of your Kerberos realm. | |
11780 | If this value is @code{#f} | |
11781 | then a realm must be specified with every Kerberos principal when invoking programs | |
11782 | such as @command{kinit}. | |
11783 | ||
11784 | @item @code{realms} | |
11785 | This should be a non-empty list of @code{krb5-realm} objects, which clients may | |
11786 | access. | |
11787 | Normally, one of them will have a @code{name} field matching the @code{default-realm} | |
11788 | field. | |
11789 | @end table | |
11790 | @end deftp | |
11791 | ||
11792 | ||
859e367d JD |
11793 | @subsubheading PAM krb5 Service |
11794 | @cindex pam-krb5 | |
11795 | ||
df31e36a | 11796 | The @code{pam-krb5} service allows for login authentication and password |
859e367d JD |
11797 | management via Kerberos. |
11798 | You will need this service if you want PAM enabled applications to authenticate | |
11799 | users using Kerberos. | |
11800 | ||
11801 | @defvr {Scheme Variable} pam-krb5-service-type | |
11802 | A service type for the Kerberos 5 PAM module. | |
11803 | @end defvr | |
11804 | ||
11805 | @deftp {Data Type} pam-krb5-configuration | |
11806 | Data type representing the configuration of the Kerberos 5 PAM module | |
11807 | This type has the following parameters: | |
11808 | @table @asis | |
11809 | @item @code{pam-krb5} (default: @code{pam-krb5}) | |
11810 | The pam-krb5 package to use. | |
11811 | ||
11812 | @item @code{minimum-uid} (default: @code{1000}) | |
11813 | The smallest user ID for which Kerberos authentications should be attempted. | |
11814 | Local accounts with lower values will silently fail to authenticate. | |
11815 | @end table | |
11816 | @end deftp | |
11817 | ||
11818 | ||
58724c48 DT |
11819 | @node Web Services |
11820 | @subsubsection Web Services | |
11821 | ||
e32171ee JD |
11822 | @cindex web |
11823 | @cindex www | |
11824 | @cindex HTTP | |
58724c48 DT |
11825 | The @code{(gnu services web)} module provides the following service: |
11826 | ||
be1c2c54 | 11827 | @deffn {Scheme Procedure} nginx-service [#:nginx nginx] @ |
58724c48 DT |
11828 | [#:log-directory ``/var/log/nginx''] @ |
11829 | [#:run-directory ``/var/run/nginx''] @ | |
8c00b838 | 11830 | [#:vhost-list (list (nginx-vhost-configuration))] @ |
58724c48 DT |
11831 | [#:config-file] |
11832 | ||
11833 | Return a service that runs @var{nginx}, the nginx web server. | |
11834 | ||
11835 | The nginx daemon loads its runtime configuration from @var{config-file}. | |
11836 | Log files are written to @var{log-directory} and temporary runtime data | |
11837 | files are written to @var{run-directory}. For proper operation, these | |
11838 | arguments should match what is in @var{config-file} to ensure that the | |
11839 | directories are created when the service is activated. | |
11840 | ||
8c00b838 JL |
11841 | As an alternative to using a @var{config-file}, @var{vhost-list} can be |
11842 | used to specify the list of @dfn{virtual hosts} required on the host. For | |
11843 | this to work, use the default value for @var{config-file}. | |
11844 | ||
58724c48 DT |
11845 | @end deffn |
11846 | ||
8c00b838 JL |
11847 | @deftp {Data Type} nginx-vhost-configuration |
11848 | Data type representing the configuration of an nginx virtual host. | |
11849 | This type has the following parameters: | |
11850 | ||
11851 | @table @asis | |
11852 | @item @code{http-port} (default: @code{80}) | |
11853 | Nginx will listen for HTTP connection on this port. Set it at @code{#f} if | |
11854 | nginx should not listen for HTTP (non secure) connection for this | |
11855 | @dfn{virtual host}. | |
11856 | ||
11857 | @item @code{https-port} (default: @code{443}) | |
11858 | Nginx will listen for HTTPS connection on this port. Set it at @code{#f} if | |
11859 | nginx should not listen for HTTPS (secure) connection for this @dfn{virtual host}. | |
11860 | ||
11861 | Note that nginx can listen for HTTP and HTTPS connections in the same | |
11862 | @dfn{virtual host}. | |
11863 | ||
11864 | @item @code{server-name} (default: @code{(list 'default)}) | |
11865 | A list of server names this vhost represents. @code{'default} represents the | |
11866 | default vhost for connections matching no other vhost. | |
11867 | ||
11868 | @item @code{root} (default: @code{"/srv/http"}) | |
11869 | Root of the website nginx will serve. | |
11870 | ||
11871 | @item @code{index} (default: @code{(list "index.html")}) | |
11872 | Index files to look for when clients ask for a directory. If it cannot be found, | |
11873 | Nginx will send the list of files in the directory. | |
11874 | ||
11875 | @item @code{ssl-certificate} (default: @code{"/etc/nginx/cert.pem"}) | |
11876 | Where to find the certificate for secure connections. Set it to @code{#f} if | |
11877 | you don't have a certificate or you don't want to use HTTPS. | |
11878 | ||
11879 | @item @code{ssl-certificate-key} (default: @code{"/etc/nginx/key.pem"}) | |
11880 | Where to find the private key for secure connections. Set it to @code{#f} if | |
11881 | you don't have a key or you don't want to use HTTPS. | |
11882 | ||
11883 | @item @code{server-tokens?} (default: @code{#f}) | |
11884 | Whether the server should add its configuration to response. | |
11885 | ||
11886 | @end table | |
11887 | @end deftp | |
11888 | ||
eb419bc9 JD |
11889 | @node Network File System |
11890 | @subsubsection Network File System | |
11891 | @cindex NFS | |
fe1a39d3 | 11892 | |
eb419bc9 JD |
11893 | The @code{(gnu services nfs)} module provides the following services, |
11894 | which are most commonly used in relation to mounting or exporting | |
11895 | directory trees as @dfn{network file systems} (NFS). | |
d6a07ee6 JD |
11896 | |
11897 | @subsubheading RPC Bind Service | |
11898 | @cindex rpcbind | |
11899 | ||
eb419bc9 JD |
11900 | The RPC Bind service provides a facility to map program numbers into |
11901 | universal addresses. | |
11902 | Many NFS related services use this facility. Hence it is automatically | |
11903 | started when a dependent service starts. | |
d6a07ee6 JD |
11904 | |
11905 | @defvr {Scheme Variable} rpcbind-service-type | |
11906 | A service type for the RPC portmapper daemon. | |
11907 | @end defvr | |
11908 | ||
11909 | ||
11910 | @deftp {Data Type} rpcbind-configuration | |
11911 | Data type representing the configuration of the RPC Bind Service. | |
11912 | This type has the following parameters: | |
11913 | @table @asis | |
11914 | @item @code{rpcbind} (default: @code{rpcbind}) | |
11915 | The rpcbind package to use. | |
11916 | ||
11917 | @item @code{warm-start?} (default: @code{#t}) | |
11918 | If this parameter is @code{#t}, then the daemon will read a | |
11919 | state file on startup thus reloading state information saved by a previous | |
11920 | instance. | |
11921 | @end table | |
11922 | @end deftp | |
11923 | ||
eb419bc9 JD |
11924 | |
11925 | @subsubheading Pipefs Pseudo File System | |
11926 | @cindex pipefs | |
11927 | @cindex rpc_pipefs | |
11928 | ||
11929 | The pipefs file system is used to transfer NFS related data | |
11930 | between the kernel and user space programs. | |
11931 | ||
11932 | @defvr {Scheme Variable} pipefs-service-type | |
11933 | A service type for the pipefs pseudo file system. | |
11934 | @end defvr | |
11935 | ||
11936 | @deftp {Data Type} pipefs-configuration | |
11937 | Data type representing the configuration of the pipefs pseudo file system service. | |
11938 | This type has the following parameters: | |
11939 | @table @asis | |
11940 | @item @code{mount-point} (default: @code{"/var/lib/nfs/rpc_pipefs"}) | |
11941 | The directory to which the file system is to be attached. | |
11942 | @end table | |
11943 | @end deftp | |
11944 | ||
11945 | ||
11946 | @subsubheading GSS Daemon Service | |
11947 | @cindex GSSD | |
11948 | @cindex GSS | |
11949 | @cindex global security system | |
11950 | ||
11951 | The @dfn{global security system} (GSS) daemon provides strong security for RPC | |
11952 | based protocols. | |
11953 | Before exchanging RPC requests an RPC client must establish a security | |
11954 | context. Typically this is done using the Kerberos command @command{kinit} | |
859e367d | 11955 | or automatically at login time using PAM services (@pxref{Kerberos Services}). |
eb419bc9 JD |
11956 | |
11957 | @defvr {Scheme Variable} gss-service-type | |
11958 | A service type for the Global Security System (GSS) daemon. | |
11959 | @end defvr | |
11960 | ||
11961 | @deftp {Data Type} gss-configuration | |
11962 | Data type representing the configuration of the GSS daemon service. | |
11963 | This type has the following parameters: | |
11964 | @table @asis | |
11965 | @item @code{nfs-utils} (default: @code{nfs-utils}) | |
11966 | The package in which the @command{rpc.gssd} command is to be found. | |
11967 | ||
11968 | @item @code{pipefs-directory} (default: @code{"/var/lib/nfs/rpc_pipefs"}) | |
11969 | The directory where the pipefs file system is mounted. | |
11970 | ||
11971 | @end table | |
11972 | @end deftp | |
11973 | ||
11974 | ||
11975 | @subsubheading IDMAP Daemon Service | |
11976 | @cindex idmapd | |
11977 | @cindex name mapper | |
11978 | ||
11979 | The idmap daemon service provides mapping between user IDs and user names. | |
11980 | Typically it is required in order to access file systems mounted via NFSv4. | |
11981 | ||
11982 | @defvr {Scheme Variable} idmap-service-type | |
11983 | A service type for the Identity Mapper (IDMAP) daemon. | |
11984 | @end defvr | |
11985 | ||
11986 | @deftp {Data Type} idmap-configuration | |
11987 | Data type representing the configuration of the IDMAP daemon service. | |
11988 | This type has the following parameters: | |
11989 | @table @asis | |
11990 | @item @code{nfs-utils} (default: @code{nfs-utils}) | |
11991 | The package in which the @command{rpc.idmapd} command is to be found. | |
11992 | ||
11993 | @item @code{pipefs-directory} (default: @code{"/var/lib/nfs/rpc_pipefs"}) | |
11994 | The directory where the pipefs file system is mounted. | |
11995 | ||
11996 | @item @code{domain} (default: @code{#f}) | |
11997 | The local NFSv4 domain name. | |
11998 | This must be a string or @code{#f}. | |
11999 | If it is @code{#f} then the daemon will use the host's fully qualified domain name. | |
12000 | ||
12001 | @end table | |
12002 | @end deftp | |
12003 | ||
a7cf4eb6 ML |
12004 | @node Continuous Integration |
12005 | @subsubsection Continuous Integration | |
12006 | ||
12007 | @cindex continuous integration | |
12008 | @uref{https://notabug.org/mthl/cuirass, Cuirass} is a continuous | |
12009 | integration tool for Guix. It can be used both for development and for | |
12010 | providing substitutes to others (@pxref{Substitutes}). | |
12011 | ||
12012 | The @code{(gnu services cuirass)} module provides the following service. | |
12013 | ||
231eddc8 LC |
12014 | @defvr {Scheme Procedure} cuirass-service-type |
12015 | The type of the Cuirass service. Its value must be a | |
12016 | @code{cuirass-configuration} object, as described below. | |
12017 | @end defvr | |
a7cf4eb6 | 12018 | |
231eddc8 LC |
12019 | To add build jobs, you have to set the @code{specifications} field of |
12020 | the configuration. Here is an example of a service defining a build job | |
12021 | based on a specification that can be found in Cuirass source tree. This | |
12022 | service polls the Guix repository and builds a subset of the Guix | |
12023 | packages, as prescribed in the @file{gnu-system.scm} example spec: | |
a7cf4eb6 ML |
12024 | |
12025 | @example | |
8de938d5 LC |
12026 | (let ((spec #~((#:name . "guix") |
12027 | (#:url . "git://git.savannah.gnu.org/guix.git") | |
12028 | (#:load-path . ".") | |
12029 | ||
12030 | ;; Here we must provide an absolute file name. | |
12031 | ;; We take jobs from one of the examples provided | |
12032 | ;; by Cuirass. | |
12033 | (#:file . #$(file-append | |
12034 | cuirass | |
12035 | "/tests/gnu-system.scm")) | |
12036 | ||
12037 | (#:proc . hydra-jobs) | |
12038 | (#:arguments (subset . "hello")) | |
12039 | (#:branch . "master")))) | |
231eddc8 LC |
12040 | (service cuirass-service-type |
12041 | (cuirass-configuration | |
12042 | (specifications #~(list #$spec))))) | |
a7cf4eb6 ML |
12043 | @end example |
12044 | ||
231eddc8 | 12045 | While information related to build jobs is located directly in the |
a7cf4eb6 ML |
12046 | specifications, global settings for the @command{cuirass} process are |
12047 | accessible in other @code{cuirass-configuration} fields. | |
12048 | ||
12049 | @deftp {Data Type} cuirass-configuration | |
12050 | Data type representing the configuration of Cuirass. | |
12051 | ||
12052 | @table @asis | |
b17e326f LC |
12053 | @item @code{log-file} (default: @code{"/var/log/cuirass.log"}) |
12054 | Location of the log file. | |
12055 | ||
463995da | 12056 | @item @code{cache-directory} (default: @code{"/var/cache/cuirass"}) |
a7cf4eb6 ML |
12057 | Location of the repository cache. |
12058 | ||
12059 | @item @code{user} (default: @code{"cuirass"}) | |
12060 | Owner of the @code{cuirass} process. | |
12061 | ||
12062 | @item @code{group} (default: @code{"cuirass"}) | |
12063 | Owner's group of the @code{cuirass} process. | |
12064 | ||
12065 | @item @code{interval} (default: @code{60}) | |
12066 | Number of seconds between the poll of the repositories followed by the | |
12067 | Cuirass jobs. | |
12068 | ||
12069 | @item @code{database} (default: @code{"/var/run/cuirass/cuirass.db"}) | |
12070 | Location of sqlite database which contains the build results and previously | |
12071 | added specifications. | |
12072 | ||
8de938d5 LC |
12073 | @item @code{specifications} (default: @code{#~'()}) |
12074 | A gexp (@pxref{G-Expressions}) that evaluates to a list of specifications, | |
12075 | where a specification is an association list | |
a7cf4eb6 ML |
12076 | (@pxref{Associations Lists,,, guile, GNU Guile Reference Manual}) whose |
12077 | keys are keywords (@code{#:keyword-example}) as shown in the example | |
12078 | above. | |
12079 | ||
12080 | @item @code{use-substitutes?} (default: @code{#f}) | |
12081 | This allows using substitutes to avoid building every dependencies of a job | |
12082 | from source. | |
12083 | ||
12084 | @item @code{one-shot?} (default: @code{#f}) | |
12085 | Only evaluate specifications and build derivations once. | |
379b6ba5 LC |
12086 | |
12087 | @item @code{cuirass} (default: @code{cuirass}) | |
12088 | The Cuirass package to use. | |
a7cf4eb6 ML |
12089 | @end table |
12090 | @end deftp | |
eb419bc9 JD |
12091 | |
12092 | @node Miscellaneous Services | |
12093 | @subsubsection Miscellaneous Services | |
12094 | ||
12095 | ||
8ff4dcbe DC |
12096 | @cindex lirc |
12097 | @subsubheading Lirc Service | |
12098 | ||
fe1a39d3 LC |
12099 | The @code{(gnu services lirc)} module provides the following service. |
12100 | ||
be1c2c54 | 12101 | @deffn {Scheme Procedure} lirc-service [#:lirc lirc] @ |
fe1a39d3 LC |
12102 | [#:device #f] [#:driver #f] [#:config-file #f] @ |
12103 | [#:extra-options '()] | |
12104 | Return a service that runs @url{http://www.lirc.org,LIRC}, a daemon that | |
12105 | decodes infrared signals from remote controls. | |
12106 | ||
12107 | Optionally, @var{device}, @var{driver} and @var{config-file} | |
12108 | (configuration file name) may be specified. See @command{lircd} manual | |
12109 | for details. | |
12110 | ||
12111 | Finally, @var{extra-options} is a list of additional command-line options | |
12112 | passed to @command{lircd}. | |
12113 | @end deffn | |
12114 | ||
00f46905 DC |
12115 | @cindex spice |
12116 | @subsubheading Spice Service | |
12117 | ||
12118 | The @code{(gnu services spice)} module provides the following service. | |
12119 | ||
12120 | @deffn {Scheme Procedure} spice-vdagent-service [#:spice-vdagent] | |
12121 | Returns a service that runs @url{http://www.spice-space.org,VDAGENT}, a daemon | |
12122 | that enables sharing the clipboard with a vm and setting the guest display | |
12123 | resolution when the graphical console window resizes. | |
12124 | @end deffn | |
12125 | ||
c3d38b2b | 12126 | @subsubsection Dictionary Services |
e32171ee | 12127 | @cindex dictionary |
c3d38b2b SB |
12128 | The @code{(gnu services dict)} module provides the following service: |
12129 | ||
12130 | @deffn {Scheme Procedure} dicod-service [#:config (dicod-configuration)] | |
12131 | Return a service that runs the @command{dicod} daemon, an implementation | |
12132 | of DICT server (@pxref{Dicod,,, dico, GNU Dico Manual}). | |
12133 | ||
12134 | The optional @var{config} argument specifies the configuration for | |
12135 | @command{dicod}, which should be a @code{<dicod-configuration>} object, by | |
12136 | default it serves the GNU Collaborative International Dictonary of English. | |
12137 | ||
12138 | You can add @command{open localhost} to your @file{~/.dico} file to make | |
12139 | @code{localhost} the default server for @command{dico} client | |
12140 | (@pxref{Initialization File,,, dico, GNU Dico Manual}). | |
12141 | @end deffn | |
12142 | ||
12143 | @deftp {Data Type} dicod-configuration | |
12144 | Data type representing the configuration of dicod. | |
12145 | ||
12146 | @table @asis | |
12147 | @item @code{dico} (default: @var{dico}) | |
12148 | Package object of the GNU Dico dictionary server. | |
12149 | ||
a1b48465 LC |
12150 | @item @code{interfaces} (default: @var{'("localhost")}) |
12151 | This is the list of IP addresses and ports and possibly socket file | |
12152 | names to listen to (@pxref{Server Settings, @code{listen} directive,, | |
12153 | dico, GNU Dico Manual}). | |
12154 | ||
c3d38b2b SB |
12155 | @item @code{databases} (default: @var{(list %dicod-database:gcide)}) |
12156 | List of @code{<dicod-database>} objects denoting dictionaries to be served. | |
12157 | @end table | |
12158 | @end deftp | |
12159 | ||
12160 | @deftp {Data Type} dicod-database | |
12161 | Data type representing a dictionary database. | |
12162 | ||
12163 | @table @asis | |
12164 | @item @code{name} | |
12165 | Name of the database, will be used in DICT commands. | |
12166 | ||
12167 | @item @code{module} | |
12168 | Name of the dicod module used by this database | |
12169 | (@pxref{Modules,,, dico, GNU Dico Manual}). | |
12170 | ||
12171 | @item @code{options} | |
12172 | List of strings or gexps representing the arguments for the module handler | |
12173 | (@pxref{Handlers,,, dico, GNU Dico Manual}). | |
12174 | @end table | |
12175 | @end deftp | |
12176 | ||
12177 | @defvr {Scheme Variable} %dicod-database:gcide | |
12178 | A @code{<dicod-database>} object serving the GNU Collaborative International | |
12179 | Dictonary of English using the @code{gcide} package. | |
12180 | @end defvr | |
fe1a39d3 | 12181 | |
e01e2c6c | 12182 | @subsubsection Version Control |
12183 | ||
12184 | The @code{(gnu services version-control)} module provides the following services: | |
12185 | ||
12186 | @subsubheading Git daemon service | |
12187 | ||
12188 | @deffn {Scheme Procedure} git-daemon-service [#:config (git-daemon-configuration)] | |
12189 | ||
12190 | Return a service that runs @command{git daemon}, a simple TCP server to | |
12191 | expose repositiories over the Git protocol for annoymous access. | |
12192 | ||
12193 | The optional @var{config} argument should be a | |
12194 | @code{<git-daemon-configuration>} object, by default it allows read-only | |
12195 | access to exported@footnote{By creating the magic file | |
12196 | "git-daemon-export-ok" in the repository directory.} repositories under | |
12197 | @file{/srv/git}. | |
12198 | ||
12199 | @end deffn | |
12200 | ||
12201 | @deftp {Data Type} git-daemon-configuration | |
12202 | Data type representing the configuration for @code{git-daemon-service}. | |
12203 | ||
12204 | @table @asis | |
12205 | @item @code{package} (default: @var{git}) | |
12206 | Package object of the Git distributed version control system. | |
12207 | ||
12208 | @item @code{export-all?} (default: @var{#f}) | |
12209 | Whether to allow access for all Git repositories, even if they do not | |
12210 | have the @file{git-daemon-export-ok} file. | |
12211 | ||
12212 | @item @code{base-path} (default: @file{/srv/git}) | |
12213 | Whether to remap all the path requests as relative to the given path. | |
12214 | If you run git daemon with @var{(base-path "/srv/git")} on example.com, | |
12215 | then if you later try to pull @code{git://example.com/hello.git}, git | |
12216 | daemon will interpret the path as @code{/srv/git/hello.git}. | |
12217 | ||
12218 | @item @code{user-path} (default: @var{#f}) | |
12219 | Whether to allow @code{~user} notation to be used in requests. When | |
12220 | specified with empty string, requests to @code{git://host/~alice/foo} is | |
12221 | taken as a request to access @code{foo} repository in the home directory | |
12222 | of user @code{alice}. If @var{(user-path "path")} is specified, the | |
12223 | same request is taken as a request to access @code{path/foo} repository | |
12224 | in the home directory of user @code{alice}. | |
12225 | ||
12226 | @item @code{listen} (default: @var{'()}) | |
12227 | Whether to listen on specific IP addresses or hostnames, defaults to | |
12228 | all. | |
12229 | ||
12230 | @item @code{port} (default: @var{#f}) | |
12231 | Whether to listen on an alternative port, which defaults to 9418. | |
12232 | ||
12233 | @item @code{whitelist} (default: @var{'()}) | |
12234 | If not empty, only allow access to this list of directories. | |
12235 | ||
12236 | @item @code{extra-options} (default: @var{'()}) | |
12237 | Extra options will be passed to @code{git daemon}, please run | |
12238 | @command{man git-daemon} for more information. | |
12239 | ||
12240 | @end table | |
12241 | @end deftp | |
12242 | ||
0ae8c15a LC |
12243 | @node Setuid Programs |
12244 | @subsection Setuid Programs | |
12245 | ||
12246 | @cindex setuid programs | |
12247 | Some programs need to run with ``root'' privileges, even when they are | |
12248 | launched by unprivileged users. A notorious example is the | |
4d40227c LC |
12249 | @command{passwd} program, which users can run to change their |
12250 | password, and which needs to access the @file{/etc/passwd} and | |
0ae8c15a LC |
12251 | @file{/etc/shadow} files---something normally restricted to root, for |
12252 | obvious security reasons. To address that, these executables are | |
12253 | @dfn{setuid-root}, meaning that they always run with root privileges | |
12254 | (@pxref{How Change Persona,,, libc, The GNU C Library Reference Manual}, | |
f7e4ae7f | 12255 | for more info about the setuid mechanism.) |
0ae8c15a LC |
12256 | |
12257 | The store itself @emph{cannot} contain setuid programs: that would be a | |
12258 | security issue since any user on the system can write derivations that | |
12259 | populate the store (@pxref{The Store}). Thus, a different mechanism is | |
12260 | used: instead of changing the setuid bit directly on files that are in | |
12261 | the store, we let the system administrator @emph{declare} which programs | |
12262 | should be setuid root. | |
12263 | ||
12264 | The @code{setuid-programs} field of an @code{operating-system} | |
12265 | declaration contains a list of G-expressions denoting the names of | |
12266 | programs to be setuid-root (@pxref{Using the Configuration System}). | |
12267 | For instance, the @command{passwd} program, which is part of the Shadow | |
12268 | package, can be designated by this G-expression (@pxref{G-Expressions}): | |
12269 | ||
12270 | @example | |
12271 | #~(string-append #$shadow "/bin/passwd") | |
12272 | @end example | |
12273 | ||
12274 | A default set of setuid programs is defined by the | |
12275 | @code{%setuid-programs} variable of the @code{(gnu system)} module. | |
12276 | ||
12277 | @defvr {Scheme Variable} %setuid-programs | |
12278 | A list of G-expressions denoting common programs that are setuid-root. | |
12279 | ||
12280 | The list includes commands such as @command{passwd}, @command{ping}, | |
12281 | @command{su}, and @command{sudo}. | |
12282 | @end defvr | |
12283 | ||
12284 | Under the hood, the actual setuid programs are created in the | |
12285 | @file{/run/setuid-programs} directory at system activation time. The | |
12286 | files in this directory refer to the ``real'' binaries, which are in the | |
12287 | store. | |
12288 | ||
efb5e833 LC |
12289 | @node X.509 Certificates |
12290 | @subsection X.509 Certificates | |
12291 | ||
12292 | @cindex HTTPS, certificates | |
12293 | @cindex X.509 certificates | |
12294 | @cindex TLS | |
12295 | Web servers available over HTTPS (that is, HTTP over the transport-layer | |
12296 | security mechanism, TLS) send client programs an @dfn{X.509 certificate} | |
12297 | that the client can then use to @emph{authenticate} the server. To do | |
12298 | that, clients verify that the server's certificate is signed by a | |
12299 | so-called @dfn{certificate authority} (CA). But to verify the CA's | |
12300 | signature, clients must have first acquired the CA's certificate. | |
12301 | ||
12302 | Web browsers such as GNU@tie{}IceCat include their own set of CA | |
12303 | certificates, such that they are able to verify CA signatures | |
12304 | out-of-the-box. | |
12305 | ||
12306 | However, most other programs that can talk HTTPS---@command{wget}, | |
12307 | @command{git}, @command{w3m}, etc.---need to be told where CA | |
12308 | certificates can be found. | |
12309 | ||
12310 | @cindex @code{nss-certs} | |
12311 | In GuixSD, this is done by adding a package that provides certificates | |
12312 | to the @code{packages} field of the @code{operating-system} declaration | |
12313 | (@pxref{operating-system Reference}). GuixSD includes one such package, | |
12314 | @code{nss-certs}, which is a set of CA certificates provided as part of | |
12315 | Mozilla's Network Security Services. | |
12316 | ||
12317 | Note that it is @emph{not} part of @var{%base-packages}, so you need to | |
12318 | explicitly add it. The @file{/etc/ssl/certs} directory, which is where | |
12319 | most applications and libraries look for certificates by default, points | |
12320 | to the certificates installed globally. | |
12321 | ||
b3129f2b LC |
12322 | Unprivileged users, including users of Guix on a foreign distro, |
12323 | can also install their own certificate package in | |
efb5e833 LC |
12324 | their profile. A number of environment variables need to be defined so |
12325 | that applications and libraries know where to find them. Namely, the | |
12326 | OpenSSL library honors the @code{SSL_CERT_DIR} and @code{SSL_CERT_FILE} | |
12327 | variables. Some applications add their own environment variables; for | |
12328 | instance, the Git version control system honors the certificate bundle | |
b3129f2b LC |
12329 | pointed to by the @code{GIT_SSL_CAINFO} environment variable. Thus, you |
12330 | would typically run something like: | |
efb5e833 | 12331 | |
b3129f2b LC |
12332 | @example |
12333 | $ guix package -i nss-certs | |
12334 | $ export SSL_CERT_DIR="$HOME/.guix-profile/etc/ssl/certs" | |
12335 | $ export SSL_CERT_FILE="$HOME/.guix-profile/etc/ssl/certs/ca-certificates.crt" | |
12336 | $ export GIT_SSL_CAINFO="$SSL_CERT_FILE" | |
12337 | @end example | |
efb5e833 | 12338 | |
996ed739 LC |
12339 | @node Name Service Switch |
12340 | @subsection Name Service Switch | |
12341 | ||
12342 | @cindex name service switch | |
12343 | @cindex NSS | |
12344 | The @code{(gnu system nss)} module provides bindings to the | |
1068f26b | 12345 | configuration file of the libc @dfn{name service switch} or @dfn{NSS} |
996ed739 LC |
12346 | (@pxref{NSS Configuration File,,, libc, The GNU C Library Reference |
12347 | Manual}). In a nutshell, the NSS is a mechanism that allows libc to be | |
12348 | extended with new ``name'' lookup methods for system databases, which | |
12349 | includes host names, service names, user accounts, and more (@pxref{Name | |
12350 | Service Switch, System Databases and Name Service Switch,, libc, The GNU | |
12351 | C Library Reference Manual}). | |
12352 | ||
12353 | The NSS configuration specifies, for each system database, which lookup | |
12354 | method is to be used, and how the various methods are chained | |
12355 | together---for instance, under which circumstances NSS should try the | |
12356 | next method in the list. The NSS configuration is given in the | |
12357 | @code{name-service-switch} field of @code{operating-system} declarations | |
12358 | (@pxref{operating-system Reference, @code{name-service-switch}}). | |
12359 | ||
4c9050c6 LC |
12360 | @cindex nss-mdns |
12361 | @cindex .local, host name lookup | |
996ed739 | 12362 | As an example, the declaration below configures the NSS to use the |
4c9050c6 LC |
12363 | @uref{http://0pointer.de/lennart/projects/nss-mdns/, @code{nss-mdns} |
12364 | back-end}, which supports host name lookups over multicast DNS (mDNS) | |
12365 | for host names ending in @code{.local}: | |
996ed739 LC |
12366 | |
12367 | @example | |
12368 | (name-service-switch | |
12369 | (hosts (list %files ;first, check /etc/hosts | |
12370 | ||
12371 | ;; If the above did not succeed, try | |
12372 | ;; with 'mdns_minimal'. | |
12373 | (name-service | |
12374 | (name "mdns_minimal") | |
12375 | ||
12376 | ;; 'mdns_minimal' is authoritative for | |
12377 | ;; '.local'. When it returns "not found", | |
12378 | ;; no need to try the next methods. | |
12379 | (reaction (lookup-specification | |
12380 | (not-found => return)))) | |
12381 | ||
12382 | ;; Then fall back to DNS. | |
12383 | (name-service | |
12384 | (name "dns")) | |
12385 | ||
12386 | ;; Finally, try with the "full" 'mdns'. | |
12387 | (name-service | |
12388 | (name "mdns"))))) | |
12389 | @end example | |
12390 | ||
1068f26b AE |
12391 | Do not worry: the @code{%mdns-host-lookup-nss} variable (see below) |
12392 | contains this configuration, so you will not have to type it if all you | |
15137a29 LC |
12393 | want is to have @code{.local} host lookup working. |
12394 | ||
4c9050c6 LC |
12395 | Note that, in this case, in addition to setting the |
12396 | @code{name-service-switch} of the @code{operating-system} declaration, | |
cc9c1f39 LC |
12397 | you also need to use @code{avahi-service} (@pxref{Networking Services, |
12398 | @code{avahi-service}}), or @var{%desktop-services}, which includes it | |
12399 | (@pxref{Desktop Services}). Doing this makes @code{nss-mdns} accessible | |
12400 | to the name service cache daemon (@pxref{Base Services, | |
12401 | @code{nscd-service}}). | |
15137a29 LC |
12402 | |
12403 | For convenience, the following variables provide typical NSS | |
12404 | configurations. | |
12405 | ||
12406 | @defvr {Scheme Variable} %default-nss | |
12407 | This is the default name service switch configuration, a | |
12408 | @code{name-service-switch} object. | |
12409 | @end defvr | |
12410 | ||
12411 | @defvr {Scheme Variable} %mdns-host-lookup-nss | |
12412 | This is the name service switch configuration with support for host name | |
12413 | lookup over multicast DNS (mDNS) for host names ending in @code{.local}. | |
12414 | @end defvr | |
4c9050c6 | 12415 | |
996ed739 | 12416 | The reference for name service switch configuration is given below. It |
1068f26b | 12417 | is a direct mapping of the configuration file format of the C library , so |
996ed739 LC |
12418 | please refer to the C library manual for more information (@pxref{NSS |
12419 | Configuration File,,, libc, The GNU C Library Reference Manual}). | |
1068f26b | 12420 | Compared to the configuration file format of libc NSS, it has the advantage |
996ed739 | 12421 | not only of adding this warm parenthetic feel that we like, but also |
1068f26b | 12422 | static checks: you will know about syntax errors and typos as soon as you |
996ed739 LC |
12423 | run @command{guix system}. |
12424 | ||
996ed739 LC |
12425 | @deftp {Data Type} name-service-switch |
12426 | ||
12427 | This is the data type representation the configuration of libc's name | |
12428 | service switch (NSS). Each field below represents one of the supported | |
12429 | system databases. | |
12430 | ||
12431 | @table @code | |
12432 | @item aliases | |
12433 | @itemx ethers | |
12434 | @itemx group | |
12435 | @itemx gshadow | |
12436 | @itemx hosts | |
12437 | @itemx initgroups | |
12438 | @itemx netgroup | |
12439 | @itemx networks | |
12440 | @itemx password | |
12441 | @itemx public-key | |
12442 | @itemx rpc | |
12443 | @itemx services | |
12444 | @itemx shadow | |
12445 | The system databases handled by the NSS. Each of these fields must be a | |
1068f26b | 12446 | list of @code{<name-service>} objects (see below). |
996ed739 LC |
12447 | @end table |
12448 | @end deftp | |
12449 | ||
12450 | @deftp {Data Type} name-service | |
12451 | ||
12452 | This is the data type representing an actual name service and the | |
12453 | associated lookup action. | |
12454 | ||
12455 | @table @code | |
12456 | @item name | |
12457 | A string denoting the name service (@pxref{Services in the NSS | |
12458 | configuration,,, libc, The GNU C Library Reference Manual}). | |
12459 | ||
4aee6e60 LC |
12460 | Note that name services listed here must be visible to nscd. This is |
12461 | achieved by passing the @code{#:name-services} argument to | |
12462 | @code{nscd-service} the list of packages providing the needed name | |
12463 | services (@pxref{Base Services, @code{nscd-service}}). | |
12464 | ||
996ed739 LC |
12465 | @item reaction |
12466 | An action specified using the @code{lookup-specification} macro | |
12467 | (@pxref{Actions in the NSS configuration,,, libc, The GNU C Library | |
12468 | Reference Manual}). For example: | |
12469 | ||
12470 | @example | |
12471 | (lookup-specification (unavailable => continue) | |
12472 | (success => return)) | |
12473 | @end example | |
12474 | @end table | |
12475 | @end deftp | |
0ae8c15a | 12476 | |
fd1b1fa2 LC |
12477 | @node Initial RAM Disk |
12478 | @subsection Initial RAM Disk | |
12479 | ||
e32171ee JD |
12480 | @cindex initrd |
12481 | @cindex initial RAM disk | |
fd1b1fa2 LC |
12482 | For bootstrapping purposes, the Linux-Libre kernel is passed an |
12483 | @dfn{initial RAM disk}, or @dfn{initrd}. An initrd contains a temporary | |
1068f26b | 12484 | root file system as well as an initialization script. The latter is |
fd1b1fa2 LC |
12485 | responsible for mounting the real root file system, and for loading any |
12486 | kernel modules that may be needed to achieve that. | |
12487 | ||
12488 | The @code{initrd} field of an @code{operating-system} declaration allows | |
12489 | you to specify which initrd you would like to use. The @code{(gnu | |
12490 | system linux-initrd)} module provides two ways to build an initrd: the | |
12491 | high-level @code{base-initrd} procedure, and the low-level | |
12492 | @code{expression->initrd} procedure. | |
12493 | ||
12494 | The @code{base-initrd} procedure is intended to cover most common uses. | |
12495 | For example, if you want to add a bunch of kernel modules to be loaded | |
12496 | at boot time, you can define the @code{initrd} field of the operating | |
12497 | system declaration like this: | |
12498 | ||
12499 | @example | |
52ac153e | 12500 | (initrd (lambda (file-systems . rest) |
027981d6 LC |
12501 | ;; Create a standard initrd that has modules "foo.ko" |
12502 | ;; and "bar.ko", as well as their dependencies, in | |
12503 | ;; addition to the modules available by default. | |
52ac153e | 12504 | (apply base-initrd file-systems |
027981d6 | 12505 | #:extra-modules '("foo" "bar") |
52ac153e | 12506 | rest))) |
fd1b1fa2 LC |
12507 | @end example |
12508 | ||
52ac153e | 12509 | The @code{base-initrd} procedure also handles common use cases that |
1068f26b AE |
12510 | involves using the system as a QEMU guest, or as a ``live'' system with |
12511 | volatile root file system. | |
fd1b1fa2 | 12512 | |
e90cf6c1 LC |
12513 | The initial RAM disk produced by @code{base-initrd} honors several |
12514 | options passed on the Linux kernel command line (that is, arguments | |
1068f26b | 12515 | passed @i{via} the @code{linux} command of GRUB, or the |
4af2fafd | 12516 | @code{-append} option of QEMU), notably: |
e90cf6c1 LC |
12517 | |
12518 | @table @code | |
12519 | @item --load=@var{boot} | |
12520 | Tell the initial RAM disk to load @var{boot}, a file containing a Scheme | |
12521 | program, once it has mounted the root file system. | |
12522 | ||
12523 | GuixSD uses this option to yield control to a boot program that runs the | |
dd17bc38 | 12524 | service activation programs and then spawns the GNU@tie{}Shepherd, the |
e90cf6c1 LC |
12525 | initialization system. |
12526 | ||
12527 | @item --root=@var{root} | |
1068f26b | 12528 | Mount @var{root} as the root file system. @var{root} can be a |
e90cf6c1 LC |
12529 | device name like @code{/dev/sda1}, a partition label, or a partition |
12530 | UUID. | |
12531 | ||
12532 | @item --system=@var{system} | |
12533 | Have @file{/run/booted-system} and @file{/run/current-system} point to | |
12534 | @var{system}. | |
12535 | ||
12536 | @item modprobe.blacklist=@var{modules}@dots{} | |
12537 | @cindex module, black-listing | |
12538 | @cindex black list, of kernel modules | |
12539 | Instruct the initial RAM disk as well as the @command{modprobe} command | |
12540 | (from the kmod package) to refuse to load @var{modules}. @var{modules} | |
12541 | must be a comma-separated list of module names---e.g., | |
12542 | @code{usbkbd,9pnet}. | |
12543 | ||
12544 | @item --repl | |
12545 | Start a read-eval-print loop (REPL) from the initial RAM disk before it | |
12546 | tries to load kernel modules and to mount the root file system. Our | |
12547 | marketing team calls it @dfn{boot-to-Guile}. The Schemer in you will | |
12548 | love it. @xref{Using Guile Interactively,,, guile, GNU Guile Reference | |
12549 | Manual}, for more information on Guile's REPL. | |
12550 | ||
12551 | @end table | |
12552 | ||
12553 | Now that you know all the features that initial RAM disks produced by | |
12554 | @code{base-initrd} provide, here is how to use it and customize it | |
12555 | further. | |
12556 | ||
e32171ee JD |
12557 | @cindex initrd |
12558 | @cindex initial RAM disk | |
fd1b1fa2 | 12559 | @deffn {Monadic Procedure} base-initrd @var{file-systems} @ |
9059b97d | 12560 | [#:qemu-networking? #f] [#:virtio? #t] [#:volatile-root? #f] @ |
52ac153e | 12561 | [#:extra-modules '()] [#:mapped-devices '()] |
fd1b1fa2 | 12562 | Return a monadic derivation that builds a generic initrd. @var{file-systems} is |
1068f26b | 12563 | a list of file systems to be mounted by the initrd, possibly in addition to |
fd1b1fa2 | 12564 | the root file system specified on the kernel command line via @code{--root}. |
52ac153e LC |
12565 | @var{mapped-devices} is a list of device mappings to realize before |
12566 | @var{file-systems} are mounted (@pxref{Mapped Devices}). | |
fd1b1fa2 LC |
12567 | |
12568 | When @var{qemu-networking?} is true, set up networking with the standard QEMU | |
1068f26b AE |
12569 | parameters. When @var{virtio?} is true, load additional modules so that the |
12570 | initrd can be used as a QEMU guest with para-virtualized I/O drivers. | |
fd1b1fa2 LC |
12571 | |
12572 | When @var{volatile-root?} is true, the root file system is writable but any changes | |
12573 | to it are lost. | |
12574 | ||
12575 | The initrd is automatically populated with all the kernel modules necessary | |
12576 | for @var{file-systems} and for the given options. However, additional kernel | |
12577 | modules can be listed in @var{extra-modules}. They will be added to the initrd, and | |
12578 | loaded at boot time in the order in which they appear. | |
12579 | @end deffn | |
12580 | ||
12581 | Needless to say, the initrds we produce and use embed a | |
12582 | statically-linked Guile, and the initialization program is a Guile | |
12583 | program. That gives a lot of flexibility. The | |
12584 | @code{expression->initrd} procedure builds such an initrd, given the | |
12585 | program to run in that initrd. | |
12586 | ||
12587 | @deffn {Monadic Procedure} expression->initrd @var{exp} @ | |
4ee96a79 | 12588 | [#:guile %guile-static-stripped] [#:name "guile-initrd"] |
fd1b1fa2 LC |
12589 | Return a derivation that builds a Linux initrd (a gzipped cpio archive) |
12590 | containing @var{guile} and that evaluates @var{exp}, a G-expression, | |
df650fa8 LC |
12591 | upon booting. All the derivations referenced by @var{exp} are |
12592 | automatically copied to the initrd. | |
fd1b1fa2 LC |
12593 | @end deffn |
12594 | ||
88faf933 LC |
12595 | @node GRUB Configuration |
12596 | @subsection GRUB Configuration | |
12597 | ||
12598 | @cindex GRUB | |
12599 | @cindex boot loader | |
12600 | ||
12601 | The operating system uses GNU@tie{}GRUB as its boot loader | |
12602 | (@pxref{Overview, overview of GRUB,, grub, GNU GRUB Manual}). It is | |
1068f26b AE |
12603 | configured using a @code{grub-configuration} declaration. This data type |
12604 | is exported by the @code{(gnu system grub)} module and described below. | |
88faf933 LC |
12605 | |
12606 | @deftp {Data Type} grub-configuration | |
12607 | The type of a GRUB configuration declaration. | |
12608 | ||
12609 | @table @asis | |
12610 | ||
12611 | @item @code{device} | |
12612 | This is a string denoting the boot device. It must be a device name | |
12613 | understood by the @command{grub-install} command, such as | |
12614 | @code{/dev/sda} or @code{(hd0)} (@pxref{Invoking grub-install,,, grub, | |
12615 | GNU GRUB Manual}). | |
12616 | ||
12617 | @item @code{menu-entries} (default: @code{()}) | |
12618 | A possibly empty list of @code{menu-entry} objects (see below), denoting | |
12619 | entries to appear in the GRUB boot menu, in addition to the current | |
12620 | system entry and the entry pointing to previous system generations. | |
12621 | ||
12622 | @item @code{default-entry} (default: @code{0}) | |
1068f26b AE |
12623 | The index of the default boot menu entry. Index 0 is for the entry of the |
12624 | current system. | |
88faf933 LC |
12625 | |
12626 | @item @code{timeout} (default: @code{5}) | |
12627 | The number of seconds to wait for keyboard input before booting. Set to | |
12628 | 0 to boot immediately, and to -1 to wait indefinitely. | |
12629 | ||
12630 | @item @code{theme} (default: @var{%default-theme}) | |
12631 | The @code{grub-theme} object describing the theme to use. | |
9b06f503 LC |
12632 | |
12633 | @item @code{grub} (default: @code{grub}) | |
12634 | The GRUB package to use. | |
88faf933 LC |
12635 | @end table |
12636 | ||
12637 | @end deftp | |
12638 | ||
44d5f54e LC |
12639 | @cindex dual boot |
12640 | @cindex boot menu | |
88faf933 LC |
12641 | Should you want to list additional boot menu entries @i{via} the |
12642 | @code{menu-entries} field above, you will need to create them with the | |
44d5f54e LC |
12643 | @code{menu-entry} form. For example, imagine you want to be able to |
12644 | boot another distro (hard to imagine!), you can define a menu entry | |
12645 | along these lines: | |
12646 | ||
12647 | @example | |
12648 | (menu-entry | |
12649 | (label "The Other Distro") | |
12650 | (linux "/boot/old/vmlinux-2.6.32") | |
12651 | (linux-arguments '("root=/dev/sda2")) | |
12652 | (initrd "/boot/old/initrd")) | |
12653 | @end example | |
12654 | ||
12655 | Details below. | |
88faf933 LC |
12656 | |
12657 | @deftp {Data Type} menu-entry | |
12658 | The type of an entry in the GRUB boot menu. | |
12659 | ||
12660 | @table @asis | |
12661 | ||
12662 | @item @code{label} | |
35ed9306 | 12663 | The label to show in the menu---e.g., @code{"GNU"}. |
88faf933 LC |
12664 | |
12665 | @item @code{linux} | |
44d5f54e LC |
12666 | The Linux kernel image to boot, for example: |
12667 | ||
12668 | @example | |
12669 | (file-append linux-libre "/bzImage") | |
12670 | @end example | |
88faf933 | 12671 | |
1ef8b72a CM |
12672 | It is also possible to specify a device explicitly in the file path |
12673 | using GRUB's device naming convention (@pxref{Naming convention,,, grub, | |
12674 | GNU GRUB manual}), for example: | |
12675 | ||
12676 | @example | |
12677 | "(hd0,msdos1)/boot/vmlinuz" | |
12678 | @end example | |
12679 | ||
12680 | If the device is specified explicitly as above, then the @code{device} | |
12681 | field is ignored entirely. | |
12682 | ||
88faf933 LC |
12683 | @item @code{linux-arguments} (default: @code{()}) |
12684 | The list of extra Linux kernel command-line arguments---e.g., | |
12685 | @code{("console=ttyS0")}. | |
12686 | ||
12687 | @item @code{initrd} | |
12688 | A G-Expression or string denoting the file name of the initial RAM disk | |
12689 | to use (@pxref{G-Expressions}). | |
12690 | ||
1ef8b72a CM |
12691 | @item @code{device} (default: @code{#f}) |
12692 | The device where the kernel and initrd are to be found---i.e., the GRUB | |
12693 | @dfn{root} for this menu entry (@pxref{root,,, grub, GNU GRUB manual}). | |
12694 | ||
12695 | This may be a file system label (a string), a file system UUID (a | |
12696 | bytevector, @pxref{File Systems}), or @code{#f}, in which case GRUB will | |
12697 | search the device containing the file specified by the @code{linux} | |
12698 | field (@pxref{search,,, grub, GNU GRUB manual}). It must @emph{not} be | |
12699 | an OS device name such as @file{/dev/sda1}. | |
12700 | ||
12701 | @item @code{device-mount-point} (default: @code{"/"}) | |
12702 | The mount point of the above device on the system. You probably do not | |
12703 | need to change the default value. GuixSD uses it to strip the prefix of | |
12704 | store file names for systems where @file{/gnu} or @file{/gnu/store} is | |
12705 | on a separate partition. | |
12706 | ||
88faf933 LC |
12707 | @end table |
12708 | @end deftp | |
12709 | ||
12710 | @c FIXME: Write documentation once it's stable. | |
12711 | Themes are created using the @code{grub-theme} form, which is not | |
12712 | documented yet. | |
12713 | ||
12714 | @defvr {Scheme Variable} %default-theme | |
12715 | This is the default GRUB theme used by the operating system, with a | |
12716 | fancy background image displaying the GNU and Guix logos. | |
12717 | @end defvr | |
12718 | ||
12719 | ||
cf4a9129 LC |
12720 | @node Invoking guix system |
12721 | @subsection Invoking @code{guix system} | |
0918e64a | 12722 | |
1068f26b | 12723 | Once you have written an operating system declaration as seen in the |
cf4a9129 LC |
12724 | previous section, it can be @dfn{instantiated} using the @command{guix |
12725 | system} command. The synopsis is: | |
4af2447e | 12726 | |
cf4a9129 LC |
12727 | @example |
12728 | guix system @var{options}@dots{} @var{action} @var{file} | |
12729 | @end example | |
4af2447e | 12730 | |
cf4a9129 LC |
12731 | @var{file} must be the name of a file containing an |
12732 | @code{operating-system} declaration. @var{action} specifies how the | |
a40424bd | 12733 | operating system is instantiated. Currently the following values are |
cf4a9129 | 12734 | supported: |
4af2447e | 12735 | |
cf4a9129 LC |
12736 | @table @code |
12737 | @item reconfigure | |
12738 | Build the operating system described in @var{file}, activate it, and | |
8074b330 CM |
12739 | switch to it@footnote{This action (and the related actions |
12740 | @code{switch-generation} and @code{roll-back}) are usable only on | |
12741 | systems already running GuixSD.}. | |
4af2447e | 12742 | |
cf4a9129 LC |
12743 | This effects all the configuration specified in @var{file}: user |
12744 | accounts, system services, global package list, setuid programs, etc. | |
240b57f0 LC |
12745 | The command starts system services specified in @var{file} that are not |
12746 | currently running; if a service is currently running, it does not | |
1068f26b | 12747 | attempt to upgrade it since this would not be possible without stopping it |
240b57f0 | 12748 | first. |
4af2447e | 12749 | |
067a2e2d CM |
12750 | This command creates a new generation whose number is one greater than |
12751 | the current generation (as reported by @command{guix system | |
12752 | list-generations}). If that generation already exists, it will be | |
12753 | overwritten. This behavior mirrors that of @command{guix package} | |
12754 | (@pxref{Invoking guix package}). | |
12755 | ||
cf4a9129 LC |
12756 | It also adds a GRUB menu entry for the new OS configuration, and moves |
12757 | entries for older configurations to a submenu---unless | |
12758 | @option{--no-grub} is passed. | |
4af2447e | 12759 | |
240b57f0 | 12760 | @quotation Note |
bf2479c7 LC |
12761 | @c The paragraph below refers to the problem discussed at |
12762 | @c <http://lists.gnu.org/archive/html/guix-devel/2014-08/msg00057.html>. | |
12763 | It is highly recommended to run @command{guix pull} once before you run | |
12764 | @command{guix system reconfigure} for the first time (@pxref{Invoking | |
12765 | guix pull}). Failing to do that you would see an older version of Guix | |
12766 | once @command{reconfigure} has completed. | |
240b57f0 | 12767 | @end quotation |
bf2479c7 | 12768 | |
8074b330 | 12769 | @item switch-generation |
e32171ee | 12770 | @cindex generations |
8074b330 CM |
12771 | Switch to an existing system generation. This action atomically |
12772 | switches the system profile to the specified system generation. It also | |
12773 | rearranges the system's existing GRUB menu entries. It makes the menu | |
12774 | entry for the specified system generation the default, and it moves the | |
12775 | entries for the other generations to a submenu. The next time the | |
12776 | system boots, it will use the specified system generation. | |
12777 | ||
12778 | The target generation can be specified explicitly by its generation | |
12779 | number. For example, the following invocation would switch to system | |
12780 | generation 7: | |
12781 | ||
12782 | @example | |
12783 | guix system switch-generation 7 | |
12784 | @end example | |
12785 | ||
12786 | The target generation can also be specified relative to the current | |
12787 | generation with the form @code{+N} or @code{-N}, where @code{+3} means | |
12788 | ``3 generations ahead of the current generation,'' and @code{-1} means | |
12789 | ``1 generation prior to the current generation.'' When specifying a | |
12790 | negative value such as @code{-1}, you must precede it with @code{--} to | |
12791 | prevent it from being parsed as an option. For example: | |
12792 | ||
12793 | @example | |
12794 | guix system switch-generation -- -1 | |
12795 | @end example | |
12796 | ||
12797 | Currently, the effect of invoking this action is @emph{only} to switch | |
12798 | the system profile to an existing generation and rearrange the GRUB menu | |
12799 | entries. To actually start using the target system generation, you must | |
12800 | reboot after running this action. In the future, it will be updated to | |
12801 | do the same things as @command{reconfigure}, like activating and | |
12802 | deactivating services. | |
12803 | ||
12804 | This action will fail if the specified generation does not exist. | |
12805 | ||
12806 | @item roll-back | |
e32171ee | 12807 | @cindex rolling back |
8074b330 CM |
12808 | Switch to the preceding system generation. The next time the system |
12809 | boots, it will use the preceding system generation. This is the inverse | |
12810 | of @command{reconfigure}, and it is exactly the same as invoking | |
12811 | @command{switch-generation} with an argument of @code{-1}. | |
12812 | ||
12813 | Currently, as with @command{switch-generation}, you must reboot after | |
12814 | running this action to actually start using the preceding system | |
12815 | generation. | |
12816 | ||
cf4a9129 | 12817 | @item build |
1068f26b | 12818 | Build the derivation of the operating system, which includes all the |
cf4a9129 LC |
12819 | configuration files and programs needed to boot and run the system. |
12820 | This action does not actually install anything. | |
113daf62 | 12821 | |
cf4a9129 LC |
12822 | @item init |
12823 | Populate the given directory with all the files necessary to run the | |
12824 | operating system specified in @var{file}. This is useful for first-time | |
4705641f | 12825 | installations of GuixSD. For instance: |
113daf62 LC |
12826 | |
12827 | @example | |
cf4a9129 | 12828 | guix system init my-os-config.scm /mnt |
113daf62 LC |
12829 | @end example |
12830 | ||
cf4a9129 LC |
12831 | copies to @file{/mnt} all the store items required by the configuration |
12832 | specified in @file{my-os-config.scm}. This includes configuration | |
12833 | files, packages, and so on. It also creates other essential files | |
12834 | needed for the system to operate correctly---e.g., the @file{/etc}, | |
12835 | @file{/var}, and @file{/run} directories, and the @file{/bin/sh} file. | |
113daf62 | 12836 | |
cf4a9129 LC |
12837 | This command also installs GRUB on the device specified in |
12838 | @file{my-os-config}, unless the @option{--no-grub} option was passed. | |
113daf62 | 12839 | |
cf4a9129 LC |
12840 | @item vm |
12841 | @cindex virtual machine | |
0276f697 | 12842 | @cindex VM |
f535dcbe | 12843 | @anchor{guix system vm} |
1068f26b | 12844 | Build a virtual machine that contains the operating system declared in |
cf4a9129 | 12845 | @var{file}, and return a script to run that virtual machine (VM). |
1068f26b | 12846 | Arguments given to the script are passed to QEMU. |
113daf62 | 12847 | |
cf4a9129 | 12848 | The VM shares its store with the host system. |
113daf62 | 12849 | |
0276f697 LC |
12850 | Additional file systems can be shared between the host and the VM using |
12851 | the @code{--share} and @code{--expose} command-line options: the former | |
12852 | specifies a directory to be shared with write access, while the latter | |
12853 | provides read-only access to the shared directory. | |
12854 | ||
12855 | The example below creates a VM in which the user's home directory is | |
12856 | accessible read-only, and where the @file{/exchange} directory is a | |
1068f26b | 12857 | read-write mapping of @file{$HOME/tmp} on the host: |
0276f697 LC |
12858 | |
12859 | @example | |
12860 | guix system vm my-config.scm \ | |
12861 | --expose=$HOME --share=$HOME/tmp=/exchange | |
12862 | @end example | |
12863 | ||
6aa260af LC |
12864 | On GNU/Linux, the default is to boot directly to the kernel; this has |
12865 | the advantage of requiring only a very tiny root disk image since the | |
1068f26b | 12866 | store of the host can then be mounted. |
6aa260af LC |
12867 | |
12868 | The @code{--full-boot} option forces a complete boot sequence, starting | |
12869 | with the bootloader. This requires more disk space since a root image | |
12870 | containing at least the kernel, initrd, and bootloader data files must | |
12871 | be created. The @code{--image-size} option can be used to specify the | |
1068f26b | 12872 | size of the image. |
ab11f0be | 12873 | |
cf4a9129 LC |
12874 | @item vm-image |
12875 | @itemx disk-image | |
12876 | Return a virtual machine or disk image of the operating system declared | |
12877 | in @var{file} that stands alone. Use the @option{--image-size} option | |
12878 | to specify the size of the image. | |
113daf62 | 12879 | |
cf4a9129 | 12880 | When using @code{vm-image}, the returned image is in qcow2 format, which |
97d76250 LF |
12881 | the QEMU emulator can efficiently use. @xref{Running GuixSD in a VM}, |
12882 | for more information on how to run the image in a virtual machine. | |
113daf62 | 12883 | |
cf4a9129 LC |
12884 | When using @code{disk-image}, a raw disk image is produced; it can be |
12885 | copied as is to a USB stick, for instance. Assuming @code{/dev/sdc} is | |
1068f26b | 12886 | the device corresponding to a USB stick, one can copy the image to it |
cf4a9129 | 12887 | using the following command: |
113daf62 | 12888 | |
cf4a9129 LC |
12889 | @example |
12890 | # dd if=$(guix system disk-image my-os.scm) of=/dev/sdc | |
12891 | @end example | |
113daf62 | 12892 | |
1c8a81b1 DT |
12893 | @item container |
12894 | Return a script to run the operating system declared in @var{file} | |
12895 | within a container. Containers are a set of lightweight isolation | |
12896 | mechanisms provided by the kernel Linux-libre. Containers are | |
12897 | substantially less resource-demanding than full virtual machines since | |
12898 | the kernel, shared objects, and other resources can be shared with the | |
12899 | host system; this also means they provide thinner isolation. | |
12900 | ||
12901 | Currently, the script must be run as root in order to support more than | |
12902 | a single user and group. The container shares its store with the host | |
12903 | system. | |
12904 | ||
12905 | As with the @code{vm} action (@pxref{guix system vm}), additional file | |
12906 | systems to be shared between the host and container can be specified | |
12907 | using the @option{--share} and @option{--expose} options: | |
12908 | ||
12909 | @example | |
12910 | guix system container my-config.scm \ | |
12911 | --expose=$HOME --share=$HOME/tmp=/exchange | |
12912 | @end example | |
12913 | ||
0f252e26 | 12914 | @quotation Note |
cfd35b4e | 12915 | This option requires Linux-libre 3.19 or newer. |
0f252e26 DT |
12916 | @end quotation |
12917 | ||
cf4a9129 | 12918 | @end table |
113daf62 | 12919 | |
ccd7158d LC |
12920 | @var{options} can contain any of the common build options (@pxref{Common |
12921 | Build Options}). In addition, @var{options} can contain one of the | |
12922 | following: | |
113daf62 | 12923 | |
cf4a9129 LC |
12924 | @table @option |
12925 | @item --system=@var{system} | |
12926 | @itemx -s @var{system} | |
1068f26b | 12927 | Attempt to build for @var{system} instead of the host system type. |
cf4a9129 | 12928 | This works as per @command{guix build} (@pxref{Invoking guix build}). |
113daf62 | 12929 | |
f3f427c2 LC |
12930 | @item --derivation |
12931 | @itemx -d | |
12932 | Return the derivation file name of the given operating system without | |
12933 | building anything. | |
12934 | ||
cf4a9129 LC |
12935 | @item --image-size=@var{size} |
12936 | For the @code{vm-image} and @code{disk-image} actions, create an image | |
12937 | of the given @var{size}. @var{size} may be a number of bytes, or it may | |
4a44d7bb LC |
12938 | include a unit as a suffix (@pxref{Block size, size specifications,, |
12939 | coreutils, GNU Coreutils}). | |
db030303 LC |
12940 | |
12941 | @item --on-error=@var{strategy} | |
12942 | Apply @var{strategy} when an error occurs when reading @var{file}. | |
12943 | @var{strategy} may be one of the following: | |
12944 | ||
12945 | @table @code | |
12946 | @item nothing-special | |
12947 | Report the error concisely and exit. This is the default strategy. | |
12948 | ||
12949 | @item backtrace | |
12950 | Likewise, but also display a backtrace. | |
12951 | ||
12952 | @item debug | |
12953 | Report the error and enter Guile's debugger. From there, you can run | |
12954 | commands such as @code{,bt} to get a backtrace, @code{,locals} to | |
1068f26b AE |
12955 | display local variable values, and more generally inspect the state of the |
12956 | program. @xref{Debug Commands,,, guile, GNU Guile Reference Manual}, for | |
db030303 LC |
12957 | a list of available debugging commands. |
12958 | @end table | |
113daf62 | 12959 | @end table |
113daf62 | 12960 | |
eca69fc0 LC |
12961 | @quotation Note |
12962 | All the actions above, except @code{build} and @code{init}, | |
12963 | can use KVM support in the Linux-libre kernel. Specifically, if the | |
12964 | machine has hardware virtualization support, the corresponding | |
cf4a9129 | 12965 | KVM kernel module should be loaded, and the @file{/dev/kvm} device node |
1068f26b | 12966 | must exist and be readable and writable by the user and by the |
eca69fc0 LC |
12967 | build users of the daemon (@pxref{Build Environment Setup}). |
12968 | @end quotation | |
8451a568 | 12969 | |
65797bff LC |
12970 | Once you have built, configured, re-configured, and re-re-configured |
12971 | your GuixSD installation, you may find it useful to list the operating | |
12972 | system generations available on disk---and that you can choose from the | |
12973 | GRUB boot menu: | |
12974 | ||
12975 | @table @code | |
12976 | ||
12977 | @item list-generations | |
12978 | List a summary of each generation of the operating system available on | |
12979 | disk, in a human-readable way. This is similar to the | |
12980 | @option{--list-generations} option of @command{guix package} | |
12981 | (@pxref{Invoking guix package}). | |
12982 | ||
12983 | Optionally, one can specify a pattern, with the same syntax that is used | |
12984 | in @command{guix package --list-generations}, to restrict the list of | |
12985 | generations displayed. For instance, the following command displays | |
1068f26b | 12986 | generations that are up to 10 days old: |
65797bff LC |
12987 | |
12988 | @example | |
12989 | $ guix system list-generations 10d | |
12990 | @end example | |
12991 | ||
12992 | @end table | |
12993 | ||
d6c3267a LC |
12994 | The @command{guix system} command has even more to offer! The following |
12995 | sub-commands allow you to visualize how your system services relate to | |
12996 | each other: | |
12997 | ||
12998 | @anchor{system-extension-graph} | |
12999 | @table @code | |
13000 | ||
13001 | @item extension-graph | |
13002 | Emit in Dot/Graphviz format to standard output the @dfn{service | |
13003 | extension graph} of the operating system defined in @var{file} | |
13004 | (@pxref{Service Composition}, for more information on service | |
13005 | extensions.) | |
13006 | ||
13007 | The command: | |
13008 | ||
13009 | @example | |
13010 | $ guix system extension-graph @var{file} | dot -Tpdf > services.pdf | |
13011 | @end example | |
13012 | ||
13013 | produces a PDF file showing the extension relations among services. | |
13014 | ||
710fa231 AK |
13015 | @anchor{system-shepherd-graph} |
13016 | @item shepherd-graph | |
6f305ea5 | 13017 | Emit in Dot/Graphviz format to standard output the @dfn{dependency |
dd17bc38 AK |
13018 | graph} of shepherd services of the operating system defined in |
13019 | @var{file}. @xref{Shepherd Services}, for more information and for an | |
13020 | example graph. | |
6f305ea5 | 13021 | |
d6c3267a LC |
13022 | @end table |
13023 | ||
97d76250 | 13024 | @node Running GuixSD in a VM |
70ac09a5 | 13025 | @subsection Running GuixSD in a Virtual Machine |
97d76250 | 13026 | |
e32171ee | 13027 | @cindex virtual machine |
97d76250 LF |
13028 | One way to run GuixSD in a virtual machine (VM) is to build a GuixSD |
13029 | virtual machine image using @command{guix system vm-image} | |
13030 | (@pxref{Invoking guix system}). The returned image is in qcow2 format, | |
13031 | which the @uref{http://qemu.org/, QEMU emulator} can efficiently use. | |
13032 | ||
e32171ee | 13033 | @cindex QEMU |
97d76250 LF |
13034 | To run the image in QEMU, copy it out of the store (@pxref{The Store}) |
13035 | and give yourself permission to write to the copy. When invoking QEMU, | |
13036 | you must choose a system emulator that is suitable for your hardware | |
13037 | platform. Here is a minimal QEMU invocation that will boot the result | |
13038 | of @command{guix system vm-image} on x86_64 hardware: | |
13039 | ||
13040 | @example | |
13041 | $ qemu-system-x86_64 \ | |
13042 | -net user -net nic,model=virtio \ | |
13043 | -enable-kvm -m 256 /tmp/qemu-image | |
13044 | @end example | |
13045 | ||
13046 | Here is what each of these options means: | |
13047 | ||
13048 | @table @code | |
13049 | @item qemu-system-x86_64 | |
13050 | This specifies the hardware platform to emulate. This should match the | |
13051 | host. | |
13052 | ||
13053 | @item -net user | |
13054 | Enable the unprivileged user-mode network stack. The guest OS can | |
13055 | access the host but not vice versa. This is the simplest way to get the | |
58806e6f | 13056 | guest OS online. |
97d76250 LF |
13057 | |
13058 | @item -net nic,model=virtio | |
1068f26b | 13059 | You must create a network interface of a given model. If you do not |
97d76250 LF |
13060 | create a NIC, the boot will fail. Assuming your hardware platform is |
13061 | x86_64, you can get a list of available NIC models by running | |
13062 | @command{qemu-system-x86_64 -net nic,model=help}. | |
13063 | ||
13064 | @item -enable-kvm | |
13065 | If your system has hardware virtualization extensions, enabling the | |
1068f26b | 13066 | virtual machine support (KVM) of the Linux kernel will make things run |
97d76250 LF |
13067 | faster. |
13068 | ||
13069 | @item -m 256 | |
13070 | RAM available to the guest OS, in mebibytes. Defaults to 128@tie{}MiB, | |
7414de0a | 13071 | which may be insufficient for some operations. |
97d76250 LF |
13072 | |
13073 | @item /tmp/qemu-image | |
13074 | The file name of the qcow2 image. | |
13075 | @end table | |
d6c3267a | 13076 | |
3ddc50db DC |
13077 | The default @command{run-vm.sh} script that is returned by an invokation of |
13078 | @command{guix system vm} does not add a @command{-net user} flag by default. | |
13079 | To get network access from within the vm add the @code{(dhcp-client-service)} | |
13080 | to your system definition and start the VM using | |
13081 | @command{`guix system vm config.scm` -net user}. An important caveat of using | |
13082 | @command{-net user} for networking is that @command{ping} will not work, because | |
13083 | it uses the ICMP protocol. You'll have to use a different command to check for | |
13084 | network connectivity, like for example @command{curl}. | |
13085 | ||
13086 | @subsubsection Connecting Through SSH | |
13087 | ||
e32171ee JD |
13088 | @cindex SSH |
13089 | @cindex SSH server | |
3ddc50db DC |
13090 | To enable SSH inside a VM you need to add a SSH server like @code{(dropbear-service)} |
13091 | or @code{(lsh-service)} to your VM. The @code{(lsh-service}) doesn't currently | |
13092 | boot unsupervised. It requires you to type some characters to initialize the | |
13093 | randomness generator. In addition you need to forward the SSH port, 22 by | |
13094 | default, to the host. You can do this with | |
13095 | ||
13096 | @example | |
13097 | `guix system vm config.scm` -net user,hostfwd=tcp::10022-:22 | |
13098 | @end example | |
13099 | ||
13100 | To connect to the VM you can run | |
13101 | ||
13102 | @example | |
13103 | ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 10022 | |
13104 | @end example | |
13105 | ||
13106 | The @command{-p} tells @command{ssh} the port you want to connect to. | |
13107 | @command{-o UserKnownHostsFile=/dev/null} prevents @command{ssh} from complaining | |
13108 | every time you modify your @command{config.scm} file and the | |
13109 | @command{-o StrictHostKeyChecking=no} prevents you from having to allow a | |
13110 | connection to an unknown host every time you connect. | |
13111 | ||
13112 | @subsubsection Using @command{virt-viewer} with Spice | |
13113 | ||
13114 | As an alternative to the default @command{qemu} graphical client you can | |
13115 | use the @command{remote-viewer} from the @command{virt-viewer} package. To | |
13116 | connect pass the @command{-spice port=5930,disable-ticketing} flag to | |
13117 | @command{qemu}. See previous section for further information on how to do this. | |
13118 | ||
13119 | Spice also allows you to do some nice stuff like share your clipboard with your | |
13120 | VM. To enable that you'll also have to pass the following flags to @command{qemu}: | |
13121 | ||
13122 | @example | |
13123 | -device virtio-serial-pci,id=virtio-serial0,max_ports=16,bus=pci.0,addr=0x5 | |
13124 | -chardev spicevmc,name=vdagent,id=vdagent | |
13125 | -device virtserialport,nr=1,bus=virtio-serial0.0,chardev=vdagent, | |
13126 | name=com.redhat.spice.0 | |
13127 | @end example | |
13128 | ||
13129 | You'll also need to add the @pxref{Miscellaneous Services, Spice service}. | |
13130 | ||
cf4a9129 LC |
13131 | @node Defining Services |
13132 | @subsection Defining Services | |
8451a568 | 13133 | |
eb524192 | 13134 | The previous sections show the available services and how one can combine |
0adfe95a LC |
13135 | them in an @code{operating-system} declaration. But how do we define |
13136 | them in the first place? And what is a service anyway? | |
8451a568 | 13137 | |
0adfe95a LC |
13138 | @menu |
13139 | * Service Composition:: The model for composing services. | |
13140 | * Service Types and Services:: Types and services. | |
13141 | * Service Reference:: API reference. | |
dd17bc38 | 13142 | * Shepherd Services:: A particular type of service. |
0adfe95a LC |
13143 | @end menu |
13144 | ||
13145 | @node Service Composition | |
13146 | @subsubsection Service Composition | |
13147 | ||
13148 | @cindex services | |
13149 | @cindex daemons | |
13150 | Here we define a @dfn{service} as, broadly, something that extends the | |
1068f26b | 13151 | functionality of the operating system. Often a service is a process---a |
0adfe95a LC |
13152 | @dfn{daemon}---started when the system boots: a secure shell server, a |
13153 | Web server, the Guix build daemon, etc. Sometimes a service is a daemon | |
13154 | whose execution can be triggered by another daemon---e.g., an FTP server | |
13155 | started by @command{inetd} or a D-Bus service activated by | |
13156 | @command{dbus-daemon}. Occasionally, a service does not map to a | |
13157 | daemon. For instance, the ``account'' service collects user accounts | |
13158 | and makes sure they exist when the system runs; the ``udev'' service | |
13159 | collects device management rules and makes them available to the eudev | |
1068f26b AE |
13160 | daemon; the @file{/etc} service populates the @file{/etc} directory |
13161 | of the system. | |
0adfe95a | 13162 | |
d6c3267a | 13163 | @cindex service extensions |
0adfe95a | 13164 | GuixSD services are connected by @dfn{extensions}. For instance, the |
1068f26b | 13165 | secure shell service @emph{extends} the Shepherd---the GuixSD |
dd17bc38 AK |
13166 | initialization system, running as PID@tie{}1---by giving it the command |
13167 | lines to start and stop the secure shell daemon (@pxref{Networking | |
13168 | Services, @code{lsh-service}}); the UPower service extends the D-Bus | |
13169 | service by passing it its @file{.service} specification, and extends the | |
13170 | udev service by passing it device management rules (@pxref{Desktop | |
13171 | Services, @code{upower-service}}); the Guix daemon service extends the | |
13172 | Shepherd by passing it the command lines to start and stop the daemon, | |
13173 | and extends the account service by passing it a list of required build | |
13174 | user accounts (@pxref{Base Services}). | |
0adfe95a LC |
13175 | |
13176 | All in all, services and their ``extends'' relations form a directed | |
13177 | acyclic graph (DAG). If we represent services as boxes and extensions | |
13178 | as arrows, a typical system might provide something like this: | |
13179 | ||
13180 | @image{images/service-graph,,5in,Typical service extension graph.} | |
13181 | ||
d62e201c LC |
13182 | @cindex system service |
13183 | At the bottom, we see the @dfn{system service}, which produces the | |
13184 | directory containing everything to run and boot the system, as returned | |
13185 | by the @command{guix system build} command. @xref{Service Reference}, | |
13186 | to learn about the other service types shown here. | |
d6c3267a LC |
13187 | @xref{system-extension-graph, the @command{guix system extension-graph} |
13188 | command}, for information on how to generate this representation for a | |
13189 | particular operating system definition. | |
0adfe95a LC |
13190 | |
13191 | @cindex service types | |
13192 | Technically, developers can define @dfn{service types} to express these | |
13193 | relations. There can be any number of services of a given type on the | |
13194 | system---for instance, a system running two instances of the GNU secure | |
13195 | shell server (lsh) has two instances of @var{lsh-service-type}, with | |
13196 | different parameters. | |
13197 | ||
13198 | The following section describes the programming interface for service | |
13199 | types and services. | |
13200 | ||
13201 | @node Service Types and Services | |
13202 | @subsubsection Service Types and Services | |
13203 | ||
13204 | A @dfn{service type} is a node in the DAG described above. Let us start | |
13205 | with a simple example, the service type for the Guix build daemon | |
13206 | (@pxref{Invoking guix-daemon}): | |
13207 | ||
13208 | @example | |
13209 | (define guix-service-type | |
13210 | (service-type | |
13211 | (name 'guix) | |
13212 | (extensions | |
d4053c71 | 13213 | (list (service-extension shepherd-root-service-type guix-shepherd-service) |
0adfe95a LC |
13214 | (service-extension account-service-type guix-accounts) |
13215 | (service-extension activation-service-type guix-activation))))) | |
13216 | @end example | |
8451a568 | 13217 | |
cf4a9129 | 13218 | @noindent |
1068f26b | 13219 | It defines two things: |
0adfe95a LC |
13220 | |
13221 | @enumerate | |
13222 | @item | |
13223 | A name, whose sole purpose is to make inspection and debugging easier. | |
13224 | ||
13225 | @item | |
13226 | A list of @dfn{service extensions}, where each extension designates the | |
1068f26b AE |
13227 | target service type and a procedure that, given the parameters of the |
13228 | service, returns a list of objects to extend the service of that type. | |
0adfe95a LC |
13229 | |
13230 | Every service type has at least one service extension. The only | |
13231 | exception is the @dfn{boot service type}, which is the ultimate service. | |
13232 | @end enumerate | |
13233 | ||
13234 | In this example, @var{guix-service-type} extends three services: | |
13235 | ||
13236 | @table @var | |
d4053c71 AK |
13237 | @item shepherd-root-service-type |
13238 | The @var{guix-shepherd-service} procedure defines how the Shepherd | |
13239 | service is extended. Namely, it returns a @code{<shepherd-service>} | |
13240 | object that defines how @command{guix-daemon} is started and stopped | |
13241 | (@pxref{Shepherd Services}). | |
0adfe95a LC |
13242 | |
13243 | @item account-service-type | |
13244 | This extension for this service is computed by @var{guix-accounts}, | |
13245 | which returns a list of @code{user-group} and @code{user-account} | |
13246 | objects representing the build user accounts (@pxref{Invoking | |
13247 | guix-daemon}). | |
13248 | ||
13249 | @item activation-service-type | |
13250 | Here @var{guix-activation} is a procedure that returns a gexp, which is | |
13251 | a code snippet to run at ``activation time''---e.g., when the service is | |
13252 | booted. | |
13253 | @end table | |
13254 | ||
13255 | A service of this type is instantiated like this: | |
13256 | ||
13257 | @example | |
13258 | (service guix-service-type | |
13259 | (guix-configuration | |
13260 | (build-accounts 5) | |
13261 | (use-substitutes? #f))) | |
13262 | @end example | |
13263 | ||
13264 | The second argument to the @code{service} form is a value representing | |
13265 | the parameters of this specific service instance. | |
13266 | @xref{guix-configuration-type, @code{guix-configuration}}, for | |
13267 | information about the @code{guix-configuration} data type. | |
13268 | ||
13269 | @var{guix-service-type} is quite simple because it extends other | |
13270 | services but is not extensible itself. | |
13271 | ||
13272 | @c @subsubsubsection Extensible Service Types | |
13273 | ||
13274 | The service type for an @emph{extensible} service looks like this: | |
13275 | ||
13276 | @example | |
13277 | (define udev-service-type | |
13278 | (service-type (name 'udev) | |
13279 | (extensions | |
d4053c71 AK |
13280 | (list (service-extension shepherd-root-service-type |
13281 | udev-shepherd-service))) | |
0adfe95a LC |
13282 | |
13283 | (compose concatenate) ;concatenate the list of rules | |
13284 | (extend (lambda (config rules) | |
13285 | (match config | |
13286 | (($ <udev-configuration> udev initial-rules) | |
13287 | (udev-configuration | |
13288 | (udev udev) ;the udev package to use | |
13289 | (rules (append initial-rules rules))))))))) | |
13290 | @end example | |
13291 | ||
13292 | This is the service type for the | |
13293 | @uref{https://wiki.gentoo.org/wiki/Project:Eudev, eudev device | |
13294 | management daemon}. Compared to the previous example, in addition to an | |
d4053c71 | 13295 | extension of @var{shepherd-root-service-type}, we see two new fields: |
0adfe95a LC |
13296 | |
13297 | @table @code | |
13298 | @item compose | |
13299 | This is the procedure to @dfn{compose} the list of extensions to | |
13300 | services of this type. | |
13301 | ||
13302 | Services can extend the udev service by passing it lists of rules; we | |
13303 | compose those extensions simply by concatenating them. | |
13304 | ||
13305 | @item extend | |
1068f26b | 13306 | This procedure defines how the value of the service is @dfn{extended} with |
0adfe95a LC |
13307 | the composition of the extensions. |
13308 | ||
13309 | Udev extensions are composed into a list of rules, but the udev service | |
13310 | value is itself a @code{<udev-configuration>} record. So here, we | |
a40424bd | 13311 | extend that record by appending the list of rules it contains to the |
0adfe95a LC |
13312 | list of contributed rules. |
13313 | @end table | |
13314 | ||
13315 | There can be only one instance of an extensible service type such as | |
13316 | @var{udev-service-type}. If there were more, the | |
13317 | @code{service-extension} specifications would be ambiguous. | |
13318 | ||
13319 | Still here? The next section provides a reference of the programming | |
13320 | interface for services. | |
13321 | ||
13322 | @node Service Reference | |
13323 | @subsubsection Service Reference | |
13324 | ||
13325 | We have seen an overview of service types (@pxref{Service Types and | |
13326 | Services}). This section provides a reference on how to manipulate | |
13327 | services and service types. This interface is provided by the | |
13328 | @code{(gnu services)} module. | |
13329 | ||
13330 | @deffn {Scheme Procedure} service @var{type} @var{value} | |
13331 | Return a new service of @var{type}, a @code{<service-type>} object (see | |
13332 | below.) @var{value} can be any object; it represents the parameters of | |
13333 | this particular service instance. | |
13334 | @end deffn | |
13335 | ||
13336 | @deffn {Scheme Procedure} service? @var{obj} | |
13337 | Return true if @var{obj} is a service. | |
13338 | @end deffn | |
8451a568 | 13339 | |
0adfe95a LC |
13340 | @deffn {Scheme Procedure} service-kind @var{service} |
13341 | Return the type of @var{service}---i.e., a @code{<service-type>} object. | |
13342 | @end deffn | |
13343 | ||
13344 | @deffn {Scheme Procedure} service-parameters @var{service} | |
13345 | Return the value associated with @var{service}. It represents its | |
13346 | parameters. | |
13347 | @end deffn | |
13348 | ||
13349 | Here is an example of how a service is created and manipulated: | |
13350 | ||
13351 | @example | |
13352 | (define s | |
13353 | (service nginx-service-type | |
13354 | (nginx-configuration | |
13355 | (nginx nginx) | |
13356 | (log-directory log-directory) | |
13357 | (run-directory run-directory) | |
13358 | (file config-file)))) | |
13359 | ||
13360 | (service? s) | |
13361 | @result{} #t | |
13362 | ||
13363 | (eq? (service-kind s) nginx-service-type) | |
13364 | @result{} #t | |
13365 | @end example | |
13366 | ||
cd6f6c22 LC |
13367 | The @code{modify-services} form provides a handy way to change the |
13368 | parameters of some of the services of a list such as | |
4d343a14 | 13369 | @var{%base-services} (@pxref{Base Services, @code{%base-services}}). It |
7414de0a | 13370 | evaluates to a list of services. Of course, you could always use |
4d343a14 CM |
13371 | standard list combinators such as @code{map} and @code{fold} to do that |
13372 | (@pxref{SRFI-1, List Library,, guile, GNU Guile Reference Manual}); | |
13373 | @code{modify-services} simply provides a more concise form for this | |
13374 | common pattern. | |
cd6f6c22 LC |
13375 | |
13376 | @deffn {Scheme Syntax} modify-services @var{services} @ | |
13377 | (@var{type} @var{variable} => @var{body}) @dots{} | |
13378 | ||
13379 | Modify the services listed in @var{services} according to the given | |
13380 | clauses. Each clause has the form: | |
13381 | ||
13382 | @example | |
13383 | (@var{type} @var{variable} => @var{body}) | |
13384 | @end example | |
13385 | ||
4d343a14 CM |
13386 | where @var{type} is a service type---e.g., |
13387 | @code{guix-service-type}---and @var{variable} is an identifier that is | |
13388 | bound within the @var{body} to the service parameters---e.g., a | |
13389 | @code{guix-configuration} instance---of the original service of that | |
13390 | @var{type}. | |
cd6f6c22 | 13391 | |
4d343a14 CM |
13392 | The @var{body} should evaluate to the new service parameters, which will |
13393 | be used to configure the new service. This new service will replace the | |
13394 | original in the resulting list. Because a service's service parameters | |
7414de0a | 13395 | are created using @code{define-record-type*}, you can write a succinct |
4d343a14 CM |
13396 | @var{body} that evaluates to the new service parameters by using the |
13397 | @code{inherit} feature that @code{define-record-type*} provides. | |
13398 | ||
b53daad0 | 13399 | @xref{Using the Configuration System}, for example usage. |
cd6f6c22 | 13400 | |
cd6f6c22 LC |
13401 | @end deffn |
13402 | ||
13403 | Next comes the programming interface for service types. This is | |
13404 | something you want to know when writing new service definitions, but not | |
13405 | necessarily when simply looking for ways to customize your | |
13406 | @code{operating-system} declaration. | |
13407 | ||
0adfe95a LC |
13408 | @deftp {Data Type} service-type |
13409 | @cindex service type | |
13410 | This is the representation of a @dfn{service type} (@pxref{Service Types | |
13411 | and Services}). | |
13412 | ||
13413 | @table @asis | |
13414 | @item @code{name} | |
13415 | This is a symbol, used only to simplify inspection and debugging. | |
13416 | ||
13417 | @item @code{extensions} | |
1068f26b | 13418 | A non-empty list of @code{<service-extension>} objects (see below). |
0adfe95a LC |
13419 | |
13420 | @item @code{compose} (default: @code{#f}) | |
13421 | If this is @code{#f}, then the service type denotes services that cannot | |
13422 | be extended---i.e., services that do not receive ``values'' from other | |
13423 | services. | |
13424 | ||
13425 | Otherwise, it must be a one-argument procedure. The procedure is called | |
13426 | by @code{fold-services} and is passed a list of values collected from | |
13427 | extensions. It must return a value that is a valid parameter value for | |
13428 | the service instance. | |
13429 | ||
13430 | @item @code{extend} (default: @code{#f}) | |
13431 | If this is @code{#f}, services of this type cannot be extended. | |
13432 | ||
13433 | Otherwise, it must be a two-argument procedure: @code{fold-services} | |
1068f26b | 13434 | calls it, passing it the initial value of the service as the first argument |
0adfe95a LC |
13435 | and the result of applying @code{compose} to the extension values as the |
13436 | second argument. | |
13437 | @end table | |
13438 | ||
13439 | @xref{Service Types and Services}, for examples. | |
13440 | @end deftp | |
13441 | ||
13442 | @deffn {Scheme Procedure} service-extension @var{target-type} @ | |
13443 | @var{compute} | |
13444 | Return a new extension for services of type @var{target-type}. | |
13445 | @var{compute} must be a one-argument procedure: @code{fold-services} | |
13446 | calls it, passing it the value associated with the service that provides | |
13447 | the extension; it must return a valid value for the target service. | |
13448 | @end deffn | |
13449 | ||
13450 | @deffn {Scheme Procedure} service-extension? @var{obj} | |
13451 | Return true if @var{obj} is a service extension. | |
13452 | @end deffn | |
13453 | ||
71654dfd LC |
13454 | Occasionally, you might want to simply extend an existing service. This |
13455 | involves creating a new service type and specifying the extension of | |
13456 | interest, which can be verbose; the @code{simple-service} procedure | |
13457 | provides a shorthand for this. | |
13458 | ||
13459 | @deffn {Scheme Procedure} simple-service @var{name} @var{target} @var{value} | |
13460 | Return a service that extends @var{target} with @var{value}. This works | |
13461 | by creating a singleton service type @var{name}, of which the returned | |
13462 | service is an instance. | |
13463 | ||
13464 | For example, this extends mcron (@pxref{Scheduled Job Execution}) with | |
13465 | an additional job: | |
13466 | ||
13467 | @example | |
13468 | (simple-service 'my-mcron-job mcron-service-type | |
13469 | #~(job '(next-hour (3)) "guix gc -F 2G")) | |
13470 | @end example | |
13471 | @end deffn | |
13472 | ||
0adfe95a LC |
13473 | At the core of the service abstraction lies the @code{fold-services} |
13474 | procedure, which is responsible for ``compiling'' a list of services | |
d62e201c LC |
13475 | down to a single directory that contains everything needed to boot and |
13476 | run the system---the directory shown by the @command{guix system build} | |
13477 | command (@pxref{Invoking guix system}). In essence, it propagates | |
13478 | service extensions down the service graph, updating each node parameters | |
13479 | on the way, until it reaches the root node. | |
0adfe95a LC |
13480 | |
13481 | @deffn {Scheme Procedure} fold-services @var{services} @ | |
d62e201c | 13482 | [#:target-type @var{system-service-type}] |
0adfe95a LC |
13483 | Fold @var{services} by propagating their extensions down to the root of |
13484 | type @var{target-type}; return the root service adjusted accordingly. | |
13485 | @end deffn | |
13486 | ||
13487 | Lastly, the @code{(gnu services)} module also defines several essential | |
13488 | service types, some of which are listed below. | |
13489 | ||
d62e201c LC |
13490 | @defvr {Scheme Variable} system-service-type |
13491 | This is the root of the service graph. It produces the system directory | |
13492 | as returned by the @command{guix system build} command. | |
13493 | @end defvr | |
13494 | ||
0adfe95a | 13495 | @defvr {Scheme Variable} boot-service-type |
d62e201c LC |
13496 | The type of the ``boot service'', which produces the @dfn{boot script}. |
13497 | The boot script is what the initial RAM disk runs when booting. | |
0adfe95a LC |
13498 | @end defvr |
13499 | ||
13500 | @defvr {Scheme Variable} etc-service-type | |
13501 | The type of the @file{/etc} service. This service can be extended by | |
13502 | passing it name/file tuples such as: | |
13503 | ||
13504 | @example | |
13505 | (list `("issue" ,(plain-file "issue" "Welcome!\n"))) | |
13506 | @end example | |
13507 | ||
13508 | In this example, the effect would be to add an @file{/etc/issue} file | |
13509 | pointing to the given file. | |
13510 | @end defvr | |
13511 | ||
13512 | @defvr {Scheme Variable} setuid-program-service-type | |
13513 | Type for the ``setuid-program service''. This service collects lists of | |
13514 | executable file names, passed as gexps, and adds them to the set of | |
13515 | setuid-root programs on the system (@pxref{Setuid Programs}). | |
13516 | @end defvr | |
13517 | ||
af4c3fd5 LC |
13518 | @defvr {Scheme Variable} profile-service-type |
13519 | Type of the service that populates the @dfn{system profile}---i.e., the | |
13520 | programs under @file{/run/current-system/profile}. Other services can | |
13521 | extend it by passing it lists of packages to add to the system profile. | |
13522 | @end defvr | |
13523 | ||
0adfe95a | 13524 | |
dd17bc38 AK |
13525 | @node Shepherd Services |
13526 | @subsubsection Shepherd Services | |
0adfe95a | 13527 | |
e32171ee | 13528 | @cindex shepherd services |
0adfe95a LC |
13529 | @cindex PID 1 |
13530 | @cindex init system | |
a40424bd CM |
13531 | The @code{(gnu services shepherd)} module provides a way to define |
13532 | services managed by the GNU@tie{}Shepherd, which is the GuixSD | |
13533 | initialization system---the first process that is started when the | |
1068f26b AE |
13534 | system boots, also known as PID@tie{}1 |
13535 | (@pxref{Introduction,,, shepherd, The GNU Shepherd Manual}). | |
6f305ea5 | 13536 | |
dd17bc38 AK |
13537 | Services in the Shepherd can depend on each other. For instance, the |
13538 | SSH daemon may need to be started after the syslog daemon has been | |
13539 | started, which in turn can only happen once all the file systems have | |
13540 | been mounted. The simple operating system defined earlier (@pxref{Using | |
13541 | the Configuration System}) results in a service graph like this: | |
6f305ea5 | 13542 | |
710fa231 | 13543 | @image{images/shepherd-graph,,5in,Typical shepherd service graph.} |
6f305ea5 LC |
13544 | |
13545 | You can actually generate such a graph for any operating system | |
710fa231 AK |
13546 | definition using the @command{guix system shepherd-graph} command |
13547 | (@pxref{system-shepherd-graph, @command{guix system shepherd-graph}}). | |
6f305ea5 | 13548 | |
d4053c71 AK |
13549 | The @var{%shepherd-root-service} is a service object representing |
13550 | PID@tie{}1, of type @var{shepherd-root-service-type}; it can be extended | |
13551 | by passing it lists of @code{<shepherd-service>} objects. | |
0adfe95a | 13552 | |
d4053c71 | 13553 | @deftp {Data Type} shepherd-service |
dd17bc38 | 13554 | The data type representing a service managed by the Shepherd. |
0adfe95a LC |
13555 | |
13556 | @table @asis | |
13557 | @item @code{provision} | |
13558 | This is a list of symbols denoting what the service provides. | |
13559 | ||
dd17bc38 AK |
13560 | These are the names that may be passed to @command{herd start}, |
13561 | @command{herd status}, and similar commands (@pxref{Invoking herd,,, | |
13562 | shepherd, The GNU Shepherd Manual}). @xref{Slots of services, the | |
13563 | @code{provides} slot,, shepherd, The GNU Shepherd Manual}, for details. | |
0adfe95a LC |
13564 | |
13565 | @item @code{requirements} (default: @code{'()}) | |
dd17bc38 | 13566 | List of symbols denoting the Shepherd services this one depends on. |
0adfe95a LC |
13567 | |
13568 | @item @code{respawn?} (default: @code{#t}) | |
13569 | Whether to restart the service when it stops, for instance when the | |
13570 | underlying process dies. | |
13571 | ||
13572 | @item @code{start} | |
13573 | @itemx @code{stop} (default: @code{#~(const #f)}) | |
dd17bc38 AK |
13574 | The @code{start} and @code{stop} fields refer to the Shepherd's |
13575 | facilities to start and stop processes (@pxref{Service De- and | |
13576 | Constructors,,, shepherd, The GNU Shepherd Manual}). They are given as | |
13577 | G-expressions that get expanded in the Shepherd configuration file | |
13578 | (@pxref{G-Expressions}). | |
0adfe95a LC |
13579 | |
13580 | @item @code{documentation} | |
13581 | A documentation string, as shown when running: | |
13582 | ||
13583 | @example | |
dd17bc38 | 13584 | herd doc @var{service-name} |
0adfe95a LC |
13585 | @end example |
13586 | ||
13587 | where @var{service-name} is one of the symbols in @var{provision} | |
dd17bc38 | 13588 | (@pxref{Invoking herd,,, shepherd, The GNU Shepherd Manual}). |
fae685b9 LC |
13589 | |
13590 | @item @code{modules} (default: @var{%default-modules}) | |
13591 | This is the list of modules that must be in scope when @code{start} and | |
13592 | @code{stop} are evaluated. | |
13593 | ||
0adfe95a LC |
13594 | @end table |
13595 | @end deftp | |
13596 | ||
d4053c71 | 13597 | @defvr {Scheme Variable} shepherd-root-service-type |
dd17bc38 | 13598 | The service type for the Shepherd ``root service''---i.e., PID@tie{}1. |
0adfe95a LC |
13599 | |
13600 | This is the service type that extensions target when they want to create | |
dd17bc38 | 13601 | shepherd services (@pxref{Service Types and Services}, for an example). |
d4053c71 | 13602 | Each extension must pass a list of @code{<shepherd-service>}. |
0adfe95a LC |
13603 | @end defvr |
13604 | ||
d4053c71 | 13605 | @defvr {Scheme Variable} %shepherd-root-service |
0adfe95a LC |
13606 | This service represents PID@tie{}1. |
13607 | @end defvr | |
8451a568 | 13608 | |
8451a568 | 13609 | |
cf4a9129 LC |
13610 | @node Installing Debugging Files |
13611 | @section Installing Debugging Files | |
8451a568 | 13612 | |
cf4a9129 LC |
13613 | @cindex debugging files |
13614 | Program binaries, as produced by the GCC compilers for instance, are | |
13615 | typically written in the ELF format, with a section containing | |
13616 | @dfn{debugging information}. Debugging information is what allows the | |
13617 | debugger, GDB, to map binary code to source code; it is required to | |
13618 | debug a compiled program in good conditions. | |
8451a568 | 13619 | |
cf4a9129 LC |
13620 | The problem with debugging information is that is takes up a fair amount |
13621 | of disk space. For example, debugging information for the GNU C Library | |
13622 | weighs in at more than 60 MiB. Thus, as a user, keeping all the | |
13623 | debugging info of all the installed programs is usually not an option. | |
13624 | Yet, space savings should not come at the cost of an impediment to | |
13625 | debugging---especially in the GNU system, which should make it easier | |
13626 | for users to exert their computing freedom (@pxref{GNU Distribution}). | |
8451a568 | 13627 | |
cf4a9129 LC |
13628 | Thankfully, the GNU Binary Utilities (Binutils) and GDB provide a |
13629 | mechanism that allows users to get the best of both worlds: debugging | |
13630 | information can be stripped from the binaries and stored in separate | |
13631 | files. GDB is then able to load debugging information from those files, | |
13632 | when they are available (@pxref{Separate Debug Files,,, gdb, Debugging | |
13633 | with GDB}). | |
8451a568 | 13634 | |
cf4a9129 LC |
13635 | The GNU distribution takes advantage of this by storing debugging |
13636 | information in the @code{lib/debug} sub-directory of a separate package | |
13637 | output unimaginatively called @code{debug} (@pxref{Packages with | |
13638 | Multiple Outputs}). Users can choose to install the @code{debug} output | |
13639 | of a package when they need it. For instance, the following command | |
13640 | installs the debugging information for the GNU C Library and for GNU | |
13641 | Guile: | |
8451a568 LC |
13642 | |
13643 | @example | |
cf4a9129 | 13644 | guix package -i glibc:debug guile:debug |
8451a568 LC |
13645 | @end example |
13646 | ||
cf4a9129 LC |
13647 | GDB must then be told to look for debug files in the user's profile, by |
13648 | setting the @code{debug-file-directory} variable (consider setting it | |
13649 | from the @file{~/.gdbinit} file, @pxref{Startup,,, gdb, Debugging with | |
13650 | GDB}): | |
8451a568 | 13651 | |
cf4a9129 LC |
13652 | @example |
13653 | (gdb) set debug-file-directory ~/.guix-profile/lib/debug | |
13654 | @end example | |
8451a568 | 13655 | |
cf4a9129 LC |
13656 | From there on, GDB will pick up debugging information from the |
13657 | @code{.debug} files under @file{~/.guix-profile/lib/debug}. | |
8451a568 | 13658 | |
cf4a9129 LC |
13659 | In addition, you will most likely want GDB to be able to show the source |
13660 | code being debugged. To do that, you will have to unpack the source | |
13661 | code of the package of interest (obtained with @code{guix build | |
13662 | --source}, @pxref{Invoking guix build}), and to point GDB to that source | |
13663 | directory using the @code{directory} command (@pxref{Source Path, | |
13664 | @code{directory},, gdb, Debugging with GDB}). | |
8451a568 | 13665 | |
cf4a9129 LC |
13666 | @c XXX: keep me up-to-date |
13667 | The @code{debug} output mechanism in Guix is implemented by the | |
13668 | @code{gnu-build-system} (@pxref{Build Systems}). Currently, it is | |
1068f26b AE |
13669 | opt-in---debugging information is available only for the packages |
13670 | with definitions explicitly declaring a @code{debug} output. This may be | |
13671 | changed to opt-out in the future if our build farm servers can handle | |
cf4a9129 LC |
13672 | the load. To check whether a package has a @code{debug} output, use |
13673 | @command{guix package --list-available} (@pxref{Invoking guix package}). | |
8451a568 | 13674 | |
8451a568 | 13675 | |
05962f29 LC |
13676 | @node Security Updates |
13677 | @section Security Updates | |
13678 | ||
09866b39 LC |
13679 | @cindex security updates |
13680 | @cindex security vulnerabilities | |
13681 | Occasionally, important security vulnerabilities are discovered in software | |
13682 | packages and must be patched. Guix developers try hard to keep track of | |
13683 | known vulnerabilities and to apply fixes as soon as possible in the | |
13684 | @code{master} branch of Guix (we do not yet provide a ``stable'' branch | |
13685 | containing only security updates.) The @command{guix lint} tool helps | |
13686 | developers find out about vulnerable versions of software packages in the | |
13687 | distribution: | |
13688 | ||
13689 | @smallexample | |
13690 | $ guix lint -c cve | |
13691 | gnu/packages/base.scm:652:2: glibc-2.21: probably vulnerable to CVE-2015-1781, CVE-2015-7547 | |
13692 | gnu/packages/gcc.scm:334:2: gcc-4.9.3: probably vulnerable to CVE-2015-5276 | |
13693 | gnu/packages/image.scm:312:2: openjpeg-2.1.0: probably vulnerable to CVE-2016-1923, CVE-2016-1924 | |
13694 | @dots{} | |
13695 | @end smallexample | |
13696 | ||
13697 | @xref{Invoking guix lint}, for more information. | |
13698 | ||
843858b8 | 13699 | @quotation Note |
09866b39 LC |
13700 | As of version @value{VERSION}, the feature described below is considered |
13701 | ``beta''. | |
843858b8 | 13702 | @end quotation |
05962f29 | 13703 | |
09866b39 | 13704 | Guix follows a functional |
05962f29 LC |
13705 | package management discipline (@pxref{Introduction}), which implies |
13706 | that, when a package is changed, @emph{every package that depends on it} | |
13707 | must be rebuilt. This can significantly slow down the deployment of | |
13708 | fixes in core packages such as libc or Bash, since basically the whole | |
13709 | distribution would need to be rebuilt. Using pre-built binaries helps | |
13710 | (@pxref{Substitutes}), but deployment may still take more time than | |
13711 | desired. | |
13712 | ||
13713 | @cindex grafts | |
1068f26b | 13714 | To address this, Guix implements @dfn{grafts}, a mechanism that allows |
05962f29 LC |
13715 | for fast deployment of critical updates without the costs associated |
13716 | with a whole-distribution rebuild. The idea is to rebuild only the | |
13717 | package that needs to be patched, and then to ``graft'' it onto packages | |
13718 | explicitly installed by the user and that were previously referring to | |
13719 | the original package. The cost of grafting is typically very low, and | |
13720 | order of magnitudes lower than a full rebuild of the dependency chain. | |
13721 | ||
13722 | @cindex replacements of packages, for grafts | |
13723 | For instance, suppose a security update needs to be applied to Bash. | |
13724 | Guix developers will provide a package definition for the ``fixed'' | |
13725 | Bash, say @var{bash-fixed}, in the usual way (@pxref{Defining | |
13726 | Packages}). Then, the original package definition is augmented with a | |
13727 | @code{replacement} field pointing to the package containing the bug fix: | |
13728 | ||
13729 | @example | |
13730 | (define bash | |
13731 | (package | |
13732 | (name "bash") | |
13733 | ;; @dots{} | |
13734 | (replacement bash-fixed))) | |
13735 | @end example | |
13736 | ||
c22a1324 LC |
13737 | From there on, any package depending directly or indirectly on Bash---as |
13738 | reported by @command{guix gc --requisites} (@pxref{Invoking guix | |
13739 | gc})---that is installed is automatically ``rewritten'' to refer to | |
05962f29 | 13740 | @var{bash-fixed} instead of @var{bash}. This grafting process takes |
1068f26b | 13741 | time proportional to the size of the package, usually less than a |
c22a1324 LC |
13742 | minute for an ``average'' package on a recent machine. Grafting is |
13743 | recursive: when an indirect dependency requires grafting, then grafting | |
13744 | ``propagates'' up to the package that the user is installing. | |
05962f29 | 13745 | |
57bdd79e LC |
13746 | Currently, the length of the name and version of the graft and that of |
13747 | the package it replaces (@var{bash-fixed} and @var{bash} in the example | |
13748 | above) must be equal. This restriction mostly comes from the fact that | |
13749 | grafting works by patching files, including binary files, directly. | |
05962f29 LC |
13750 | Other restrictions may apply: for instance, when adding a graft to a |
13751 | package providing a shared library, the original shared library and its | |
13752 | replacement must have the same @code{SONAME} and be binary-compatible. | |
13753 | ||
59a4dd50 LC |
13754 | The @option{--no-grafts} command-line option allows you to forcefully |
13755 | avoid grafting (@pxref{Common Build Options, @option{--no-grafts}}). | |
13756 | Thus, the command: | |
13757 | ||
13758 | @example | |
13759 | guix build bash --no-grafts | |
13760 | @end example | |
13761 | ||
13762 | @noindent | |
13763 | returns the store file name of the original Bash, whereas: | |
13764 | ||
13765 | @example | |
13766 | guix build bash | |
13767 | @end example | |
13768 | ||
13769 | @noindent | |
13770 | returns the store file name of the ``fixed'', replacement Bash. This | |
13771 | allows you to distinguish between the two variants of Bash. | |
13772 | ||
13773 | To verify which Bash your whole profile refers to, you can run | |
13774 | (@pxref{Invoking guix gc}): | |
13775 | ||
13776 | @example | |
13777 | guix gc -R `readlink -f ~/.guix-profile` | grep bash | |
13778 | @end example | |
13779 | ||
13780 | @noindent | |
13781 | @dots{} and compare the store file names that you get with those above. | |
13782 | Likewise for a complete GuixSD system generation: | |
13783 | ||
13784 | @example | |
13785 | guix gc -R `guix system build my-config.scm` | grep bash | |
13786 | @end example | |
13787 | ||
13788 | Lastly, to check which Bash running processes are using, you can use the | |
13789 | @command{lsof} command: | |
13790 | ||
13791 | @example | |
13792 | lsof | grep /gnu/store/.*bash | |
13793 | @end example | |
13794 | ||
05962f29 | 13795 | |
cf4a9129 LC |
13796 | @node Package Modules |
13797 | @section Package Modules | |
8451a568 | 13798 | |
cf4a9129 LC |
13799 | From a programming viewpoint, the package definitions of the |
13800 | GNU distribution are provided by Guile modules in the @code{(gnu packages | |
13801 | @dots{})} name space@footnote{Note that packages under the @code{(gnu | |
13802 | packages @dots{})} module name space are not necessarily ``GNU | |
13803 | packages''. This module naming scheme follows the usual Guile module | |
13804 | naming convention: @code{gnu} means that these modules are distributed | |
13805 | as part of the GNU system, and @code{packages} identifies modules that | |
13806 | define packages.} (@pxref{Modules, Guile modules,, guile, GNU Guile | |
13807 | Reference Manual}). For instance, the @code{(gnu packages emacs)} | |
13808 | module exports a variable named @code{emacs}, which is bound to a | |
13809 | @code{<package>} object (@pxref{Defining Packages}). | |
113daf62 | 13810 | |
300868ba | 13811 | The @code{(gnu packages @dots{})} module name space is |
cf4a9129 LC |
13812 | automatically scanned for packages by the command-line tools. For |
13813 | instance, when running @code{guix package -i emacs}, all the @code{(gnu | |
13814 | packages @dots{})} modules are scanned until one that exports a package | |
13815 | object whose name is @code{emacs} is found. This package search | |
13816 | facility is implemented in the @code{(gnu packages)} module. | |
113daf62 | 13817 | |
300868ba | 13818 | @cindex customization, of packages |
8689901f | 13819 | @cindex package module search path |
cf4a9129 | 13820 | Users can store package definitions in modules with different |
60142854 | 13821 | names---e.g., @code{(my-packages emacs)}@footnote{Note that the file |
c95ded7e LC |
13822 | name and module name must match. For instance, the @code{(my-packages |
13823 | emacs)} module must be stored in a @file{my-packages/emacs.scm} file | |
13824 | relative to the load path specified with @option{--load-path} or | |
13825 | @code{GUIX_PACKAGE_PATH}. @xref{Modules and the File System,,, | |
13826 | guile, GNU Guile Reference Manual}, for details.}. These package definitions | |
1068f26b AE |
13827 | will not be visible by default. Users can invoke commands such as |
13828 | @command{guix package} and @command{guix build} with the | |
c95ded7e LC |
13829 | @code{-e} option so that they know where to find the package. Better |
13830 | yet, they can use the | |
300868ba | 13831 | @code{-L} option of these commands to make those modules visible |
8689901f LC |
13832 | (@pxref{Invoking guix build, @code{--load-path}}), or define the |
13833 | @code{GUIX_PACKAGE_PATH} environment variable. This environment | |
13834 | variable makes it easy to extend or customize the distribution and is | |
13835 | honored by all the user interfaces. | |
13836 | ||
13837 | @defvr {Environment Variable} GUIX_PACKAGE_PATH | |
1068f26b AE |
13838 | This is a colon-separated list of directories to search for additional |
13839 | package modules. Directories listed in this variable take precedence | |
13840 | over the own modules of the distribution. | |
8689901f | 13841 | @end defvr |
ef5dd60a | 13842 | |
cf4a9129 LC |
13843 | The distribution is fully @dfn{bootstrapped} and @dfn{self-contained}: |
13844 | each package is built based solely on other packages in the | |
13845 | distribution. The root of this dependency graph is a small set of | |
13846 | @dfn{bootstrap binaries}, provided by the @code{(gnu packages | |
13847 | bootstrap)} module. For more information on bootstrapping, | |
081145cf | 13848 | @pxref{Bootstrapping}. |
ef5dd60a | 13849 | |
cf4a9129 LC |
13850 | @node Packaging Guidelines |
13851 | @section Packaging Guidelines | |
ef5dd60a | 13852 | |
e32171ee | 13853 | @cindex packages, creating |
cf4a9129 LC |
13854 | The GNU distribution is nascent and may well lack some of your favorite |
13855 | packages. This section describes how you can help make the distribution | |
13856 | grow. @xref{Contributing}, for additional information on how you can | |
13857 | help. | |
ef5dd60a | 13858 | |
cf4a9129 LC |
13859 | Free software packages are usually distributed in the form of |
13860 | @dfn{source code tarballs}---typically @file{tar.gz} files that contain | |
13861 | all the source files. Adding a package to the distribution means | |
13862 | essentially two things: adding a @dfn{recipe} that describes how to | |
13863 | build the package, including a list of other packages required to build | |
f97c9175 | 13864 | it, and adding @dfn{package metadata} along with that recipe, such as a |
cf4a9129 | 13865 | description and licensing information. |
ef5dd60a | 13866 | |
cf4a9129 LC |
13867 | In Guix all this information is embodied in @dfn{package definitions}. |
13868 | Package definitions provide a high-level view of the package. They are | |
13869 | written using the syntax of the Scheme programming language; in fact, | |
13870 | for each package we define a variable bound to the package definition, | |
13871 | and export that variable from a module (@pxref{Package Modules}). | |
13872 | However, in-depth Scheme knowledge is @emph{not} a prerequisite for | |
13873 | creating packages. For more information on package definitions, | |
081145cf | 13874 | @pxref{Defining Packages}. |
ef5dd60a | 13875 | |
cf4a9129 LC |
13876 | Once a package definition is in place, stored in a file in the Guix |
13877 | source tree, it can be tested using the @command{guix build} command | |
13878 | (@pxref{Invoking guix build}). For example, assuming the new package is | |
c71979f4 LC |
13879 | called @code{gnew}, you may run this command from the Guix build tree |
13880 | (@pxref{Running Guix Before It Is Installed}): | |
ef5dd60a LC |
13881 | |
13882 | @example | |
cf4a9129 | 13883 | ./pre-inst-env guix build gnew --keep-failed |
ef5dd60a | 13884 | @end example |
ef5dd60a | 13885 | |
cf4a9129 LC |
13886 | Using @code{--keep-failed} makes it easier to debug build failures since |
13887 | it provides access to the failed build tree. Another useful | |
13888 | command-line option when debugging is @code{--log-file}, to access the | |
13889 | build log. | |
ef5dd60a | 13890 | |
cf4a9129 LC |
13891 | If the package is unknown to the @command{guix} command, it may be that |
13892 | the source file contains a syntax error, or lacks a @code{define-public} | |
13893 | clause to export the package variable. To figure it out, you may load | |
13894 | the module from Guile to get more information about the actual error: | |
ef5dd60a | 13895 | |
cf4a9129 LC |
13896 | @example |
13897 | ./pre-inst-env guile -c '(use-modules (gnu packages gnew))' | |
13898 | @end example | |
ef5dd60a | 13899 | |
cf4a9129 LC |
13900 | Once your package builds correctly, please send us a patch |
13901 | (@pxref{Contributing}). Well, if you need help, we will be happy to | |
13902 | help you too. Once the patch is committed in the Guix repository, the | |
13903 | new package automatically gets built on the supported platforms by | |
2b1cee21 | 13904 | @url{http://hydra.gnu.org/jobset/gnu/master, our continuous integration |
cf4a9129 | 13905 | system}. |
ef5dd60a | 13906 | |
cf4a9129 LC |
13907 | @cindex substituter |
13908 | Users can obtain the new package definition simply by running | |
13909 | @command{guix pull} (@pxref{Invoking guix pull}). When | |
13910 | @code{hydra.gnu.org} is done building the package, installing the | |
13911 | package automatically downloads binaries from there | |
13912 | (@pxref{Substitutes}). The only place where human intervention is | |
13913 | needed is to review and apply the patch. | |
ef5dd60a | 13914 | |
ef5dd60a | 13915 | |
cf4a9129 | 13916 | @menu |
ec0339cd LC |
13917 | * Software Freedom:: What may go into the distribution. |
13918 | * Package Naming:: What's in a name? | |
13919 | * Version Numbers:: When the name is not enough. | |
cbd02397 | 13920 | * Synopses and Descriptions:: Helping users find the right package. |
ec0339cd LC |
13921 | * Python Modules:: Taming the snake. |
13922 | * Perl Modules:: Little pearls. | |
e1c963bf | 13923 | * Java Packages:: Coffee break. |
ec0339cd | 13924 | * Fonts:: Fond of fonts. |
cf4a9129 | 13925 | @end menu |
ef5dd60a | 13926 | |
cf4a9129 LC |
13927 | @node Software Freedom |
13928 | @subsection Software Freedom | |
ef5dd60a | 13929 | |
cf4a9129 | 13930 | @c Adapted from http://www.gnu.org/philosophy/philosophy.html. |
e32171ee | 13931 | @cindex free software |
cf4a9129 LC |
13932 | The GNU operating system has been developed so that users can have |
13933 | freedom in their computing. GNU is @dfn{free software}, meaning that | |
13934 | users have the @url{http://www.gnu.org/philosophy/free-sw.html,four | |
13935 | essential freedoms}: to run the program, to study and change the program | |
13936 | in source code form, to redistribute exact copies, and to distribute | |
13937 | modified versions. Packages found in the GNU distribution provide only | |
13938 | software that conveys these four freedoms. | |
c11a6eb1 | 13939 | |
cf4a9129 LC |
13940 | In addition, the GNU distribution follow the |
13941 | @url{http://www.gnu.org/distros/free-system-distribution-guidelines.html,free | |
13942 | software distribution guidelines}. Among other things, these guidelines | |
13943 | reject non-free firmware, recommendations of non-free software, and | |
13944 | discuss ways to deal with trademarks and patents. | |
ef5dd60a | 13945 | |
1068f26b AE |
13946 | Some otherwise free upstream package sources contain a small and optional |
13947 | subset that violates the above guidelines, for instance because this subset | |
13948 | is itself non-free code. When that happens, the offending items are removed | |
13949 | with appropriate patches or code snippets in the @code{origin} form of the | |
13950 | package (@pxref{Defining Packages}). This way, @code{guix | |
cf4a9129 LC |
13951 | build --source} returns the ``freed'' source rather than the unmodified |
13952 | upstream source. | |
ef5dd60a | 13953 | |
ef5dd60a | 13954 | |
cf4a9129 LC |
13955 | @node Package Naming |
13956 | @subsection Package Naming | |
ef5dd60a | 13957 | |
e32171ee | 13958 | @cindex package name |
cf4a9129 LC |
13959 | A package has actually two names associated with it: |
13960 | First, there is the name of the @emph{Scheme variable}, the one following | |
13961 | @code{define-public}. By this name, the package can be made known in the | |
13962 | Scheme code, for instance as input to another package. Second, there is | |
13963 | the string in the @code{name} field of a package definition. This name | |
13964 | is used by package management commands such as | |
13965 | @command{guix package} and @command{guix build}. | |
ef5dd60a | 13966 | |
cf4a9129 LC |
13967 | Both are usually the same and correspond to the lowercase conversion of |
13968 | the project name chosen upstream, with underscores replaced with | |
13969 | hyphens. For instance, GNUnet is available as @code{gnunet}, and | |
13970 | SDL_net as @code{sdl-net}. | |
927097ef | 13971 | |
cf4a9129 | 13972 | We do not add @code{lib} prefixes for library packages, unless these are |
081145cf | 13973 | already part of the official project name. But @pxref{Python |
cf4a9129 LC |
13974 | Modules} and @ref{Perl Modules} for special rules concerning modules for |
13975 | the Python and Perl languages. | |
927097ef | 13976 | |
1b366ee4 | 13977 | Font package names are handled differently, @pxref{Fonts}. |
7fec52b7 | 13978 | |
ef5dd60a | 13979 | |
cf4a9129 LC |
13980 | @node Version Numbers |
13981 | @subsection Version Numbers | |
ef5dd60a | 13982 | |
e32171ee | 13983 | @cindex package version |
cf4a9129 LC |
13984 | We usually package only the latest version of a given free software |
13985 | project. But sometimes, for instance for incompatible library versions, | |
13986 | two (or more) versions of the same package are needed. These require | |
13987 | different Scheme variable names. We use the name as defined | |
13988 | in @ref{Package Naming} | |
13989 | for the most recent version; previous versions use the same name, suffixed | |
13990 | by @code{-} and the smallest prefix of the version number that may | |
13991 | distinguish the two versions. | |
ef5dd60a | 13992 | |
cf4a9129 LC |
13993 | The name inside the package definition is the same for all versions of a |
13994 | package and does not contain any version number. | |
ef5dd60a | 13995 | |
cf4a9129 | 13996 | For instance, the versions 2.24.20 and 3.9.12 of GTK+ may be packaged as follows: |
ef5dd60a | 13997 | |
cf4a9129 LC |
13998 | @example |
13999 | (define-public gtk+ | |
14000 | (package | |
17d8e33f ML |
14001 | (name "gtk+") |
14002 | (version "3.9.12") | |
14003 | ...)) | |
cf4a9129 LC |
14004 | (define-public gtk+-2 |
14005 | (package | |
17d8e33f ML |
14006 | (name "gtk+") |
14007 | (version "2.24.20") | |
14008 | ...)) | |
cf4a9129 LC |
14009 | @end example |
14010 | If we also wanted GTK+ 3.8.2, this would be packaged as | |
14011 | @example | |
14012 | (define-public gtk+-3.8 | |
14013 | (package | |
17d8e33f ML |
14014 | (name "gtk+") |
14015 | (version "3.8.2") | |
14016 | ...)) | |
cf4a9129 | 14017 | @end example |
ef5dd60a | 14018 | |
880d647d LC |
14019 | @c See <https://lists.gnu.org/archive/html/guix-devel/2016-01/msg00425.html>, |
14020 | @c for a discussion of what follows. | |
14021 | @cindex version number, for VCS snapshots | |
14022 | Occasionally, we package snapshots of upstream's version control system | |
14023 | (VCS) instead of formal releases. This should remain exceptional, | |
14024 | because it is up to upstream developers to clarify what the stable | |
14025 | release is. Yet, it is sometimes necessary. So, what should we put in | |
14026 | the @code{version} field? | |
14027 | ||
14028 | Clearly, we need to make the commit identifier of the VCS snapshot | |
14029 | visible in the version string, but we also need to make sure that the | |
14030 | version string is monotonically increasing so that @command{guix package | |
14031 | --upgrade} can determine which version is newer. Since commit | |
14032 | identifiers, notably with Git, are not monotonically increasing, we add | |
14033 | a revision number that we increase each time we upgrade to a newer | |
14034 | snapshot. The resulting version string looks like this: | |
14035 | ||
14036 | @example | |
14037 | 2.0.11-3.cabba9e | |
14038 | ^ ^ ^ | |
14039 | | | `-- upstream commit ID | |
14040 | | | | |
14041 | | `--- Guix package revision | |
14042 | | | |
14043 | latest upstream version | |
14044 | @end example | |
14045 | ||
14046 | It is a good idea to strip commit identifiers in the @code{version} | |
14047 | field to, say, 7 digits. It avoids an aesthetic annoyance (assuming | |
14048 | aesthetics have a role to play here) as well as problems related to OS | |
14049 | limits such as the maximum shebang length (127 bytes for the Linux | |
14050 | kernel.) It is best to use the full commit identifiers in | |
561360a5 LC |
14051 | @code{origin}s, though, to avoid ambiguities. A typical package |
14052 | definition may look like this: | |
14053 | ||
14054 | @example | |
14055 | (define my-package | |
6e42660b | 14056 | (let ((commit "c3f29bc928d5900971f65965feaae59e1272a3f7") |
14057 | (revision "1")) ;Guix package revision | |
561360a5 | 14058 | (package |
6e42660b | 14059 | (version (string-append "0.9-" revision "." |
561360a5 LC |
14060 | (string-take commit 7))) |
14061 | (source (origin | |
14062 | (method git-fetch) | |
14063 | (uri (git-reference | |
14064 | (url "git://example.org/my-package.git") | |
14065 | (commit commit))) | |
14066 | (sha256 (base32 "1mbikn@dots{}")) | |
14067 | (file-name (string-append "my-package-" version | |
14068 | "-checkout")))) | |
14069 | ;; @dots{} | |
14070 | ))) | |
14071 | @end example | |
880d647d | 14072 | |
cbd02397 LC |
14073 | @node Synopses and Descriptions |
14074 | @subsection Synopses and Descriptions | |
14075 | ||
e32171ee JD |
14076 | @cindex package description |
14077 | @cindex package synopsis | |
cbd02397 LC |
14078 | As we have seen before, each package in GNU@tie{}Guix includes a |
14079 | synopsis and a description (@pxref{Defining Packages}). Synopses and | |
14080 | descriptions are important: They are what @command{guix package | |
14081 | --search} searches, and a crucial piece of information to help users | |
14082 | determine whether a given package suits their needs. Consequently, | |
14083 | packagers should pay attention to what goes into them. | |
14084 | ||
14085 | Synopses must start with a capital letter and must not end with a | |
14086 | period. They must not start with ``a'' or ``the'', which usually does | |
14087 | not bring anything; for instance, prefer ``File-frobbing tool'' over ``A | |
14088 | tool that frobs files''. The synopsis should say what the package | |
14089 | is---e.g., ``Core GNU utilities (file, text, shell)''---or what it is | |
14090 | used for---e.g., the synopsis for GNU@tie{}grep is ``Print lines | |
14091 | matching a pattern''. | |
14092 | ||
14093 | Keep in mind that the synopsis must be meaningful for a very wide | |
14094 | audience. For example, ``Manipulate alignments in the SAM format'' | |
14095 | might make sense for a seasoned bioinformatics researcher, but might be | |
14096 | fairly unhelpful or even misleading to a non-specialized audience. It | |
14097 | is a good idea to come up with a synopsis that gives an idea of the | |
14098 | application domain of the package. In this example, this might give | |
14099 | something like ``Manipulate nucleotide sequence alignments'', which | |
14100 | hopefully gives the user a better idea of whether this is what they are | |
14101 | looking for. | |
14102 | ||
cbd02397 LC |
14103 | Descriptions should take between five and ten lines. Use full |
14104 | sentences, and avoid using acronyms without first introducing them. | |
762e54b7 LC |
14105 | Please avoid marketing phrases such as ``world-leading'', |
14106 | ``industrial-strength'', and ``next-generation'', and avoid superlatives | |
14107 | like ``the most advanced''---they are not helpful to users looking for a | |
14108 | package and may even sound suspicious. Instead, try to be factual, | |
14109 | mentioning use cases and features. | |
14110 | ||
14111 | @cindex Texinfo markup, in package descriptions | |
cbd02397 LC |
14112 | Descriptions can include Texinfo markup, which is useful to introduce |
14113 | ornaments such as @code{@@code} or @code{@@dfn}, bullet lists, or | |
ba7d6c76 ML |
14114 | hyperlinks (@pxref{Overview,,, texinfo, GNU Texinfo}). However you |
14115 | should be careful when using some characters for example @samp{@@} and | |
14116 | curly braces which are the basic special characters in Texinfo | |
14117 | (@pxref{Special Characters,,, texinfo, GNU Texinfo}). User interfaces | |
14118 | such as @command{guix package --show} take care of rendering it | |
14119 | appropriately. | |
cbd02397 LC |
14120 | |
14121 | Synopses and descriptions are translated by volunteers | |
14122 | @uref{http://translationproject.org/domain/guix-packages.html, at the | |
14123 | Translation Project} so that as many users as possible can read them in | |
14124 | their native language. User interfaces search them and display them in | |
14125 | the language specified by the current locale. | |
14126 | ||
14127 | Translation is a lot of work so, as a packager, please pay even more | |
14128 | attention to your synopses and descriptions as every change may entail | |
ba7d6c76 | 14129 | additional work for translators. In order to help them, it is possible |
36743e71 | 14130 | to make recommendations or instructions visible to them by inserting |
ba7d6c76 ML |
14131 | special comments like this (@pxref{xgettext Invocation,,, gettext, GNU |
14132 | Gettext}): | |
14133 | ||
14134 | @example | |
14135 | ;; TRANSLATORS: "X11 resize-and-rotate" should not be translated. | |
14136 | (description "ARandR is designed to provide a simple visual front end | |
14137 | for the X11 resize-and-rotate (RandR) extension. @dots{}") | |
14138 | @end example | |
cbd02397 | 14139 | |
ef5dd60a | 14140 | |
cf4a9129 LC |
14141 | @node Python Modules |
14142 | @subsection Python Modules | |
ef5dd60a | 14143 | |
e32171ee | 14144 | @cindex python |
cf4a9129 LC |
14145 | We currently package Python 2 and Python 3, under the Scheme variable names |
14146 | @code{python-2} and @code{python} as explained in @ref{Version Numbers}. | |
14147 | To avoid confusion and naming clashes with other programming languages, it | |
14148 | seems desirable that the name of a package for a Python module contains | |
14149 | the word @code{python}. | |
ef5dd60a | 14150 | |
cf4a9129 LC |
14151 | Some modules are compatible with only one version of Python, others with both. |
14152 | If the package Foo compiles only with Python 3, we name it | |
14153 | @code{python-foo}; if it compiles only with Python 2, we name it | |
14154 | @code{python2-foo}. If it is compatible with both versions, we create two | |
14155 | packages with the corresponding names. | |
ef5dd60a | 14156 | |
cf4a9129 LC |
14157 | If a project already contains the word @code{python}, we drop this; |
14158 | for instance, the module python-dateutil is packaged under the names | |
99c866a0 HG |
14159 | @code{python-dateutil} and @code{python2-dateutil}. If the project name |
14160 | starts with @code{py} (e.g. @code{pytz}), we keep it and prefix it as | |
14161 | described above. | |
113daf62 | 14162 | |
e940a271 HG |
14163 | @subsubsection Specifying Dependencies |
14164 | @cindex inputs, for Python packages | |
14165 | ||
14166 | Dependency information for Python packages is usually available in the | |
14167 | package source tree, with varying degrees of accuracy: in the | |
14168 | @file{setup.py} file, in @file{requirements.txt}, or in @file{tox.ini}. | |
14169 | ||
14170 | Your mission, when writing a recipe for a Python package, is to map | |
14171 | these dependencies to the appropriate type of ``input'' (@pxref{package | |
14172 | Reference, inputs}). Although the @code{pypi} importer normally does a | |
14173 | good job (@pxref{Invoking guix import}), you may want to check the | |
14174 | following check list to determine which dependency goes where. | |
14175 | ||
14176 | @itemize | |
14177 | ||
aaf75c89 HG |
14178 | @item |
14179 | We currently package Python 2 with @code{setuptools} and @code{pip} | |
14180 | installed like Python 3.4 has per default. Thus you don't need to | |
891a843d HG |
14181 | specify either of these as an input. @command{guix lint} will warn you |
14182 | if you do. | |
aaf75c89 | 14183 | |
e940a271 HG |
14184 | @item |
14185 | Python dependencies required at run time go into | |
14186 | @code{propagated-inputs}. They are typically defined with the | |
14187 | @code{install_requires} keyword in @file{setup.py}, or in the | |
14188 | @file{requirements.txt} file. | |
14189 | ||
14190 | @item | |
14191 | Python packages required only at build time---e.g., those listed with | |
14192 | the @code{setup_requires} keyword in @file{setup.py}---or only for | |
14193 | testing---e.g., those in @code{tests_require}---go into | |
14194 | @code{native-inputs}. The rationale is that (1) they do not need to be | |
14195 | propagated because they are not needed at run time, and (2) in a | |
14196 | cross-compilation context, it's the ``native'' input that we'd want. | |
14197 | ||
aaf75c89 | 14198 | Examples are the @code{pytest}, @code{mock}, and @code{nose} test |
e940a271 HG |
14199 | frameworks. Of course if any of these packages is also required at |
14200 | run-time, it needs to go to @code{propagated-inputs}. | |
14201 | ||
14202 | @item | |
14203 | Anything that does not fall in the previous categories goes to | |
14204 | @code{inputs}, for example programs or C libraries required for building | |
14205 | Python packages containing C extensions. | |
14206 | ||
14207 | @item | |
14208 | If a Python package has optional dependencies (@code{extras_require}), | |
14209 | it is up to you to decide whether to add them or not, based on their | |
14210 | usefulness/overhead ratio (@pxref{Submitting Patches, @command{guix | |
14211 | size}}). | |
14212 | ||
14213 | @end itemize | |
14214 | ||
14215 | ||
cf4a9129 LC |
14216 | @node Perl Modules |
14217 | @subsection Perl Modules | |
523e4896 | 14218 | |
e32171ee | 14219 | @cindex perl |
cf4a9129 LC |
14220 | Perl programs standing for themselves are named as any other package, |
14221 | using the lowercase upstream name. | |
14222 | For Perl packages containing a single class, we use the lowercase class name, | |
14223 | replace all occurrences of @code{::} by dashes and prepend the prefix | |
14224 | @code{perl-}. | |
14225 | So the class @code{XML::Parser} becomes @code{perl-xml-parser}. | |
14226 | Modules containing several classes keep their lowercase upstream name and | |
14227 | are also prepended by @code{perl-}. Such modules tend to have the word | |
14228 | @code{perl} somewhere in their name, which gets dropped in favor of the | |
14229 | prefix. For instance, @code{libwww-perl} becomes @code{perl-libwww}. | |
523e4896 | 14230 | |
523e4896 | 14231 | |
e1c963bf HG |
14232 | @node Java Packages |
14233 | @subsection Java Packages | |
14234 | ||
e32171ee | 14235 | @cindex java |
e1c963bf HG |
14236 | Java programs standing for themselves are named as any other package, |
14237 | using the lowercase upstream name. | |
14238 | ||
14239 | To avoid confusion and naming clashes with other programming languages, | |
14240 | it is desirable that the name of a package for a Java package is | |
14241 | prefixed with @code{java-}. If a project already contains the word | |
14242 | @code{java}, we drop this; for instance, the package @code{ngsjava} is | |
14243 | packaged under the name @code{java-ngs}. | |
14244 | ||
14245 | For Java packages containing a single class or a small class hierarchy, | |
14246 | we use the lowercase class name, replace all occurrences of @code{.} by | |
14247 | dashes and prepend the prefix @code{java-}. So the class | |
14248 | @code{apache.commons.cli} becomes package | |
14249 | @code{java-apache-commons-cli}. | |
14250 | ||
14251 | ||
7fec52b7 AE |
14252 | @node Fonts |
14253 | @subsection Fonts | |
14254 | ||
e32171ee | 14255 | @cindex fonts |
7fec52b7 AE |
14256 | For fonts that are in general not installed by a user for typesetting |
14257 | purposes, or that are distributed as part of a larger software package, | |
14258 | we rely on the general packaging rules for software; for instance, this | |
14259 | applies to the fonts delivered as part of the X.Org system or fonts that | |
14260 | are part of TeX Live. | |
14261 | ||
14262 | To make it easier for a user to search for fonts, names for other packages | |
14263 | containing only fonts are constructed as follows, independently of the | |
14264 | upstream package name. | |
14265 | ||
14266 | The name of a package containing only one font family starts with | |
14267 | @code{font-}; it is followed by the foundry name and a dash @code{-} | |
14268 | if the foundry is known, and the font family name, in which spaces are | |
14269 | replaced by dashes (and as usual, all upper case letters are transformed | |
14270 | to lower case). | |
14271 | For example, the Gentium font family by SIL is packaged under the name | |
14272 | @code{font-sil-gentium}. | |
14273 | ||
14274 | For a package containing several font families, the name of the collection | |
14275 | is used in the place of the font family name. | |
14276 | For instance, the Liberation fonts consist of three families, | |
14277 | Liberation Sans, Liberation Serif and Liberation Mono. | |
14278 | These could be packaged separately under the names | |
14279 | @code{font-liberation-sans} and so on; but as they are distributed together | |
14280 | under a common name, we prefer to package them together as | |
14281 | @code{font-liberation}. | |
14282 | ||
14283 | In the case where several formats of the same font family or font collection | |
14284 | are packaged separately, a short form of the format, prepended by a dash, | |
14285 | is added to the package name. We use @code{-ttf} for TrueType fonts, | |
1b366ee4 | 14286 | @code{-otf} for OpenType fonts and @code{-type1} for PostScript Type 1 |
7fec52b7 AE |
14287 | fonts. |
14288 | ||
14289 | ||
b25937e3 | 14290 | |
cf4a9129 LC |
14291 | @node Bootstrapping |
14292 | @section Bootstrapping | |
b25937e3 | 14293 | |
cf4a9129 | 14294 | @c Adapted from the ELS 2013 paper. |
b25937e3 | 14295 | |
cf4a9129 | 14296 | @cindex bootstrapping |
7889394e | 14297 | |
cf4a9129 LC |
14298 | Bootstrapping in our context refers to how the distribution gets built |
14299 | ``from nothing''. Remember that the build environment of a derivation | |
14300 | contains nothing but its declared inputs (@pxref{Introduction}). So | |
14301 | there's an obvious chicken-and-egg problem: how does the first package | |
14302 | get built? How does the first compiler get compiled? Note that this is | |
14303 | a question of interest only to the curious hacker, not to the regular | |
14304 | user, so you can shamelessly skip this section if you consider yourself | |
14305 | a ``regular user''. | |
72b9d60d | 14306 | |
cf4a9129 LC |
14307 | @cindex bootstrap binaries |
14308 | The GNU system is primarily made of C code, with libc at its core. The | |
14309 | GNU build system itself assumes the availability of a Bourne shell and | |
14310 | command-line tools provided by GNU Coreutils, Awk, Findutils, `sed', and | |
14311 | `grep'. Furthermore, build programs---programs that run | |
14312 | @code{./configure}, @code{make}, etc.---are written in Guile Scheme | |
14313 | (@pxref{Derivations}). Consequently, to be able to build anything at | |
14314 | all, from scratch, Guix relies on pre-built binaries of Guile, GCC, | |
14315 | Binutils, libc, and the other packages mentioned above---the | |
14316 | @dfn{bootstrap binaries}. | |
72b9d60d | 14317 | |
cf4a9129 LC |
14318 | These bootstrap binaries are ``taken for granted'', though we can also |
14319 | re-create them if needed (more on that later). | |
72b9d60d | 14320 | |
cf4a9129 | 14321 | @unnumberedsubsec Preparing to Use the Bootstrap Binaries |
c79d54fe | 14322 | |
cf4a9129 LC |
14323 | @c As of Emacs 24.3, Info-mode displays the image, but since it's a |
14324 | @c large image, it's hard to scroll. Oh well. | |
14325 | @image{images/bootstrap-graph,6in,,Dependency graph of the early bootstrap derivations} | |
523e4896 | 14326 | |
cf4a9129 LC |
14327 | The figure above shows the very beginning of the dependency graph of the |
14328 | distribution, corresponding to the package definitions of the @code{(gnu | |
d33fa0c7 LC |
14329 | packages bootstrap)} module. A similar figure can be generated with |
14330 | @command{guix graph} (@pxref{Invoking guix graph}), along the lines of: | |
14331 | ||
14332 | @example | |
14333 | guix graph -t derivation \ | |
14334 | -e '(@@@@ (gnu packages bootstrap) %bootstrap-gcc)' \ | |
14335 | | dot -Tps > t.ps | |
14336 | @end example | |
14337 | ||
14338 | At this level of detail, things are | |
cf4a9129 LC |
14339 | slightly complex. First, Guile itself consists of an ELF executable, |
14340 | along with many source and compiled Scheme files that are dynamically | |
14341 | loaded when it runs. This gets stored in the @file{guile-2.0.7.tar.xz} | |
14342 | tarball shown in this graph. This tarball is part of Guix's ``source'' | |
14343 | distribution, and gets inserted into the store with @code{add-to-store} | |
14344 | (@pxref{The Store}). | |
2e7b5cea | 14345 | |
cf4a9129 LC |
14346 | But how do we write a derivation that unpacks this tarball and adds it |
14347 | to the store? To solve this problem, the @code{guile-bootstrap-2.0.drv} | |
14348 | derivation---the first one that gets built---uses @code{bash} as its | |
14349 | builder, which runs @code{build-bootstrap-guile.sh}, which in turn calls | |
14350 | @code{tar} to unpack the tarball. Thus, @file{bash}, @file{tar}, | |
14351 | @file{xz}, and @file{mkdir} are statically-linked binaries, also part of | |
14352 | the Guix source distribution, whose sole purpose is to allow the Guile | |
14353 | tarball to be unpacked. | |
fb729425 | 14354 | |
cf4a9129 LC |
14355 | Once @code{guile-bootstrap-2.0.drv} is built, we have a functioning |
14356 | Guile that can be used to run subsequent build programs. Its first task | |
14357 | is to download tarballs containing the other pre-built binaries---this | |
14358 | is what the @code{.tar.xz.drv} derivations do. Guix modules such as | |
14359 | @code{ftp-client.scm} are used for this purpose. The | |
14360 | @code{module-import.drv} derivations import those modules in a directory | |
14361 | in the store, using the original layout. The | |
14362 | @code{module-import-compiled.drv} derivations compile those modules, and | |
14363 | write them in an output directory with the right layout. This | |
14364 | corresponds to the @code{#:modules} argument of | |
14365 | @code{build-expression->derivation} (@pxref{Derivations}). | |
fb729425 | 14366 | |
cf4a9129 LC |
14367 | Finally, the various tarballs are unpacked by the |
14368 | derivations @code{gcc-bootstrap-0.drv}, @code{glibc-bootstrap-0.drv}, | |
14369 | etc., at which point we have a working C tool chain. | |
fb729425 | 14370 | |
fb729425 | 14371 | |
cf4a9129 | 14372 | @unnumberedsubsec Building the Build Tools |
523e4896 | 14373 | |
cf4a9129 LC |
14374 | Bootstrapping is complete when we have a full tool chain that does not |
14375 | depend on the pre-built bootstrap tools discussed above. This | |
14376 | no-dependency requirement is verified by checking whether the files of | |
14377 | the final tool chain contain references to the @file{/gnu/store} | |
14378 | directories of the bootstrap inputs. The process that leads to this | |
14379 | ``final'' tool chain is described by the package definitions found in | |
1f6f57df | 14380 | the @code{(gnu packages commencement)} module. |
df2ce343 | 14381 | |
d33fa0c7 LC |
14382 | The @command{guix graph} command allows us to ``zoom out'' compared to |
14383 | the graph above, by looking at the level of package objects instead of | |
14384 | individual derivations---remember that a package may translate to | |
14385 | several derivations, typically one derivation to download its source, | |
14386 | one to build the Guile modules it needs, and one to actually build the | |
14387 | package from source. The command: | |
14388 | ||
14389 | @example | |
14390 | guix graph -t bag \ | |
14391 | -e '(@@@@ (gnu packages commencement) | |
14392 | glibc-final-with-bootstrap-bash)' | dot -Tps > t.ps | |
14393 | @end example | |
14394 | ||
14395 | @noindent | |
14396 | produces the dependency graph leading to the ``final'' C | |
14397 | library@footnote{You may notice the @code{glibc-intermediate} label, | |
14398 | suggesting that it is not @emph{quite} final, but as a good | |
14399 | approximation, we will consider it final.}, depicted below. | |
14400 | ||
14401 | @image{images/bootstrap-packages,6in,,Dependency graph of the early packages} | |
14402 | ||
cf4a9129 LC |
14403 | @c See <http://lists.gnu.org/archive/html/gnu-system-discuss/2012-10/msg00000.html>. |
14404 | The first tool that gets built with the bootstrap binaries is | |
d33fa0c7 LC |
14405 | GNU@tie{}Make---noted @code{make-boot0} above---which is a prerequisite |
14406 | for all the following packages. From there Findutils and Diffutils get | |
14407 | built. | |
523e4896 | 14408 | |
cf4a9129 LC |
14409 | Then come the first-stage Binutils and GCC, built as pseudo cross |
14410 | tools---i.e., with @code{--target} equal to @code{--host}. They are | |
14411 | used to build libc. Thanks to this cross-build trick, this libc is | |
14412 | guaranteed not to hold any reference to the initial tool chain. | |
4af2447e | 14413 | |
d33fa0c7 LC |
14414 | From there the final Binutils and GCC (not shown above) are built. |
14415 | GCC uses @code{ld} | |
cf4a9129 LC |
14416 | from the final Binutils, and links programs against the just-built libc. |
14417 | This tool chain is used to build the other packages used by Guix and by | |
14418 | the GNU Build System: Guile, Bash, Coreutils, etc. | |
4af2447e | 14419 | |
cf4a9129 LC |
14420 | And voilà! At this point we have the complete set of build tools that |
14421 | the GNU Build System expects. These are in the @code{%final-inputs} | |
dd164244 MW |
14422 | variable of the @code{(gnu packages commencement)} module, and are |
14423 | implicitly used by any package that uses @code{gnu-build-system} | |
1f6f57df | 14424 | (@pxref{Build Systems, @code{gnu-build-system}}). |
4af2447e | 14425 | |
4af2447e | 14426 | |
cf4a9129 | 14427 | @unnumberedsubsec Building the Bootstrap Binaries |
4af2447e | 14428 | |
e32171ee | 14429 | @cindex bootstrap binaries |
cf4a9129 LC |
14430 | Because the final tool chain does not depend on the bootstrap binaries, |
14431 | those rarely need to be updated. Nevertheless, it is useful to have an | |
14432 | automated way to produce them, should an update occur, and this is what | |
14433 | the @code{(gnu packages make-bootstrap)} module provides. | |
4af2447e | 14434 | |
cf4a9129 LC |
14435 | The following command builds the tarballs containing the bootstrap |
14436 | binaries (Guile, Binutils, GCC, libc, and a tarball containing a mixture | |
14437 | of Coreutils and other basic command-line tools): | |
4b2615e1 | 14438 | |
cf4a9129 LC |
14439 | @example |
14440 | guix build bootstrap-tarballs | |
14441 | @end example | |
14442 | ||
14443 | The generated tarballs are those that should be referred to in the | |
14444 | @code{(gnu packages bootstrap)} module mentioned at the beginning of | |
14445 | this section. | |
14446 | ||
14447 | Still here? Then perhaps by now you've started to wonder: when do we | |
14448 | reach a fixed point? That is an interesting question! The answer is | |
14449 | unknown, but if you would like to investigate further (and have | |
14450 | significant computational and storage resources to do so), then let us | |
14451 | know. | |
14452 | ||
14453 | @node Porting | |
14454 | @section Porting to a New Platform | |
14455 | ||
14456 | As discussed above, the GNU distribution is self-contained, and | |
14457 | self-containment is achieved by relying on pre-built ``bootstrap | |
14458 | binaries'' (@pxref{Bootstrapping}). These binaries are specific to an | |
14459 | operating system kernel, CPU architecture, and application binary | |
14460 | interface (ABI). Thus, to port the distribution to a platform that is | |
14461 | not yet supported, one must build those bootstrap binaries, and update | |
14462 | the @code{(gnu packages bootstrap)} module to use them on that platform. | |
14463 | ||
14464 | Fortunately, Guix can @emph{cross compile} those bootstrap binaries. | |
14465 | When everything goes well, and assuming the GNU tool chain supports the | |
14466 | target platform, this can be as simple as running a command like this | |
14467 | one: | |
14468 | ||
14469 | @example | |
14470 | guix build --target=armv5tel-linux-gnueabi bootstrap-tarballs | |
14471 | @end example | |
14472 | ||
1c0c417d LC |
14473 | For this to work, the @code{glibc-dynamic-linker} procedure in |
14474 | @code{(gnu packages bootstrap)} must be augmented to return the right | |
14475 | file name for libc's dynamic linker on that platform; likewise, | |
14476 | @code{system->linux-architecture} in @code{(gnu packages linux)} must be | |
14477 | taught about the new platform. | |
14478 | ||
cf4a9129 | 14479 | Once these are built, the @code{(gnu packages bootstrap)} module needs |
1c0c417d LC |
14480 | to be updated to refer to these binaries on the target platform. That |
14481 | is, the hashes and URLs of the bootstrap tarballs for the new platform | |
14482 | must be added alongside those of the currently supported platforms. The | |
14483 | bootstrap Guile tarball is treated specially: it is expected to be | |
03d0e2d2 | 14484 | available locally, and @file{gnu/local.mk} has rules do download it for |
1c0c417d LC |
14485 | the supported architectures; a rule for the new platform must be added |
14486 | as well. | |
cf4a9129 LC |
14487 | |
14488 | In practice, there may be some complications. First, it may be that the | |
14489 | extended GNU triplet that specifies an ABI (like the @code{eabi} suffix | |
14490 | above) is not recognized by all the GNU tools. Typically, glibc | |
14491 | recognizes some of these, whereas GCC uses an extra @code{--with-abi} | |
14492 | configure flag (see @code{gcc.scm} for examples of how to handle this). | |
14493 | Second, some of the required packages could fail to build for that | |
14494 | platform. Lastly, the generated binaries could be broken for some | |
14495 | reason. | |
4af2447e | 14496 | |
9bf3c1a7 | 14497 | @c ********************************************************************* |
8c01b9d0 | 14498 | @include contributing.texi |
c78bd12b | 14499 | |
568717fd LC |
14500 | @c ********************************************************************* |
14501 | @node Acknowledgments | |
14502 | @chapter Acknowledgments | |
14503 | ||
136787cb LC |
14504 | Guix is based on the @uref{http://nixos.org/nix/, Nix package manager}, |
14505 | which was designed and | |
4c7ac9aa LC |
14506 | implemented by Eelco Dolstra, with contributions from other people (see |
14507 | the @file{nix/AUTHORS} file in Guix.) Nix pioneered functional package | |
568717fd LC |
14508 | management, and promoted unprecedented features, such as transactional |
14509 | package upgrades and rollbacks, per-user profiles, and referentially | |
14510 | transparent build processes. Without this work, Guix would not exist. | |
14511 | ||
14512 | The Nix-based software distributions, Nixpkgs and NixOS, have also been | |
14513 | an inspiration for Guix. | |
14514 | ||
4c7ac9aa LC |
14515 | GNU@tie{}Guix itself is a collective work with contributions from a |
14516 | number of people. See the @file{AUTHORS} file in Guix for more | |
14517 | information on these fine people. The @file{THANKS} file lists people | |
14518 | who have helped by reporting bugs, taking care of the infrastructure, | |
14519 | providing artwork and themes, making suggestions, and more---thank you! | |
14520 | ||
14521 | ||
568717fd LC |
14522 | @c ********************************************************************* |
14523 | @node GNU Free Documentation License | |
14524 | @appendix GNU Free Documentation License | |
e32171ee | 14525 | @cindex license, GNU Free Documentation License |
568717fd LC |
14526 | @include fdl-1.3.texi |
14527 | ||
14528 | @c ********************************************************************* | |
14529 | @node Concept Index | |
14530 | @unnumbered Concept Index | |
14531 | @printindex cp | |
14532 | ||
a85b83d2 LC |
14533 | @node Programming Index |
14534 | @unnumbered Programming Index | |
14535 | @syncodeindex tp fn | |
14536 | @syncodeindex vr fn | |
568717fd LC |
14537 | @printindex fn |
14538 | ||
14539 | @bye | |
14540 | ||
14541 | @c Local Variables: | |
14542 | @c ispell-local-dictionary: "american"; | |
14543 | @c End: |