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@* |
8a9cffb2 | 23 | Copyright @copyright{} 2015, 2016, 2017 Leo Famulari@* |
909147e4 | 24 | Copyright @copyright{} 2015, 2016 Ricardo Wurmus@* |
4d343a14 | 25 | Copyright @copyright{} 2016 Ben Woodcroft@* |
76192896 | 26 | Copyright @copyright{} 2016 Chris Marusich@* |
3b88f376 | 27 | Copyright @copyright{} 2016, 2017 Efraim Flashner@* |
d6a07ee6 | 28 | Copyright @copyright{} 2016 John Darrington@* |
92c03a87 | 29 | Copyright @copyright{} 2016 ng0@* |
8c00b838 | 30 | Copyright @copyright{} 2016 Jan Nieuwenhuizen@* |
9747d189 | 31 | Copyright @copyright{} 2016 Julien Lepiller@* |
78cef99b | 32 | Copyright @copyright{} 2016 Alex ter Weele@* |
11b7717d | 33 | Copyright @copyright{} 2017 Clément Lassieur@* |
bc5844d1 FB |
34 | Copyright @copyright{} 2017 Mathieu Othacehe@* |
35 | Copyright @copyright{} 2017 Federico Beffa | |
7df7a74e NK |
36 | |
37 | Permission is granted to copy, distribute and/or modify this document | |
38 | under the terms of the GNU Free Documentation License, Version 1.3 or | |
39 | any later version published by the Free Software Foundation; with no | |
40 | Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A | |
41 | copy of the license is included in the section entitled ``GNU Free | |
42 | Documentation License''. | |
43 | @end copying | |
568717fd | 44 | |
abd67856 | 45 | @dircategory System administration |
568717fd | 46 | @direntry |
abd67856 LC |
47 | * Guix: (guix). Manage installed software and system configuration. |
48 | * guix package: (guix)Invoking guix package. Installing, removing, and upgrading packages. | |
49 | * guix build: (guix)Invoking guix build. Building packages. | |
50 | * guix gc: (guix)Invoking guix gc. Reclaiming unused disk space. | |
51 | * guix pull: (guix)Invoking guix pull. Update the list of available packages. | |
52 | * guix system: (guix)Invoking guix system. Manage the operating system configuration. | |
568717fd | 53 | @end direntry |
568717fd | 54 | |
372c4bbc DT |
55 | @dircategory Software development |
56 | @direntry | |
abd67856 | 57 | * guix environment: (guix)Invoking guix environment. Building development environments with Guix. |
372c4bbc DT |
58 | @end direntry |
59 | ||
568717fd | 60 | @titlepage |
7730d112 LC |
61 | @title GNU Guix Reference Manual |
62 | @subtitle Using the GNU Guix Functional Package Manager | |
2cbed07e | 63 | @author The GNU Guix Developers |
568717fd LC |
64 | |
65 | @page | |
66 | @vskip 0pt plus 1filll | |
67 | Edition @value{EDITION} @* | |
68 | @value{UPDATED} @* | |
69 | ||
7df7a74e | 70 | @insertcopying |
568717fd LC |
71 | @end titlepage |
72 | ||
568717fd LC |
73 | @contents |
74 | ||
75 | @c ********************************************************************* | |
76 | @node Top | |
f8348b91 | 77 | @top GNU Guix |
568717fd | 78 | |
f8348b91 LC |
79 | This document describes GNU Guix version @value{VERSION}, a functional |
80 | package management tool written for the GNU system. | |
568717fd LC |
81 | |
82 | @menu | |
83 | * Introduction:: What is Guix about? | |
bd5e766b | 84 | * Installation:: Installing Guix. |
eeaf4427 | 85 | * Package Management:: Package installation, upgrade, etc. |
568717fd LC |
86 | * Programming Interface:: Using Guix in Scheme. |
87 | * Utilities:: Package management commands. | |
a1ba8475 | 88 | * GNU Distribution:: Software for your friendly GNU system. |
9bf3c1a7 | 89 | * Contributing:: Your help needed! |
568717fd LC |
90 | |
91 | * Acknowledgments:: Thanks! | |
92 | * GNU Free Documentation License:: The license of this manual. | |
93 | * Concept Index:: Concepts. | |
a85b83d2 | 94 | * Programming Index:: Data types, functions, and variables. |
aaa3eaa9 LC |
95 | |
96 | @detailmenu | |
97 | --- The Detailed Node Listing --- | |
98 | ||
99 | Installation | |
100 | ||
1b2b8177 | 101 | * Binary Installation:: Getting Guix running in no time! |
aaa3eaa9 | 102 | * Requirements:: Software needed to build and run Guix. |
ec0339cd | 103 | * Running the Test Suite:: Testing Guix. |
aaa3eaa9 LC |
104 | * Setting Up the Daemon:: Preparing the build daemon's environment. |
105 | * Invoking guix-daemon:: Running the build daemon. | |
0e2d0213 | 106 | * Application Setup:: Application-specific setup. |
aaa3eaa9 LC |
107 | |
108 | Setting Up the Daemon | |
109 | ||
110 | * Build Environment Setup:: Preparing the isolated build environment. | |
111 | * Daemon Offload Setup:: Offloading builds to remote machines. | |
112 | ||
113 | Package Management | |
114 | ||
115 | * Features:: How Guix will make your life brighter. | |
116 | * Invoking guix package:: Package installation, removal, etc. | |
aaa3eaa9 LC |
117 | * Substitutes:: Downloading pre-built binaries. |
118 | * Packages with Multiple Outputs:: Single source package, multiple outputs. | |
119 | * Invoking guix gc:: Running the garbage collector. | |
120 | * Invoking guix pull:: Fetching the latest Guix and distribution. | |
121 | * Invoking guix archive:: Exporting and importing store files. | |
122 | ||
123 | Programming Interface | |
124 | ||
125 | * Defining Packages:: Defining new packages. | |
126 | * Build Systems:: Specifying how packages are built. | |
127 | * The Store:: Manipulating the package store. | |
128 | * Derivations:: Low-level interface to package derivations. | |
129 | * The Store Monad:: Purely functional interface to the store. | |
130 | * G-Expressions:: Manipulating build expressions. | |
131 | ||
92492b23 LC |
132 | Defining Packages |
133 | ||
134 | * package Reference:: The package data type. | |
135 | * origin Reference:: The origin data type. | |
136 | ||
aaa3eaa9 LC |
137 | Utilities |
138 | ||
139 | * Invoking guix build:: Building packages from the command line. | |
fcc58db6 | 140 | * Invoking guix edit:: Editing package definitions. |
aaa3eaa9 LC |
141 | * Invoking guix download:: Downloading a file and printing its hash. |
142 | * Invoking guix hash:: Computing the cryptographic hash of a file. | |
143 | * Invoking guix import:: Importing package definitions. | |
144 | * Invoking guix refresh:: Updating package definitions. | |
145 | * Invoking guix lint:: Finding errors in package definitions. | |
fcc58db6 | 146 | * Invoking guix size:: Profiling disk usage. |
88856916 | 147 | * Invoking guix graph:: Visualizing the graph of packages. |
aaa3eaa9 | 148 | * Invoking guix environment:: Setting up development environments. |
aff8ce7c | 149 | * Invoking guix publish:: Sharing substitutes. |
d23c20f1 | 150 | * Invoking guix challenge:: Challenging substitute servers. |
f11c444d | 151 | * Invoking guix copy:: Copying to and from a remote store. |
32efa254 | 152 | * Invoking guix container:: Process isolation. |
aaa3eaa9 | 153 | |
e3009f60 LC |
154 | Invoking @command{guix build} |
155 | ||
156 | * Common Build Options:: Build options for most commands. | |
f11c444d | 157 | * Package Transformation Options:: Creating variants of packages. |
e3009f60 LC |
158 | * Additional Build Options:: Options specific to 'guix build'. |
159 | ||
aaa3eaa9 LC |
160 | GNU Distribution |
161 | ||
162 | * System Installation:: Installing the whole operating system. | |
35ed9306 | 163 | * System Configuration:: Configuring the operating system. |
aaa3eaa9 LC |
164 | * Installing Debugging Files:: Feeding the debugger. |
165 | * Security Updates:: Deploying security fixes quickly. | |
166 | * Package Modules:: Packages from the programmer's viewpoint. | |
167 | * Packaging Guidelines:: Growing the distribution. | |
168 | * Bootstrapping:: GNU/Linux built from scratch. | |
169 | * Porting:: Targeting another platform or kernel. | |
170 | ||
e3009f60 LC |
171 | System Installation |
172 | ||
173 | * Limitations:: What you can expect. | |
174 | * Hardware Considerations:: Supported hardware. | |
175 | * USB Stick Installation:: Preparing the installation medium. | |
176 | * Preparing for Installation:: Networking, partitioning, etc. | |
177 | * Proceeding with the Installation:: The real thing. | |
c8b54374 | 178 | * Installing GuixSD in a VM:: GuixSD playground. |
e3009f60 LC |
179 | * Building the Installation Image:: How this comes to be. |
180 | ||
aaa3eaa9 LC |
181 | System Configuration |
182 | ||
183 | * Using the Configuration System:: Customizing your GNU system. | |
184 | * operating-system Reference:: Detail of operating-system declarations. | |
185 | * File Systems:: Configuring file system mounts. | |
186 | * Mapped Devices:: Block device extra processing. | |
187 | * User Accounts:: Specifying user accounts. | |
598e19dc | 188 | * Locales:: Language and cultural convention settings. |
aaa3eaa9 LC |
189 | * Services:: Specifying system services. |
190 | * Setuid Programs:: Programs running with root privileges. | |
1b2b8177 | 191 | * X.509 Certificates:: Authenticating HTTPS servers. |
996ed739 | 192 | * Name Service Switch:: Configuring libc's name service switch. |
aaa3eaa9 LC |
193 | * Initial RAM Disk:: Linux-Libre bootstrapping. |
194 | * GRUB Configuration:: Configuring the boot loader. | |
195 | * Invoking guix system:: Instantiating a system configuration. | |
97d76250 | 196 | * Running GuixSD in a VM:: How to run GuixSD in a virtual machine. |
aaa3eaa9 LC |
197 | * Defining Services:: Adding new service definitions. |
198 | ||
199 | Services | |
200 | ||
201 | * Base Services:: Essential system services. | |
c311089b | 202 | * Scheduled Job Execution:: The mcron service. |
92c03a87 | 203 | * Log Rotation:: The rottlog service. |
aaa3eaa9 LC |
204 | * Networking Services:: Network setup, SSH daemon, etc. |
205 | * X Window:: Graphical display. | |
f11c444d | 206 | * Printing Services:: Local and remote printer support. |
1b2b8177 LC |
207 | * Desktop Services:: D-Bus and desktop services. |
208 | * Database Services:: SQL databases. | |
d8c18af8 | 209 | * Mail Services:: IMAP, POP3, SMTP, and all that. |
78cef99b | 210 | * Messaging Services:: Messaging services. |
859e367d | 211 | * Kerberos Services:: Kerberos services. |
cbd02397 | 212 | * Web Services:: Web servers. |
2be1b471 | 213 | * VPN Services:: VPN daemons. |
eb419bc9 | 214 | * Network File System:: NFS related services. |
f11c444d | 215 | * Continuous Integration:: The Cuirass service. |
dbc6d370 | 216 | * Miscellaneous Services:: Other services. |
aaa3eaa9 | 217 | |
0adfe95a LC |
218 | Defining Services |
219 | ||
220 | * Service Composition:: The model for composing services. | |
221 | * Service Types and Services:: Types and services. | |
222 | * Service Reference:: API reference. | |
dd17bc38 | 223 | * Shepherd Services:: A particular type of service. |
0adfe95a | 224 | |
aaa3eaa9 LC |
225 | Packaging Guidelines |
226 | ||
ec0339cd LC |
227 | * Software Freedom:: What may go into the distribution. |
228 | * Package Naming:: What's in a name? | |
229 | * Version Numbers:: When the name is not enough. | |
cbd02397 | 230 | * Synopses and Descriptions:: Helping users find the right package. |
ec0339cd LC |
231 | * Python Modules:: Taming the snake. |
232 | * Perl Modules:: Little pearls. | |
e1c963bf | 233 | * Java Packages:: Coffee break. |
ec0339cd | 234 | * Fonts:: Fond of fonts. |
aaa3eaa9 | 235 | |
8c01b9d0 ML |
236 | Contributing |
237 | ||
238 | * Building from Git:: The latest and greatest. | |
239 | * Running Guix Before It Is Installed:: Hacker tricks. | |
240 | * The Perfect Setup:: The right tools. | |
241 | * Coding Style:: Hygiene of the contributor. | |
242 | * Submitting Patches:: Share your work. | |
243 | ||
244 | Coding Style | |
245 | ||
246 | * Programming Paradigm:: How to compose your elements. | |
247 | * Modules:: Where to store your code? | |
248 | * Data Types and Pattern Matching:: Implementing data structures. | |
249 | * Formatting Code:: Writing conventions. | |
250 | ||
aaa3eaa9 | 251 | @end detailmenu |
568717fd LC |
252 | @end menu |
253 | ||
254 | @c ********************************************************************* | |
255 | @node Introduction | |
256 | @chapter Introduction | |
257 | ||
6f773606 | 258 | @cindex purpose |
c80e7e55 | 259 | GNU Guix@footnote{``Guix'' is pronounced like ``geeks'', or ``ɡiːks'' |
6f773606 LC |
260 | using the international phonetic alphabet (IPA).} is a package |
261 | management tool for the GNU system. Guix makes it easy for unprivileged | |
262 | users to install, upgrade, or remove packages, to roll back to a | |
263 | previous package set, to build packages from source, and generally | |
264 | assists with the creation and maintenance of software environments. | |
265 | ||
266 | @cindex user interfaces | |
267 | Guix provides a command-line package management interface | |
268 | (@pxref{Invoking guix package}), a set of command-line utilities | |
deb6276d | 269 | (@pxref{Utilities}), as well as Scheme programming interfaces |
6f773606 LC |
270 | (@pxref{Programming Interface}). |
271 | @cindex build daemon | |
272 | Its @dfn{build daemon} is responsible for building packages on behalf of | |
273 | users (@pxref{Setting Up the Daemon}) and for downloading pre-built | |
274 | binaries from authorized sources (@pxref{Substitutes}). | |
275 | ||
276 | @cindex extensibility of the distribution | |
e32171ee | 277 | @cindex customization, of packages |
6f773606 LC |
278 | Guix includes package definitions for many GNU and non-GNU packages, all |
279 | of which @uref{https://www.gnu.org/philosophy/free-sw.html, respect the | |
280 | user's computing freedom}. It is @emph{extensible}: users can write | |
281 | their own package definitions (@pxref{Defining Packages}) and make them | |
282 | available as independent package modules (@pxref{Package Modules}). It | |
283 | is also @emph{customizable}: users can @emph{derive} specialized package | |
284 | definitions from existing ones, including from the command line | |
285 | (@pxref{Package Transformation Options}). | |
286 | ||
287 | @cindex Guix System Distribution | |
288 | @cindex GuixSD | |
289 | You can install GNU@tie{}Guix on top of an existing GNU/Linux system | |
290 | where it complements the available tools without interference | |
291 | (@pxref{Installation}), or you can use it as part of the standalone | |
292 | @dfn{Guix System Distribution} or GuixSD (@pxref{GNU Distribution}). | |
293 | With GNU@tie{}GuixSD, you @emph{declare} all aspects of the operating | |
294 | system configuration and Guix takes care of instantiating the | |
295 | configuration in a transactional, reproducible, and stateless fashion | |
296 | (@pxref{System Configuration}). | |
568717fd LC |
297 | |
298 | @cindex functional package management | |
6f773606 | 299 | Under the hood, Guix implements the @dfn{functional package management} |
136787cb LC |
300 | discipline pioneered by Nix (@pxref{Acknowledgments}). |
301 | In Guix, the package build and installation process is seen | |
6f773606 | 302 | as a @emph{function}, in the mathematical sense. That function takes inputs, |
4bfc4ea3 NK |
303 | such as build scripts, a compiler, and libraries, and |
304 | returns an installed package. As a pure function, its result depends | |
568717fd LC |
305 | solely on its inputs---for instance, it cannot refer to software or |
306 | scripts that were not explicitly passed as inputs. A build function | |
4bfc4ea3 | 307 | always produces the same result when passed a given set of inputs. It |
f97c9175 | 308 | cannot alter the environment of the running system in |
568717fd LC |
309 | any way; for instance, it cannot create, modify, or delete files outside |
310 | of its build and installation directories. This is achieved by running | |
e900c503 | 311 | build processes in isolated environments (or @dfn{containers}), where only their |
4bfc4ea3 | 312 | explicit inputs are visible. |
568717fd | 313 | |
e531ac2a | 314 | @cindex store |
568717fd | 315 | The result of package build functions is @dfn{cached} in the file |
e531ac2a | 316 | system, in a special directory called @dfn{the store} (@pxref{The |
f97c9175 | 317 | Store}). Each package is installed in a directory of its own in the |
834129e0 | 318 | store---by default under @file{/gnu/store}. The directory name contains |
568717fd LC |
319 | a hash of all the inputs used to build that package; thus, changing an |
320 | input yields a different directory name. | |
321 | ||
f97c9175 AE |
322 | This approach is the foundation for the salient features of Guix: support |
323 | for transactional package upgrade and rollback, per-user installation, and | |
eeaf4427 | 324 | garbage collection of packages (@pxref{Features}). |
568717fd | 325 | |
a1ba8475 | 326 | |
bd5e766b LC |
327 | @c ********************************************************************* |
328 | @node Installation | |
329 | @chapter Installation | |
330 | ||
e32171ee | 331 | @cindex installing Guix |
48febeb8 LC |
332 | GNU Guix is available for download from its website at |
333 | @url{http://www.gnu.org/software/guix/}. This section describes the | |
334 | software requirements of Guix, as well as how to install it and get | |
335 | ready to use it. | |
bd5e766b | 336 | |
5af6de3e LC |
337 | Note that this section is concerned with the installation of the package |
338 | manager, which can be done on top of a running GNU/Linux system. If, | |
339 | instead, you want to install the complete GNU operating system, | |
6621cdb6 | 340 | @pxref{System Installation}. |
5af6de3e | 341 | |
d23ef788 LC |
342 | @cindex foreign distro |
343 | When installed on a running GNU/Linux system---thereafter called a | |
344 | @dfn{foreign distro}---GNU@tie{}Guix complements the available tools | |
345 | without interference. Its data lives exclusively in two directories, | |
346 | usually @file{/gnu/store} and @file{/var/guix}; other files on your | |
347 | system, such as @file{/etc}, are left untouched. | |
348 | ||
7fcf2a0b LC |
349 | Once installed, Guix can be updated by running @command{guix pull} |
350 | (@pxref{Invoking guix pull}). | |
351 | ||
bd5e766b | 352 | @menu |
09722b11 | 353 | * Binary Installation:: Getting Guix running in no time! |
bd5e766b | 354 | * Requirements:: Software needed to build and run Guix. |
ec0339cd | 355 | * Running the Test Suite:: Testing Guix. |
bd5e766b LC |
356 | * Setting Up the Daemon:: Preparing the build daemon's environment. |
357 | * Invoking guix-daemon:: Running the build daemon. | |
0e2d0213 | 358 | * Application Setup:: Application-specific setup. |
bd5e766b LC |
359 | @end menu |
360 | ||
09722b11 LC |
361 | @node Binary Installation |
362 | @section Binary Installation | |
363 | ||
e32171ee | 364 | @cindex installing Guix from binaries |
09722b11 LC |
365 | This section describes how to install Guix on an arbitrary system from a |
366 | self-contained tarball providing binaries for Guix and for all its | |
367 | dependencies. This is often quicker than installing from source, which | |
368 | is described in the next sections. The only requirement is to have | |
369 | GNU@tie{}tar and Xz. | |
370 | ||
371 | Installing goes along these lines: | |
372 | ||
373 | @enumerate | |
374 | @item | |
e32171ee | 375 | @cindex downloading Guix binary |
09722b11 | 376 | Download the binary tarball from |
daa8922a LC |
377 | @indicateurl{ftp://alpha.gnu.org/gnu/guix/guix-binary-@value{VERSION}.@var{system}.tar.xz}, |
378 | where @var{system} is @code{x86_64-linux} for an @code{x86_64} machine | |
379 | already running the kernel Linux, and so on. | |
380 | ||
debc6360 | 381 | @c The following is somewhat duplicated in ``System Installation''. |
daa8922a LC |
382 | Make sure to download the associated @file{.sig} file and to verify the |
383 | authenticity of the tarball against it, along these lines: | |
384 | ||
385 | @example | |
386 | $ wget ftp://alpha.gnu.org/gnu/guix/guix-binary-@value{VERSION}.@var{system}.tar.xz.sig | |
387 | $ gpg --verify guix-binary-@value{VERSION}.@var{system}.tar.xz.sig | |
388 | @end example | |
389 | ||
f97c9175 | 390 | If that command fails because you do not have the required public key, |
daa8922a LC |
391 | then run this command to import it: |
392 | ||
393 | @example | |
debc6360 | 394 | $ gpg --keyserver pgp.mit.edu --recv-keys @value{OPENPGP-SIGNING-KEY-ID} |
daa8922a LC |
395 | @end example |
396 | ||
397 | @noindent | |
398 | and rerun the @code{gpg --verify} command. | |
debc6360 | 399 | @c end authentication part |
09722b11 LC |
400 | |
401 | @item | |
402 | As @code{root}, run: | |
403 | ||
404 | @example | |
5dc42964 | 405 | # cd /tmp |
254b1c2e LC |
406 | # tar --warning=no-timestamp -xf \ |
407 | guix-binary-@value{VERSION}.@var{system}.tar.xz | |
5dc42964 | 408 | # mv var/guix /var/ && mv gnu / |
09722b11 LC |
409 | @end example |
410 | ||
7acd3439 LC |
411 | This creates @file{/gnu/store} (@pxref{The Store}) and @file{/var/guix}. |
412 | The latter contains a ready-to-use profile for @code{root} (see next | |
413 | step.) | |
09722b11 | 414 | |
5dc3ce5f LC |
415 | Do @emph{not} unpack the tarball on a working Guix system since that |
416 | would overwrite its own essential files. | |
417 | ||
254b1c2e | 418 | The @code{--warning=no-timestamp} option makes sure GNU@tie{}tar does |
e9ba6357 LC |
419 | not emit warnings about ``implausibly old time stamps'' (such |
420 | warnings were triggered by GNU@tie{}tar 1.26 and older; recent | |
421 | versions are fine.) | |
422 | They stem from the fact that all the | |
254b1c2e LC |
423 | files in the archive have their modification time set to zero (which |
424 | means January 1st, 1970.) This is done on purpose to make sure the | |
425 | archive content is independent of its creation time, thus making it | |
426 | reproducible. | |
427 | ||
7acd3439 LC |
428 | @item |
429 | Make @code{root}'s profile available under @file{~/.guix-profile}: | |
430 | ||
431 | @example | |
432 | # ln -sf /var/guix/profiles/per-user/root/guix-profile \ | |
433 | ~root/.guix-profile | |
434 | @end example | |
435 | ||
43c33047 LC |
436 | @item |
437 | Create the group and user accounts for build users as explained below | |
438 | (@pxref{Build Environment Setup}). | |
439 | ||
09722b11 | 440 | @item |
bf98aea9 | 441 | Run the daemon, and set it to automatically start on boot. |
c8e26887 | 442 | |
bf98aea9 LC |
443 | If your host distro uses the systemd init system, this can be achieved |
444 | with these commands: | |
c8e26887 GC |
445 | |
446 | @example | |
b7230de5 | 447 | # ln -s ~root/.guix-profile/lib/systemd/system/guix-daemon.service \ |
c8e26887 GC |
448 | /etc/systemd/system/ |
449 | # systemctl start guix-daemon && systemctl enable guix-daemon | |
450 | @end example | |
451 | ||
452 | If your host distro uses the Upstart init system: | |
09722b11 LC |
453 | |
454 | @example | |
b7230de5 | 455 | # ln -s ~root/.guix-profile/lib/upstart/system/guix-daemon.conf /etc/init/ |
4a780bdf | 456 | # initctl reload-configuration |
bf98aea9 | 457 | # start guix-daemon |
09722b11 LC |
458 | @end example |
459 | ||
c8e26887 GC |
460 | Otherwise, you can still start the daemon manually with: |
461 | ||
462 | @example | |
463 | # ~root/.guix-profile/bin/guix-daemon --build-users-group=guixbuild | |
464 | @end example | |
d2825c96 | 465 | |
09722b11 LC |
466 | @item |
467 | Make the @command{guix} command available to other users on the machine, | |
468 | for instance with: | |
469 | ||
470 | @example | |
471 | # mkdir -p /usr/local/bin | |
472 | # cd /usr/local/bin | |
d72d05f9 | 473 | # ln -s /var/guix/profiles/per-user/root/guix-profile/bin/guix |
09722b11 | 474 | @end example |
39f8ed14 | 475 | |
aca738f3 LC |
476 | It is also a good idea to make the Info version of this manual available |
477 | there: | |
478 | ||
479 | @example | |
480 | # mkdir -p /usr/local/share/info | |
481 | # cd /usr/local/share/info | |
482 | # for i in /var/guix/profiles/per-user/root/guix-profile/share/info/* ; | |
483 | do ln -s $i ; done | |
484 | @end example | |
485 | ||
486 | That way, assuming @file{/usr/local/share/info} is in the search path, | |
487 | running @command{info guix} will open this manual (@pxref{Other Info | |
488 | Directories,,, texinfo, GNU Texinfo}, for more details on changing the | |
489 | Info search path.) | |
490 | ||
39f8ed14 | 491 | @item |
e32171ee | 492 | @cindex substitutes, authorization thereof |
df061d07 LC |
493 | To use substitutes from @code{hydra.gnu.org} or one of its mirrors |
494 | (@pxref{Substitutes}), authorize them: | |
39f8ed14 LC |
495 | |
496 | @example | |
7acd3439 | 497 | # guix archive --authorize < ~root/.guix-profile/share/guix/hydra.gnu.org.pub |
39f8ed14 | 498 | @end example |
09722b11 LC |
499 | @end enumerate |
500 | ||
bf98aea9 | 501 | This completes root-level install of Guix. Each user will need to |
7414de0a | 502 | perform additional steps to make their Guix environment ready for use, |
c8e26887 | 503 | @pxref{Application Setup}. |
09722b11 | 504 | |
c8e26887 GC |
505 | You can confirm that Guix is working by installing a sample package into |
506 | the root profile: | |
09722b11 LC |
507 | |
508 | @example | |
c8e26887 | 509 | # guix package -i hello |
09722b11 LC |
510 | @end example |
511 | ||
c8e26887 GC |
512 | The @code{guix} package must remain available in @code{root}'s profile, |
513 | or it would become subject to garbage collection---in which case you | |
514 | would find yourself badly handicapped by the lack of the @command{guix} | |
bf98aea9 LC |
515 | command. In other words, do not remove @code{guix} by running |
516 | @code{guix package -r guix}. | |
517 | ||
518 | The binary installation tarball can be (re)produced and verified simply | |
519 | by running the following command in the Guix source tree: | |
520 | ||
521 | @example | |
522 | make guix-binary.@var{system}.tar.xz | |
523 | @end example | |
c8e26887 | 524 | |
09722b11 | 525 | |
bd5e766b LC |
526 | @node Requirements |
527 | @section Requirements | |
528 | ||
09722b11 LC |
529 | This section lists requirements when building Guix from source. The |
530 | build procedure for Guix is the same as for other GNU software, and is | |
531 | not covered here. Please see the files @file{README} and @file{INSTALL} | |
532 | in the Guix source tree for additional details. | |
533 | ||
bd5e766b LC |
534 | GNU Guix depends on the following packages: |
535 | ||
536 | @itemize | |
47c66da0 | 537 | @item @url{http://gnu.org/software/guile/, GNU Guile}, version 2.0.7 or later; |
288dca55 | 538 | @item @url{http://gnupg.org/, GNU libgcrypt}; |
f0b98b84 | 539 | @item @url{http://www.gnu.org/software/make/, GNU Make}. |
8a96bd4b ID |
540 | @end itemize |
541 | ||
542 | The following dependencies are optional: | |
543 | ||
544 | @itemize | |
9b7bd1b1 LC |
545 | @item |
546 | Installing @uref{http://gnutls.org/, GnuTLS-Guile} will allow you to | |
547 | access @code{https} URLs for substitutes, which is highly recommended | |
548 | (@pxref{Substitutes}). It also allows you to access HTTPS URLs with the | |
549 | @command{guix download} command (@pxref{Invoking guix download}), the | |
550 | @command{guix import pypi} command, and the @command{guix import cpan} | |
551 | command. @xref{Guile Preparations, how to install the GnuTLS bindings | |
552 | for Guile,, gnutls-guile, GnuTLS-Guile}. | |
553 | ||
288dca55 | 554 | @item |
8a96bd4b | 555 | Installing |
288dca55 | 556 | @url{http://savannah.nongnu.org/projects/guile-json/, Guile-JSON} will |
2f7d2d91 LC |
557 | allow you to use the @command{guix import pypi} command (@pxref{Invoking |
558 | guix import}). It is of | |
288dca55 | 559 | interest primarily for developers and not for casual users. |
4591c02e | 560 | |
21531add LC |
561 | @item |
562 | @c Note: We need at least 0.10.2 for 'channel-send-eof'. | |
f11c444d LC |
563 | Support for build offloading (@pxref{Daemon Offload Setup}) and |
564 | @command{guix copy} (@pxref{Invoking guix copy}) depends on | |
21531add LC |
565 | @uref{https://github.com/artyom-poptsov/guile-ssh, Guile-SSH}, |
566 | version 0.10.2 or later. | |
567 | ||
4591c02e LC |
568 | @item |
569 | When @url{http://zlib.net, zlib} is available, @command{guix publish} | |
570 | can compress build byproducts (@pxref{Invoking guix publish}). | |
bd5e766b LC |
571 | @end itemize |
572 | ||
573 | Unless @code{--disable-daemon} was passed to @command{configure}, the | |
574 | following packages are also needed: | |
575 | ||
576 | @itemize | |
368d08f7 LC |
577 | @item @url{http://sqlite.org, SQLite 3}; |
578 | @item @url{http://www.bzip.org, libbz2}; | |
579 | @item @url{http://gcc.gnu.org, GCC's g++}, with support for the | |
580 | C++11 standard. | |
bd5e766b LC |
581 | @end itemize |
582 | ||
e32171ee | 583 | @cindex state directory |
ef5f5c86 LC |
584 | When configuring Guix on a system that already has a Guix installation, |
585 | be sure to specify the same state directory as the existing installation | |
586 | using the @code{--localstatedir} option of the @command{configure} | |
587 | script (@pxref{Directory Variables, @code{localstatedir},, standards, | |
588 | GNU Coding Standards}). The @command{configure} script protects against | |
589 | unintended misconfiguration of @var{localstatedir} so you do not | |
590 | inadvertently corrupt your store (@pxref{The Store}). | |
591 | ||
e32171ee | 592 | @cindex Nix, compatibility |
4bfc4ea3 NK |
593 | When a working installation of @url{http://nixos.org/nix/, the Nix package |
594 | manager} is available, you | |
bd5e766b | 595 | can instead configure Guix with @code{--disable-daemon}. In that case, |
4bfc4ea3 | 596 | Nix replaces the three dependencies above. |
bd5e766b | 597 | |
b22a12fd LC |
598 | Guix is compatible with Nix, so it is possible to share the same store |
599 | between both. To do so, you must pass @command{configure} not only the | |
600 | same @code{--with-store-dir} value, but also the same | |
4bfc4ea3 NK |
601 | @code{--localstatedir} value. The latter is essential because it |
602 | specifies where the database that stores metadata about the store is | |
834129e0 | 603 | located, among other things. The default values for Nix are |
b22a12fd | 604 | @code{--with-store-dir=/nix/store} and @code{--localstatedir=/nix/var}. |
4bfc4ea3 NK |
605 | Note that @code{--disable-daemon} is not required if |
606 | your goal is to share the store with Nix. | |
b22a12fd | 607 | |
ec0339cd LC |
608 | @node Running the Test Suite |
609 | @section Running the Test Suite | |
610 | ||
e32171ee | 611 | @cindex test suite |
ec0339cd LC |
612 | After a successful @command{configure} and @code{make} run, it is a good |
613 | idea to run the test suite. It can help catch issues with the setup or | |
614 | environment, or bugs in Guix itself---and really, reporting test | |
615 | failures is a good way to help improve the software. To run the test | |
616 | suite, type: | |
617 | ||
618 | @example | |
619 | make check | |
620 | @end example | |
621 | ||
622 | Test cases can run in parallel: you can use the @code{-j} option of | |
623 | GNU@tie{}make to speed things up. The first run may take a few minutes | |
624 | on a recent machine; subsequent runs will be faster because the store | |
625 | that is created for test purposes will already have various things in | |
626 | cache. | |
627 | ||
a887fd8d LC |
628 | It is also possible to run a subset of the tests by defining the |
629 | @code{TESTS} makefile variable as in this example: | |
630 | ||
631 | @example | |
632 | make check TESTS="tests/store.scm tests/cpio.scm" | |
633 | @end example | |
634 | ||
a9edb211 ML |
635 | By default, tests results are displayed at a file level. In order to |
636 | see the details of every individual test cases, it is possible to define | |
637 | the @code{SCM_LOG_DRIVER_FLAGS} makefile variable as in this example: | |
638 | ||
639 | @example | |
640 | make check TESTS="tests/base64.scm" SCM_LOG_DRIVER_FLAGS="--brief=no" | |
641 | @end example | |
642 | ||
ec0339cd | 643 | Upon failure, please email @email{bug-guix@@gnu.org} and attach the |
a9edb211 ML |
644 | @file{test-suite.log} file. Please specify the Guix version being used |
645 | as well as version numbers of the dependencies (@pxref{Requirements}) in | |
646 | your message. | |
ec0339cd | 647 | |
0a2f2848 LC |
648 | Guix also comes with a whole-system test suite that tests complete |
649 | GuixSD operating system instances. It can only run on systems where | |
650 | Guix is already installed, using: | |
651 | ||
652 | @example | |
653 | make check-system | |
654 | @end example | |
655 | ||
656 | @noindent | |
657 | or, again, by defining @code{TESTS} to select a subset of tests to run: | |
658 | ||
659 | @example | |
660 | make check-system TESTS="basic mcron" | |
661 | @end example | |
662 | ||
663 | These system tests are defined in the @code{(gnu tests @dots{})} | |
664 | modules. They work by running the operating systems under test with | |
665 | lightweight instrumentation in a virtual machine (VM). They can be | |
666 | computationally intensive or rather cheap, depending on whether | |
667 | substitutes are available for their dependencies (@pxref{Substitutes}). | |
668 | Some of them require a lot of storage space to hold VM images. | |
669 | ||
670 | Again in case of test failures, please send @email{bug-guix@@gnu.org} | |
671 | all the details. | |
672 | ||
bd5e766b LC |
673 | @node Setting Up the Daemon |
674 | @section Setting Up the Daemon | |
675 | ||
676 | @cindex daemon | |
677 | Operations such as building a package or running the garbage collector | |
49e6291a | 678 | are all performed by a specialized process, the @dfn{build daemon}, on |
bd5e766b LC |
679 | behalf of clients. Only the daemon may access the store and its |
680 | associated database. Thus, any operation that manipulates the store | |
681 | goes through the daemon. For instance, command-line tools such as | |
e49951eb | 682 | @command{guix package} and @command{guix build} communicate with the |
bd5e766b LC |
683 | daemon (@i{via} remote procedure calls) to instruct it what to do. |
684 | ||
49e6291a | 685 | The following sections explain how to prepare the build daemon's |
f97c9175 | 686 | environment. See also @ref{Substitutes}, for information on how to allow |
225dafde | 687 | the daemon to download pre-built binaries. |
49e6291a LC |
688 | |
689 | @menu | |
690 | * Build Environment Setup:: Preparing the isolated build environment. | |
691 | * Daemon Offload Setup:: Offloading builds to remote machines. | |
692 | @end menu | |
693 | ||
694 | @node Build Environment Setup | |
695 | @subsection Build Environment Setup | |
696 | ||
e32171ee | 697 | @cindex build environment |
bd5e766b LC |
698 | In a standard multi-user setup, Guix and its daemon---the |
699 | @command{guix-daemon} program---are installed by the system | |
834129e0 | 700 | administrator; @file{/gnu/store} is owned by @code{root} and |
bd5e766b LC |
701 | @command{guix-daemon} runs as @code{root}. Unprivileged users may use |
702 | Guix tools to build packages or otherwise access the store, and the | |
703 | daemon will do it on their behalf, ensuring that the store is kept in a | |
704 | consistent state, and allowing built packages to be shared among users. | |
705 | ||
706 | @cindex build users | |
707 | When @command{guix-daemon} runs as @code{root}, you may not want package | |
708 | build processes themselves to run as @code{root} too, for obvious | |
709 | security reasons. To avoid that, a special pool of @dfn{build users} | |
710 | should be created for use by build processes started by the daemon. | |
711 | These build users need not have a shell and a home directory: they will | |
712 | just be used when the daemon drops @code{root} privileges in build | |
713 | processes. Having several such users allows the daemon to launch | |
714 | distinct build processes under separate UIDs, which guarantees that they | |
715 | do not interfere with each other---an essential feature since builds are | |
716 | regarded as pure functions (@pxref{Introduction}). | |
717 | ||
718 | On a GNU/Linux system, a build user pool may be created like this (using | |
719 | Bash syntax and the @code{shadow} commands): | |
720 | ||
091196b3 LC |
721 | @c See http://lists.gnu.org/archive/html/bug-guix/2013-01/msg00239.html |
722 | @c for why `-G' is needed. | |
bd5e766b | 723 | @example |
cfc149dc LC |
724 | # groupadd --system guixbuild |
725 | # for i in `seq -w 1 10`; | |
bd5e766b | 726 | do |
cfc149dc LC |
727 | useradd -g guixbuild -G guixbuild \ |
728 | -d /var/empty -s `which nologin` \ | |
729 | -c "Guix build user $i" --system \ | |
730 | guixbuilder$i; | |
bd5e766b LC |
731 | done |
732 | @end example | |
733 | ||
734 | @noindent | |
54eb03ab LC |
735 | The number of build users determines how many build jobs may run in |
736 | parallel, as specified by the @option{--max-jobs} option | |
eca69fc0 LC |
737 | (@pxref{Invoking guix-daemon, @option{--max-jobs}}). To use |
738 | @command{guix system vm} and related commands, you may need to add the | |
739 | build users to the @code{kvm} group so they can access @file{/dev/kvm}, | |
740 | using @code{-G guixbuild,kvm} instead of @code{-G guixbuild} | |
741 | (@pxref{Invoking guix system}). | |
742 | ||
743 | The @code{guix-daemon} program may then be run as @code{root} with the | |
d2825c96 LC |
744 | following command@footnote{If your machine uses the systemd init system, |
745 | dropping the @file{@var{prefix}/lib/systemd/system/guix-daemon.service} | |
746 | file in @file{/etc/systemd/system} will ensure that | |
ad227484 MDRS |
747 | @command{guix-daemon} is automatically started. Similarly, if your |
748 | machine uses the Upstart init system, drop the | |
749 | @file{@var{prefix}/lib/upstart/system/guix-daemon.conf} | |
750 | file in @file{/etc/init}.}: | |
bd5e766b LC |
751 | |
752 | @example | |
cfc149dc | 753 | # guix-daemon --build-users-group=guixbuild |
bd5e766b LC |
754 | @end example |
755 | ||
e900c503 | 756 | @cindex chroot |
b095792f LC |
757 | @noindent |
758 | This way, the daemon starts build processes in a chroot, under one of | |
cfc149dc | 759 | the @code{guixbuilder} users. On GNU/Linux, by default, the chroot |
6dc99317 LC |
760 | environment contains nothing but: |
761 | ||
762 | @c Keep this list in sync with libstore/build.cc! ----------------------- | |
763 | @itemize | |
764 | @item | |
4743a4da LC |
765 | a minimal @code{/dev} directory, created mostly independently from the |
766 | host @code{/dev}@footnote{``Mostly'', because while the set of files | |
767 | that appear in the chroot's @code{/dev} is fixed, most of these files | |
768 | can only be created if the host has them.}; | |
769 | ||
770 | @item | |
f97c9175 | 771 | the @code{/proc} directory; it only shows the processes of the container |
4743a4da | 772 | since a separate PID name space is used; |
6dc99317 LC |
773 | |
774 | @item | |
775 | @file{/etc/passwd} with an entry for the current user and an entry for | |
776 | user @file{nobody}; | |
777 | ||
778 | @item | |
779 | @file{/etc/group} with an entry for the user's group; | |
780 | ||
781 | @item | |
782 | @file{/etc/hosts} with an entry that maps @code{localhost} to | |
783 | @code{127.0.0.1}; | |
784 | ||
785 | @item | |
786 | a writable @file{/tmp} directory. | |
787 | @end itemize | |
b095792f | 788 | |
cb960102 ED |
789 | You can influence the directory where the daemon stores build trees |
790 | @i{via} the @code{TMPDIR} environment variable. However, the build tree | |
f97c9175 | 791 | within the chroot is always called @file{/tmp/guix-build-@var{name}.drv-0}, |
cb960102 ED |
792 | where @var{name} is the derivation name---e.g., @code{coreutils-8.24}. |
793 | This way, the value of @code{TMPDIR} does not leak inside build | |
794 | environments, which avoids discrepancies in cases where build processes | |
795 | capture the name of their build tree. | |
796 | ||
e0c941fe LC |
797 | @vindex http_proxy |
798 | The daemon also honors the @code{http_proxy} environment variable for | |
799 | HTTP downloads it performs, be it for fixed-output derivations | |
800 | (@pxref{Derivations}) or for substitutes (@pxref{Substitutes}). | |
801 | ||
1e2644bb LC |
802 | If you are installing Guix as an unprivileged user, it is still possible |
803 | to run @command{guix-daemon} provided you pass @code{--disable-chroot}. | |
804 | However, build processes will not be isolated from one another, and not | |
805 | from the rest of the system. Thus, build processes may interfere with | |
806 | each other, and may access programs, libraries, and other files | |
807 | available on the system---making it much harder to view them as | |
808 | @emph{pure} functions. | |
bd5e766b | 809 | |
49e6291a LC |
810 | |
811 | @node Daemon Offload Setup | |
812 | @subsection Using the Offload Facility | |
813 | ||
814 | @cindex offloading | |
4ec2e92d | 815 | @cindex build hook |
21531add LC |
816 | When desired, the build daemon can @dfn{offload} derivation builds to |
817 | other machines running Guix, using the @code{offload} @dfn{build | |
818 | hook}@footnote{This feature is available only when | |
819 | @uref{https://github.com/artyom-poptsov/guile-ssh, Guile-SSH} is | |
820 | present.}. When that | |
49e6291a | 821 | feature is enabled, a list of user-specified build machines is read from |
f97c9175 | 822 | @file{/etc/guix/machines.scm}; every time a build is requested, for |
49e6291a | 823 | instance via @code{guix build}, the daemon attempts to offload it to one |
f97c9175 | 824 | of the machines that satisfy the constraints of the derivation, in |
49e6291a LC |
825 | particular its system type---e.g., @file{x86_64-linux}. Missing |
826 | prerequisites for the build are copied over SSH to the target machine, | |
827 | which then proceeds with the build; upon success the output(s) of the | |
828 | build are copied back to the initial machine. | |
829 | ||
4ec2e92d | 830 | The @file{/etc/guix/machines.scm} file typically looks like this: |
49e6291a LC |
831 | |
832 | @example | |
833 | (list (build-machine | |
834 | (name "eightysix.example.org") | |
835 | (system "x86_64-linux") | |
21531add | 836 | (host-key "ssh-ed25519 AAAAC3Nza@dots{}") |
49e6291a | 837 | (user "bob") |
21531add | 838 | (speed 2.)) ;incredibly fast! |
49e6291a LC |
839 | |
840 | (build-machine | |
841 | (name "meeps.example.org") | |
842 | (system "mips64el-linux") | |
21531add | 843 | (host-key "ssh-rsa AAAAB3Nza@dots{}") |
49e6291a LC |
844 | (user "alice") |
845 | (private-key | |
846 | (string-append (getenv "HOME") | |
21531add | 847 | "/.ssh/identity-for-guix")))) |
49e6291a LC |
848 | @end example |
849 | ||
850 | @noindent | |
851 | In the example above we specify a list of two build machines, one for | |
852 | the @code{x86_64} architecture and one for the @code{mips64el} | |
4ec2e92d LC |
853 | architecture. |
854 | ||
855 | In fact, this file is---not surprisingly!---a Scheme file that is | |
856 | evaluated when the @code{offload} hook is started. Its return value | |
857 | must be a list of @code{build-machine} objects. While this example | |
858 | shows a fixed list of build machines, one could imagine, say, using | |
859 | DNS-SD to return a list of potential build machines discovered in the | |
860 | local network (@pxref{Introduction, Guile-Avahi,, guile-avahi, Using | |
c678a4ee LC |
861 | Avahi in Guile Scheme Programs}). The @code{build-machine} data type is |
862 | detailed below. | |
4ec2e92d | 863 | |
c678a4ee | 864 | @deftp {Data Type} build-machine |
f97c9175 AE |
865 | This data type represents build machines to which the daemon may offload |
866 | builds. The important fields are: | |
49e6291a LC |
867 | |
868 | @table @code | |
869 | ||
870 | @item name | |
f97c9175 | 871 | The host name of the remote machine. |
49e6291a LC |
872 | |
873 | @item system | |
f97c9175 | 874 | The system type of the remote machine---e.g., @code{"x86_64-linux"}. |
49e6291a LC |
875 | |
876 | @item user | |
877 | The user account to use when connecting to the remote machine over SSH. | |
878 | Note that the SSH key pair must @emph{not} be passphrase-protected, to | |
879 | allow non-interactive logins. | |
880 | ||
21531add LC |
881 | @item host-key |
882 | This must be the machine's SSH @dfn{public host key} in OpenSSH format. | |
883 | This is used to authenticate the machine when we connect to it. It is a | |
884 | long string that looks like this: | |
885 | ||
886 | @example | |
887 | ssh-ed25519 AAAAC3NzaC@dots{}mde+UhL hint@@example.org | |
888 | @end example | |
889 | ||
890 | If the machine is running the OpenSSH daemon, @command{sshd}, the host | |
891 | key can be found in a file such as | |
892 | @file{/etc/ssh/ssh_host_ed25519_key.pub}. | |
893 | ||
894 | If the machine is running the SSH daemon of GNU@tie{}lsh, | |
895 | @command{lshd}, the host key is in @file{/etc/lsh/host-key.pub} or a | |
896 | similar file. It can be converted to the OpenSSH format using | |
897 | @command{lsh-export-key} (@pxref{Converting keys,,, lsh, LSH Manual}): | |
898 | ||
899 | @example | |
900 | $ lsh-export-key --openssh < /etc/lsh/host-key.pub | |
901 | ssh-rsa AAAAB3NzaC1yc2EAAAAEOp8FoQAAAQEAs1eB46LV@dots{} | |
902 | @end example | |
903 | ||
49e6291a LC |
904 | @end table |
905 | ||
4ec2e92d | 906 | A number of optional fields may be specified: |
49e6291a | 907 | |
21531add | 908 | @table @asis |
49e6291a | 909 | |
21531add LC |
910 | @item @code{port} (default: @code{22}) |
911 | Port number of SSH server on the machine. | |
cecd72d5 | 912 | |
21531add LC |
913 | @item @code{private-key} (default: @file{~/.ssh/id_rsa}) |
914 | The SSH private key file to use when connecting to the machine, in | |
915 | OpenSSH format. | |
49e6291a | 916 | |
1d48cf94 LC |
917 | @item @code{compression} (default: @code{"zlib@@openssh.com,zlib"}) |
918 | @itemx @code{compression-level} (default: @code{3}) | |
919 | The SSH-level compression methods and compression level requested. | |
920 | ||
921 | Note that offloading relies on SSH compression to reduce bandwidth usage | |
922 | when transferring files to and from build machines. | |
923 | ||
cf283dd9 LC |
924 | @item @code{daemon-socket} (default: @code{"/var/guix/daemon-socket/socket"}) |
925 | File name of the Unix-domain socket @command{guix-daemon} is listening | |
926 | to on that machine. | |
c4fdfd6f | 927 | |
21531add LC |
928 | @item @code{parallel-builds} (default: @code{1}) |
929 | The number of builds that may run in parallel on the machine. | |
49e6291a | 930 | |
21531add | 931 | @item @code{speed} (default: @code{1.0}) |
49e6291a LC |
932 | A ``relative speed factor''. The offload scheduler will tend to prefer |
933 | machines with a higher speed factor. | |
934 | ||
21531add | 935 | @item @code{features} (default: @code{'()}) |
49e6291a LC |
936 | A list of strings denoting specific features supported by the machine. |
937 | An example is @code{"kvm"} for machines that have the KVM Linux modules | |
938 | and corresponding hardware support. Derivations can request features by | |
939 | name, and they will be scheduled on matching build machines. | |
940 | ||
941 | @end table | |
c678a4ee | 942 | @end deftp |
49e6291a | 943 | |
aebaee95 LC |
944 | The @code{guile} command must be in the search path on the build |
945 | machines. In addition, the Guix modules must be in | |
c4fdfd6f LC |
946 | @code{$GUILE_LOAD_PATH} on the build machine---you can check whether |
947 | this is the case by running: | |
948 | ||
949 | @example | |
21531add | 950 | ssh build-machine guile -c "'(use-modules (guix config))'" |
c4fdfd6f | 951 | @end example |
49e6291a | 952 | |
f97c9175 | 953 | There is one last thing to do once @file{machines.scm} is in place. As |
49e6291a | 954 | explained above, when offloading, files are transferred back and forth |
c4fdfd6f LC |
955 | between the machine stores. For this to work, you first need to |
956 | generate a key pair on each machine to allow the daemon to export signed | |
957 | archives of files from the store (@pxref{Invoking guix archive}): | |
49e6291a LC |
958 | |
959 | @example | |
960 | # guix archive --generate-key | |
961 | @end example | |
962 | ||
963 | @noindent | |
c4fdfd6f LC |
964 | Each build machine must authorize the key of the master machine so that |
965 | it accepts store items it receives from the master: | |
966 | ||
967 | @example | |
968 | # guix archive --authorize < master-public-key.txt | |
969 | @end example | |
970 | ||
971 | @noindent | |
972 | Likewise, the master machine must authorize the key of each build machine. | |
973 | ||
974 | All the fuss with keys is here to express pairwise mutual trust | |
975 | relations between the master and the build machines. Concretely, when | |
976 | the master receives files from a build machine (and @i{vice versa}), its | |
977 | build daemon can make sure they are genuine, have not been tampered | |
978 | with, and that they are signed by an authorized key. | |
49e6291a | 979 | |
aebaee95 LC |
980 | @cindex offload test |
981 | To test whether your setup is operational, run this command on the | |
982 | master node: | |
983 | ||
984 | @example | |
985 | # guix offload test | |
986 | @end example | |
987 | ||
988 | This will attempt to connect to each of the build machines specified in | |
989 | @file{/etc/guix/machines.scm}, make sure Guile and the Guix modules are | |
990 | available on each machine, attempt to export to the machine and import | |
991 | from it, and report any error in the process. | |
992 | ||
993 | If you want to test a different machine file, just specify it on the | |
994 | command line: | |
995 | ||
996 | @example | |
997 | # guix offload test machines-qualif.scm | |
998 | @end example | |
999 | ||
27991c97 LC |
1000 | Last, you can test the subset of the machines whose name matches a |
1001 | regular expression like this: | |
1002 | ||
1003 | @example | |
1004 | # guix offload test machines.scm '\.gnu\.org$' | |
1005 | @end example | |
49e6291a | 1006 | |
bd5e766b LC |
1007 | @node Invoking guix-daemon |
1008 | @section Invoking @command{guix-daemon} | |
1009 | ||
1010 | The @command{guix-daemon} program implements all the functionality to | |
1011 | access the store. This includes launching build processes, running the | |
1012 | garbage collector, querying the availability of a build result, etc. It | |
1013 | is normally run as @code{root} like this: | |
1014 | ||
1015 | @example | |
cfc149dc | 1016 | # guix-daemon --build-users-group=guixbuild |
bd5e766b LC |
1017 | @end example |
1018 | ||
1019 | @noindent | |
081145cf | 1020 | For details on how to set it up, @pxref{Setting Up the Daemon}. |
bd5e766b | 1021 | |
e900c503 LC |
1022 | @cindex chroot |
1023 | @cindex container, build environment | |
1024 | @cindex build environment | |
1025 | @cindex reproducible builds | |
bd5e766b LC |
1026 | By default, @command{guix-daemon} launches build processes under |
1027 | different UIDs, taken from the build group specified with | |
1028 | @code{--build-users-group}. In addition, each build process is run in a | |
1029 | chroot environment that only contains the subset of the store that the | |
1030 | build process depends on, as specified by its derivation | |
1031 | (@pxref{Programming Interface, derivation}), plus a set of specific | |
1032 | system directories. By default, the latter contains @file{/dev} and | |
e900c503 LC |
1033 | @file{/dev/pts}. Furthermore, on GNU/Linux, the build environment is a |
1034 | @dfn{container}: in addition to having its own file system tree, it has | |
1035 | a separate mount name space, its own PID name space, network name space, | |
1036 | etc. This helps achieve reproducible builds (@pxref{Features}). | |
bd5e766b | 1037 | |
cbc538fe LC |
1038 | When the daemon performs a build on behalf of the user, it creates a |
1039 | build directory under @file{/tmp} or under the directory specified by | |
1040 | its @code{TMPDIR} environment variable; this directory is shared with | |
1041 | the container for the duration of the build. Be aware that using a | |
1042 | directory other than @file{/tmp} can affect build results---for example, | |
1043 | with a longer directory name, a build process that uses Unix-domain | |
1044 | sockets might hit the name length limitation for @code{sun_path}, which | |
1045 | it would otherwise not hit. | |
1046 | ||
1047 | The build directory is automatically deleted upon completion, unless the | |
1048 | build failed and the client specified @option{--keep-failed} | |
1049 | (@pxref{Invoking guix build, @option{--keep-failed}}). | |
1050 | ||
bd5e766b LC |
1051 | The following command-line options are supported: |
1052 | ||
1053 | @table @code | |
1054 | @item --build-users-group=@var{group} | |
1055 | Take users from @var{group} to run build processes (@pxref{Setting Up | |
1056 | the Daemon, build users}). | |
1057 | ||
6858f9d1 | 1058 | @item --no-substitutes |
b5385b52 | 1059 | @cindex substitutes |
6858f9d1 | 1060 | Do not use substitutes for build products. That is, always build things |
c4202d60 LC |
1061 | locally instead of allowing downloads of pre-built binaries |
1062 | (@pxref{Substitutes}). | |
6858f9d1 | 1063 | |
b5385b52 LC |
1064 | By default substitutes are used, unless the client---such as the |
1065 | @command{guix package} command---is explicitly invoked with | |
1066 | @code{--no-substitutes}. | |
1067 | ||
1068 | When the daemon runs with @code{--no-substitutes}, clients can still | |
1069 | explicitly enable substitution @i{via} the @code{set-build-options} | |
1070 | remote procedure call (@pxref{The Store}). | |
1071 | ||
9176607e | 1072 | @item --substitute-urls=@var{urls} |
f8a8e0fe | 1073 | @anchor{daemon-substitute-urls} |
9176607e | 1074 | Consider @var{urls} the default whitespace-separated list of substitute |
df061d07 LC |
1075 | source URLs. When this option is omitted, |
1076 | @indicateurl{https://mirror.hydra.gnu.org https://hydra.gnu.org} is used | |
1077 | (@code{mirror.hydra.gnu.org} is a mirror of @code{hydra.gnu.org}). | |
9176607e LC |
1078 | |
1079 | This means that substitutes may be downloaded from @var{urls}, as long | |
1080 | as they are signed by a trusted signature (@pxref{Substitutes}). | |
1081 | ||
4ec2e92d LC |
1082 | @cindex build hook |
1083 | @item --no-build-hook | |
1084 | Do not use the @dfn{build hook}. | |
1085 | ||
1086 | The build hook is a helper program that the daemon can start and to | |
1087 | which it submits build requests. This mechanism is used to offload | |
1088 | builds to other machines (@pxref{Daemon Offload Setup}). | |
1089 | ||
bd5e766b LC |
1090 | @item --cache-failures |
1091 | Cache build failures. By default, only successful builds are cached. | |
1092 | ||
30d9aa54 LC |
1093 | When this option is used, @command{guix gc --list-failures} can be used |
1094 | to query the set of store items marked as failed; @command{guix gc | |
1095 | --clear-failures} removes store items from the set of cached failures. | |
1096 | @xref{Invoking guix gc}. | |
1097 | ||
bd5e766b LC |
1098 | @item --cores=@var{n} |
1099 | @itemx -c @var{n} | |
1100 | Use @var{n} CPU cores to build each derivation; @code{0} means as many | |
1101 | as available. | |
1102 | ||
6efc160e | 1103 | The default value is @code{0}, but it may be overridden by clients, such |
e49951eb MW |
1104 | as the @code{--cores} option of @command{guix build} (@pxref{Invoking |
1105 | guix build}). | |
bd5e766b LC |
1106 | |
1107 | The effect is to define the @code{NIX_BUILD_CORES} environment variable | |
1108 | in the build process, which can then use it to exploit internal | |
1109 | parallelism---for instance, by running @code{make -j$NIX_BUILD_CORES}. | |
1110 | ||
1111 | @item --max-jobs=@var{n} | |
1112 | @itemx -M @var{n} | |
1113 | Allow at most @var{n} build jobs in parallel. The default value is | |
f6526eb3 LC |
1114 | @code{1}. Setting it to @code{0} means that no builds will be performed |
1115 | locally; instead, the daemon will offload builds (@pxref{Daemon Offload | |
1116 | Setup}), or simply fail. | |
bd5e766b | 1117 | |
ecf84b7c LC |
1118 | @item --rounds=@var{N} |
1119 | Build each derivation @var{n} times in a row, and raise an error if | |
1120 | consecutive build results are not bit-for-bit identical. Note that this | |
1121 | setting can be overridden by clients such as @command{guix build} | |
1122 | (@pxref{Invoking guix build}). | |
1123 | ||
b4528110 ED |
1124 | When used in conjunction with @option{--keep-failed}, the differing |
1125 | output is kept in the store, under @file{/gnu/store/@dots{}-check}. | |
1126 | This makes it easy to look for differences between the two results. | |
1127 | ||
bd5e766b LC |
1128 | @item --debug |
1129 | Produce debugging output. | |
1130 | ||
1131 | This is useful to debug daemon start-up issues, but then it may be | |
1132 | overridden by clients, for example the @code{--verbosity} option of | |
e49951eb | 1133 | @command{guix build} (@pxref{Invoking guix build}). |
bd5e766b LC |
1134 | |
1135 | @item --chroot-directory=@var{dir} | |
1136 | Add @var{dir} to the build chroot. | |
1137 | ||
1138 | Doing this may change the result of build processes---for instance if | |
1139 | they use optional dependencies found in @var{dir} when it is available, | |
1140 | and not otherwise. For that reason, it is not recommended to do so. | |
1141 | Instead, make sure that each derivation declares all the inputs that it | |
1142 | needs. | |
1143 | ||
1144 | @item --disable-chroot | |
1145 | Disable chroot builds. | |
1146 | ||
1147 | Using this option is not recommended since, again, it would allow build | |
1e2644bb LC |
1148 | processes to gain access to undeclared dependencies. It is necessary, |
1149 | though, when @command{guix-daemon} is running under an unprivileged user | |
1150 | account. | |
bd5e766b LC |
1151 | |
1152 | @item --disable-log-compression | |
1153 | Disable compression of the build logs. | |
1154 | ||
1da983b9 LC |
1155 | Unless @code{--lose-logs} is used, all the build logs are kept in the |
1156 | @var{localstatedir}. To save space, the daemon automatically compresses | |
1157 | them with bzip2 by default. This option disables that. | |
1158 | ||
ab3893d7 LC |
1159 | @item --disable-deduplication |
1160 | @cindex deduplication | |
bd5e766b LC |
1161 | Disable automatic file ``deduplication'' in the store. |
1162 | ||
1da983b9 | 1163 | By default, files added to the store are automatically ``deduplicated'': |
ab3893d7 LC |
1164 | if a newly added file is identical to another one found in the store, |
1165 | the daemon makes the new file a hard link to the other file. This can | |
4988dd40 | 1166 | noticeably reduce disk usage, at the expense of slightly increased |
ab3893d7 LC |
1167 | input/output load at the end of a build process. This option disables |
1168 | this optimization. | |
1da983b9 | 1169 | |
6e37066e LC |
1170 | @item --gc-keep-outputs[=yes|no] |
1171 | Tell whether the garbage collector (GC) must keep outputs of live | |
1172 | derivations. | |
1173 | ||
1174 | When set to ``yes'', the GC will keep the outputs of any live derivation | |
1175 | available in the store---the @code{.drv} files. The default is ``no'', | |
1176 | meaning that derivation outputs are kept only if they are GC roots. | |
1177 | ||
1178 | @item --gc-keep-derivations[=yes|no] | |
1179 | Tell whether the garbage collector (GC) must keep derivations | |
1180 | corresponding to live outputs. | |
1181 | ||
1182 | When set to ``yes'', as is the case by default, the GC keeps | |
1183 | derivations---i.e., @code{.drv} files---as long as at least one of their | |
1184 | outputs is live. This allows users to keep track of the origins of | |
1185 | items in their store. Setting it to ``no'' saves a bit of disk space. | |
1186 | ||
1187 | Note that when both @code{--gc-keep-derivations} and | |
1188 | @code{--gc-keep-outputs} are used, the effect is to keep all the build | |
1189 | prerequisites (the sources, compiler, libraries, and other build-time | |
1190 | tools) of live objects in the store, regardless of whether these | |
1191 | prerequisites are live. This is convenient for developers since it | |
1192 | saves rebuilds or downloads. | |
1193 | ||
bd5e766b LC |
1194 | @item --impersonate-linux-2.6 |
1195 | On Linux-based systems, impersonate Linux 2.6. This means that the | |
1196 | kernel's @code{uname} system call will report 2.6 as the release number. | |
1197 | ||
1198 | This might be helpful to build programs that (usually wrongfully) depend | |
1199 | on the kernel version number. | |
1200 | ||
1201 | @item --lose-logs | |
1202 | Do not keep build logs. By default they are kept under | |
ce33631f | 1203 | @code{@var{localstatedir}/guix/log}. |
bd5e766b LC |
1204 | |
1205 | @item --system=@var{system} | |
1206 | Assume @var{system} as the current system type. By default it is the | |
1207 | architecture/kernel pair found at configure time, such as | |
1208 | @code{x86_64-linux}. | |
b8d2aa26 LC |
1209 | |
1210 | @item --listen=@var{socket} | |
1211 | Listen for connections on @var{socket}, the file name of a Unix-domain | |
1212 | socket. The default socket is | |
1213 | @file{@var{localstatedir}/daemon-socket/socket}. This option is only | |
1214 | useful in exceptional circumstances, such as if you need to run several | |
1215 | daemons on the same machine. | |
bd5e766b LC |
1216 | @end table |
1217 | ||
1218 | ||
0e2d0213 LC |
1219 | @node Application Setup |
1220 | @section Application Setup | |
1221 | ||
d23ef788 | 1222 | @cindex foreign distro |
85e57214 LC |
1223 | When using Guix on top of GNU/Linux distribution other than GuixSD---a |
1224 | so-called @dfn{foreign distro}---a few additional steps are needed to | |
1225 | get everything in place. Here are some of them. | |
0e2d0213 LC |
1226 | |
1227 | @subsection Locales | |
1228 | ||
5c3c1427 | 1229 | @anchor{locales-and-locpath} |
0e2d0213 | 1230 | @cindex locales, when not on GuixSD |
5c3c1427 | 1231 | @vindex LOCPATH |
85e57214 | 1232 | @vindex GUIX_LOCPATH |
f97c9175 AE |
1233 | Packages installed @i{via} Guix will not use the locale data of the |
1234 | host system. Instead, you must first install one of the locale packages | |
85e57214 LC |
1235 | available with Guix and then define the @code{GUIX_LOCPATH} environment |
1236 | variable: | |
0e2d0213 LC |
1237 | |
1238 | @example | |
1239 | $ guix package -i glibc-locales | |
85e57214 | 1240 | $ export GUIX_LOCPATH=$HOME/.guix-profile/lib/locale |
0e2d0213 LC |
1241 | @end example |
1242 | ||
1243 | Note that the @code{glibc-locales} package contains data for all the | |
1244 | locales supported by the GNU@tie{}libc and weighs in at around | |
f97c9175 | 1245 | 110@tie{}MiB. Alternatively, the @code{glibc-utf8-locales} is smaller but |
0e2d0213 LC |
1246 | limited to a few UTF-8 locales. |
1247 | ||
85e57214 LC |
1248 | The @code{GUIX_LOCPATH} variable plays a role similar to @code{LOCPATH} |
1249 | (@pxref{Locale Names, @code{LOCPATH},, libc, The GNU C Library Reference | |
1250 | Manual}). There are two important differences though: | |
1251 | ||
1252 | @enumerate | |
1253 | @item | |
f97c9175 | 1254 | @code{GUIX_LOCPATH} is honored only by the libc in Guix, and not by the libc |
85e57214 | 1255 | provided by foreign distros. Thus, using @code{GUIX_LOCPATH} allows you |
f97c9175 | 1256 | to make sure the programs of the foreign distro will not end up loading |
85e57214 LC |
1257 | incompatible locale data. |
1258 | ||
1259 | @item | |
1260 | libc suffixes each entry of @code{GUIX_LOCPATH} with @code{/X.Y}, where | |
1261 | @code{X.Y} is the libc version---e.g., @code{2.22}. This means that, | |
1262 | should your Guix profile contain a mixture of programs linked against | |
1263 | different libc version, each libc version will only try to load locale | |
1264 | data in the right format. | |
1265 | @end enumerate | |
1266 | ||
1267 | This is important because the locale data format used by different libc | |
1268 | versions may be incompatible. | |
1269 | ||
9a5187b6 LC |
1270 | @subsection Name Service Switch |
1271 | ||
1272 | @cindex name service switch, glibc | |
1273 | @cindex NSS (name service switch), glibc | |
1274 | @cindex nscd (name service caching daemon) | |
1275 | @cindex name service caching daemon (nscd) | |
1276 | When using Guix on a foreign distro, we @emph{strongly recommend} that | |
1277 | the system run the GNU C library's @dfn{name service cache daemon}, | |
1278 | @command{nscd}, which should be listening on the | |
1279 | @file{/var/run/nscd/socket} socket. Failing to do that, applications | |
1280 | installed with Guix may fail to look up host names or user accounts, or | |
1281 | may even crash. The next paragraphs explain why. | |
1282 | ||
1283 | @cindex @file{nsswitch.conf} | |
1284 | The GNU C library implements a @dfn{name service switch} (NSS), which is | |
1285 | an extensible mechanism for ``name lookups'' in general: host name | |
1286 | resolution, user accounts, and more (@pxref{Name Service Switch,,, libc, | |
1287 | The GNU C Library Reference Manual}). | |
1288 | ||
1289 | @cindex Network information service (NIS) | |
1290 | @cindex NIS (Network information service) | |
1291 | Being extensible, the NSS supports @dfn{plugins}, which provide new name | |
1292 | lookup implementations: for example, the @code{nss-mdns} plugin allow | |
1293 | resolution of @code{.local} host names, the @code{nis} plugin allows | |
1294 | user account lookup using the Network information service (NIS), and so | |
1295 | on. These extra ``lookup services'' are configured system-wide in | |
1296 | @file{/etc/nsswitch.conf}, and all the programs running on the system | |
1297 | honor those settings (@pxref{NSS Configuration File,,, libc, The GNU C | |
1298 | Reference Manual}). | |
1299 | ||
1300 | When they perform a name lookup---for instance by calling the | |
1301 | @code{getaddrinfo} function in C---applications first try to connect to | |
1302 | the nscd; on success, nscd performs name lookups on their behalf. If | |
1303 | the nscd is not running, then they perform the name lookup by | |
1304 | themselves, by loading the name lookup services into their own address | |
1305 | space and running it. These name lookup services---the | |
1306 | @file{libnss_*.so} files---are @code{dlopen}'d, but they may come from | |
1307 | the host system's C library, rather than from the C library the | |
1308 | application is linked against (the C library coming from Guix). | |
1309 | ||
1310 | And this is where the problem is: if your application is linked against | |
1311 | Guix's C library (say, glibc 2.24) and tries to load NSS plugins from | |
1312 | another C library (say, @code{libnss_mdns.so} for glibc 2.22), it will | |
1313 | likely crash or have its name lookups fail unexpectedly. | |
1314 | ||
1315 | Running @command{nscd} on the system, among other advantages, eliminates | |
1316 | this binary incompatibility problem because those @code{libnss_*.so} | |
1317 | files are loaded in the @command{nscd} process, not in applications | |
1318 | themselves. | |
1319 | ||
0e2d0213 LC |
1320 | @subsection X11 Fonts |
1321 | ||
e32171ee | 1322 | @cindex fonts |
4988dd40 | 1323 | The majority of graphical applications use Fontconfig to locate and |
f97c9175 AE |
1324 | load fonts and perform X11-client-side rendering. The @code{fontconfig} |
1325 | package in Guix looks for fonts in @file{$HOME/.guix-profile} | |
0e2d0213 | 1326 | by default. Thus, to allow graphical applications installed with Guix |
f97c9175 | 1327 | to display fonts, you have to install fonts with Guix as well. |
0e2d0213 | 1328 | Essential font packages include @code{gs-fonts}, @code{font-dejavu}, and |
8fe5b1d1 | 1329 | @code{font-gnu-freefont-ttf}. |
0e2d0213 | 1330 | |
5c36edc8 LC |
1331 | To display text written in Chinese languages, Japanese, or Korean in |
1332 | graphical applications, consider installing | |
1333 | @code{font-adobe-source-han-sans} or @code{font-wqy-zenhei}. The former | |
1334 | has multiple outputs, one per language family (@pxref{Packages with | |
1335 | Multiple Outputs}). For instance, the following command installs fonts | |
1336 | for Chinese languages: | |
1337 | ||
1338 | @example | |
1339 | guix package -i font-adobe-source-han-sans:cn | |
1340 | @end example | |
1341 | ||
e32171ee | 1342 | @cindex @code{xterm} |
1a3e6b15 AK |
1343 | Older programs such as @command{xterm} do not use Fontconfig and instead |
1344 | rely on server-side font rendering. Such programs require to specify a | |
1345 | full name of a font using XLFD (X Logical Font Description), like this: | |
1346 | ||
1347 | @example | |
1348 | -*-dejavu sans-medium-r-normal-*-*-100-*-*-*-*-*-1 | |
1349 | @end example | |
1350 | ||
1351 | To be able to use such full names for the TrueType fonts installed in | |
1352 | your Guix profile, you need to extend the font path of the X server: | |
1353 | ||
1354 | @example | |
1355 | xset +fp ~/.guix-profile/share/fonts/truetype | |
1356 | @end example | |
1357 | ||
e32171ee | 1358 | @cindex @code{xlsfonts} |
1a3e6b15 AK |
1359 | After that, you can run @code{xlsfonts} (from @code{xlsfonts} package) |
1360 | to make sure your TrueType fonts are listed there. | |
1361 | ||
b3129f2b LC |
1362 | @subsection X.509 Certificates |
1363 | ||
e32171ee | 1364 | @cindex @code{nss-certs} |
b3129f2b LC |
1365 | The @code{nss-certs} package provides X.509 certificates, which allow |
1366 | programs to authenticate Web servers accessed over HTTPS. | |
1367 | ||
1368 | When using Guix on a foreign distro, you can install this package and | |
1369 | define the relevant environment variables so that packages know where to | |
80d944b7 | 1370 | look for certificates. @xref{X.509 Certificates}, for detailed |
b3129f2b LC |
1371 | information. |
1372 | ||
6d97319c AK |
1373 | @subsection Emacs Packages |
1374 | ||
e32171ee | 1375 | @cindex @code{emacs} |
6d97319c AK |
1376 | When you install Emacs packages with Guix, the elisp files may be placed |
1377 | either in @file{$HOME/.guix-profile/share/emacs/site-lisp/} or in | |
1378 | sub-directories of | |
1379 | @file{$HOME/.guix-profile/share/emacs/site-lisp/guix.d/}. The latter | |
1380 | directory exists because potentially there may exist thousands of Emacs | |
1381 | packages and storing all their files in a single directory may be not | |
1382 | reliable (because of name conflicts). So we think using a separate | |
1383 | directory for each package is a good idea. It is very similar to how | |
1384 | the Emacs package system organizes the file structure (@pxref{Package | |
1385 | Files,,, emacs, The GNU Emacs Manual}). | |
1386 | ||
1387 | By default, Emacs (installed with Guix) ``knows'' where these packages | |
f97c9175 | 1388 | are placed, so you do not need to perform any configuration. If, for |
6d97319c | 1389 | some reason, you want to avoid auto-loading Emacs packages installed |
f97c9175 | 1390 | with Guix, you can do so by running Emacs with @code{--no-site-file} |
6d97319c AK |
1391 | option (@pxref{Init File,,, emacs, The GNU Emacs Manual}). |
1392 | ||
0e2d0213 LC |
1393 | @c TODO What else? |
1394 | ||
eeaf4427 LC |
1395 | @c ********************************************************************* |
1396 | @node Package Management | |
1397 | @chapter Package Management | |
1398 | ||
e32171ee | 1399 | @cindex packages |
f8348b91 | 1400 | The purpose of GNU Guix is to allow users to easily install, upgrade, and |
eeaf4427 | 1401 | remove software packages, without having to know about their build |
f97c9175 | 1402 | procedures or dependencies. Guix also goes beyond this obvious set of |
eeaf4427 LC |
1403 | features. |
1404 | ||
1405 | This chapter describes the main features of Guix, as well as the package | |
deb6276d AK |
1406 | management tools it provides. Along with the command-line interface |
1407 | described below (@pxref{Invoking guix package, @code{guix package}}), | |
1408 | you may also use Emacs Interface, after installing @code{emacs-guix} | |
1409 | package (run @kbd{M-x guix-help} command to start with it): | |
1410 | ||
1411 | @example | |
1412 | guix package -i emacs-guix | |
1413 | @end example | |
eeaf4427 LC |
1414 | |
1415 | @menu | |
1416 | * Features:: How Guix will make your life brighter. | |
e49951eb | 1417 | * Invoking guix package:: Package installation, removal, etc. |
c4202d60 | 1418 | * Substitutes:: Downloading pre-built binaries. |
760c60d6 | 1419 | * Packages with Multiple Outputs:: Single source package, multiple outputs. |
e49951eb | 1420 | * Invoking guix gc:: Running the garbage collector. |
f651b477 | 1421 | * Invoking guix pull:: Fetching the latest Guix and distribution. |
760c60d6 | 1422 | * Invoking guix archive:: Exporting and importing store files. |
eeaf4427 LC |
1423 | @end menu |
1424 | ||
1425 | @node Features | |
1426 | @section Features | |
1427 | ||
1428 | When using Guix, each package ends up in the @dfn{package store}, in its | |
1429 | own directory---something that resembles | |
deb6276d | 1430 | @file{/gnu/store/xxx-package-1.2}, where @code{xxx} is a base32 string. |
eeaf4427 LC |
1431 | |
1432 | Instead of referring to these directories, users have their own | |
1433 | @dfn{profile}, which points to the packages that they actually want to | |
821b0015 LC |
1434 | use. These profiles are stored within each user's home directory, at |
1435 | @code{$HOME/.guix-profile}. | |
eeaf4427 | 1436 | |
821b0015 | 1437 | For example, @code{alice} installs GCC 4.7.2. As a result, |
eeaf4427 | 1438 | @file{/home/alice/.guix-profile/bin/gcc} points to |
834129e0 | 1439 | @file{/gnu/store/@dots{}-gcc-4.7.2/bin/gcc}. Now, on the same machine, |
821b0015 LC |
1440 | @code{bob} had already installed GCC 4.8.0. The profile of @code{bob} |
1441 | simply continues to point to | |
834129e0 | 1442 | @file{/gnu/store/@dots{}-gcc-4.8.0/bin/gcc}---i.e., both versions of GCC |
821b0015 | 1443 | coexist on the same system without any interference. |
eeaf4427 | 1444 | |
e49951eb | 1445 | The @command{guix package} command is the central tool to manage |
f97c9175 | 1446 | packages (@pxref{Invoking guix package}). It operates on the per-user |
821b0015 | 1447 | profiles, and can be used @emph{with normal user privileges}. |
eeaf4427 | 1448 | |
e32171ee | 1449 | @cindex transactions |
eeaf4427 LC |
1450 | The command provides the obvious install, remove, and upgrade |
1451 | operations. Each invocation is actually a @emph{transaction}: either | |
ba55b1cb | 1452 | the specified operation succeeds, or nothing happens. Thus, if the |
e49951eb | 1453 | @command{guix package} process is terminated during the transaction, |
eeaf4427 LC |
1454 | or if a power outage occurs during the transaction, then the user's |
1455 | profile remains in its previous state, and remains usable. | |
1456 | ||
1457 | In addition, any package transaction may be @emph{rolled back}. So, if, | |
1458 | for example, an upgrade installs a new version of a package that turns | |
1459 | out to have a serious bug, users may roll back to the previous instance | |
4af2447e | 1460 | of their profile, which was known to work well. Similarly, the global |
6f773606 LC |
1461 | system configuration on GuixSD is subject to |
1462 | transactional upgrades and roll-back | |
4af2447e | 1463 | (@pxref{Using the Configuration System}). |
eeaf4427 | 1464 | |
f97c9175 AE |
1465 | All packages in the package store may be @emph{garbage-collected}. |
1466 | Guix can determine which packages are still referenced by user | |
fe8ff028 | 1467 | profiles, and remove those that are provably no longer referenced |
e49951eb | 1468 | (@pxref{Invoking guix gc}). Users may also explicitly remove old |
fe8ff028 LC |
1469 | generations of their profile so that the packages they refer to can be |
1470 | collected. | |
eeaf4427 | 1471 | |
e900c503 LC |
1472 | @cindex reproducibility |
1473 | @cindex reproducible builds | |
eeaf4427 LC |
1474 | Finally, Guix takes a @dfn{purely functional} approach to package |
1475 | management, as described in the introduction (@pxref{Introduction}). | |
834129e0 | 1476 | Each @file{/gnu/store} package directory name contains a hash of all the |
eeaf4427 LC |
1477 | inputs that were used to build that package---compiler, libraries, build |
1478 | scripts, etc. This direct correspondence allows users to make sure a | |
1479 | given package installation matches the current state of their | |
e900c503 LC |
1480 | distribution. It also helps maximize @dfn{build reproducibility}: |
1481 | thanks to the isolated build environments that are used, a given build | |
1482 | is likely to yield bit-identical files when performed on different | |
1483 | machines (@pxref{Invoking guix-daemon, container}). | |
eeaf4427 | 1484 | |
c4202d60 | 1485 | @cindex substitutes |
eeaf4427 | 1486 | This foundation allows Guix to support @dfn{transparent binary/source |
c4202d60 | 1487 | deployment}. When a pre-built binary for a @file{/gnu/store} item is |
18f2887b | 1488 | available from an external source---a @dfn{substitute}, Guix just |
c4202d60 LC |
1489 | downloads it and unpacks it; |
1490 | otherwise, it builds the package from source, locally | |
bf9eacd2 LC |
1491 | (@pxref{Substitutes}). Because build results are usually bit-for-bit |
1492 | reproducible, users do not have to trust servers that provide | |
1493 | substitutes: they can force a local build and @emph{challenge} providers | |
1494 | (@pxref{Invoking guix challenge}). | |
eeaf4427 | 1495 | |
f5fd4fd2 LC |
1496 | Control over the build environment is a feature that is also useful for |
1497 | developers. The @command{guix environment} command allows developers of | |
1498 | a package to quickly set up the right development environment for their | |
f97c9175 AE |
1499 | package, without having to manually install the dependencies of the |
1500 | package into their profile (@pxref{Invoking guix environment}). | |
f5fd4fd2 | 1501 | |
e49951eb MW |
1502 | @node Invoking guix package |
1503 | @section Invoking @command{guix package} | |
eeaf4427 | 1504 | |
e32171ee JD |
1505 | @cindex installing packages |
1506 | @cindex removing packages | |
1507 | @cindex package installation | |
1508 | @cindex package removal | |
e49951eb | 1509 | The @command{guix package} command is the tool that allows users to |
eeaf4427 LC |
1510 | install, upgrade, and remove packages, as well as rolling back to |
1511 | previous configurations. It operates only on the user's own profile, | |
1512 | and works with normal user privileges (@pxref{Features}). Its syntax | |
1513 | is: | |
1514 | ||
1515 | @example | |
e49951eb | 1516 | guix package @var{options} |
eeaf4427 | 1517 | @end example |
e32171ee | 1518 | @cindex transactions |
ba55b1cb | 1519 | Primarily, @var{options} specifies the operations to be performed during |
eeaf4427 | 1520 | the transaction. Upon completion, a new profile is created, but |
99bd74d5 | 1521 | previous @dfn{generations} of the profile remain available, should the user |
eeaf4427 LC |
1522 | want to roll back. |
1523 | ||
6447738c MW |
1524 | For example, to remove @code{lua} and install @code{guile} and |
1525 | @code{guile-cairo} in a single transaction: | |
1526 | ||
1527 | @example | |
1528 | guix package -r lua -i guile guile-cairo | |
1529 | @end example | |
1530 | ||
99bd74d5 LC |
1531 | @command{guix package} also supports a @dfn{declarative approach} |
1532 | whereby the user specifies the exact set of packages to be available and | |
1533 | passes it @i{via} the @option{--manifest} option | |
1534 | (@pxref{profile-manifest, @option{--manifest}}). | |
1535 | ||
e32171ee | 1536 | @cindex profile |
b9e5c0a9 | 1537 | For each user, a symlink to the user's default profile is automatically |
0ec1af59 | 1538 | created in @file{$HOME/.guix-profile}. This symlink always points to the |
b9e5c0a9 LC |
1539 | current generation of the user's default profile. Thus, users can add |
1540 | @file{$HOME/.guix-profile/bin} to their @code{PATH} environment | |
1541 | variable, and so on. | |
d664f1b4 LC |
1542 | @cindex search paths |
1543 | If you are not using the Guix System Distribution, consider adding the | |
1544 | following lines to your @file{~/.bash_profile} (@pxref{Bash Startup | |
1545 | Files,,, bash, The GNU Bash Reference Manual}) so that newly-spawned | |
1546 | shells get all the right environment variable definitions: | |
1547 | ||
1548 | @example | |
1549 | GUIX_PROFILE="$HOME/.guix-profile" \ | |
1550 | source "$HOME/.guix-profile/etc/profile" | |
1551 | @end example | |
b9e5c0a9 | 1552 | |
4379c35b LC |
1553 | In a multi-user setup, user profiles are stored in a place registered as |
1554 | a @dfn{garbage-collector root}, which @file{$HOME/.guix-profile} points | |
1555 | to (@pxref{Invoking guix gc}). That directory is normally | |
0ec1af59 LC |
1556 | @code{@var{localstatedir}/profiles/per-user/@var{user}}, where |
1557 | @var{localstatedir} is the value passed to @code{configure} as | |
4379c35b LC |
1558 | @code{--localstatedir}, and @var{user} is the user name. The |
1559 | @file{per-user} directory is created when @command{guix-daemon} is | |
1560 | started, and the @var{user} sub-directory is created by @command{guix | |
1561 | package}. | |
0ec1af59 LC |
1562 | |
1563 | The @var{options} can be among the following: | |
1564 | ||
eeaf4427 LC |
1565 | @table @code |
1566 | ||
6447738c MW |
1567 | @item --install=@var{package} @dots{} |
1568 | @itemx -i @var{package} @dots{} | |
1569 | Install the specified @var{package}s. | |
eeaf4427 | 1570 | |
6447738c | 1571 | Each @var{package} may specify either a simple package name, such as |
1b846da8 ML |
1572 | @code{guile}, or a package name followed by an at-sign and version number, |
1573 | such as @code{guile@@1.8.8} or simply @code{guile@@1.8} (in the latter | |
724311a2 LC |
1574 | case, the newest version prefixed by @code{1.8} is selected.) |
1575 | ||
1576 | If no version number is specified, the | |
dc5669cd MW |
1577 | newest available version will be selected. In addition, @var{package} |
1578 | may contain a colon, followed by the name of one of the outputs of the | |
1b846da8 | 1579 | package, as in @code{gcc:doc} or @code{binutils@@2.22:lib} |
e7f34eb0 LC |
1580 | (@pxref{Packages with Multiple Outputs}). Packages with a corresponding |
1581 | name (and optionally version) are searched for among the GNU | |
1582 | distribution modules (@pxref{Package Modules}). | |
eeaf4427 | 1583 | |
461572cc LC |
1584 | @cindex propagated inputs |
1585 | Sometimes packages have @dfn{propagated inputs}: these are dependencies | |
21461f27 LC |
1586 | that automatically get installed along with the required package |
1587 | (@pxref{package-propagated-inputs, @code{propagated-inputs} in | |
1588 | @code{package} objects}, for information about propagated inputs in | |
1589 | package definitions). | |
461572cc | 1590 | |
21461f27 | 1591 | @anchor{package-cmd-propagated-inputs} |
461572cc LC |
1592 | An example is the GNU MPC library: its C header files refer to those of |
1593 | the GNU MPFR library, which in turn refer to those of the GMP library. | |
1594 | Thus, when installing MPC, the MPFR and GMP libraries also get installed | |
1595 | in the profile; removing MPC also removes MPFR and GMP---unless they had | |
f97c9175 | 1596 | also been explicitly installed by the user. |
461572cc | 1597 | |
ba7ea5ce | 1598 | Besides, packages sometimes rely on the definition of environment |
5924080d | 1599 | variables for their search paths (see explanation of |
ba7ea5ce | 1600 | @code{--search-paths} below). Any missing or possibly incorrect |
5924080d LC |
1601 | environment variable definitions are reported here. |
1602 | ||
5d4b411f LC |
1603 | @item --install-from-expression=@var{exp} |
1604 | @itemx -e @var{exp} | |
1605 | Install the package @var{exp} evaluates to. | |
1606 | ||
1607 | @var{exp} must be a Scheme expression that evaluates to a | |
1608 | @code{<package>} object. This option is notably useful to disambiguate | |
1609 | between same-named variants of a package, with expressions such as | |
1610 | @code{(@@ (gnu packages base) guile-final)}. | |
1611 | ||
1612 | Note that this option installs the first output of the specified | |
1613 | package, which may be insufficient when needing a specific output of a | |
1614 | multiple-output package. | |
1615 | ||
0d279400 DT |
1616 | @item --install-from-file=@var{file} |
1617 | @itemx -f @var{file} | |
1618 | Install the package that the code within @var{file} evaluates to. | |
1619 | ||
1620 | As an example, @var{file} might contain a definition like this | |
1621 | (@pxref{Defining Packages}): | |
1622 | ||
1623 | @example | |
1624 | @verbatiminclude package-hello.scm | |
1625 | @end example | |
1626 | ||
baacf042 | 1627 | Developers may find it useful to include such a @file{guix.scm} file |
f97c9175 | 1628 | in the root of their project source tree that can be used to test |
0d279400 DT |
1629 | development snapshots and create reproducible development environments |
1630 | (@pxref{Invoking guix environment}). | |
1631 | ||
6447738c MW |
1632 | @item --remove=@var{package} @dots{} |
1633 | @itemx -r @var{package} @dots{} | |
1634 | Remove the specified @var{package}s. | |
eeaf4427 | 1635 | |
6447738c | 1636 | As for @code{--install}, each @var{package} may specify a version number |
13ed095c LC |
1637 | and/or output name in addition to the package name. For instance, |
1638 | @code{-r glibc:debug} would remove the @code{debug} output of | |
1639 | @code{glibc}. | |
1640 | ||
6447738c MW |
1641 | @item --upgrade[=@var{regexp} @dots{}] |
1642 | @itemx -u [@var{regexp} @dots{}] | |
e32171ee | 1643 | @cindex upgrading packages |
6447738c MW |
1644 | Upgrade all the installed packages. If one or more @var{regexp}s are |
1645 | specified, upgrade only installed packages whose name matches a | |
d5f01e48 | 1646 | @var{regexp}. Also see the @code{--do-not-upgrade} option below. |
eeaf4427 | 1647 | |
f651b477 LC |
1648 | Note that this upgrades package to the latest version of packages found |
1649 | in the distribution currently installed. To update your distribution, | |
1650 | you should regularly run @command{guix pull} (@pxref{Invoking guix | |
1651 | pull}). | |
1652 | ||
d5f01e48 MW |
1653 | @item --do-not-upgrade[=@var{regexp} @dots{}] |
1654 | When used together with the @code{--upgrade} option, do @emph{not} | |
1655 | upgrade any packages whose name matches a @var{regexp}. For example, to | |
1656 | upgrade all packages in the current profile except those containing the | |
1657 | substring ``emacs'': | |
1658 | ||
1659 | @example | |
1660 | $ guix package --upgrade . --do-not-upgrade emacs | |
1661 | @end example | |
1662 | ||
99bd74d5 | 1663 | @item @anchor{profile-manifest}--manifest=@var{file} |
1b676447 | 1664 | @itemx -m @var{file} |
99bd74d5 LC |
1665 | @cindex profile declaration |
1666 | @cindex profile manifest | |
1667 | Create a new generation of the profile from the manifest object | |
1b676447 DT |
1668 | returned by the Scheme code in @var{file}. |
1669 | ||
99bd74d5 LC |
1670 | This allows you to @emph{declare} the profile's contents rather than |
1671 | constructing it through a sequence of @code{--install} and similar | |
1672 | commands. The advantage is that @var{file} can be put under version | |
1673 | control, copied to different machines to reproduce the same profile, and | |
1674 | so on. | |
1675 | ||
1676 | @c FIXME: Add reference to (guix profile) documentation when available. | |
1677 | @var{file} must return a @dfn{manifest} object, which is roughly a list | |
1678 | of packages: | |
1b676447 | 1679 | |
99bd74d5 | 1680 | @findex packages->manifest |
1b676447 | 1681 | @example |
99bd74d5 | 1682 | (use-package-modules guile emacs) |
1b676447 DT |
1683 | |
1684 | (packages->manifest | |
99bd74d5 LC |
1685 | (list emacs |
1686 | guile-2.0 | |
1b676447 | 1687 | ;; Use a specific package output. |
99bd74d5 | 1688 | (list guile-2.0 "debug"))) |
1b676447 DT |
1689 | @end example |
1690 | ||
6cd10593 LC |
1691 | @findex specification->package+output |
1692 | In this example we have to know which modules define the @code{emacs} | |
1693 | and @code{guile-2.0} variables to provide the right | |
1694 | @code{use-package-modules} line, which can be cumbersome. We can | |
1695 | instead provide regular package specifications and let | |
1696 | @code{specification->package-output} look up the corresponding package | |
1697 | objects, like this: | |
1698 | ||
1699 | @example | |
1700 | (packages->manifest | |
1701 | (map (compose list specification->package+output) | |
1702 | '("emacs" "guile@@2.0" "guile@@2.0:debug"))) | |
1703 | @end example | |
1704 | ||
24e262f0 | 1705 | @item --roll-back |
e32171ee JD |
1706 | @cindex rolling back |
1707 | @cindex undoing transactions | |
1708 | @cindex transactions, undoing | |
24e262f0 LC |
1709 | Roll back to the previous @dfn{generation} of the profile---i.e., undo |
1710 | the last transaction. | |
1711 | ||
1712 | When combined with options such as @code{--install}, roll back occurs | |
1713 | before any other actions. | |
1714 | ||
d9307267 | 1715 | When rolling back from the first generation that actually contains |
4b2bc804 | 1716 | installed packages, the profile is made to point to the @dfn{zeroth |
f97c9175 | 1717 | generation}, which contains no files apart from its own metadata. |
d9307267 | 1718 | |
f97c9175 AE |
1719 | After having rolled back, installing, removing, or upgrading packages |
1720 | overwrites previous future generations. Thus, the history of the | |
1721 | generations in a profile is always linear. | |
82fe08ed | 1722 | |
b3bb82f1 AK |
1723 | @item --switch-generation=@var{pattern} |
1724 | @itemx -S @var{pattern} | |
e32171ee | 1725 | @cindex generations |
b3bb82f1 AK |
1726 | Switch to a particular generation defined by @var{pattern}. |
1727 | ||
1728 | @var{pattern} may be either a generation number or a number prefixed | |
1729 | with ``+'' or ``-''. The latter means: move forward/backward by a | |
1730 | specified number of generations. For example, if you want to return to | |
1731 | the latest generation after @code{--roll-back}, use | |
1732 | @code{--switch-generation=+1}. | |
1733 | ||
1734 | The difference between @code{--roll-back} and | |
1735 | @code{--switch-generation=-1} is that @code{--switch-generation} will | |
1736 | not make a zeroth generation, so if a specified generation does not | |
1737 | exist, the current generation will not be changed. | |
1738 | ||
dbc31ab2 | 1739 | @item --search-paths[=@var{kind}] |
5924080d LC |
1740 | @cindex search paths |
1741 | Report environment variable definitions, in Bash syntax, that may be | |
1742 | needed in order to use the set of installed packages. These environment | |
1743 | variables are used to specify @dfn{search paths} for files used by some | |
1744 | of the installed packages. | |
1745 | ||
1746 | For example, GCC needs the @code{CPATH} and @code{LIBRARY_PATH} | |
1747 | environment variables to be defined so it can look for headers and | |
1748 | libraries in the user's profile (@pxref{Environment Variables,,, gcc, | |
1749 | Using the GNU Compiler Collection (GCC)}). If GCC and, say, the C | |
1750 | library are installed in the profile, then @code{--search-paths} will | |
1751 | suggest setting these variables to @code{@var{profile}/include} and | |
1752 | @code{@var{profile}/lib}, respectively. | |
1753 | ||
dbc31ab2 LC |
1754 | The typical use case is to define these environment variables in the |
1755 | shell: | |
1756 | ||
1757 | @example | |
1758 | $ eval `guix package --search-paths` | |
1759 | @end example | |
1760 | ||
1761 | @var{kind} may be one of @code{exact}, @code{prefix}, or @code{suffix}, | |
1762 | meaning that the returned environment variable definitions will either | |
1763 | be exact settings, or prefixes or suffixes of the current value of these | |
1764 | variables. When omitted, @var{kind} defaults to @code{exact}. | |
1765 | ||
fc2d2339 LC |
1766 | This option can also be used to compute the @emph{combined} search paths |
1767 | of several profiles. Consider this example: | |
1768 | ||
1769 | @example | |
1770 | $ guix package -p foo -i guile | |
1771 | $ guix package -p bar -i guile-json | |
1772 | $ guix package -p foo -p bar --search-paths | |
1773 | @end example | |
1774 | ||
1775 | The last command above reports about the @code{GUILE_LOAD_PATH} | |
1776 | variable, even though, taken individually, neither @file{foo} nor | |
1777 | @file{bar} would lead to that recommendation. | |
1778 | ||
1779 | ||
eeaf4427 LC |
1780 | @item --profile=@var{profile} |
1781 | @itemx -p @var{profile} | |
1782 | Use @var{profile} instead of the user's default profile. | |
1783 | ||
70915c1a | 1784 | @item --verbose |
f97c9175 AE |
1785 | Produce verbose output. In particular, emit the build log of the |
1786 | environment on the standard error port. | |
70915c1a | 1787 | |
eeaf4427 LC |
1788 | @item --bootstrap |
1789 | Use the bootstrap Guile to build the profile. This option is only | |
1790 | useful to distribution developers. | |
1791 | ||
1792 | @end table | |
1793 | ||
f97c9175 | 1794 | In addition to these actions, @command{guix package} supports the |
733b4130 LC |
1795 | following options to query the current state of a profile, or the |
1796 | availability of packages: | |
eeaf4427 | 1797 | |
733b4130 LC |
1798 | @table @option |
1799 | ||
acc08466 NK |
1800 | @item --search=@var{regexp} |
1801 | @itemx -s @var{regexp} | |
b110869d | 1802 | @cindex searching for packages |
5763ad92 | 1803 | List the available packages whose name, synopsis, or description matches |
f97c9175 | 1804 | @var{regexp}. Print all the metadata of matching packages in |
299112d3 LC |
1805 | @code{recutils} format (@pxref{Top, GNU recutils databases,, recutils, |
1806 | GNU recutils manual}). | |
acc08466 | 1807 | |
299112d3 LC |
1808 | This allows specific fields to be extracted using the @command{recsel} |
1809 | command, for instance: | |
1810 | ||
1811 | @example | |
e49951eb | 1812 | $ guix package -s malloc | recsel -p name,version |
299112d3 LC |
1813 | name: glibc |
1814 | version: 2.17 | |
1815 | ||
1816 | name: libgc | |
1817 | version: 7.2alpha6 | |
1818 | @end example | |
acc08466 | 1819 | |
a12d92f5 LC |
1820 | Similarly, to show the name of all the packages available under the |
1821 | terms of the GNU@tie{}LGPL version 3: | |
1822 | ||
1823 | @example | |
1824 | $ guix package -s "" | recsel -p name -e 'license ~ "LGPL 3"' | |
1825 | name: elfutils | |
1826 | ||
1827 | name: gmp | |
1828 | @dots{} | |
1829 | @end example | |
1830 | ||
db5a9444 LC |
1831 | It is also possible to refine search results using several @code{-s} |
1832 | flags. For example, the following command returns a list of board | |
1833 | games: | |
1834 | ||
1835 | @example | |
1836 | $ guix package -s '\<board\>' -s game | recsel -p name | |
1837 | name: gnubg | |
1838 | @dots{} | |
1839 | @end example | |
1840 | ||
1841 | If we were to omit @code{-s game}, we would also get software packages | |
1842 | that deal with printed circuit boards; removing the angle brackets | |
1843 | around @code{board} would further add packages that have to do with | |
1844 | keyboards. | |
1845 | ||
b110869d LC |
1846 | And now for a more elaborate example. The following command searches |
1847 | for cryptographic libraries, filters out Haskell, Perl, Python, and Ruby | |
1848 | libraries, and prints the name and synopsis of the matching packages: | |
1849 | ||
1850 | @example | |
1851 | $ guix package -s crypto -s library | \ | |
1852 | recsel -e '! (name ~ "^(ghc|perl|python|ruby)")' -p name,synopsis | |
1853 | @end example | |
1854 | ||
1855 | @noindent | |
1856 | @xref{Selection Expressions,,, recutils, GNU recutils manual}, for more | |
1857 | information on @dfn{selection expressions} for @code{recsel -e}. | |
1858 | ||
2aa6efb0 CR |
1859 | @item --show=@var{package} |
1860 | Show details about @var{package}, taken from the list of available packages, in | |
1861 | @code{recutils} format (@pxref{Top, GNU recutils databases,, recutils, GNU | |
1862 | recutils manual}). | |
1863 | ||
1864 | @example | |
1865 | $ guix package --show=python | recsel -p name,version | |
1866 | name: python | |
1867 | version: 2.7.6 | |
1868 | ||
1869 | name: python | |
1870 | version: 3.3.5 | |
1871 | @end example | |
1872 | ||
1873 | You may also specify the full name of a package to only get details about a | |
1874 | specific version of it: | |
1875 | @example | |
ea206df4 | 1876 | $ guix package --show=python@@3.4 | recsel -p name,version |
2aa6efb0 | 1877 | name: python |
ea206df4 | 1878 | version: 3.4.3 |
2aa6efb0 CR |
1879 | @end example |
1880 | ||
1881 | ||
1882 | ||
733b4130 LC |
1883 | @item --list-installed[=@var{regexp}] |
1884 | @itemx -I [@var{regexp}] | |
bd9bde1c LC |
1885 | List the currently installed packages in the specified profile, with the |
1886 | most recently installed packages shown last. When @var{regexp} is | |
1887 | specified, list only installed packages whose name matches @var{regexp}. | |
733b4130 LC |
1888 | |
1889 | For each installed package, print the following items, separated by | |
1890 | tabs: the package name, its version string, the part of the package that | |
1891 | is installed (for instance, @code{out} for the default output, | |
1892 | @code{include} for its headers, etc.), and the path of this package in | |
1893 | the store. | |
1894 | ||
64fc89b6 LC |
1895 | @item --list-available[=@var{regexp}] |
1896 | @itemx -A [@var{regexp}] | |
5763ad92 | 1897 | List packages currently available in the distribution for this system |
a1ba8475 LC |
1898 | (@pxref{GNU Distribution}). When @var{regexp} is specified, list only |
1899 | installed packages whose name matches @var{regexp}. | |
64fc89b6 LC |
1900 | |
1901 | For each package, print the following items separated by tabs: its name, | |
6e721c4d LC |
1902 | its version string, the parts of the package (@pxref{Packages with |
1903 | Multiple Outputs}), and the source location of its definition. | |
64fc89b6 | 1904 | |
f566d765 LC |
1905 | @item --list-generations[=@var{pattern}] |
1906 | @itemx -l [@var{pattern}] | |
e32171ee | 1907 | @cindex generations |
f566d765 LC |
1908 | Return a list of generations along with their creation dates; for each |
1909 | generation, show the installed packages, with the most recently | |
4b2bc804 NK |
1910 | installed packages shown last. Note that the zeroth generation is never |
1911 | shown. | |
f566d765 LC |
1912 | |
1913 | For each installed package, print the following items, separated by | |
1914 | tabs: the name of a package, its version string, the part of the package | |
1915 | that is installed (@pxref{Packages with Multiple Outputs}), and the | |
1916 | location of this package in the store. | |
1917 | ||
1918 | When @var{pattern} is used, the command returns only matching | |
1919 | generations. Valid patterns include: | |
1920 | ||
1921 | @itemize | |
1922 | @item @emph{Integers and comma-separated integers}. Both patterns denote | |
1923 | generation numbers. For instance, @code{--list-generations=1} returns | |
1924 | the first one. | |
1925 | ||
1926 | And @code{--list-generations=1,8,2} outputs three generations in the | |
1927 | specified order. Neither spaces nor trailing commas are allowed. | |
1928 | ||
1929 | @item @emph{Ranges}. @code{--list-generations=2..9} prints the | |
1930 | specified generations and everything in between. Note that the start of | |
f97c9175 | 1931 | a range must be smaller than its end. |
f566d765 LC |
1932 | |
1933 | It is also possible to omit the endpoint. For example, | |
1934 | @code{--list-generations=2..}, returns all generations starting from the | |
1935 | second one. | |
1936 | ||
1937 | @item @emph{Durations}. You can also get the last @emph{N}@tie{}days, weeks, | |
1938 | or months by passing an integer along with the first letter of the | |
d7ddb257 LC |
1939 | duration. For example, @code{--list-generations=20d} lists generations |
1940 | that are up to 20 days old. | |
f566d765 LC |
1941 | @end itemize |
1942 | ||
b7884ca3 NK |
1943 | @item --delete-generations[=@var{pattern}] |
1944 | @itemx -d [@var{pattern}] | |
d7ddb257 LC |
1945 | When @var{pattern} is omitted, delete all generations except the current |
1946 | one. | |
b7884ca3 NK |
1947 | |
1948 | This command accepts the same patterns as @option{--list-generations}. | |
d7ddb257 LC |
1949 | When @var{pattern} is specified, delete the matching generations. When |
1950 | @var{pattern} specifies a duration, generations @emph{older} than the | |
1951 | specified duration match. For instance, @code{--delete-generations=1m} | |
1952 | deletes generations that are more than one month old. | |
1953 | ||
391bdd8f LC |
1954 | If the current generation matches, it is @emph{not} deleted. Also, the |
1955 | zeroth generation is never deleted. | |
b7884ca3 | 1956 | |
f97c9175 | 1957 | Note that deleting generations prevents rolling back to them. |
1bb9900a LC |
1958 | Consequently, this command must be used with care. |
1959 | ||
733b4130 | 1960 | @end table |
eeaf4427 | 1961 | |
70ee5642 | 1962 | Finally, since @command{guix package} may actually start build |
ccd7158d | 1963 | processes, it supports all the common build options (@pxref{Common Build |
f97c9175 | 1964 | Options}). It also supports package transformation options, such as |
b8638f03 LC |
1965 | @option{--with-source} (@pxref{Package Transformation Options}). |
1966 | However, note that package transformations are lost when upgrading; to | |
f97c9175 | 1967 | preserve transformations across upgrades, you should define your own |
b8638f03 LC |
1968 | package variant in a Guile module and add it to @code{GUIX_PACKAGE_PATH} |
1969 | (@pxref{Defining Packages}). | |
1970 | ||
70ee5642 | 1971 | |
c4202d60 LC |
1972 | @node Substitutes |
1973 | @section Substitutes | |
1974 | ||
1975 | @cindex substitutes | |
1976 | @cindex pre-built binaries | |
1977 | Guix supports transparent source/binary deployment, which means that it | |
1978 | can either build things locally, or download pre-built items from a | |
1979 | server. We call these pre-built items @dfn{substitutes}---they are | |
1980 | substitutes for local build results. In many cases, downloading a | |
1981 | substitute is much faster than building things locally. | |
1982 | ||
1983 | Substitutes can be anything resulting from a derivation build | |
1984 | (@pxref{Derivations}). Of course, in the common case, they are | |
1985 | pre-built package binaries, but source tarballs, for instance, which | |
1986 | also result from derivation builds, can be available as substitutes. | |
1987 | ||
1988 | The @code{hydra.gnu.org} server is a front-end to a build farm that | |
1989 | builds packages from the GNU distribution continuously for some | |
deb6276d | 1990 | architectures, and makes them available as substitutes. This is the |
f8a8e0fe LC |
1991 | default source of substitutes; it can be overridden by passing the |
1992 | @option{--substitute-urls} option either to @command{guix-daemon} | |
1993 | (@pxref{daemon-substitute-urls,, @code{guix-daemon --substitute-urls}}) | |
1994 | or to client tools such as @command{guix package} | |
1995 | (@pxref{client-substitute-urls,, client @option{--substitute-urls} | |
1996 | option}). | |
c4202d60 | 1997 | |
9b7bd1b1 LC |
1998 | Substitute URLs can be either HTTP or HTTPS@footnote{For HTTPS access, |
1999 | the Guile bindings of GnuTLS must be installed. @xref{Requirements}.} | |
2000 | HTTPS is recommended because communications are encrypted; conversely, | |
2001 | using HTTP makes all communications visible to an eavesdropper, who | |
2002 | could use the information gathered to determine, for instance, whether | |
2003 | your system has unpatched security vulnerabilities. | |
2004 | ||
c4202d60 LC |
2005 | @cindex security |
2006 | @cindex digital signatures | |
e32171ee | 2007 | @cindex substitutes, authorization thereof |
df061d07 LC |
2008 | To allow Guix to download substitutes from @code{hydra.gnu.org} or a |
2009 | mirror thereof, you | |
c4202d60 LC |
2010 | must add its public key to the access control list (ACL) of archive |
2011 | imports, using the @command{guix archive} command (@pxref{Invoking guix | |
2012 | archive}). Doing so implies that you trust @code{hydra.gnu.org} to not | |
2013 | be compromised and to serve genuine substitutes. | |
2014 | ||
2015 | This public key is installed along with Guix, in | |
2016 | @code{@var{prefix}/share/guix/hydra.gnu.org.pub}, where @var{prefix} is | |
2017 | the installation prefix of Guix. If you installed Guix from source, | |
2018 | make sure you checked the GPG signature of | |
2019 | @file{guix-@value{VERSION}.tar.gz}, which contains this public key file. | |
2020 | Then, you can run something like this: | |
2021 | ||
2022 | @example | |
2023 | # guix archive --authorize < hydra.gnu.org.pub | |
2024 | @end example | |
2025 | ||
2026 | Once this is in place, the output of a command like @code{guix build} | |
2027 | should change from something like: | |
2028 | ||
2029 | @example | |
2030 | $ guix build emacs --dry-run | |
2031 | The following derivations would be built: | |
2032 | /gnu/store/yr7bnx8xwcayd6j95r2clmkdl1qh688w-emacs-24.3.drv | |
2033 | /gnu/store/x8qsh1hlhgjx6cwsjyvybnfv2i37z23w-dbus-1.6.4.tar.gz.drv | |
2034 | /gnu/store/1ixwp12fl950d15h2cj11c73733jay0z-alsa-lib-1.0.27.1.tar.bz2.drv | |
2035 | /gnu/store/nlma1pw0p603fpfiqy7kn4zm105r5dmw-util-linux-2.21.drv | |
2036 | @dots{} | |
2037 | @end example | |
2038 | ||
2039 | @noindent | |
2040 | to something like: | |
2041 | ||
2042 | @example | |
2043 | $ guix build emacs --dry-run | |
2044 | The following files would be downloaded: | |
2045 | /gnu/store/pk3n22lbq6ydamyymqkkz7i69wiwjiwi-emacs-24.3 | |
2046 | /gnu/store/2ygn4ncnhrpr61rssa6z0d9x22si0va3-libjpeg-8d | |
2047 | /gnu/store/71yz6lgx4dazma9dwn2mcjxaah9w77jq-cairo-1.12.16 | |
2048 | /gnu/store/7zdhgp0n1518lvfn8mb96sxqfmvqrl7v-libxrender-0.9.7 | |
2049 | @dots{} | |
2050 | @end example | |
2051 | ||
2052 | @noindent | |
2053 | This indicates that substitutes from @code{hydra.gnu.org} are usable and | |
2054 | will be downloaded, when possible, for future builds. | |
2055 | ||
2056 | Guix ignores substitutes that are not signed, or that are not signed by | |
ef27aa9c | 2057 | one of the keys listed in the ACL. It also detects and raises an error |
c4202d60 LC |
2058 | when attempting to use a substitute that has been tampered with. |
2059 | ||
e0c941fe | 2060 | @vindex http_proxy |
9b7bd1b1 LC |
2061 | Substitutes are downloaded over HTTP or HTTPS. |
2062 | The @code{http_proxy} environment | |
e0c941fe LC |
2063 | variable can be set in the environment of @command{guix-daemon} and is |
2064 | honored for downloads of substitutes. Note that the value of | |
2065 | @code{http_proxy} in the environment where @command{guix build}, | |
2066 | @command{guix package}, and other client commands are run has | |
2067 | @emph{absolutely no effect}. | |
2068 | ||
9b7bd1b1 LC |
2069 | When using HTTPS, the server's X.509 certificate is @emph{not} validated |
2070 | (in other words, the server is not authenticated), contrary to what | |
2071 | HTTPS clients such as Web browsers usually do. This is because Guix | |
2072 | authenticates substitute information itself, as explained above, which | |
2073 | is what we care about (whereas X.509 certificates are about | |
2074 | authenticating bindings between domain names and public keys.) | |
2075 | ||
c4202d60 LC |
2076 | The substitute mechanism can be disabled globally by running |
2077 | @code{guix-daemon} with @code{--no-substitutes} (@pxref{Invoking | |
2078 | guix-daemon}). It can also be disabled temporarily by passing the | |
2079 | @code{--no-substitutes} option to @command{guix package}, @command{guix | |
2080 | build}, and other command-line tools. | |
2081 | ||
2082 | ||
9b7bd1b1 LC |
2083 | @unnumberedsubsec On Trusting Binaries |
2084 | ||
c4202d60 LC |
2085 | Today, each individual's control over their own computing is at the |
2086 | mercy of institutions, corporations, and groups with enough power and | |
2087 | determination to subvert the computing infrastructure and exploit its | |
2088 | weaknesses. While using @code{hydra.gnu.org} substitutes can be | |
2089 | convenient, we encourage users to also build on their own, or even run | |
2090 | their own build farm, such that @code{hydra.gnu.org} is less of an | |
8ce229fc LC |
2091 | interesting target. One way to help is by publishing the software you |
2092 | build using @command{guix publish} so that others have one more choice | |
2093 | of server to download substitutes from (@pxref{Invoking guix publish}). | |
c4202d60 LC |
2094 | |
2095 | Guix has the foundations to maximize build reproducibility | |
2096 | (@pxref{Features}). In most cases, independent builds of a given | |
2097 | package or derivation should yield bit-identical results. Thus, through | |
2098 | a diverse set of independent package builds, we can strengthen the | |
d23c20f1 LC |
2099 | integrity of our systems. The @command{guix challenge} command aims to |
2100 | help users assess substitute servers, and to assist developers in | |
2101 | finding out about non-deterministic package builds (@pxref{Invoking guix | |
a8d65643 LC |
2102 | challenge}). Similarly, the @option{--check} option of @command{guix |
2103 | build} allows users to check whether previously-installed substitutes | |
2104 | are genuine by rebuilding them locally (@pxref{build-check, | |
2105 | @command{guix build --check}}). | |
c4202d60 LC |
2106 | |
2107 | In the future, we want Guix to have support to publish and retrieve | |
2108 | binaries to/from other users, in a peer-to-peer fashion. If you would | |
2109 | like to discuss this project, join us on @email{guix-devel@@gnu.org}. | |
2110 | ||
2111 | ||
6e721c4d LC |
2112 | @node Packages with Multiple Outputs |
2113 | @section Packages with Multiple Outputs | |
2114 | ||
2115 | @cindex multiple-output packages | |
2116 | @cindex package outputs | |
e32171ee | 2117 | @cindex outputs |
6e721c4d LC |
2118 | |
2119 | Often, packages defined in Guix have a single @dfn{output}---i.e., the | |
f97c9175 | 2120 | source package leads to exactly one directory in the store. When running |
6e721c4d LC |
2121 | @command{guix package -i glibc}, one installs the default output of the |
2122 | GNU libc package; the default output is called @code{out}, but its name | |
2123 | can be omitted as shown in this command. In this particular case, the | |
2124 | default output of @code{glibc} contains all the C header files, shared | |
2125 | libraries, static libraries, Info documentation, and other supporting | |
2126 | files. | |
2127 | ||
2128 | Sometimes it is more appropriate to separate the various types of files | |
2129 | produced from a single source package into separate outputs. For | |
2130 | instance, the GLib C library (used by GTK+ and related packages) | |
2131 | installs more than 20 MiB of reference documentation as HTML pages. | |
2132 | To save space for users who do not need it, the documentation goes to a | |
2133 | separate output, called @code{doc}. To install the main GLib output, | |
2134 | which contains everything but the documentation, one would run: | |
2135 | ||
2136 | @example | |
2137 | guix package -i glib | |
2138 | @end example | |
2139 | ||
e32171ee | 2140 | @cindex documentation |
6e721c4d LC |
2141 | The command to install its documentation is: |
2142 | ||
2143 | @example | |
2144 | guix package -i glib:doc | |
2145 | @end example | |
2146 | ||
2147 | Some packages install programs with different ``dependency footprints''. | |
f97c9175 | 2148 | For instance, the WordNet package installs both command-line tools and |
6e721c4d LC |
2149 | graphical user interfaces (GUIs). The former depend solely on the C |
2150 | library, whereas the latter depend on Tcl/Tk and the underlying X | |
2151 | libraries. In this case, we leave the command-line tools in the default | |
2152 | output, whereas the GUIs are in a separate output. This allows users | |
fcc58db6 LC |
2153 | who do not need the GUIs to save space. The @command{guix size} command |
2154 | can help find out about such situations (@pxref{Invoking guix size}). | |
88856916 | 2155 | @command{guix graph} can also be helpful (@pxref{Invoking guix graph}). |
6e721c4d LC |
2156 | |
2157 | There are several such multiple-output packages in the GNU distribution. | |
91ef73d4 LC |
2158 | Other conventional output names include @code{lib} for libraries and |
2159 | possibly header files, @code{bin} for stand-alone programs, and | |
2160 | @code{debug} for debugging information (@pxref{Installing Debugging | |
2161 | Files}). The outputs of a packages are listed in the third column of | |
2162 | the output of @command{guix package --list-available} (@pxref{Invoking | |
2163 | guix package}). | |
6e721c4d | 2164 | |
eeaf4427 | 2165 | |
e49951eb MW |
2166 | @node Invoking guix gc |
2167 | @section Invoking @command{guix gc} | |
fe8ff028 LC |
2168 | |
2169 | @cindex garbage collector | |
e32171ee | 2170 | @cindex disk space |
f97c9175 | 2171 | Packages that are installed, but not used, may be @dfn{garbage-collected}. |
e49951eb | 2172 | The @command{guix gc} command allows users to explicitly run the garbage |
c22eb992 LC |
2173 | collector to reclaim space from the @file{/gnu/store} directory. It is |
2174 | the @emph{only} way to remove files from @file{/gnu/store}---removing | |
2175 | files or directories manually may break it beyond repair! | |
fe8ff028 LC |
2176 | |
2177 | The garbage collector has a set of known @dfn{roots}: any file under | |
834129e0 | 2178 | @file{/gnu/store} reachable from a root is considered @dfn{live} and |
fe8ff028 LC |
2179 | cannot be deleted; any other file is considered @dfn{dead} and may be |
2180 | deleted. The set of garbage collector roots includes default user | |
e49951eb MW |
2181 | profiles, and may be augmented with @command{guix build --root}, for |
2182 | example (@pxref{Invoking guix build}). | |
fe8ff028 | 2183 | |
1bb9900a LC |
2184 | Prior to running @code{guix gc --collect-garbage} to make space, it is |
2185 | often useful to remove old generations from user profiles; that way, old | |
2186 | package builds referenced by those generations can be reclaimed. This | |
2187 | is achieved by running @code{guix package --delete-generations} | |
2188 | (@pxref{Invoking guix package}). | |
2189 | ||
e49951eb | 2190 | The @command{guix gc} command has three modes of operation: it can be |
fe8ff028 | 2191 | used to garbage-collect any dead files (the default), to delete specific |
7770aafc LC |
2192 | files (the @code{--delete} option), to print garbage-collector |
2193 | information, or for more advanced queries. The garbage collection | |
2194 | options are as follows: | |
fe8ff028 LC |
2195 | |
2196 | @table @code | |
2197 | @item --collect-garbage[=@var{min}] | |
2198 | @itemx -C [@var{min}] | |
834129e0 | 2199 | Collect garbage---i.e., unreachable @file{/gnu/store} files and |
fe8ff028 LC |
2200 | sub-directories. This is the default operation when no option is |
2201 | specified. | |
2202 | ||
2203 | When @var{min} is given, stop once @var{min} bytes have been collected. | |
2204 | @var{min} may be a number of bytes, or it may include a unit as a | |
4a44d7bb LC |
2205 | suffix, such as @code{MiB} for mebibytes and @code{GB} for gigabytes |
2206 | (@pxref{Block size, size specifications,, coreutils, GNU Coreutils}). | |
fe8ff028 LC |
2207 | |
2208 | When @var{min} is omitted, collect all the garbage. | |
2209 | ||
0054e470 LC |
2210 | @item --free-space=@var{free} |
2211 | @itemx -F @var{free} | |
2212 | Collect garbage until @var{free} space is available under | |
2213 | @file{/gnu/store}, if possible; @var{free} denotes storage space, such | |
2214 | as @code{500MiB}, as described above. | |
2215 | ||
2216 | When @var{free} or more is already available in @file{/gnu/store}, do | |
2217 | nothing and exit immediately. | |
2218 | ||
fe8ff028 LC |
2219 | @item --delete |
2220 | @itemx -d | |
2221 | Attempt to delete all the store files and directories specified as | |
2222 | arguments. This fails if some of the files are not in the store, or if | |
2223 | they are still live. | |
2224 | ||
30d9aa54 LC |
2225 | @item --list-failures |
2226 | List store items corresponding to cached build failures. | |
2227 | ||
2228 | This prints nothing unless the daemon was started with | |
2229 | @option{--cache-failures} (@pxref{Invoking guix-daemon, | |
2230 | @option{--cache-failures}}). | |
2231 | ||
2232 | @item --clear-failures | |
2233 | Remove the specified store items from the failed-build cache. | |
2234 | ||
2235 | Again, this option only makes sense when the daemon is started with | |
2236 | @option{--cache-failures}. Otherwise, it does nothing. | |
2237 | ||
fe8ff028 LC |
2238 | @item --list-dead |
2239 | Show the list of dead files and directories still present in the | |
2240 | store---i.e., files and directories no longer reachable from any root. | |
2241 | ||
2242 | @item --list-live | |
2243 | Show the list of live store files and directories. | |
ba8b732d LC |
2244 | |
2245 | @end table | |
2246 | ||
2247 | In addition, the references among existing store files can be queried: | |
2248 | ||
2249 | @table @code | |
2250 | ||
2251 | @item --references | |
2252 | @itemx --referrers | |
e32171ee | 2253 | @cindex package dependencies |
ba8b732d LC |
2254 | List the references (respectively, the referrers) of store files given |
2255 | as arguments. | |
2256 | ||
8e59fdd5 LC |
2257 | @item --requisites |
2258 | @itemx -R | |
fcc58db6 | 2259 | @cindex closure |
8e59fdd5 LC |
2260 | List the requisites of the store files passed as arguments. Requisites |
2261 | include the store files themselves, their references, and the references | |
2262 | of these, recursively. In other words, the returned list is the | |
2263 | @dfn{transitive closure} of the store files. | |
2264 | ||
f97c9175 AE |
2265 | @xref{Invoking guix size}, for a tool to profile the size of the closure |
2266 | of an element. @xref{Invoking guix graph}, for a tool to visualize | |
88856916 | 2267 | the graph of references. |
fcc58db6 | 2268 | |
fe8ff028 LC |
2269 | @end table |
2270 | ||
7770aafc LC |
2271 | Lastly, the following options allow you to check the integrity of the |
2272 | store and to control disk usage. | |
2273 | ||
2274 | @table @option | |
2275 | ||
2276 | @item --verify[=@var{options}] | |
2277 | @cindex integrity, of the store | |
2278 | @cindex integrity checking | |
2279 | Verify the integrity of the store. | |
2280 | ||
2281 | By default, make sure that all the store items marked as valid in the | |
f97c9175 | 2282 | database of the daemon actually exist in @file{/gnu/store}. |
7770aafc | 2283 | |
f97c9175 | 2284 | When provided, @var{options} must be a comma-separated list containing one |
7770aafc LC |
2285 | or more of @code{contents} and @code{repair}. |
2286 | ||
7414de0a | 2287 | When passing @option{--verify=contents}, the daemon computes the |
f97c9175 | 2288 | content hash of each store item and compares it against its hash in the |
7770aafc LC |
2289 | database. Hash mismatches are reported as data corruptions. Because it |
2290 | traverses @emph{all the files in the store}, this command can take a | |
2291 | long time, especially on systems with a slow disk drive. | |
2292 | ||
2293 | @cindex repairing the store | |
6da5bb7b | 2294 | @cindex corruption, recovering from |
7770aafc LC |
2295 | Using @option{--verify=repair} or @option{--verify=contents,repair} |
2296 | causes the daemon to try to repair corrupt store items by fetching | |
2297 | substitutes for them (@pxref{Substitutes}). Because repairing is not | |
2298 | atomic, and thus potentially dangerous, it is available only to the | |
6da5bb7b LC |
2299 | system administrator. A lightweight alternative, when you know exactly |
2300 | which items in the store are corrupt, is @command{guix build --repair} | |
2301 | (@pxref{Invoking guix build}). | |
7770aafc LC |
2302 | |
2303 | @item --optimize | |
2304 | @cindex deduplication | |
2305 | Optimize the store by hard-linking identical files---this is | |
2306 | @dfn{deduplication}. | |
2307 | ||
2308 | The daemon performs deduplication after each successful build or archive | |
2309 | import, unless it was started with @code{--disable-deduplication} | |
2310 | (@pxref{Invoking guix-daemon, @code{--disable-deduplication}}). Thus, | |
2311 | this option is primarily useful when the daemon was running with | |
2312 | @code{--disable-deduplication}. | |
2313 | ||
2314 | @end table | |
eeaf4427 | 2315 | |
f651b477 LC |
2316 | @node Invoking guix pull |
2317 | @section Invoking @command{guix pull} | |
2318 | ||
e32171ee | 2319 | @cindex upgrading Guix |
7fcf2a0b | 2320 | @cindex updating Guix |
e32171ee JD |
2321 | @cindex @command{guix pull} |
2322 | @cindex pull | |
f651b477 LC |
2323 | Packages are installed or upgraded to the latest version available in |
2324 | the distribution currently available on your local machine. To update | |
2325 | that distribution, along with the Guix tools, you must run @command{guix | |
2326 | pull}: the command downloads the latest Guix source code and package | |
2327 | descriptions, and deploys it. | |
2328 | ||
2329 | On completion, @command{guix package} will use packages and package | |
2330 | versions from this just-retrieved copy of Guix. Not only that, but all | |
2331 | the Guix commands and Scheme modules will also be taken from that latest | |
2332 | version. New @command{guix} sub-commands added by the update also | |
cb05108a LC |
2333 | become available. |
2334 | ||
2335 | Any user can update their Guix copy using @command{guix pull}, and the | |
2336 | effect is limited to the user who run @command{guix pull}. For | |
2337 | instance, when user @code{root} runs @command{guix pull}, this has no | |
2338 | effect on the version of Guix that user @code{alice} sees, and vice | |
2339 | versa@footnote{Under the hood, @command{guix pull} updates the | |
2340 | @file{~/.config/guix/latest} symbolic link to point to the latest Guix, | |
5e2017ed CM |
2341 | and the @command{guix} command loads code from there. Currently, the |
2342 | only way to roll back an invocation of @command{guix pull} is to | |
2343 | manually update this symlink to point to the previous Guix.}. | |
f651b477 LC |
2344 | |
2345 | The @command{guix pull} command is usually invoked with no arguments, | |
2346 | but it supports the following options: | |
2347 | ||
2348 | @table @code | |
2349 | @item --verbose | |
2350 | Produce verbose output, writing build logs to the standard error output. | |
2351 | ||
ab5d72ad LC |
2352 | @item --url=@var{url} |
2353 | Download the source tarball of Guix from @var{url}. | |
2354 | ||
2355 | By default, the tarball is taken from its canonical address at | |
2356 | @code{gnu.org}, for the stable branch of Guix. | |
2357 | ||
8a9cffb2 LF |
2358 | With some Git servers, this can be used to deploy any version of Guix. |
2359 | For example, to download and deploy version 0.12.0 of Guix from the | |
2360 | canonical Git repo: | |
2361 | ||
2362 | @example | |
2363 | guix pull --url=http://git.savannah.gnu.org/cgit/guix.git/snapshot/v0.12.0.tar.gz | |
2364 | @end example | |
2365 | ||
2366 | It can also be used to deploy arbitrary Git revisions: | |
2367 | ||
2368 | @example | |
2369 | guix pull --url=http://git.savannah.gnu.org/cgit/guix.git/snapshot/74d862e8a.tar.gz | |
2370 | @end example | |
2371 | ||
f651b477 LC |
2372 | @item --bootstrap |
2373 | Use the bootstrap Guile to build the latest Guix. This option is only | |
2374 | useful to Guix developers. | |
2375 | @end table | |
2376 | ||
760c60d6 LC |
2377 | |
2378 | @node Invoking guix archive | |
2379 | @section Invoking @command{guix archive} | |
2380 | ||
e32171ee JD |
2381 | @cindex @command{guix archive} |
2382 | @cindex archive | |
760c60d6 LC |
2383 | The @command{guix archive} command allows users to @dfn{export} files |
2384 | from the store into a single archive, and to later @dfn{import} them. | |
2385 | In particular, it allows store files to be transferred from one machine | |
4d4c4816 AE |
2386 | to the store on another machine. |
2387 | ||
e32171ee | 2388 | @cindex exporting store items |
4d4c4816 AE |
2389 | To export store files as an archive to standard output, run: |
2390 | ||
2391 | @example | |
2392 | guix archive --export @var{options} @var{specifications}... | |
2393 | @end example | |
2394 | ||
2395 | @var{specifications} may be either store file names or package | |
2396 | specifications, as for @command{guix package} (@pxref{Invoking guix | |
2397 | package}). For instance, the following command creates an archive | |
2398 | containing the @code{gui} output of the @code{git} package and the main | |
2399 | output of @code{emacs}: | |
2400 | ||
2401 | @example | |
2402 | guix archive --export git:gui /gnu/store/...-emacs-24.3 > great.nar | |
2403 | @end example | |
2404 | ||
2405 | If the specified packages are not built yet, @command{guix archive} | |
2406 | automatically builds them. The build process may be controlled with the | |
2407 | common build options (@pxref{Common Build Options}). | |
2408 | ||
2409 | To transfer the @code{emacs} package to a machine connected over SSH, | |
2410 | one would run: | |
760c60d6 LC |
2411 | |
2412 | @example | |
56607088 | 2413 | guix archive --export -r emacs | ssh the-machine guix archive --import |
760c60d6 LC |
2414 | @end example |
2415 | ||
87236aed | 2416 | @noindent |
56607088 LC |
2417 | Similarly, a complete user profile may be transferred from one machine |
2418 | to another like this: | |
2419 | ||
2420 | @example | |
2421 | guix archive --export -r $(readlink -f ~/.guix-profile) | \ | |
2422 | ssh the-machine guix-archive --import | |
2423 | @end example | |
2424 | ||
2425 | @noindent | |
2426 | However, note that, in both examples, all of @code{emacs} and the | |
2427 | profile as well as all of their dependencies are transferred (due to | |
f97c9175 AE |
2428 | @code{-r}), regardless of what is already available in the store on the |
2429 | target machine. The @code{--missing} option can help figure out which | |
f11c444d LC |
2430 | items are missing from the target store. The @command{guix copy} |
2431 | command simplifies and optimizes this whole process, so this is probably | |
2432 | what you should use in this case (@pxref{Invoking guix copy}). | |
87236aed | 2433 | |
5597b3ae LC |
2434 | @cindex nar, archive format |
2435 | @cindex normalized archive (nar) | |
03476a23 | 2436 | By default archives are stored in the ``normalized archive'' or ``nar'' format, which is |
5597b3ae | 2437 | comparable in spirit to `tar', but with differences |
0dbd88db | 2438 | that make it more appropriate for our purposes. First, rather than |
5597b3ae | 2439 | recording all Unix metadata for each file, the nar format only mentions |
0dbd88db LC |
2440 | the file type (regular, directory, or symbolic link); Unix permissions |
2441 | and owner/group are dismissed. Second, the order in which directory | |
2442 | entries are stored always follows the order of file names according to | |
2443 | the C locale collation order. This makes archive production fully | |
2444 | deterministic. | |
2445 | ||
2446 | When exporting, the daemon digitally signs the contents of the archive, | |
2447 | and that digital signature is appended. When importing, the daemon | |
2448 | verifies the signature and rejects the import in case of an invalid | |
2449 | signature or if the signing key is not authorized. | |
760c60d6 LC |
2450 | @c FIXME: Add xref to daemon doc about signatures. |
2451 | ||
03476a23 RW |
2452 | Optionally, archives can be exported as a Docker image in the tar |
2453 | archive format using @code{--format=docker}. | |
2454 | ||
760c60d6 LC |
2455 | The main options are: |
2456 | ||
2457 | @table @code | |
2458 | @item --export | |
2459 | Export the specified store files or packages (see below.) Write the | |
2460 | resulting archive to the standard output. | |
2461 | ||
56607088 LC |
2462 | Dependencies are @emph{not} included in the output, unless |
2463 | @code{--recursive} is passed. | |
2464 | ||
2465 | @item -r | |
2466 | @itemx --recursive | |
2467 | When combined with @code{--export}, this instructs @command{guix | |
2468 | archive} to include dependencies of the given items in the archive. | |
2469 | Thus, the resulting archive is self-contained: it contains the closure | |
2470 | of the exported store items. | |
2471 | ||
760c60d6 LC |
2472 | @item --import |
2473 | Read an archive from the standard input, and import the files listed | |
2474 | therein into the store. Abort if the archive has an invalid digital | |
f82cc5fd LC |
2475 | signature, or if it is signed by a public key not among the authorized |
2476 | keys (see @code{--authorize} below.) | |
554f26ec | 2477 | |
87236aed LC |
2478 | @item --missing |
2479 | Read a list of store file names from the standard input, one per line, | |
2480 | and write on the standard output the subset of these files missing from | |
2481 | the store. | |
2482 | ||
03476a23 RW |
2483 | @item -f |
2484 | @item --format=@var{FMT} | |
2485 | @cindex docker, export | |
2486 | @cindex export format | |
2487 | Specify the export format. Acceptable arguments are @code{nar} and | |
2488 | @code{docker}. The default is the nar format. When the format is | |
2489 | @code{docker}, recursively export the specified store directory as a | |
2490 | Docker image in tar archive format, as specified in | |
2491 | @uref{https://github.com/docker/docker/blob/master/image/spec/v1.2.md, | |
2492 | version 1.2.0 of the Docker Image Specification}. Using | |
2493 | @code{--format=docker} implies @code{--recursive}. The generated | |
2494 | archive can be loaded by Docker using @command{docker load}. | |
2495 | ||
554f26ec | 2496 | @item --generate-key[=@var{parameters}] |
f82cc5fd | 2497 | @cindex signing, archives |
f97c9175 | 2498 | Generate a new key pair for the daemon. This is a prerequisite before |
554f26ec LC |
2499 | archives can be exported with @code{--export}. Note that this operation |
2500 | usually takes time, because it needs to gather enough entropy to | |
2501 | generate the key pair. | |
2502 | ||
2503 | The generated key pair is typically stored under @file{/etc/guix}, in | |
2504 | @file{signing-key.pub} (public key) and @file{signing-key.sec} (private | |
867d8473 LC |
2505 | key, which must be kept secret.) When @var{parameters} is omitted, |
2506 | an ECDSA key using the Ed25519 curve is generated, or, for Libgcrypt | |
2507 | versions before 1.6.0, it is a 4096-bit RSA key. | |
f97c9175 | 2508 | Alternatively, @var{parameters} can specify |
554f26ec LC |
2509 | @code{genkey} parameters suitable for Libgcrypt (@pxref{General |
2510 | public-key related Functions, @code{gcry_pk_genkey},, gcrypt, The | |
2511 | Libgcrypt Reference Manual}). | |
f82cc5fd LC |
2512 | |
2513 | @item --authorize | |
2514 | @cindex authorizing, archives | |
2515 | Authorize imports signed by the public key passed on standard input. | |
2516 | The public key must be in ``s-expression advanced format''---i.e., the | |
2517 | same format as the @file{signing-key.pub} file. | |
2518 | ||
2519 | The list of authorized keys is kept in the human-editable file | |
2520 | @file{/etc/guix/acl}. The file contains | |
2521 | @url{http://people.csail.mit.edu/rivest/Sexp.txt, ``advanced-format | |
2522 | s-expressions''} and is structured as an access-control list in the | |
2523 | @url{http://theworld.com/~cme/spki.txt, Simple Public-Key Infrastructure | |
2524 | (SPKI)}. | |
c6f8e9dd LC |
2525 | |
2526 | @item --extract=@var{directory} | |
2527 | @itemx -x @var{directory} | |
2528 | Read a single-item archive as served by substitute servers | |
2529 | (@pxref{Substitutes}) and extract it to @var{directory}. This is a | |
2530 | low-level operation needed in only very narrow use cases; see below. | |
2531 | ||
2532 | For example, the following command extracts the substitute for Emacs | |
2533 | served by @code{hydra.gnu.org} to @file{/tmp/emacs}: | |
2534 | ||
2535 | @example | |
2536 | $ wget -O - \ | |
df061d07 | 2537 | https://hydra.gnu.org/nar/@dots{}-emacs-24.5 \ |
c6f8e9dd LC |
2538 | | bunzip2 | guix archive -x /tmp/emacs |
2539 | @end example | |
2540 | ||
2541 | Single-item archives are different from multiple-item archives produced | |
2542 | by @command{guix archive --export}; they contain a single store item, | |
2543 | and they do @emph{not} embed a signature. Thus this operation does | |
2544 | @emph{no} signature verification and its output should be considered | |
2545 | unsafe. | |
2546 | ||
2547 | The primary purpose of this operation is to facilitate inspection of | |
2548 | archive contents coming from possibly untrusted substitute servers. | |
2549 | ||
760c60d6 LC |
2550 | @end table |
2551 | ||
568717fd LC |
2552 | @c ********************************************************************* |
2553 | @node Programming Interface | |
2554 | @chapter Programming Interface | |
2555 | ||
3dc1970d LC |
2556 | GNU Guix provides several Scheme programming interfaces (APIs) to |
2557 | define, build, and query packages. The first interface allows users to | |
2558 | write high-level package definitions. These definitions refer to | |
2559 | familiar packaging concepts, such as the name and version of a package, | |
2560 | its build system, and its dependencies. These definitions can then be | |
2561 | turned into concrete build actions. | |
2562 | ||
ba55b1cb | 2563 | Build actions are performed by the Guix daemon, on behalf of users. In a |
3dc1970d | 2564 | standard setup, the daemon has write access to the store---the |
834129e0 | 2565 | @file{/gnu/store} directory---whereas users do not. The recommended |
3dc1970d LC |
2566 | setup also has the daemon perform builds in chroots, under a specific |
2567 | build users, to minimize interference with the rest of the system. | |
2568 | ||
2569 | @cindex derivation | |
2570 | Lower-level APIs are available to interact with the daemon and the | |
2571 | store. To instruct the daemon to perform a build action, users actually | |
2572 | provide it with a @dfn{derivation}. A derivation is a low-level | |
2573 | representation of the build actions to be taken, and the environment in | |
2574 | which they should occur---derivations are to package definitions what | |
49ad317a LC |
2575 | assembly is to C programs. The term ``derivation'' comes from the fact |
2576 | that build results @emph{derive} from them. | |
3dc1970d LC |
2577 | |
2578 | This chapter describes all these APIs in turn, starting from high-level | |
2579 | package definitions. | |
2580 | ||
568717fd | 2581 | @menu |
b860f382 | 2582 | * Defining Packages:: Defining new packages. |
7458bd0a | 2583 | * Build Systems:: Specifying how packages are built. |
b860f382 LC |
2584 | * The Store:: Manipulating the package store. |
2585 | * Derivations:: Low-level interface to package derivations. | |
2586 | * The Store Monad:: Purely functional interface to the store. | |
21b679f6 | 2587 | * G-Expressions:: Manipulating build expressions. |
568717fd LC |
2588 | @end menu |
2589 | ||
2590 | @node Defining Packages | |
2591 | @section Defining Packages | |
2592 | ||
3dc1970d LC |
2593 | The high-level interface to package definitions is implemented in the |
2594 | @code{(guix packages)} and @code{(guix build-system)} modules. As an | |
2595 | example, the package definition, or @dfn{recipe}, for the GNU Hello | |
2596 | package looks like this: | |
2597 | ||
2598 | @example | |
e7f34eb0 LC |
2599 | (define-module (gnu packages hello) |
2600 | #:use-module (guix packages) | |
2601 | #:use-module (guix download) | |
2602 | #:use-module (guix build-system gnu) | |
a6dcdcac SB |
2603 | #:use-module (guix licenses) |
2604 | #:use-module (gnu packages gawk)) | |
b22a12fd | 2605 | |
79f5dd59 | 2606 | (define-public hello |
3dc1970d LC |
2607 | (package |
2608 | (name "hello") | |
17d8e33f | 2609 | (version "2.10") |
3dc1970d | 2610 | (source (origin |
17d8e33f ML |
2611 | (method url-fetch) |
2612 | (uri (string-append "mirror://gnu/hello/hello-" version | |
2613 | ".tar.gz")) | |
2614 | (sha256 | |
2615 | (base32 | |
2616 | "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i")))) | |
3dc1970d | 2617 | (build-system gnu-build-system) |
654c0d97 | 2618 | (arguments '(#:configure-flags '("--enable-silent-rules"))) |
3dc1970d | 2619 | (inputs `(("gawk" ,gawk))) |
7458bd0a LC |
2620 | (synopsis "Hello, GNU world: An example GNU package") |
2621 | (description "Guess what GNU Hello prints!") | |
3dc1970d | 2622 | (home-page "http://www.gnu.org/software/hello/") |
b22a12fd | 2623 | (license gpl3+))) |
3dc1970d LC |
2624 | @end example |
2625 | ||
2626 | @noindent | |
2627 | Without being a Scheme expert, the reader may have guessed the meaning | |
f97c9175 AE |
2628 | of the various fields here. This expression binds the variable |
2629 | @code{hello} to a @code{<package>} object, which is essentially a record | |
3dc1970d LC |
2630 | (@pxref{SRFI-9, Scheme records,, guile, GNU Guile Reference Manual}). |
2631 | This package object can be inspected using procedures found in the | |
2632 | @code{(guix packages)} module; for instance, @code{(package-name hello)} | |
2633 | returns---surprise!---@code{"hello"}. | |
2634 | ||
2f7d2d91 LC |
2635 | With luck, you may be able to import part or all of the definition of |
2636 | the package you are interested in from another repository, using the | |
2637 | @code{guix import} command (@pxref{Invoking guix import}). | |
2638 | ||
f97c9175 | 2639 | In the example above, @var{hello} is defined in a module of its own, |
e7f34eb0 LC |
2640 | @code{(gnu packages hello)}. Technically, this is not strictly |
2641 | necessary, but it is convenient to do so: all the packages defined in | |
2642 | modules under @code{(gnu packages @dots{})} are automatically known to | |
2643 | the command-line tools (@pxref{Package Modules}). | |
2644 | ||
3dc1970d LC |
2645 | There are a few points worth noting in the above package definition: |
2646 | ||
2647 | @itemize | |
2648 | @item | |
a2bf4907 LC |
2649 | The @code{source} field of the package is an @code{<origin>} object |
2650 | (@pxref{origin Reference}, for the complete reference). | |
3dc1970d LC |
2651 | Here, the @code{url-fetch} method from @code{(guix download)} is used, |
2652 | meaning that the source is a file to be downloaded over FTP or HTTP. | |
2653 | ||
2654 | The @code{mirror://gnu} prefix instructs @code{url-fetch} to use one of | |
2655 | the GNU mirrors defined in @code{(guix download)}. | |
2656 | ||
2657 | The @code{sha256} field specifies the expected SHA256 hash of the file | |
2658 | being downloaded. It is mandatory, and allows Guix to check the | |
2659 | integrity of the file. The @code{(base32 @dots{})} form introduces the | |
6c365eca | 2660 | base32 representation of the hash. You can obtain this information with |
210cc920 LC |
2661 | @code{guix download} (@pxref{Invoking guix download}) and @code{guix |
2662 | hash} (@pxref{Invoking guix hash}). | |
3dc1970d | 2663 | |
f9cc8971 LC |
2664 | @cindex patches |
2665 | When needed, the @code{origin} form can also have a @code{patches} field | |
2666 | listing patches to be applied, and a @code{snippet} field giving a | |
2667 | Scheme expression to modify the source code. | |
2668 | ||
3dc1970d LC |
2669 | @item |
2670 | @cindex GNU Build System | |
7458bd0a LC |
2671 | The @code{build-system} field specifies the procedure to build the |
2672 | package (@pxref{Build Systems}). Here, @var{gnu-build-system} | |
2673 | represents the familiar GNU Build System, where packages may be | |
2674 | configured, built, and installed with the usual @code{./configure && | |
2675 | make && make check && make install} command sequence. | |
2676 | ||
2677 | @item | |
2678 | The @code{arguments} field specifies options for the build system | |
2679 | (@pxref{Build Systems}). Here it is interpreted by | |
2680 | @var{gnu-build-system} as a request run @file{configure} with the | |
2681 | @code{--enable-silent-rules} flag. | |
3dc1970d | 2682 | |
654c0d97 LC |
2683 | @cindex quote |
2684 | @cindex quoting | |
2685 | @findex ' | |
2686 | @findex quote | |
2687 | What about these quote (@code{'}) characters? They are Scheme syntax to | |
2688 | introduce a literal list; @code{'} is synonymous with @code{quote}. | |
2689 | @xref{Expression Syntax, quoting,, guile, GNU Guile Reference Manual}, | |
2690 | for details. Here the value of the @code{arguments} field is a list of | |
2691 | arguments passed to the build system down the road, as with @code{apply} | |
2692 | (@pxref{Fly Evaluation, @code{apply},, guile, GNU Guile Reference | |
2693 | Manual}). | |
2694 | ||
2695 | The hash-colon (@code{#:}) sequence defines a Scheme @dfn{keyword} | |
2696 | (@pxref{Keywords,,, guile, GNU Guile Reference Manual}), and | |
2697 | @code{#:configure-flags} is a keyword used to pass a keyword argument | |
2698 | to the build system (@pxref{Coding With Keywords,,, guile, GNU Guile | |
2699 | Reference Manual}). | |
2700 | ||
3dc1970d LC |
2701 | @item |
2702 | The @code{inputs} field specifies inputs to the build process---i.e., | |
2703 | build-time or run-time dependencies of the package. Here, we define an | |
2704 | input called @code{"gawk"} whose value is that of the @var{gawk} | |
2705 | variable; @var{gawk} is itself bound to a @code{<package>} object. | |
2706 | ||
654c0d97 LC |
2707 | @cindex backquote (quasiquote) |
2708 | @findex ` | |
2709 | @findex quasiquote | |
2710 | @cindex comma (unquote) | |
2711 | @findex , | |
2712 | @findex unquote | |
2713 | @findex ,@@ | |
2714 | @findex unquote-splicing | |
2715 | Again, @code{`} (a backquote, synonymous with @code{quasiquote}) allows | |
2716 | us to introduce a literal list in the @code{inputs} field, while | |
2717 | @code{,} (a comma, synonymous with @code{unquote}) allows us to insert a | |
2718 | value in that list (@pxref{Expression Syntax, unquote,, guile, GNU Guile | |
2719 | Reference Manual}). | |
2720 | ||
3dc1970d LC |
2721 | Note that GCC, Coreutils, Bash, and other essential tools do not need to |
2722 | be specified as inputs here. Instead, @var{gnu-build-system} takes care | |
7458bd0a | 2723 | of ensuring that they are present (@pxref{Build Systems}). |
3dc1970d LC |
2724 | |
2725 | However, any other dependencies need to be specified in the | |
2726 | @code{inputs} field. Any dependency not specified here will simply be | |
2727 | unavailable to the build process, possibly leading to a build failure. | |
2728 | @end itemize | |
2729 | ||
87eafdbd TUBK |
2730 | @xref{package Reference}, for a full description of possible fields. |
2731 | ||
2f7d2d91 | 2732 | Once a package definition is in place, the |
e49951eb | 2733 | package may actually be built using the @code{guix build} command-line |
39bee8a2 LC |
2734 | tool (@pxref{Invoking guix build}). You can easily jump back to the |
2735 | package definition using the @command{guix edit} command | |
2736 | (@pxref{Invoking guix edit}). | |
2737 | @xref{Packaging Guidelines}, for | |
b4f5e0e8 CR |
2738 | more information on how to test package definitions, and |
2739 | @ref{Invoking guix lint}, for information on how to check a definition | |
2740 | for style conformance. | |
2741 | ||
f97c9175 | 2742 | Finally, updating the package definition to a new upstream version |
7458bd0a LC |
2743 | can be partly automated by the @command{guix refresh} command |
2744 | (@pxref{Invoking guix refresh}). | |
3dc1970d LC |
2745 | |
2746 | Behind the scenes, a derivation corresponding to the @code{<package>} | |
2747 | object is first computed by the @code{package-derivation} procedure. | |
834129e0 | 2748 | That derivation is stored in a @code{.drv} file under @file{/gnu/store}. |
ba55b1cb | 2749 | The build actions it prescribes may then be realized by using the |
3dc1970d LC |
2750 | @code{build-derivations} procedure (@pxref{The Store}). |
2751 | ||
2752 | @deffn {Scheme Procedure} package-derivation @var{store} @var{package} [@var{system}] | |
59688fc4 LC |
2753 | Return the @code{<derivation>} object of @var{package} for @var{system} |
2754 | (@pxref{Derivations}). | |
3dc1970d LC |
2755 | |
2756 | @var{package} must be a valid @code{<package>} object, and @var{system} | |
2757 | must be a string denoting the target system type---e.g., | |
2758 | @code{"x86_64-linux"} for an x86_64 Linux-based GNU system. @var{store} | |
2759 | must be a connection to the daemon, which operates on the store | |
2760 | (@pxref{The Store}). | |
2761 | @end deffn | |
568717fd | 2762 | |
9c1edabd LC |
2763 | @noindent |
2764 | @cindex cross-compilation | |
2765 | Similarly, it is possible to compute a derivation that cross-builds a | |
2766 | package for some other system: | |
2767 | ||
2768 | @deffn {Scheme Procedure} package-cross-derivation @var{store} @ | |
2769 | @var{package} @var{target} [@var{system}] | |
59688fc4 LC |
2770 | Return the @code{<derivation>} object of @var{package} cross-built from |
2771 | @var{system} to @var{target}. | |
9c1edabd LC |
2772 | |
2773 | @var{target} must be a valid GNU triplet denoting the target hardware | |
2774 | and operating system, such as @code{"mips64el-linux-gnu"} | |
2775 | (@pxref{Configuration Names, GNU configuration triplets,, configure, GNU | |
2776 | Configure and Build System}). | |
2777 | @end deffn | |
2778 | ||
2a75b0b6 LC |
2779 | @cindex package transformations |
2780 | @cindex input rewriting | |
2781 | @cindex dependency tree rewriting | |
2782 | Packages can be manipulated in arbitrary ways. An example of a useful | |
2783 | transformation is @dfn{input rewriting}, whereby the dependency tree of | |
2784 | a package is rewritten by replacing specific inputs by others: | |
2785 | ||
2786 | @deffn {Scheme Procedure} package-input-rewriting @var{replacements} @ | |
2787 | [@var{rewrite-name}] | |
2788 | Return a procedure that, when passed a package, replaces its direct and | |
2789 | indirect dependencies (but not its implicit inputs) according to | |
2790 | @var{replacements}. @var{replacements} is a list of package pairs; the | |
2791 | first element of each pair is the package to replace, and the second one | |
2792 | is the replacement. | |
2793 | ||
2794 | Optionally, @var{rewrite-name} is a one-argument procedure that takes | |
2795 | the name of a package and returns its new name after rewrite. | |
2796 | @end deffn | |
2797 | ||
2798 | @noindent | |
2799 | Consider this example: | |
2800 | ||
2801 | @example | |
2802 | (define libressl-instead-of-openssl | |
2803 | ;; This is a procedure to replace OPENSSL by LIBRESSL, | |
2804 | ;; recursively. | |
2805 | (package-input-rewriting `((,openssl . ,libressl)))) | |
2806 | ||
2807 | (define git-with-libressl | |
2808 | (libressl-instead-of-openssl git)) | |
2809 | @end example | |
2810 | ||
2811 | @noindent | |
2812 | Here we first define a rewriting procedure that replaces @var{openssl} | |
2813 | with @var{libressl}. Then we use it to define a @dfn{variant} of the | |
2814 | @var{git} package that uses @var{libressl} instead of @var{openssl}. | |
2815 | This is exactly what the @option{--with-input} command-line option does | |
2816 | (@pxref{Package Transformation Options, @option{--with-input}}). | |
2817 | ||
87eafdbd TUBK |
2818 | @menu |
2819 | * package Reference :: The package data type. | |
2820 | * origin Reference:: The origin data type. | |
2821 | @end menu | |
2822 | ||
2823 | ||
2824 | @node package Reference | |
2825 | @subsection @code{package} Reference | |
2826 | ||
2827 | This section summarizes all the options available in @code{package} | |
2828 | declarations (@pxref{Defining Packages}). | |
2829 | ||
2830 | @deftp {Data Type} package | |
2831 | This is the data type representing a package recipe. | |
2832 | ||
2833 | @table @asis | |
2834 | @item @code{name} | |
2835 | The name of the package, as a string. | |
2836 | ||
2837 | @item @code{version} | |
2838 | The version of the package, as a string. | |
2839 | ||
2840 | @item @code{source} | |
da675305 LC |
2841 | An object telling how the source code for the package should be |
2842 | acquired. Most of the time, this is an @code{origin} object, which | |
2843 | denotes a file fetched from the Internet (@pxref{origin Reference}). It | |
2844 | can also be any other ``file-like'' object such as a @code{local-file}, | |
2845 | which denotes a file from the local file system (@pxref{G-Expressions, | |
2846 | @code{local-file}}). | |
87eafdbd TUBK |
2847 | |
2848 | @item @code{build-system} | |
2849 | The build system that should be used to build the package (@pxref{Build | |
2850 | Systems}). | |
2851 | ||
2852 | @item @code{arguments} (default: @code{'()}) | |
2853 | The arguments that should be passed to the build system. This is a | |
2854 | list, typically containing sequential keyword-value pairs. | |
2855 | ||
2856 | @item @code{inputs} (default: @code{'()}) | |
70650c68 LC |
2857 | @itemx @code{native-inputs} (default: @code{'()}) |
2858 | @itemx @code{propagated-inputs} (default: @code{'()}) | |
2859 | @cindex inputs, of packages | |
2860 | These fields list dependencies of the package. Each one is a list of | |
2861 | tuples, where each tuple has a label for the input (a string) as its | |
2862 | first element, a package, origin, or derivation as its second element, | |
2863 | and optionally the name of the output thereof that should be used, which | |
2864 | defaults to @code{"out"} (@pxref{Packages with Multiple Outputs}, for | |
f97c9175 | 2865 | more on package outputs). For example, the list below specifies three |
70650c68 | 2866 | inputs: |
87eafdbd | 2867 | |
70650c68 LC |
2868 | @example |
2869 | `(("libffi" ,libffi) | |
2870 | ("libunistring" ,libunistring) | |
2871 | ("glib:bin" ,glib "bin")) ;the "bin" output of Glib | |
2872 | @end example | |
2873 | ||
2874 | @cindex cross compilation, package dependencies | |
2875 | The distinction between @code{native-inputs} and @code{inputs} is | |
2876 | necessary when considering cross-compilation. When cross-compiling, | |
2877 | dependencies listed in @code{inputs} are built for the @emph{target} | |
2878 | architecture; conversely, dependencies listed in @code{native-inputs} | |
2879 | are built for the architecture of the @emph{build} machine. | |
2880 | ||
f97c9175 AE |
2881 | @code{native-inputs} is typically used to list tools needed at |
2882 | build time, but not at run time, such as Autoconf, Automake, pkg-config, | |
70650c68 LC |
2883 | Gettext, or Bison. @command{guix lint} can report likely mistakes in |
2884 | this area (@pxref{Invoking guix lint}). | |
2885 | ||
2886 | @anchor{package-propagated-inputs} | |
2887 | Lastly, @code{propagated-inputs} is similar to @code{inputs}, but the | |
f97c9175 AE |
2888 | specified packages will be automatically installed alongside the package |
2889 | they belong to (@pxref{package-cmd-propagated-inputs, @command{guix | |
70650c68 LC |
2890 | package}}, for information on how @command{guix package} deals with |
2891 | propagated inputs.) | |
21461f27 | 2892 | |
e0508b6b LC |
2893 | For example this is necessary when a C/C++ library needs headers of |
2894 | another library to compile, or when a pkg-config file refers to another | |
2895 | one @i{via} its @code{Requires} field. | |
2896 | ||
f97c9175 AE |
2897 | Another example where @code{propagated-inputs} is useful is for languages |
2898 | that lack a facility to record the run-time search path akin to the | |
c8ebb4c4 | 2899 | @code{RUNPATH} of ELF files; this includes Guile, Python, Perl, and |
e0508b6b LC |
2900 | more. To ensure that libraries written in those languages can find |
2901 | library code they depend on at run time, run-time dependencies must be | |
2902 | listed in @code{propagated-inputs} rather than @code{inputs}. | |
87eafdbd | 2903 | |
87eafdbd TUBK |
2904 | @item @code{self-native-input?} (default: @code{#f}) |
2905 | This is a Boolean field telling whether the package should use itself as | |
2906 | a native input when cross-compiling. | |
2907 | ||
2908 | @item @code{outputs} (default: @code{'("out")}) | |
2909 | The list of output names of the package. @xref{Packages with Multiple | |
2910 | Outputs}, for typical uses of additional outputs. | |
2911 | ||
2912 | @item @code{native-search-paths} (default: @code{'()}) | |
2913 | @itemx @code{search-paths} (default: @code{'()}) | |
2914 | A list of @code{search-path-specification} objects describing | |
2915 | search-path environment variables honored by the package. | |
2916 | ||
2917 | @item @code{replacement} (default: @code{#f}) | |
f97c9175 | 2918 | This must be either @code{#f} or a package object that will be used as a |
87eafdbd TUBK |
2919 | @dfn{replacement} for this package. @xref{Security Updates, grafts}, |
2920 | for details. | |
2921 | ||
2922 | @item @code{synopsis} | |
2923 | A one-line description of the package. | |
2924 | ||
2925 | @item @code{description} | |
2926 | A more elaborate description of the package. | |
2927 | ||
2928 | @item @code{license} | |
e32171ee | 2929 | @cindex license, of packages |
f97c9175 AE |
2930 | The license of the package; a value from @code{(guix licenses)}, |
2931 | or a list of such values. | |
87eafdbd TUBK |
2932 | |
2933 | @item @code{home-page} | |
2934 | The URL to the home-page of the package, as a string. | |
2935 | ||
2936 | @item @code{supported-systems} (default: @var{%supported-systems}) | |
2937 | The list of systems supported by the package, as strings of the form | |
2938 | @code{architecture-kernel}, for example @code{"x86_64-linux"}. | |
2939 | ||
2940 | @item @code{maintainers} (default: @code{'()}) | |
2941 | The list of maintainers of the package, as @code{maintainer} objects. | |
2942 | ||
2943 | @item @code{location} (default: source location of the @code{package} form) | |
f97c9175 | 2944 | The source location of the package. It is useful to override this when |
87eafdbd TUBK |
2945 | inheriting from another package, in which case this field is not |
2946 | automatically corrected. | |
2947 | @end table | |
2948 | @end deftp | |
2949 | ||
2950 | ||
2951 | @node origin Reference | |
2952 | @subsection @code{origin} Reference | |
2953 | ||
2954 | This section summarizes all the options available in @code{origin} | |
2955 | declarations (@pxref{Defining Packages}). | |
2956 | ||
2957 | @deftp {Data Type} origin | |
2958 | This is the data type representing a source code origin. | |
2959 | ||
2960 | @table @asis | |
2961 | @item @code{uri} | |
2962 | An object containing the URI of the source. The object type depends on | |
2963 | the @code{method} (see below). For example, when using the | |
2964 | @var{url-fetch} method of @code{(guix download)}, the valid @code{uri} | |
2965 | values are: a URL represented as a string, or a list thereof. | |
2966 | ||
2967 | @item @code{method} | |
f97c9175 | 2968 | A procedure that handles the URI. |
87eafdbd TUBK |
2969 | |
2970 | Examples include: | |
2971 | ||
2972 | @table @asis | |
2973 | @item @var{url-fetch} from @code{(guix download)} | |
f97c9175 | 2974 | download a file from the HTTP, HTTPS, or FTP URL specified in the |
87eafdbd TUBK |
2975 | @code{uri} field; |
2976 | ||
db97a03a | 2977 | @vindex git-fetch |
87eafdbd TUBK |
2978 | @item @var{git-fetch} from @code{(guix git-download)} |
2979 | clone the Git version control repository, and check out the revision | |
2980 | specified in the @code{uri} field as a @code{git-reference} object; a | |
2981 | @code{git-reference} looks like this: | |
2982 | ||
2983 | @example | |
2984 | (git-reference | |
2985 | (url "git://git.debian.org/git/pkg-shadow/shadow") | |
2986 | (commit "v4.1.5.1")) | |
2987 | @end example | |
2988 | @end table | |
2989 | ||
2990 | @item @code{sha256} | |
2991 | A bytevector containing the SHA-256 hash of the source. Typically the | |
2992 | @code{base32} form is used here to generate the bytevector from a | |
2993 | base-32 string. | |
2994 | ||
db97a03a LC |
2995 | You can obtain this information using @code{guix download} |
2996 | (@pxref{Invoking guix download}) or @code{guix hash} (@pxref{Invoking | |
2997 | guix hash}). | |
2998 | ||
87eafdbd TUBK |
2999 | @item @code{file-name} (default: @code{#f}) |
3000 | The file name under which the source code should be saved. When this is | |
3001 | @code{#f}, a sensible default value will be used in most cases. In case | |
3002 | the source is fetched from a URL, the file name from the URL will be | |
f97c9175 | 3003 | used. For version control checkouts, it is recommended to provide the |
87eafdbd TUBK |
3004 | file name explicitly because the default is not very descriptive. |
3005 | ||
3006 | @item @code{patches} (default: @code{'()}) | |
3007 | A list of file names containing patches to be applied to the source. | |
3008 | ||
0dfebdaa LC |
3009 | This list of patches must be unconditional. In particular, it cannot |
3010 | depend on the value of @code{%current-system} or | |
3011 | @code{%current-target-system}. | |
3012 | ||
87eafdbd | 3013 | @item @code{snippet} (default: @code{#f}) |
1929fdba LC |
3014 | A G-expression (@pxref{G-Expressions}) or S-expression that will be run |
3015 | in the source directory. This is a convenient way to modify the source, | |
3016 | sometimes more convenient than a patch. | |
87eafdbd TUBK |
3017 | |
3018 | @item @code{patch-flags} (default: @code{'("-p1")}) | |
3019 | A list of command-line flags that should be passed to the @code{patch} | |
3020 | command. | |
3021 | ||
3022 | @item @code{patch-inputs} (default: @code{#f}) | |
3023 | Input packages or derivations to the patching process. When this is | |
3024 | @code{#f}, the usual set of inputs necessary for patching are provided, | |
3025 | such as GNU@tie{}Patch. | |
3026 | ||
3027 | @item @code{modules} (default: @code{'()}) | |
3028 | A list of Guile modules that should be loaded during the patching | |
3029 | process and while running the code in the @code{snippet} field. | |
3030 | ||
87eafdbd TUBK |
3031 | @item @code{patch-guile} (default: @code{#f}) |
3032 | The Guile package that should be used in the patching process. When | |
3033 | this is @code{#f}, a sensible default is used. | |
3034 | @end table | |
3035 | @end deftp | |
3036 | ||
9c1edabd | 3037 | |
7458bd0a LC |
3038 | @node Build Systems |
3039 | @section Build Systems | |
3040 | ||
3041 | @cindex build system | |
3042 | Each package definition specifies a @dfn{build system} and arguments for | |
3043 | that build system (@pxref{Defining Packages}). This @code{build-system} | |
f97c9175 | 3044 | field represents the build procedure of the package, as well as implicit |
7458bd0a LC |
3045 | dependencies of that build procedure. |
3046 | ||
3047 | Build systems are @code{<build-system>} objects. The interface to | |
3048 | create and manipulate them is provided by the @code{(guix build-system)} | |
3049 | module, and actual build systems are exported by specific modules. | |
3050 | ||
f5fd4fd2 | 3051 | @cindex bag (low-level package representation) |
0d5a559f LC |
3052 | Under the hood, build systems first compile package objects to |
3053 | @dfn{bags}. A @dfn{bag} is like a package, but with less | |
3054 | ornamentation---in other words, a bag is a lower-level representation of | |
3055 | a package, which includes all the inputs of that package, including some | |
3056 | that were implicitly added by the build system. This intermediate | |
3057 | representation is then compiled to a derivation (@pxref{Derivations}). | |
3058 | ||
7458bd0a LC |
3059 | Build systems accept an optional list of @dfn{arguments}. In package |
3060 | definitions, these are passed @i{via} the @code{arguments} field | |
3061 | (@pxref{Defining Packages}). They are typically keyword arguments | |
3062 | (@pxref{Optional Arguments, keyword arguments in Guile,, guile, GNU | |
3063 | Guile Reference Manual}). The value of these arguments is usually | |
3064 | evaluated in the @dfn{build stratum}---i.e., by a Guile process launched | |
3065 | by the daemon (@pxref{Derivations}). | |
3066 | ||
3067 | The main build system is @var{gnu-build-system}, which implements the | |
f97c9175 | 3068 | standard build procedure for GNU and many other packages. It |
7458bd0a LC |
3069 | is provided by the @code{(guix build-system gnu)} module. |
3070 | ||
3071 | @defvr {Scheme Variable} gnu-build-system | |
3072 | @var{gnu-build-system} represents the GNU Build System, and variants | |
3073 | thereof (@pxref{Configuration, configuration and makefile conventions,, | |
3074 | standards, GNU Coding Standards}). | |
3075 | ||
3076 | @cindex build phases | |
f97c9175 | 3077 | In a nutshell, packages using it are configured, built, and installed with |
7458bd0a LC |
3078 | the usual @code{./configure && make && make check && make install} |
3079 | command sequence. In practice, a few additional steps are often needed. | |
3080 | All these steps are split up in separate @dfn{phases}, | |
3081 | notably@footnote{Please see the @code{(guix build gnu-build-system)} | |
3082 | modules for more details about the build phases.}: | |
3083 | ||
3084 | @table @code | |
3085 | @item unpack | |
3086 | Unpack the source tarball, and change the current directory to the | |
3087 | extracted source tree. If the source is actually a directory, copy it | |
3088 | to the build tree, and enter that directory. | |
3089 | ||
3090 | @item patch-source-shebangs | |
3091 | Patch shebangs encountered in source files so they refer to the right | |
3092 | store file names. For instance, this changes @code{#!/bin/sh} to | |
3093 | @code{#!/gnu/store/@dots{}-bash-4.3/bin/sh}. | |
3094 | ||
3095 | @item configure | |
3096 | Run the @file{configure} script with a number of default options, such | |
3097 | as @code{--prefix=/gnu/store/@dots{}}, as well as the options specified | |
3098 | by the @code{#:configure-flags} argument. | |
3099 | ||
3100 | @item build | |
3101 | Run @code{make} with the list of flags specified with | |
0917e80e | 3102 | @code{#:make-flags}. If the @code{#:parallel-build?} argument is true |
7458bd0a LC |
3103 | (the default), build with @code{make -j}. |
3104 | ||
3105 | @item check | |
3106 | Run @code{make check}, or some other target specified with | |
3107 | @code{#:test-target}, unless @code{#:tests? #f} is passed. If the | |
3108 | @code{#:parallel-tests?} argument is true (the default), run @code{make | |
3109 | check -j}. | |
3110 | ||
3111 | @item install | |
3112 | Run @code{make install} with the flags listed in @code{#:make-flags}. | |
3113 | ||
3114 | @item patch-shebangs | |
3115 | Patch shebangs on the installed executable files. | |
3116 | ||
3117 | @item strip | |
3118 | Strip debugging symbols from ELF files (unless @code{#:strip-binaries?} | |
3119 | is false), copying them to the @code{debug} output when available | |
3120 | (@pxref{Installing Debugging Files}). | |
3121 | @end table | |
3122 | ||
3123 | @vindex %standard-phases | |
3124 | The build-side module @code{(guix build gnu-build-system)} defines | |
3125 | @var{%standard-phases} as the default list of build phases. | |
3126 | @var{%standard-phases} is a list of symbol/procedure pairs, where the | |
3127 | procedure implements the actual phase. | |
3128 | ||
3129 | The list of phases used for a particular package can be changed with the | |
3130 | @code{#:phases} parameter. For instance, passing: | |
3131 | ||
3132 | @example | |
c2c5dc79 | 3133 | #:phases (modify-phases %standard-phases (delete 'configure)) |
7458bd0a LC |
3134 | @end example |
3135 | ||
9bf404e9 | 3136 | means that all the phases described above will be used, except the |
7458bd0a LC |
3137 | @code{configure} phase. |
3138 | ||
3139 | In addition, this build system ensures that the ``standard'' environment | |
3140 | for GNU packages is available. This includes tools such as GCC, libc, | |
3141 | Coreutils, Bash, Make, Diffutils, grep, and sed (see the @code{(guix | |
f97c9175 AE |
3142 | build-system gnu)} module for a complete list). We call these the |
3143 | @dfn{implicit inputs} of a package, because package definitions do not | |
7458bd0a LC |
3144 | have to mention them. |
3145 | @end defvr | |
3146 | ||
3147 | Other @code{<build-system>} objects are defined to support other | |
3148 | conventions and tools used by free software packages. They inherit most | |
3149 | of @var{gnu-build-system}, and differ mainly in the set of inputs | |
3150 | implicitly added to the build process, and in the list of phases | |
3151 | executed. Some of these build systems are listed below. | |
3152 | ||
5f7a1a4d RW |
3153 | @defvr {Scheme Variable} ant-build-system |
3154 | This variable is exported by @code{(guix build-system ant)}. It | |
3155 | implements the build procedure for Java packages that can be built with | |
3156 | @url{http://ant.apache.org/, Ant build tool}. | |
3157 | ||
3158 | It adds both @code{ant} and the @dfn{Java Development Kit} (JDK) as | |
3159 | provided by the @code{icedtea} package to the set of inputs. Different | |
3160 | packages can be specified with the @code{#:ant} and @code{#:jdk} | |
3161 | parameters, respectively. | |
3162 | ||
3163 | When the original package does not provide a suitable Ant build file, | |
3164 | the parameter @code{#:jar-name} can be used to generate a minimal Ant | |
3165 | build file @file{build.xml} with tasks to build the specified jar | |
3166 | archive. | |
3167 | ||
3168 | The parameter @code{#:build-target} can be used to specify the Ant task | |
3169 | that should be run during the @code{build} phase. By default the | |
3170 | ``jar'' task will be run. | |
3171 | ||
3172 | @end defvr | |
3173 | ||
a1b30f99 AP |
3174 | @defvr {Scheme Variable} asdf-build-system/source |
3175 | @defvrx {Scheme Variable} asdf-build-system/sbcl | |
3176 | @defvrx {Scheme Variable} asdf-build-system/ecl | |
3177 | ||
3178 | These variables, exported by @code{(guix build-system asdf)}, implement | |
3179 | build procedures for Common Lisp packages using | |
3180 | @url{https://common-lisp.net/project/asdf/, ``ASDF''}. ASDF is a system | |
3181 | definition facility for Common Lisp programs and libraries. | |
3182 | ||
3183 | The @code{asdf-build-system/source} system installs the packages in | |
3184 | source form, and can be loaded using any common lisp implementation, via | |
3185 | ASDF. The others, such as @code{asdf-build-system/sbcl}, install binary | |
3186 | systems in the format which a particular implementation understands. | |
3187 | These build systems can also be used to produce executable programs, or | |
3188 | lisp images which contain a set of packages pre-loaded. | |
3189 | ||
3190 | The build system uses naming conventions. For binary packages, the | |
3191 | package itself as well as its run-time dependencies should begin their | |
3192 | name with the lisp implementation, such as @code{sbcl-} for | |
3193 | @code{asdf-build-system/sbcl}. Beginning the input name with this | |
3194 | prefix will allow the build system to encode its location into the | |
3195 | resulting library, so that the input can be found at run-time. | |
3196 | ||
3197 | If dependencies are used only for tests, it is convenient to use a | |
3198 | different prefix in order to avoid having a run-time dependency on such | |
3199 | systems. For example, | |
3200 | ||
3201 | @example | |
3202 | (define-public sbcl-bordeaux-threads | |
3203 | (package | |
3204 | ... | |
3205 | (native-inputs `(("tests:cl-fiveam" ,sbcl-fiveam))) | |
3206 | ...)) | |
3207 | @end example | |
3208 | ||
3209 | Additionally, the corresponding source package should be labeled using | |
3210 | the same convention as python packages (see @ref{Python Modules}), using | |
3211 | the @code{cl-} prefix. | |
3212 | ||
3213 | For binary packages, each system should be defined as a Guix package. | |
3214 | If one package @code{origin} contains several systems, package variants | |
3215 | can be created in order to build all the systems. Source packages, | |
3216 | which use @code{asdf-build-system/source}, may contain several systems. | |
3217 | ||
3218 | In order to create executable programs and images, the build-side | |
3219 | procedures @code{build-program} and @code{build-image} can be used. | |
3220 | They should be called in a build phase after the @code{create-symlinks} | |
3221 | phase, so that the system which was just built can be used within the | |
3222 | resulting image. @code{build-program} requires a list of Common Lisp | |
3223 | expressions to be passed as the @code{#:entry-program} argument. | |
3224 | ||
3225 | If the system is not defined within its own @code{.asd} file of the same | |
3226 | name, then the @code{#:asd-file} parameter should be used to specify | |
3227 | which file the system is defined in. | |
3228 | ||
3229 | @end defvr | |
3230 | ||
1ec34dd7 LC |
3231 | @defvr {Scheme Variable} cargo-build-system |
3232 | @cindex Rust programming language | |
3233 | @cindex Cargo (Rust build system) | |
3234 | This variable is exported by @code{(guix build-system cargo)}. It | |
3235 | supports builds of packages using Cargo, the build tool of the | |
3236 | @uref{https://www.rust-lang.org, Rust programming language}. | |
3237 | ||
3238 | In its @code{configure} phase, this build system replaces dependencies | |
3239 | specified in the @file{Carto.toml} file with inputs to the Guix package. | |
3240 | The @code{install} phase installs the binaries, and it also installs the | |
3241 | source code and @file{Cargo.toml} file. | |
3242 | @end defvr | |
3243 | ||
7458bd0a LC |
3244 | @defvr {Scheme Variable} cmake-build-system |
3245 | This variable is exported by @code{(guix build-system cmake)}. It | |
3246 | implements the build procedure for packages using the | |
3247 | @url{http://www.cmake.org, CMake build tool}. | |
3248 | ||
3249 | It automatically adds the @code{cmake} package to the set of inputs. | |
3250 | Which package is used can be specified with the @code{#:cmake} | |
3251 | parameter. | |
9849cfc1 LC |
3252 | |
3253 | The @code{#:configure-flags} parameter is taken as a list of flags | |
3254 | passed to the @command{cmake} command. The @code{#:build-type} | |
3255 | parameter specifies in abstract terms the flags passed to the compiler; | |
3256 | it defaults to @code{"RelWithDebInfo"} (short for ``release mode with | |
3257 | debugging information''), which roughly means that code is compiled with | |
3258 | @code{-O2 -g}, as is the case for Autoconf-based packages by default. | |
7458bd0a LC |
3259 | @end defvr |
3260 | ||
3afcf52b FB |
3261 | @defvr {Scheme Variable} glib-or-gtk-build-system |
3262 | This variable is exported by @code{(guix build-system glib-or-gtk)}. It | |
3263 | is intended for use with packages making use of GLib or GTK+. | |
3264 | ||
3265 | This build system adds the following two phases to the ones defined by | |
3266 | @var{gnu-build-system}: | |
3267 | ||
3268 | @table @code | |
3269 | @item glib-or-gtk-wrap | |
f97c9175 AE |
3270 | The phase @code{glib-or-gtk-wrap} ensures that programs in |
3271 | @file{bin/} are able to find GLib ``schemas'' and | |
3afcf52b FB |
3272 | @uref{https://developer.gnome.org/gtk3/stable/gtk-running.html, GTK+ |
3273 | modules}. This is achieved by wrapping the programs in launch scripts | |
3274 | that appropriately set the @code{XDG_DATA_DIRS} and @code{GTK_PATH} | |
3275 | environment variables. | |
3276 | ||
73aa8ddb LC |
3277 | It is possible to exclude specific package outputs from that wrapping |
3278 | process by listing their names in the | |
3279 | @code{#:glib-or-gtk-wrap-excluded-outputs} parameter. This is useful | |
3280 | when an output is known not to contain any GLib or GTK+ binaries, and | |
3281 | where wrapping would gratuitously add a dependency of that output on | |
3282 | GLib and GTK+. | |
3283 | ||
3afcf52b | 3284 | @item glib-or-gtk-compile-schemas |
f97c9175 | 3285 | The phase @code{glib-or-gtk-compile-schemas} makes sure that all |
3afcf52b | 3286 | @uref{https://developer.gnome.org/gio/stable/glib-compile-schemas.html, |
f97c9175 | 3287 | GSettings schemas} of GLib are compiled. Compilation is performed by the |
3afcf52b FB |
3288 | @command{glib-compile-schemas} program. It is provided by the package |
3289 | @code{glib:bin} which is automatically imported by the build system. | |
3290 | The @code{glib} package providing @command{glib-compile-schemas} can be | |
3291 | specified with the @code{#:glib} parameter. | |
3292 | @end table | |
3293 | ||
3294 | Both phases are executed after the @code{install} phase. | |
3295 | @end defvr | |
3296 | ||
3184f14a JL |
3297 | @defvr {Scheme Variable} ocaml-build-system |
3298 | This variable is exported by @code{(guix build-sytem ocaml)}. It implements | |
3299 | a build procedure for @uref{https://ocaml.org, OCaml} packages, which consists | |
3300 | of choosing the correct set of commands to run for each package. OCaml | |
3301 | packages can expect many different commands to be run. This build system will | |
3302 | try some of them. | |
3303 | ||
3304 | When the package has a @file{setup.ml} file present at the top-level, it will | |
3305 | run @code{ocaml setup.ml -configure}, @code{ocaml setup.ml -build} and | |
3306 | @code{ocaml setup.ml -install}. The build system will assume that this file | |
3307 | was generated by @uref{http://oasis.forge.ocamlcore.org/, OASIS} and will take | |
3308 | care of setting the prefix and enabling tests if they are not disabled. You | |
3309 | can pass configure and build flags with the @code{#:configure-flags} and | |
3310 | @code{#:build-flags}. The @code{#:test-flags} key can be passed to change the | |
3311 | set of flags used to enable tests. The @code{#:use-make?} key can be used to | |
3312 | bypass this system in the build and install phases. | |
3313 | ||
3314 | When the package has a @file{configure} file, it is assumed that it is a | |
3315 | hand-made configure script that requires a different argument format than | |
3316 | in the @code{gnu-build-system}. You can add more flags with the | |
3317 | @code{#:configure-flags} key. | |
3318 | ||
3319 | When the package has a @file{Makefile} file (or @code{#:use-make?} is | |
3320 | @code{#t}), it will be used and more flags can be passed to the build and | |
3321 | install phases with the @code{#:make-flags} key. | |
3322 | ||
3323 | Finally, some packages do not have these files and use a somewhat standard | |
3324 | location for its build system. In that case, the build system will run | |
3325 | @code{ocaml pkg/pkg.ml} or @code{ocaml pkg/build.ml} and take care of | |
3326 | providing the path to the required findlib module. Additional flags can | |
3327 | be passed via the @code{#:build-flags} key. Install is taken care of by | |
3328 | @command{opam-installer}. In this case, the @code{opam} package must | |
3329 | be added to the @code{native-inputs} field of the package definition. | |
3330 | ||
3331 | Note that most OCaml packages assume they will be installed in the same | |
88ba7852 | 3332 | directory as OCaml, which is not what we want in guix. In particular, they |
3184f14a | 3333 | will install @file{.so} files in their module's directory, which is usually |
88ba7852 | 3334 | fine because it is in the OCaml compiler directory. In guix though, these |
3184f14a JL |
3335 | libraries cannot be found and we use @code{CAML_LD_LIBRARY_PATH}. This |
3336 | variable points to @file{lib/ocaml/site-lib/stubslibs} and this is where | |
3337 | @file{.so} libraries should be installed. | |
3338 | @end defvr | |
3339 | ||
7458bd0a LC |
3340 | @defvr {Scheme Variable} python-build-system |
3341 | This variable is exported by @code{(guix build-system python)}. It | |
3342 | implements the more or less standard build procedure used by Python | |
3343 | packages, which consists in running @code{python setup.py build} and | |
3344 | then @code{python setup.py install --prefix=/gnu/store/@dots{}}. | |
3345 | ||
3346 | For packages that install stand-alone Python programs under @code{bin/}, | |
f97c9175 | 3347 | it takes care of wrapping these programs so that their @code{PYTHONPATH} |
7458bd0a LC |
3348 | environment variable points to all the Python libraries they depend on. |
3349 | ||
8a46205b CM |
3350 | Which Python package is used to perform the build can be specified with |
3351 | the @code{#:python} parameter. This is a useful way to force a package | |
3352 | to be built for a specific version of the Python interpreter, which | |
3353 | might be necessary if the package is only compatible with a single | |
3354 | interpreter version. | |
5f7565d1 HG |
3355 | |
3356 | By default guix calls @code{setup.py} under control of | |
3357 | @code{setuptools}, much like @command{pip} does. Some packages are not | |
3358 | compatible with setuptools (and pip), thus you can disable this by | |
3359 | setting the @code{#:use-setuptools} parameter to @code{#f}. | |
7458bd0a LC |
3360 | @end defvr |
3361 | ||
3362 | @defvr {Scheme Variable} perl-build-system | |
3363 | This variable is exported by @code{(guix build-system perl)}. It | |
2d2a53fc EB |
3364 | implements the standard build procedure for Perl packages, which either |
3365 | consists in running @code{perl Build.PL --prefix=/gnu/store/@dots{}}, | |
3366 | followed by @code{Build} and @code{Build install}; or in running | |
3367 | @code{perl Makefile.PL PREFIX=/gnu/store/@dots{}}, followed by | |
f97c9175 | 3368 | @code{make} and @code{make install}, depending on which of |
2d2a53fc EB |
3369 | @code{Build.PL} or @code{Makefile.PL} is present in the package |
3370 | distribution. Preference is given to the former if both @code{Build.PL} | |
3371 | and @code{Makefile.PL} exist in the package distribution. This | |
3372 | preference can be reversed by specifying @code{#t} for the | |
3373 | @code{#:make-maker?} parameter. | |
3374 | ||
3375 | The initial @code{perl Makefile.PL} or @code{perl Build.PL} invocation | |
3376 | passes flags specified by the @code{#:make-maker-flags} or | |
3377 | @code{#:module-build-flags} parameter, respectively. | |
7458bd0a LC |
3378 | |
3379 | Which Perl package is used can be specified with @code{#:perl}. | |
3380 | @end defvr | |
3381 | ||
f8f3bef6 RW |
3382 | @defvr {Scheme Variable} r-build-system |
3383 | This variable is exported by @code{(guix build-system r)}. It | |
3384 | implements the build procedure used by @uref{http://r-project.org, R} | |
3385 | packages, which essentially is little more than running @code{R CMD | |
3386 | INSTALL --library=/gnu/store/@dots{}} in an environment where | |
3387 | @code{R_LIBS_SITE} contains the paths to all R package inputs. Tests | |
3388 | are run after installation using the R function | |
3389 | @code{tools::testInstalledPackage}. | |
3390 | @end defvr | |
3391 | ||
c08f9818 DT |
3392 | @defvr {Scheme Variable} ruby-build-system |
3393 | This variable is exported by @code{(guix build-system ruby)}. It | |
3394 | implements the RubyGems build procedure used by Ruby packages, which | |
3395 | involves running @code{gem build} followed by @code{gem install}. | |
3396 | ||
5dc87623 DT |
3397 | The @code{source} field of a package that uses this build system |
3398 | typically references a gem archive, since this is the format that Ruby | |
3399 | developers use when releasing their software. The build system unpacks | |
3400 | the gem archive, potentially patches the source, runs the test suite, | |
3401 | repackages the gem, and installs it. Additionally, directories and | |
3402 | tarballs may be referenced to allow building unreleased gems from Git or | |
3403 | a traditional source release tarball. | |
e83c6d00 | 3404 | |
c08f9818 | 3405 | Which Ruby package is used can be specified with the @code{#:ruby} |
6e9f2913 PP |
3406 | parameter. A list of additional flags to be passed to the @command{gem} |
3407 | command can be specified with the @code{#:gem-flags} parameter. | |
c08f9818 | 3408 | @end defvr |
7458bd0a | 3409 | |
a677c726 RW |
3410 | @defvr {Scheme Variable} waf-build-system |
3411 | This variable is exported by @code{(guix build-system waf)}. It | |
3412 | implements a build procedure around the @code{waf} script. The common | |
3413 | phases---@code{configure}, @code{build}, and @code{install}---are | |
3414 | implemented by passing their names as arguments to the @code{waf} | |
3415 | script. | |
3416 | ||
3417 | The @code{waf} script is executed by the Python interpreter. Which | |
3418 | Python package is used to run the script can be specified with the | |
3419 | @code{#:python} parameter. | |
3420 | @end defvr | |
3421 | ||
14dfdf2e FB |
3422 | @defvr {Scheme Variable} haskell-build-system |
3423 | This variable is exported by @code{(guix build-system haskell)}. It | |
3424 | implements the Cabal build procedure used by Haskell packages, which | |
3425 | involves running @code{runhaskell Setup.hs configure | |
3426 | --prefix=/gnu/store/@dots{}} and @code{runhaskell Setup.hs build}. | |
3427 | Instead of installing the package by running @code{runhaskell Setup.hs | |
3428 | install}, to avoid trying to register libraries in the read-only | |
3429 | compiler store directory, the build system uses @code{runhaskell | |
3430 | Setup.hs copy}, followed by @code{runhaskell Setup.hs register}. In | |
3431 | addition, the build system generates the package documentation by | |
3432 | running @code{runhaskell Setup.hs haddock}, unless @code{#:haddock? #f} | |
3433 | is passed. Optional Haddock parameters can be passed with the help of | |
3434 | the @code{#:haddock-flags} parameter. If the file @code{Setup.hs} is | |
3435 | not found, the build system looks for @code{Setup.lhs} instead. | |
3436 | ||
3437 | Which Haskell compiler is used can be specified with the @code{#:haskell} | |
a54bd6d7 | 3438 | parameter which defaults to @code{ghc}. |
14dfdf2e FB |
3439 | @end defvr |
3440 | ||
65e862d1 DM |
3441 | @defvr {Scheme Variable} dub-build-system |
3442 | This variable is exported by @code{(guix build-system dub)}. It | |
3443 | implements the Dub build procedure used by D packages, which | |
3444 | involves running @code{dub build} and @code{dub run}. | |
3445 | Installation is done by copying the files manually. | |
3446 | ||
3447 | Which D compiler is used can be specified with the @code{#:ldc} | |
3448 | parameter which defaults to @code{ldc}. | |
3449 | @end defvr | |
3450 | ||
e9137a53 FB |
3451 | @defvr {Scheme Variable} emacs-build-system |
3452 | This variable is exported by @code{(guix build-system emacs)}. It | |
f97c9175 AE |
3453 | implements an installation procedure similar to the packaging system |
3454 | of Emacs itself (@pxref{Packages,,, emacs, The GNU Emacs Manual}). | |
e9137a53 FB |
3455 | |
3456 | It first creates the @code{@var{package}-autoloads.el} file, then it | |
3457 | byte compiles all Emacs Lisp files. Differently from the Emacs | |
3458 | packaging system, the Info documentation files are moved to the standard | |
3459 | documentation directory and the @file{dir} file is deleted. Each | |
3460 | package is installed in its own directory under | |
3461 | @file{share/emacs/site-lisp/guix.d}. | |
3462 | @end defvr | |
3463 | ||
7458bd0a LC |
3464 | Lastly, for packages that do not need anything as sophisticated, a |
3465 | ``trivial'' build system is provided. It is trivial in the sense that | |
3466 | it provides basically no support: it does not pull any implicit inputs, | |
3467 | and does not have a notion of build phases. | |
3468 | ||
3469 | @defvr {Scheme Variable} trivial-build-system | |
3470 | This variable is exported by @code{(guix build-system trivial)}. | |
3471 | ||
3472 | This build system requires a @code{#:builder} argument. This argument | |
f97c9175 | 3473 | must be a Scheme expression that builds the package output(s)---as |
7458bd0a LC |
3474 | with @code{build-expression->derivation} (@pxref{Derivations, |
3475 | @code{build-expression->derivation}}). | |
3476 | @end defvr | |
3477 | ||
568717fd LC |
3478 | @node The Store |
3479 | @section The Store | |
3480 | ||
e531ac2a | 3481 | @cindex store |
1ddee424 | 3482 | @cindex store items |
e531ac2a LC |
3483 | @cindex store paths |
3484 | ||
f97c9175 AE |
3485 | Conceptually, the @dfn{store} is the place where derivations that have |
3486 | been built successfully are stored---by default, @file{/gnu/store}. | |
1ddee424 LC |
3487 | Sub-directories in the store are referred to as @dfn{store items} or |
3488 | sometimes @dfn{store paths}. The store has an associated database that | |
3489 | contains information such as the store paths referred to by each store | |
3490 | path, and the list of @emph{valid} store items---results of successful | |
ef5f5c86 LC |
3491 | builds. This database resides in @file{@var{localstatedir}/guix/db}, |
3492 | where @var{localstatedir} is the state directory specified @i{via} | |
3493 | @option{--localstatedir} at configure time, usually @file{/var}. | |
1ddee424 LC |
3494 | |
3495 | The store is @emph{always} accessed by the daemon on behalf of its clients | |
e531ac2a | 3496 | (@pxref{Invoking guix-daemon}). To manipulate the store, clients |
f97c9175 AE |
3497 | connect to the daemon over a Unix-domain socket, send requests to it, |
3498 | and read the result---these are remote procedure calls, or RPCs. | |
e531ac2a | 3499 | |
1ddee424 LC |
3500 | @quotation Note |
3501 | Users must @emph{never} modify files under @file{/gnu/store} directly. | |
3502 | This would lead to inconsistencies and break the immutability | |
3503 | assumptions of Guix's functional model (@pxref{Introduction}). | |
3504 | ||
3505 | @xref{Invoking guix gc, @command{guix gc --verify}}, for information on | |
3506 | how to check the integrity of the store and attempt recovery from | |
3507 | accidental modifications. | |
3508 | @end quotation | |
3509 | ||
e531ac2a LC |
3510 | The @code{(guix store)} module provides procedures to connect to the |
3511 | daemon, and to perform RPCs. These are described below. | |
3512 | ||
3513 | @deffn {Scheme Procedure} open-connection [@var{file}] [#:reserve-space? #t] | |
3514 | Connect to the daemon over the Unix-domain socket at @var{file}. When | |
3515 | @var{reserve-space?} is true, instruct it to reserve a little bit of | |
3516 | extra space on the file system so that the garbage collector can still | |
f97c9175 | 3517 | operate should the disk become full. Return a server object. |
e531ac2a LC |
3518 | |
3519 | @var{file} defaults to @var{%default-socket-path}, which is the normal | |
3520 | location given the options that were passed to @command{configure}. | |
3521 | @end deffn | |
3522 | ||
3523 | @deffn {Scheme Procedure} close-connection @var{server} | |
3524 | Close the connection to @var{server}. | |
3525 | @end deffn | |
3526 | ||
3527 | @defvr {Scheme Variable} current-build-output-port | |
3528 | This variable is bound to a SRFI-39 parameter, which refers to the port | |
3529 | where build and error logs sent by the daemon should be written. | |
3530 | @end defvr | |
3531 | ||
3532 | Procedures that make RPCs all take a server object as their first | |
3533 | argument. | |
3534 | ||
3535 | @deffn {Scheme Procedure} valid-path? @var{server} @var{path} | |
06b76acc LC |
3536 | @cindex invalid store items |
3537 | Return @code{#t} when @var{path} designates a valid store item and | |
3538 | @code{#f} otherwise (an invalid item may exist on disk but still be | |
3539 | invalid, for instance because it is the result of an aborted or failed | |
3540 | build.) | |
3541 | ||
3542 | A @code{&nix-protocol-error} condition is raised if @var{path} is not | |
3543 | prefixed by the store directory (@file{/gnu/store}). | |
e531ac2a LC |
3544 | @end deffn |
3545 | ||
cfbf9160 | 3546 | @deffn {Scheme Procedure} add-text-to-store @var{server} @var{name} @var{text} [@var{references}] |
e531ac2a LC |
3547 | Add @var{text} under file @var{name} in the store, and return its store |
3548 | path. @var{references} is the list of store paths referred to by the | |
3549 | resulting store path. | |
3550 | @end deffn | |
3551 | ||
874e6874 | 3552 | @deffn {Scheme Procedure} build-derivations @var{server} @var{derivations} |
59688fc4 LC |
3553 | Build @var{derivations} (a list of @code{<derivation>} objects or |
3554 | derivation paths), and return when the worker is done building them. | |
3555 | Return @code{#t} on success. | |
874e6874 LC |
3556 | @end deffn |
3557 | ||
b860f382 LC |
3558 | Note that the @code{(guix monads)} module provides a monad as well as |
3559 | monadic versions of the above procedures, with the goal of making it | |
3560 | more convenient to work with code that accesses the store (@pxref{The | |
3561 | Store Monad}). | |
3562 | ||
e531ac2a LC |
3563 | @c FIXME |
3564 | @i{This section is currently incomplete.} | |
568717fd LC |
3565 | |
3566 | @node Derivations | |
3567 | @section Derivations | |
3568 | ||
874e6874 LC |
3569 | @cindex derivations |
3570 | Low-level build actions and the environment in which they are performed | |
70458ed5 | 3571 | are represented by @dfn{derivations}. A derivation contains the |
874e6874 LC |
3572 | following pieces of information: |
3573 | ||
3574 | @itemize | |
3575 | @item | |
3576 | The outputs of the derivation---derivations produce at least one file or | |
3577 | directory in the store, but may produce more. | |
3578 | ||
3579 | @item | |
3580 | The inputs of the derivations, which may be other derivations or plain | |
3581 | files in the store (patches, build scripts, etc.) | |
3582 | ||
3583 | @item | |
3584 | The system type targeted by the derivation---e.g., @code{x86_64-linux}. | |
3585 | ||
3586 | @item | |
3587 | The file name of a build script in the store, along with the arguments | |
3588 | to be passed. | |
3589 | ||
3590 | @item | |
3591 | A list of environment variables to be defined. | |
3592 | ||
3593 | @end itemize | |
3594 | ||
3595 | @cindex derivation path | |
3596 | Derivations allow clients of the daemon to communicate build actions to | |
3597 | the store. They exist in two forms: as an in-memory representation, | |
3598 | both on the client- and daemon-side, and as files in the store whose | |
3599 | name end in @code{.drv}---these files are referred to as @dfn{derivation | |
3600 | paths}. Derivations paths can be passed to the @code{build-derivations} | |
3601 | procedure to perform the build actions they prescribe (@pxref{The | |
3602 | Store}). | |
3603 | ||
3604 | The @code{(guix derivations)} module provides a representation of | |
3605 | derivations as Scheme objects, along with procedures to create and | |
3606 | otherwise manipulate derivations. The lowest-level primitive to create | |
3607 | a derivation is the @code{derivation} procedure: | |
3608 | ||
1909431c LC |
3609 | @deffn {Scheme Procedure} derivation @var{store} @var{name} @var{builder} @ |
3610 | @var{args} [#:outputs '("out")] [#:hash #f] [#:hash-algo #f] @ | |
2096ef47 | 3611 | [#:recursive? #f] [#:inputs '()] [#:env-vars '()] @ |
1909431c | 3612 | [#:system (%current-system)] [#:references-graphs #f] @ |
35b5ca78 LC |
3613 | [#:allowed-references #f] [#:disallowed-references #f] @ |
3614 | [#:leaked-env-vars #f] [#:local-build? #f] @ | |
4a6aeb67 | 3615 | [#:substitutable? #t] |
59688fc4 LC |
3616 | Build a derivation with the given arguments, and return the resulting |
3617 | @code{<derivation>} object. | |
874e6874 | 3618 | |
2096ef47 | 3619 | When @var{hash} and @var{hash-algo} are given, a |
874e6874 | 3620 | @dfn{fixed-output derivation} is created---i.e., one whose result is |
36bbbbd1 LC |
3621 | known in advance, such as a file download. If, in addition, |
3622 | @var{recursive?} is true, then that fixed output may be an executable | |
3623 | file or a directory and @var{hash} must be the hash of an archive | |
3624 | containing this output. | |
5b0c9d16 | 3625 | |
858e9282 | 3626 | When @var{references-graphs} is true, it must be a list of file |
5b0c9d16 LC |
3627 | name/store path pairs. In that case, the reference graph of each store |
3628 | path is exported in the build environment in the corresponding file, in | |
3629 | a simple text format. | |
1909431c | 3630 | |
b53be755 | 3631 | When @var{allowed-references} is true, it must be a list of store items |
35b5ca78 LC |
3632 | or outputs that the derivation's output may refer to. Likewise, |
3633 | @var{disallowed-references}, if true, must be a list of things the | |
3634 | outputs may @emph{not} refer to. | |
b53be755 | 3635 | |
c0468155 LC |
3636 | When @var{leaked-env-vars} is true, it must be a list of strings |
3637 | denoting environment variables that are allowed to ``leak'' from the | |
3638 | daemon's environment to the build environment. This is only applicable | |
3639 | to fixed-output derivations---i.e., when @var{hash} is true. The main | |
3640 | use is to allow variables such as @code{http_proxy} to be passed to | |
3641 | derivations that download files. | |
3642 | ||
1909431c LC |
3643 | When @var{local-build?} is true, declare that the derivation is not a |
3644 | good candidate for offloading and should rather be built locally | |
3645 | (@pxref{Daemon Offload Setup}). This is the case for small derivations | |
3646 | where the costs of data transfers would outweigh the benefits. | |
4a6aeb67 LC |
3647 | |
3648 | When @var{substitutable?} is false, declare that substitutes of the | |
3649 | derivation's output should not be used (@pxref{Substitutes}). This is | |
3650 | useful, for instance, when building packages that capture details of the | |
3651 | host CPU instruction set. | |
874e6874 LC |
3652 | @end deffn |
3653 | ||
3654 | @noindent | |
3655 | Here's an example with a shell script as its builder, assuming | |
3656 | @var{store} is an open connection to the daemon, and @var{bash} points | |
3657 | to a Bash executable in the store: | |
3658 | ||
3659 | @lisp | |
3660 | (use-modules (guix utils) | |
3661 | (guix store) | |
3662 | (guix derivations)) | |
3663 | ||
59688fc4 LC |
3664 | (let ((builder ; add the Bash script to the store |
3665 | (add-text-to-store store "my-builder.sh" | |
3666 | "echo hello world > $out\n" '()))) | |
3667 | (derivation store "foo" | |
3668 | bash `("-e" ,builder) | |
21b679f6 | 3669 | #:inputs `((,bash) (,builder)) |
59688fc4 | 3670 | #:env-vars '(("HOME" . "/homeless")))) |
834129e0 | 3671 | @result{} #<derivation /gnu/store/@dots{}-foo.drv => /gnu/store/@dots{}-foo> |
874e6874 LC |
3672 | @end lisp |
3673 | ||
21b679f6 LC |
3674 | As can be guessed, this primitive is cumbersome to use directly. A |
3675 | better approach is to write build scripts in Scheme, of course! The | |
3676 | best course of action for that is to write the build code as a | |
3677 | ``G-expression'', and to pass it to @code{gexp->derivation}. For more | |
6621cdb6 | 3678 | information, @pxref{G-Expressions}. |
21b679f6 | 3679 | |
f2fadbc1 AE |
3680 | Once upon a time, @code{gexp->derivation} did not exist and constructing |
3681 | derivations with build code written in Scheme was achieved with | |
3682 | @code{build-expression->derivation}, documented below. This procedure | |
3683 | is now deprecated in favor of the much nicer @code{gexp->derivation}. | |
3684 | ||
3685 | @deffn {Scheme Procedure} build-expression->derivation @var{store} @ | |
3686 | @var{name} @var{exp} @ | |
3687 | [#:system (%current-system)] [#:inputs '()] @ | |
3688 | [#:outputs '("out")] [#:hash #f] [#:hash-algo #f] @ | |
3689 | [#:recursive? #f] [#:env-vars '()] [#:modules '()] @ | |
3690 | [#:references-graphs #f] [#:allowed-references #f] @ | |
35b5ca78 | 3691 | [#:disallowed-references #f] @ |
f2fadbc1 AE |
3692 | [#:local-build? #f] [#:substitutable? #t] [#:guile-for-build #f] |
3693 | Return a derivation that executes Scheme expression @var{exp} as a | |
3694 | builder for derivation @var{name}. @var{inputs} must be a list of | |
3695 | @code{(name drv-path sub-drv)} tuples; when @var{sub-drv} is omitted, | |
3696 | @code{"out"} is assumed. @var{modules} is a list of names of Guile | |
3697 | modules from the current search path to be copied in the store, | |
3698 | compiled, and made available in the load path during the execution of | |
3699 | @var{exp}---e.g., @code{((guix build utils) (guix build | |
3700 | gnu-build-system))}. | |
3701 | ||
3702 | @var{exp} is evaluated in an environment where @code{%outputs} is bound | |
3703 | to a list of output/path pairs, and where @code{%build-inputs} is bound | |
3704 | to a list of string/output-path pairs made from @var{inputs}. | |
3705 | Optionally, @var{env-vars} is a list of string pairs specifying the name | |
3706 | and value of environment variables visible to the builder. The builder | |
3707 | terminates by passing the result of @var{exp} to @code{exit}; thus, when | |
3708 | @var{exp} returns @code{#f}, the build is considered to have failed. | |
3709 | ||
3710 | @var{exp} is built using @var{guile-for-build} (a derivation). When | |
3711 | @var{guile-for-build} is omitted or is @code{#f}, the value of the | |
3712 | @code{%guile-for-build} fluid is used instead. | |
3713 | ||
3714 | See the @code{derivation} procedure for the meaning of | |
35b5ca78 LC |
3715 | @var{references-graphs}, @var{allowed-references}, |
3716 | @var{disallowed-references}, @var{local-build?}, and | |
3717 | @var{substitutable?}. | |
f2fadbc1 AE |
3718 | @end deffn |
3719 | ||
3720 | @noindent | |
3721 | Here's an example of a single-output derivation that creates a directory | |
3722 | containing one file: | |
3723 | ||
3724 | @lisp | |
3725 | (let ((builder '(let ((out (assoc-ref %outputs "out"))) | |
3726 | (mkdir out) ; create /gnu/store/@dots{}-goo | |
3727 | (call-with-output-file (string-append out "/test") | |
3728 | (lambda (p) | |
3729 | (display '(hello guix) p)))))) | |
3730 | (build-expression->derivation store "goo" builder)) | |
3731 | ||
3732 | @result{} #<derivation /gnu/store/@dots{}-goo.drv => @dots{}> | |
3733 | @end lisp | |
3734 | ||
568717fd | 3735 | |
b860f382 LC |
3736 | @node The Store Monad |
3737 | @section The Store Monad | |
3738 | ||
3739 | @cindex monad | |
3740 | ||
3741 | The procedures that operate on the store described in the previous | |
3742 | sections all take an open connection to the build daemon as their first | |
3743 | argument. Although the underlying model is functional, they either have | |
3744 | side effects or depend on the current state of the store. | |
3745 | ||
3746 | The former is inconvenient: the connection to the build daemon has to be | |
3747 | carried around in all those functions, making it impossible to compose | |
3748 | functions that do not take that parameter with functions that do. The | |
3749 | latter can be problematic: since store operations have side effects | |
3750 | and/or depend on external state, they have to be properly sequenced. | |
3751 | ||
3752 | @cindex monadic values | |
3753 | @cindex monadic functions | |
3754 | This is where the @code{(guix monads)} module comes in. This module | |
3755 | provides a framework for working with @dfn{monads}, and a particularly | |
3756 | useful monad for our uses, the @dfn{store monad}. Monads are a | |
3757 | construct that allows two things: associating ``context'' with values | |
3758 | (in our case, the context is the store), and building sequences of | |
4827b36d | 3759 | computations (here computations include accesses to the store). Values |
b860f382 LC |
3760 | in a monad---values that carry this additional context---are called |
3761 | @dfn{monadic values}; procedures that return such values are called | |
3762 | @dfn{monadic procedures}. | |
3763 | ||
3764 | Consider this ``normal'' procedure: | |
3765 | ||
3766 | @example | |
45adbd62 LC |
3767 | (define (sh-symlink store) |
3768 | ;; Return a derivation that symlinks the 'bash' executable. | |
3769 | (let* ((drv (package-derivation store bash)) | |
3770 | (out (derivation->output-path drv)) | |
3771 | (sh (string-append out "/bin/bash"))) | |
3772 | (build-expression->derivation store "sh" | |
3773 | `(symlink ,sh %output)))) | |
b860f382 LC |
3774 | @end example |
3775 | ||
c6f30b81 LC |
3776 | Using @code{(guix monads)} and @code{(guix gexp)}, it may be rewritten |
3777 | as a monadic function: | |
b860f382 LC |
3778 | |
3779 | @example | |
45adbd62 | 3780 | (define (sh-symlink) |
b860f382 | 3781 | ;; Same, but return a monadic value. |
c6f30b81 LC |
3782 | (mlet %store-monad ((drv (package->derivation bash))) |
3783 | (gexp->derivation "sh" | |
3784 | #~(symlink (string-append #$drv "/bin/bash") | |
3785 | #$output)))) | |
b860f382 LC |
3786 | @end example |
3787 | ||
4827b36d | 3788 | There are several things to note in the second version: the @code{store} |
c6f30b81 LC |
3789 | parameter is now implicit and is ``threaded'' in the calls to the |
3790 | @code{package->derivation} and @code{gexp->derivation} monadic | |
3791 | procedures, and the monadic value returned by @code{package->derivation} | |
3792 | is @dfn{bound} using @code{mlet} instead of plain @code{let}. | |
3793 | ||
3794 | As it turns out, the call to @code{package->derivation} can even be | |
3795 | omitted since it will take place implicitly, as we will see later | |
3796 | (@pxref{G-Expressions}): | |
3797 | ||
3798 | @example | |
3799 | (define (sh-symlink) | |
3800 | (gexp->derivation "sh" | |
3801 | #~(symlink (string-append #$bash "/bin/bash") | |
3802 | #$output))) | |
3803 | @end example | |
b860f382 | 3804 | |
7ce21611 | 3805 | @c See |
a01ad638 | 3806 | @c <https://syntaxexclamation.wordpress.com/2014/06/26/escaping-continuations/> |
7ce21611 LC |
3807 | @c for the funny quote. |
3808 | Calling the monadic @code{sh-symlink} has no effect. As someone once | |
3809 | said, ``you exit a monad like you exit a building on fire: by running''. | |
3810 | So, to exit the monad and get the desired effect, one must use | |
3811 | @code{run-with-store}: | |
b860f382 LC |
3812 | |
3813 | @example | |
8e9aa37f CAW |
3814 | (run-with-store (open-connection) (sh-symlink)) |
3815 | @result{} /gnu/store/...-sh-symlink | |
b860f382 LC |
3816 | @end example |
3817 | ||
f97c9175 | 3818 | Note that the @code{(guix monad-repl)} module extends the Guile REPL with |
b9b86078 | 3819 | new ``meta-commands'' to make it easier to deal with monadic procedures: |
f97c9175 | 3820 | @code{run-in-store}, and @code{enter-store-monad}. The former is used |
b9b86078 LC |
3821 | to ``run'' a single monadic value through the store: |
3822 | ||
3823 | @example | |
3824 | scheme@@(guile-user)> ,run-in-store (package->derivation hello) | |
3825 | $1 = #<derivation /gnu/store/@dots{}-hello-2.9.drv => @dots{}> | |
3826 | @end example | |
3827 | ||
3828 | The latter enters a recursive REPL, where all the return values are | |
3829 | automatically run through the store: | |
3830 | ||
3831 | @example | |
3832 | scheme@@(guile-user)> ,enter-store-monad | |
3833 | store-monad@@(guile-user) [1]> (package->derivation hello) | |
3834 | $2 = #<derivation /gnu/store/@dots{}-hello-2.9.drv => @dots{}> | |
3835 | store-monad@@(guile-user) [1]> (text-file "foo" "Hello!") | |
3836 | $3 = "/gnu/store/@dots{}-foo" | |
3837 | store-monad@@(guile-user) [1]> ,q | |
3838 | scheme@@(guile-user)> | |
3839 | @end example | |
3840 | ||
3841 | @noindent | |
3842 | Note that non-monadic values cannot be returned in the | |
3843 | @code{store-monad} REPL. | |
3844 | ||
e87f0591 LC |
3845 | The main syntactic forms to deal with monads in general are provided by |
3846 | the @code{(guix monads)} module and are described below. | |
b860f382 LC |
3847 | |
3848 | @deffn {Scheme Syntax} with-monad @var{monad} @var{body} ... | |
3849 | Evaluate any @code{>>=} or @code{return} forms in @var{body} as being | |
3850 | in @var{monad}. | |
3851 | @end deffn | |
3852 | ||
3853 | @deffn {Scheme Syntax} return @var{val} | |
3854 | Return a monadic value that encapsulates @var{val}. | |
3855 | @end deffn | |
3856 | ||
751630c9 | 3857 | @deffn {Scheme Syntax} >>= @var{mval} @var{mproc} ... |
b860f382 | 3858 | @dfn{Bind} monadic value @var{mval}, passing its ``contents'' to monadic |
751630c9 LC |
3859 | procedures @var{mproc}@dots{}@footnote{This operation is commonly |
3860 | referred to as ``bind'', but that name denotes an unrelated procedure in | |
3861 | Guile. Thus we use this somewhat cryptic symbol inherited from the | |
3862 | Haskell language.}. There can be one @var{mproc} or several of them, as | |
3863 | in this example: | |
3864 | ||
3865 | @example | |
3866 | (run-with-state | |
3867 | (with-monad %state-monad | |
3868 | (>>= (return 1) | |
3869 | (lambda (x) (return (+ 1 x))) | |
3870 | (lambda (x) (return (* 2 x))))) | |
3871 | 'some-state) | |
3872 | ||
3873 | @result{} 4 | |
3874 | @result{} some-state | |
3875 | @end example | |
b860f382 LC |
3876 | @end deffn |
3877 | ||
3878 | @deffn {Scheme Syntax} mlet @var{monad} ((@var{var} @var{mval}) ...) @ | |
3879 | @var{body} ... | |
3880 | @deffnx {Scheme Syntax} mlet* @var{monad} ((@var{var} @var{mval}) ...) @ | |
3881 | @var{body} ... | |
3882 | Bind the variables @var{var} to the monadic values @var{mval} in | |
3883 | @var{body}. The form (@var{var} -> @var{val}) binds @var{var} to the | |
3884 | ``normal'' value @var{val}, as per @code{let}. | |
3885 | ||
3886 | @code{mlet*} is to @code{mlet} what @code{let*} is to @code{let} | |
3887 | (@pxref{Local Bindings,,, guile, GNU Guile Reference Manual}). | |
3888 | @end deffn | |
3889 | ||
405a9d4e LC |
3890 | @deffn {Scheme System} mbegin @var{monad} @var{mexp} ... |
3891 | Bind @var{mexp} and the following monadic expressions in sequence, | |
3892 | returning the result of the last expression. | |
3893 | ||
3894 | This is akin to @code{mlet}, except that the return values of the | |
3895 | monadic expressions are ignored. In that sense, it is analogous to | |
3896 | @code{begin}, but applied to monadic expressions. | |
3897 | @end deffn | |
3898 | ||
561fb6c3 LC |
3899 | @cindex state monad |
3900 | The @code{(guix monads)} module provides the @dfn{state monad}, which | |
3901 | allows an additional value---the state---to be @emph{threaded} through | |
3902 | monadic procedure calls. | |
3903 | ||
3904 | @defvr {Scheme Variable} %state-monad | |
3905 | The state monad. Procedures in the state monad can access and change | |
3906 | the state that is threaded. | |
3907 | ||
3908 | Consider the example below. The @code{square} procedure returns a value | |
3909 | in the state monad. It returns the square of its argument, but also | |
3910 | increments the current state value: | |
3911 | ||
3912 | @example | |
3913 | (define (square x) | |
3914 | (mlet %state-monad ((count (current-state))) | |
3915 | (mbegin %state-monad | |
3916 | (set-current-state (+ 1 count)) | |
3917 | (return (* x x))))) | |
3918 | ||
3919 | (run-with-state (sequence %state-monad (map square (iota 3))) 0) | |
3920 | @result{} (0 1 4) | |
3921 | @result{} 3 | |
3922 | @end example | |
3923 | ||
3924 | When ``run'' through @var{%state-monad}, we obtain that additional state | |
3925 | value, which is the number of @code{square} calls. | |
3926 | @end defvr | |
3927 | ||
3928 | @deffn {Monadic Procedure} current-state | |
3929 | Return the current state as a monadic value. | |
3930 | @end deffn | |
3931 | ||
3932 | @deffn {Monadic Procedure} set-current-state @var{value} | |
3933 | Set the current state to @var{value} and return the previous state as a | |
3934 | monadic value. | |
3935 | @end deffn | |
3936 | ||
3937 | @deffn {Monadic Procedure} state-push @var{value} | |
3938 | Push @var{value} to the current state, which is assumed to be a list, | |
3939 | and return the previous state as a monadic value. | |
3940 | @end deffn | |
3941 | ||
3942 | @deffn {Monadic Procedure} state-pop | |
3943 | Pop a value from the current state and return it as a monadic value. | |
3944 | The state is assumed to be a list. | |
3945 | @end deffn | |
3946 | ||
3947 | @deffn {Scheme Procedure} run-with-state @var{mval} [@var{state}] | |
3948 | Run monadic value @var{mval} starting with @var{state} as the initial | |
3949 | state. Return two values: the resulting value, and the resulting state. | |
3950 | @end deffn | |
3951 | ||
e87f0591 LC |
3952 | The main interface to the store monad, provided by the @code{(guix |
3953 | store)} module, is as follows. | |
b860f382 LC |
3954 | |
3955 | @defvr {Scheme Variable} %store-monad | |
561fb6c3 LC |
3956 | The store monad---an alias for @var{%state-monad}. |
3957 | ||
3958 | Values in the store monad encapsulate accesses to the store. When its | |
3959 | effect is needed, a value of the store monad must be ``evaluated'' by | |
3960 | passing it to the @code{run-with-store} procedure (see below.) | |
b860f382 LC |
3961 | @end defvr |
3962 | ||
3963 | @deffn {Scheme Procedure} run-with-store @var{store} @var{mval} [#:guile-for-build] [#:system (%current-system)] | |
3964 | Run @var{mval}, a monadic value in the store monad, in @var{store}, an | |
3965 | open store connection. | |
3966 | @end deffn | |
3967 | ||
ad372953 | 3968 | @deffn {Monadic Procedure} text-file @var{name} @var{text} [@var{references}] |
b860f382 | 3969 | Return as a monadic value the absolute file name in the store of the file |
ad372953 LC |
3970 | containing @var{text}, a string. @var{references} is a list of store items that the |
3971 | resulting text file refers to; it defaults to the empty list. | |
45adbd62 LC |
3972 | @end deffn |
3973 | ||
0a90af15 | 3974 | @deffn {Monadic Procedure} interned-file @var{file} [@var{name}] @ |
1ec32f4a | 3975 | [#:recursive? #t] [#:select? (const #t)] |
0a90af15 LC |
3976 | Return the name of @var{file} once interned in the store. Use |
3977 | @var{name} as its store name, or the basename of @var{file} if | |
3978 | @var{name} is omitted. | |
3979 | ||
3980 | When @var{recursive?} is true, the contents of @var{file} are added | |
3981 | recursively; if @var{file} designates a flat file and @var{recursive?} | |
3982 | is true, its contents are added, and its permission bits are kept. | |
3983 | ||
1ec32f4a LC |
3984 | When @var{recursive?} is true, call @code{(@var{select?} @var{file} |
3985 | @var{stat})} for each directory entry, where @var{file} is the entry's | |
3986 | absolute file name and @var{stat} is the result of @code{lstat}; exclude | |
3987 | entries for which @var{select?} does not return true. | |
3988 | ||
0a90af15 LC |
3989 | The example below adds a file to the store, under two different names: |
3990 | ||
3991 | @example | |
3992 | (run-with-store (open-connection) | |
3993 | (mlet %store-monad ((a (interned-file "README")) | |
3994 | (b (interned-file "README" "LEGU-MIN"))) | |
3995 | (return (list a b)))) | |
3996 | ||
3997 | @result{} ("/gnu/store/rwm@dots{}-README" "/gnu/store/44i@dots{}-LEGU-MIN") | |
3998 | @end example | |
3999 | ||
4000 | @end deffn | |
4001 | ||
e87f0591 LC |
4002 | The @code{(guix packages)} module exports the following package-related |
4003 | monadic procedures: | |
4004 | ||
b860f382 | 4005 | @deffn {Monadic Procedure} package-file @var{package} [@var{file}] @ |
4231f05b | 4006 | [#:system (%current-system)] [#:target #f] @ |
f97c9175 AE |
4007 | [#:output "out"] |
4008 | Return as a monadic | |
b860f382 LC |
4009 | value in the absolute file name of @var{file} within the @var{output} |
4010 | directory of @var{package}. When @var{file} is omitted, return the name | |
4231f05b LC |
4011 | of the @var{output} directory of @var{package}. When @var{target} is |
4012 | true, use it as a cross-compilation target triplet. | |
b860f382 LC |
4013 | @end deffn |
4014 | ||
b860f382 | 4015 | @deffn {Monadic Procedure} package->derivation @var{package} [@var{system}] |
4231f05b LC |
4016 | @deffnx {Monadic Procedure} package->cross-derivation @var{package} @ |
4017 | @var{target} [@var{system}] | |
4018 | Monadic version of @code{package-derivation} and | |
4019 | @code{package-cross-derivation} (@pxref{Defining Packages}). | |
b860f382 LC |
4020 | @end deffn |
4021 | ||
4022 | ||
21b679f6 LC |
4023 | @node G-Expressions |
4024 | @section G-Expressions | |
4025 | ||
4026 | @cindex G-expression | |
4027 | @cindex build code quoting | |
4028 | So we have ``derivations'', which represent a sequence of build actions | |
4029 | to be performed to produce an item in the store (@pxref{Derivations}). | |
f97c9175 | 4030 | These build actions are performed when asking the daemon to actually |
21b679f6 LC |
4031 | build the derivations; they are run by the daemon in a container |
4032 | (@pxref{Invoking guix-daemon}). | |
4033 | ||
4034 | @cindex strata of code | |
f97c9175 | 4035 | It should come as no surprise that we like to write these build actions |
21b679f6 LC |
4036 | in Scheme. When we do that, we end up with two @dfn{strata} of Scheme |
4037 | code@footnote{The term @dfn{stratum} in this context was coined by | |
ef4ab0a4 LC |
4038 | Manuel Serrano et al.@: in the context of their work on Hop. Oleg |
4039 | Kiselyov, who has written insightful | |
4040 | @url{http://okmij.org/ftp/meta-programming/#meta-scheme, essays and code | |
4041 | on this topic}, refers to this kind of code generation as | |
4042 | @dfn{staging}.}: the ``host code''---code that defines packages, talks | |
4043 | to the daemon, etc.---and the ``build code''---code that actually | |
4044 | performs build actions, such as making directories, invoking | |
4045 | @command{make}, etc. | |
21b679f6 LC |
4046 | |
4047 | To describe a derivation and its build actions, one typically needs to | |
4048 | embed build code inside host code. It boils down to manipulating build | |
f97c9175 | 4049 | code as data, and the homoiconicity of Scheme---code has a direct |
21b679f6 | 4050 | representation as data---comes in handy for that. But we need more than |
f97c9175 | 4051 | the normal @code{quasiquote} mechanism in Scheme to construct build |
21b679f6 LC |
4052 | expressions. |
4053 | ||
4054 | The @code{(guix gexp)} module implements @dfn{G-expressions}, a form of | |
4055 | S-expressions adapted to build expressions. G-expressions, or | |
f97c9175 | 4056 | @dfn{gexps}, consist essentially of three syntactic forms: @code{gexp}, |
21b679f6 | 4057 | @code{ungexp}, and @code{ungexp-splicing} (or simply: @code{#~}, |
f97c9175 AE |
4058 | @code{#$}, and @code{#$@@}), which are comparable to |
4059 | @code{quasiquote}, @code{unquote}, and @code{unquote-splicing}, | |
4827b36d | 4060 | respectively (@pxref{Expression Syntax, @code{quasiquote},, guile, |
f97c9175 | 4061 | GNU Guile Reference Manual}). However, there are major differences: |
21b679f6 LC |
4062 | |
4063 | @itemize | |
4064 | @item | |
4065 | Gexps are meant to be written to a file and run or manipulated by other | |
4066 | processes. | |
4067 | ||
4068 | @item | |
b39fc6f7 LC |
4069 | When a high-level object such as a package or derivation is unquoted |
4070 | inside a gexp, the result is as if its output file name had been | |
4071 | introduced. | |
ff40e9b7 | 4072 | |
21b679f6 LC |
4073 | @item |
4074 | Gexps carry information about the packages or derivations they refer to, | |
4075 | and these dependencies are automatically added as inputs to the build | |
4076 | processes that use them. | |
4077 | @end itemize | |
4078 | ||
c2b84676 | 4079 | @cindex lowering, of high-level objects in gexps |
343eacbe LC |
4080 | This mechanism is not limited to package and derivation |
4081 | objects: @dfn{compilers} able to ``lower'' other high-level objects to | |
c2b84676 LC |
4082 | derivations or files in the store can be defined, |
4083 | such that these objects can also be inserted | |
f97c9175 | 4084 | into gexps. For example, a useful type of high-level objects that can be |
343eacbe | 4085 | inserted in a gexp is ``file-like objects'', which make it easy to |
f97c9175 | 4086 | add files to the store and to refer to them in |
558e8b11 LC |
4087 | derivations and such (see @code{local-file} and @code{plain-file} |
4088 | below.) | |
b39fc6f7 | 4089 | |
21b679f6 LC |
4090 | To illustrate the idea, here is an example of a gexp: |
4091 | ||
4092 | @example | |
4093 | (define build-exp | |
4094 | #~(begin | |
4095 | (mkdir #$output) | |
4096 | (chdir #$output) | |
aff8ce7c | 4097 | (symlink (string-append #$coreutils "/bin/ls") |
21b679f6 LC |
4098 | "list-files"))) |
4099 | @end example | |
4100 | ||
4101 | This gexp can be passed to @code{gexp->derivation}; we obtain a | |
4102 | derivation that builds a directory containing exactly one symlink to | |
4103 | @file{/gnu/store/@dots{}-coreutils-8.22/bin/ls}: | |
4104 | ||
4105 | @example | |
4106 | (gexp->derivation "the-thing" build-exp) | |
4107 | @end example | |
4108 | ||
e20fd1bf | 4109 | As one would expect, the @code{"/gnu/store/@dots{}-coreutils-8.22"} string is |
21b679f6 LC |
4110 | substituted to the reference to the @var{coreutils} package in the |
4111 | actual build code, and @var{coreutils} is automatically made an input to | |
4112 | the derivation. Likewise, @code{#$output} (equivalent to @code{(ungexp | |
f97c9175 AE |
4113 | output)}) is replaced by a string containing the directory name of the |
4114 | output of the derivation. | |
667b2508 LC |
4115 | |
4116 | @cindex cross compilation | |
4117 | In a cross-compilation context, it is useful to distinguish between | |
4118 | references to the @emph{native} build of a package---that can run on the | |
4119 | host---versus references to cross builds of a package. To that end, the | |
4120 | @code{#+} plays the same role as @code{#$}, but is a reference to a | |
4121 | native package build: | |
4122 | ||
4123 | @example | |
4124 | (gexp->derivation "vi" | |
4125 | #~(begin | |
4126 | (mkdir #$output) | |
4127 | (system* (string-append #+coreutils "/bin/ln") | |
4128 | "-s" | |
4129 | (string-append #$emacs "/bin/emacs") | |
4130 | (string-append #$output "/bin/vi"))) | |
4a3b6aa5 | 4131 | #:target "mips64el-linux-gnu") |
667b2508 LC |
4132 | @end example |
4133 | ||
4134 | @noindent | |
4135 | In the example above, the native build of @var{coreutils} is used, so | |
4136 | that @command{ln} can actually run on the host; but then the | |
4137 | cross-compiled build of @var{emacs} is referenced. | |
4138 | ||
0bb9929e LC |
4139 | @cindex imported modules, for gexps |
4140 | @findex with-imported-modules | |
4141 | Another gexp feature is @dfn{imported modules}: sometimes you want to be | |
4142 | able to use certain Guile modules from the ``host environment'' in the | |
4143 | gexp, so those modules should be imported in the ``build environment''. | |
4144 | The @code{with-imported-modules} form allows you to express that: | |
4145 | ||
4146 | @example | |
4147 | (let ((build (with-imported-modules '((guix build utils)) | |
4148 | #~(begin | |
4149 | (use-modules (guix build utils)) | |
4150 | (mkdir-p (string-append #$output "/bin")))))) | |
4151 | (gexp->derivation "empty-dir" | |
4152 | #~(begin | |
4153 | #$build | |
4154 | (display "success!\n") | |
4155 | #t))) | |
4156 | @end example | |
4157 | ||
4158 | @noindent | |
4159 | In this example, the @code{(guix build utils)} module is automatically | |
4160 | pulled into the isolated build environment of our gexp, such that | |
4161 | @code{(use-modules (guix build utils))} works as expected. | |
4162 | ||
7ca87354 LC |
4163 | @cindex module closure |
4164 | @findex source-module-closure | |
4165 | Usually you want the @emph{closure} of the module to be imported---i.e., | |
4166 | the module itself and all the modules it depends on---rather than just | |
4167 | the module; failing to do that, attempts to use the module will fail | |
4168 | because of missing dependent modules. The @code{source-module-closure} | |
4169 | procedure computes the closure of a module by looking at its source file | |
4170 | headers, which comes in handy in this case: | |
4171 | ||
4172 | @example | |
4173 | (use-modules (guix modules)) ;for 'source-module-closure' | |
4174 | ||
4175 | (with-imported-modules (source-module-closure | |
4176 | '((guix build utils) | |
4177 | (gnu build vm))) | |
4178 | (gexp->derivation "something-with-vms" | |
4179 | #~(begin | |
4180 | (use-modules (guix build utils) | |
4181 | (gnu build vm)) | |
4182 | @dots{}))) | |
4183 | @end example | |
4184 | ||
667b2508 | 4185 | The syntactic form to construct gexps is summarized below. |
21b679f6 LC |
4186 | |
4187 | @deffn {Scheme Syntax} #~@var{exp} | |
4188 | @deffnx {Scheme Syntax} (gexp @var{exp}) | |
4189 | Return a G-expression containing @var{exp}. @var{exp} may contain one | |
4190 | or more of the following forms: | |
4191 | ||
4192 | @table @code | |
4193 | @item #$@var{obj} | |
4194 | @itemx (ungexp @var{obj}) | |
b39fc6f7 LC |
4195 | Introduce a reference to @var{obj}. @var{obj} may have one of the |
4196 | supported types, for example a package or a | |
21b679f6 LC |
4197 | derivation, in which case the @code{ungexp} form is replaced by its |
4198 | output file name---e.g., @code{"/gnu/store/@dots{}-coreutils-8.22}. | |
4199 | ||
b39fc6f7 LC |
4200 | If @var{obj} is a list, it is traversed and references to supported |
4201 | objects are substituted similarly. | |
21b679f6 LC |
4202 | |
4203 | If @var{obj} is another gexp, its contents are inserted and its | |
4204 | dependencies are added to those of the containing gexp. | |
4205 | ||
4206 | If @var{obj} is another kind of object, it is inserted as is. | |
4207 | ||
b39fc6f7 LC |
4208 | @item #$@var{obj}:@var{output} |
4209 | @itemx (ungexp @var{obj} @var{output}) | |
21b679f6 | 4210 | This is like the form above, but referring explicitly to the |
b39fc6f7 LC |
4211 | @var{output} of @var{obj}---this is useful when @var{obj} produces |
4212 | multiple outputs (@pxref{Packages with Multiple Outputs}). | |
21b679f6 | 4213 | |
667b2508 LC |
4214 | @item #+@var{obj} |
4215 | @itemx #+@var{obj}:output | |
4216 | @itemx (ungexp-native @var{obj}) | |
4217 | @itemx (ungexp-native @var{obj} @var{output}) | |
4218 | Same as @code{ungexp}, but produces a reference to the @emph{native} | |
4219 | build of @var{obj} when used in a cross compilation context. | |
4220 | ||
21b679f6 LC |
4221 | @item #$output[:@var{output}] |
4222 | @itemx (ungexp output [@var{output}]) | |
4223 | Insert a reference to derivation output @var{output}, or to the main | |
4224 | output when @var{output} is omitted. | |
4225 | ||
4226 | This only makes sense for gexps passed to @code{gexp->derivation}. | |
4227 | ||
4228 | @item #$@@@var{lst} | |
4229 | @itemx (ungexp-splicing @var{lst}) | |
4230 | Like the above, but splices the contents of @var{lst} inside the | |
4231 | containing list. | |
4232 | ||
667b2508 LC |
4233 | @item #+@@@var{lst} |
4234 | @itemx (ungexp-native-splicing @var{lst}) | |
4235 | Like the above, but refers to native builds of the objects listed in | |
4236 | @var{lst}. | |
4237 | ||
21b679f6 LC |
4238 | @end table |
4239 | ||
4240 | G-expressions created by @code{gexp} or @code{#~} are run-time objects | |
4241 | of the @code{gexp?} type (see below.) | |
4242 | @end deffn | |
4243 | ||
0bb9929e LC |
4244 | @deffn {Scheme Syntax} with-imported-modules @var{modules} @var{body}@dots{} |
4245 | Mark the gexps defined in @var{body}@dots{} as requiring @var{modules} | |
4246 | in their execution environment. @var{modules} must be a list of Guile | |
4247 | module names, such as @code{'((guix build utils) (guix build gremlin))}. | |
4248 | ||
4249 | This form has @emph{lexical} scope: it has an effect on the gexps | |
4250 | directly defined in @var{body}@dots{}, but not on those defined, say, in | |
4251 | procedures called from @var{body}@dots{}. | |
4252 | @end deffn | |
4253 | ||
21b679f6 LC |
4254 | @deffn {Scheme Procedure} gexp? @var{obj} |
4255 | Return @code{#t} if @var{obj} is a G-expression. | |
4256 | @end deffn | |
4257 | ||
4258 | G-expressions are meant to be written to disk, either as code building | |
4259 | some derivation, or as plain files in the store. The monadic procedures | |
4260 | below allow you to do that (@pxref{The Store Monad}, for more | |
4261 | information about monads.) | |
4262 | ||
4263 | @deffn {Monadic Procedure} gexp->derivation @var{name} @var{exp} @ | |
ce45eb4c | 4264 | [#:system (%current-system)] [#:target #f] [#:graft? #t] @ |
21b679f6 LC |
4265 | [#:hash #f] [#:hash-algo #f] @ |
4266 | [#:recursive? #f] [#:env-vars '()] [#:modules '()] @ | |
4684f301 | 4267 | [#:module-path @var{%load-path}] @ |
c8351d9a | 4268 | [#:references-graphs #f] [#:allowed-references #f] @ |
3f4ecf32 | 4269 | [#:disallowed-references #f] @ |
c0468155 | 4270 | [#:leaked-env-vars #f] @ |
0309e1b0 | 4271 | [#:script-name (string-append @var{name} "-builder")] @ |
4a6aeb67 | 4272 | [#:local-build? #f] [#:substitutable? #t] [#:guile-for-build #f] |
21b679f6 | 4273 | Return a derivation @var{name} that runs @var{exp} (a gexp) with |
0309e1b0 LC |
4274 | @var{guile-for-build} (a derivation) on @var{system}; @var{exp} is |
4275 | stored in a file called @var{script-name}. When @var{target} is true, | |
4276 | it is used as the cross-compilation target triplet for packages referred | |
4277 | to by @var{exp}. | |
21b679f6 | 4278 | |
0bb9929e LC |
4279 | @var{modules} is deprecated in favor of @code{with-imported-modules}. |
4280 | Its meaning is to | |
4281 | make @var{modules} available in the evaluation context of @var{exp}; | |
ce45eb4c LC |
4282 | @var{modules} is a list of names of Guile modules searched in |
4283 | @var{module-path} to be copied in the store, compiled, and made available in | |
21b679f6 LC |
4284 | the load path during the execution of @var{exp}---e.g., @code{((guix |
4285 | build utils) (guix build gnu-build-system))}. | |
4286 | ||
ce45eb4c LC |
4287 | @var{graft?} determines whether packages referred to by @var{exp} should be grafted when |
4288 | applicable. | |
4289 | ||
b53833b2 LC |
4290 | When @var{references-graphs} is true, it must be a list of tuples of one of the |
4291 | following forms: | |
4292 | ||
4293 | @example | |
4294 | (@var{file-name} @var{package}) | |
4295 | (@var{file-name} @var{package} @var{output}) | |
4296 | (@var{file-name} @var{derivation}) | |
4297 | (@var{file-name} @var{derivation} @var{output}) | |
4298 | (@var{file-name} @var{store-item}) | |
4299 | @end example | |
4300 | ||
4301 | The right-hand-side of each element of @var{references-graphs} is automatically made | |
4302 | an input of the build process of @var{exp}. In the build environment, each | |
4303 | @var{file-name} contains the reference graph of the corresponding item, in a simple | |
4304 | text format. | |
4305 | ||
c8351d9a LC |
4306 | @var{allowed-references} must be either @code{#f} or a list of output names and packages. |
4307 | In the latter case, the list denotes store items that the result is allowed to | |
4308 | refer to. Any reference to another store item will lead to a build error. | |
3f4ecf32 LC |
4309 | Similarly for @var{disallowed-references}, which can list items that must not be |
4310 | referenced by the outputs. | |
c8351d9a | 4311 | |
e20fd1bf | 4312 | The other arguments are as for @code{derivation} (@pxref{Derivations}). |
21b679f6 LC |
4313 | @end deffn |
4314 | ||
343eacbe | 4315 | @cindex file-like objects |
e1c153e0 LC |
4316 | The @code{local-file}, @code{plain-file}, @code{computed-file}, |
4317 | @code{program-file}, and @code{scheme-file} procedures below return | |
4318 | @dfn{file-like objects}. That is, when unquoted in a G-expression, | |
4319 | these objects lead to a file in the store. Consider this G-expression: | |
343eacbe LC |
4320 | |
4321 | @example | |
a9e5e92f | 4322 | #~(system* #$(file-append glibc "/sbin/nscd") "-f" |
343eacbe LC |
4323 | #$(local-file "/tmp/my-nscd.conf")) |
4324 | @end example | |
4325 | ||
4326 | The effect here is to ``intern'' @file{/tmp/my-nscd.conf} by copying it | |
4327 | to the store. Once expanded, for instance @i{via} | |
4328 | @code{gexp->derivation}, the G-expression refers to that copy under | |
4329 | @file{/gnu/store}; thus, modifying or removing the file in @file{/tmp} | |
4330 | does not have any effect on what the G-expression does. | |
4331 | @code{plain-file} can be used similarly; it differs in that the file | |
4332 | content is directly passed as a string. | |
4333 | ||
d9ae938f | 4334 | @deffn {Scheme Procedure} local-file @var{file} [@var{name}] @ |
0687fc9c | 4335 | [#:recursive? #f] [#:select? (const #t)] |
d9ae938f | 4336 | Return an object representing local file @var{file} to add to the store; this |
9d3994f7 LC |
4337 | object can be used in a gexp. If @var{file} is a relative file name, it is looked |
4338 | up relative to the source file where this form appears. @var{file} will be added to | |
4339 | the store under @var{name}--by default the base name of @var{file}. | |
d9ae938f LC |
4340 | |
4341 | When @var{recursive?} is true, the contents of @var{file} are added recursively; if @var{file} | |
4342 | designates a flat file and @var{recursive?} is true, its contents are added, and its | |
4343 | permission bits are kept. | |
4344 | ||
0687fc9c LC |
4345 | When @var{recursive?} is true, call @code{(@var{select?} @var{file} |
4346 | @var{stat})} for each directory entry, where @var{file} is the entry's | |
4347 | absolute file name and @var{stat} is the result of @code{lstat}; exclude | |
4348 | entries for which @var{select?} does not return true. | |
4349 | ||
d9ae938f LC |
4350 | This is the declarative counterpart of the @code{interned-file} monadic |
4351 | procedure (@pxref{The Store Monad, @code{interned-file}}). | |
4352 | @end deffn | |
4353 | ||
558e8b11 LC |
4354 | @deffn {Scheme Procedure} plain-file @var{name} @var{content} |
4355 | Return an object representing a text file called @var{name} with the given | |
4356 | @var{content} (a string) to be added to the store. | |
4357 | ||
4358 | This is the declarative counterpart of @code{text-file}. | |
4359 | @end deffn | |
4360 | ||
91937029 | 4361 | @deffn {Scheme Procedure} computed-file @var{name} @var{gexp} @ |
a769bffb | 4362 | [#:options '(#:local-build? #t)] |
91937029 | 4363 | Return an object representing the store item @var{name}, a file or |
a769bffb | 4364 | directory computed by @var{gexp}. @var{options} |
91937029 LC |
4365 | is a list of additional arguments to pass to @code{gexp->derivation}. |
4366 | ||
4367 | This is the declarative counterpart of @code{gexp->derivation}. | |
4368 | @end deffn | |
4369 | ||
21b679f6 LC |
4370 | @deffn {Monadic Procedure} gexp->script @var{name} @var{exp} |
4371 | Return an executable script @var{name} that runs @var{exp} using | |
9c14a487 | 4372 | @var{guile}, with @var{exp}'s imported modules in its search path. |
21b679f6 LC |
4373 | |
4374 | The example below builds a script that simply invokes the @command{ls} | |
4375 | command: | |
4376 | ||
4377 | @example | |
4378 | (use-modules (guix gexp) (gnu packages base)) | |
4379 | ||
4380 | (gexp->script "list-files" | |
a9e5e92f | 4381 | #~(execl #$(file-append coreutils "/bin/ls") |
21b679f6 LC |
4382 | "ls")) |
4383 | @end example | |
4384 | ||
4385 | When ``running'' it through the store (@pxref{The Store Monad, | |
e20fd1bf | 4386 | @code{run-with-store}}), we obtain a derivation that produces an |
21b679f6 LC |
4387 | executable file @file{/gnu/store/@dots{}-list-files} along these lines: |
4388 | ||
4389 | @example | |
4390 | #!/gnu/store/@dots{}-guile-2.0.11/bin/guile -ds | |
4391 | !# | |
a9e5e92f | 4392 | (execl "/gnu/store/@dots{}-coreutils-8.22"/bin/ls" "ls") |
21b679f6 LC |
4393 | @end example |
4394 | @end deffn | |
4395 | ||
15a01c72 | 4396 | @deffn {Scheme Procedure} program-file @var{name} @var{exp} @ |
9c14a487 | 4397 | [#:guile #f] |
15a01c72 LC |
4398 | Return an object representing the executable store item @var{name} that |
4399 | runs @var{gexp}. @var{guile} is the Guile package used to execute that | |
9c14a487 | 4400 | script. |
15a01c72 LC |
4401 | |
4402 | This is the declarative counterpart of @code{gexp->script}. | |
4403 | @end deffn | |
4404 | ||
2b418579 LC |
4405 | @deffn {Monadic Procedure} gexp->file @var{name} @var{exp} @ |
4406 | [#:set-load-path? #t] | |
21b679f6 | 4407 | Return a derivation that builds a file @var{name} containing @var{exp}. |
2b418579 LC |
4408 | When @var{set-load-path?} is true, emit code in the resulting file to |
4409 | set @code{%load-path} and @code{%load-compiled-path} to honor | |
4410 | @var{exp}'s imported modules. | |
21b679f6 LC |
4411 | |
4412 | The resulting file holds references to all the dependencies of @var{exp} | |
4413 | or a subset thereof. | |
4414 | @end deffn | |
1ed19464 | 4415 | |
e1c153e0 LC |
4416 | @deffn {Scheme Procedure} scheme-file @var{name} @var{exp} |
4417 | Return an object representing the Scheme file @var{name} that contains | |
4418 | @var{exp}. | |
4419 | ||
4420 | This is the declarative counterpart of @code{gexp->file}. | |
4421 | @end deffn | |
4422 | ||
1ed19464 LC |
4423 | @deffn {Monadic Procedure} text-file* @var{name} @var{text} @dots{} |
4424 | Return as a monadic value a derivation that builds a text file | |
4425 | containing all of @var{text}. @var{text} may list, in addition to | |
d9ae938f LC |
4426 | strings, objects of any type that can be used in a gexp: packages, |
4427 | derivations, local file objects, etc. The resulting store file holds | |
4428 | references to all these. | |
1ed19464 LC |
4429 | |
4430 | This variant should be preferred over @code{text-file} anytime the file | |
4431 | to create will reference items from the store. This is typically the | |
4432 | case when building a configuration file that embeds store file names, | |
4433 | like this: | |
4434 | ||
4435 | @example | |
4436 | (define (profile.sh) | |
4437 | ;; Return the name of a shell script in the store that | |
4438 | ;; initializes the 'PATH' environment variable. | |
4439 | (text-file* "profile.sh" | |
4440 | "export PATH=" coreutils "/bin:" | |
4441 | grep "/bin:" sed "/bin\n")) | |
4442 | @end example | |
4443 | ||
4444 | In this example, the resulting @file{/gnu/store/@dots{}-profile.sh} file | |
b7899749 | 4445 | will reference @var{coreutils}, @var{grep}, and @var{sed}, thereby |
1ed19464 LC |
4446 | preventing them from being garbage-collected during its lifetime. |
4447 | @end deffn | |
21b679f6 | 4448 | |
b751cde3 LC |
4449 | @deffn {Scheme Procedure} mixed-text-file @var{name} @var{text} @dots{} |
4450 | Return an object representing store file @var{name} containing | |
4451 | @var{text}. @var{text} is a sequence of strings and file-like objects, | |
4452 | as in: | |
4453 | ||
4454 | @example | |
4455 | (mixed-text-file "profile" | |
4456 | "export PATH=" coreutils "/bin:" grep "/bin") | |
4457 | @end example | |
4458 | ||
4459 | This is the declarative counterpart of @code{text-file*}. | |
4460 | @end deffn | |
4461 | ||
a9e5e92f LC |
4462 | @deffn {Scheme Procedure} file-append @var{obj} @var{suffix} @dots{} |
4463 | Return a file-like object that expands to the concatenation of @var{obj} | |
4464 | and @var{suffix}, where @var{obj} is a lowerable object and each | |
4465 | @var{suffix} is a string. | |
4466 | ||
4467 | As an example, consider this gexp: | |
4468 | ||
4469 | @example | |
4470 | (gexp->script "run-uname" | |
4471 | #~(system* #$(file-append coreutils | |
4472 | "/bin/uname"))) | |
4473 | @end example | |
4474 | ||
4475 | The same effect could be achieved with: | |
4476 | ||
4477 | @example | |
4478 | (gexp->script "run-uname" | |
4479 | #~(system* (string-append #$coreutils | |
4480 | "/bin/uname"))) | |
4481 | @end example | |
4482 | ||
4483 | There is one difference though: in the @code{file-append} case, the | |
4484 | resulting script contains the absolute file name as a string, whereas in | |
4485 | the second case, the resulting script contains a @code{(string-append | |
4486 | @dots{})} expression to construct the file name @emph{at run time}. | |
4487 | @end deffn | |
4488 | ||
4489 | ||
21b679f6 LC |
4490 | Of course, in addition to gexps embedded in ``host'' code, there are |
4491 | also modules containing build tools. To make it clear that they are | |
4492 | meant to be used in the build stratum, these modules are kept in the | |
4493 | @code{(guix build @dots{})} name space. | |
4494 | ||
c2b84676 LC |
4495 | @cindex lowering, of high-level objects in gexps |
4496 | Internally, high-level objects are @dfn{lowered}, using their compiler, | |
4497 | to either derivations or store items. For instance, lowering a package | |
4498 | yields a derivation, and lowering a @code{plain-file} yields a store | |
4499 | item. This is achieved using the @code{lower-object} monadic procedure. | |
4500 | ||
4501 | @deffn {Monadic Procedure} lower-object @var{obj} [@var{system}] @ | |
4502 | [#:target #f] | |
4503 | Return as a value in @var{%store-monad} the derivation or store item | |
4504 | corresponding to @var{obj} for @var{system}, cross-compiling for | |
4505 | @var{target} if @var{target} is true. @var{obj} must be an object that | |
4506 | has an associated gexp compiler, such as a @code{<package>}. | |
4507 | @end deffn | |
4508 | ||
21b679f6 | 4509 | |
568717fd LC |
4510 | @c ********************************************************************* |
4511 | @node Utilities | |
4512 | @chapter Utilities | |
4513 | ||
6f773606 LC |
4514 | This section describes Guix command-line utilities. Some of them are |
4515 | primarily targeted at developers and users who write new package | |
4516 | definitions, while others are more generally useful. They complement | |
4517 | the Scheme programming interface of Guix in a convenient way. | |
210cc920 | 4518 | |
568717fd | 4519 | @menu |
37166310 | 4520 | * Invoking guix build:: Building packages from the command line. |
39bee8a2 | 4521 | * Invoking guix edit:: Editing package definitions. |
210cc920 | 4522 | * Invoking guix download:: Downloading a file and printing its hash. |
37166310 | 4523 | * Invoking guix hash:: Computing the cryptographic hash of a file. |
2f7d2d91 | 4524 | * Invoking guix import:: Importing package definitions. |
37166310 | 4525 | * Invoking guix refresh:: Updating package definitions. |
b4f5e0e8 | 4526 | * Invoking guix lint:: Finding errors in package definitions. |
fcc58db6 | 4527 | * Invoking guix size:: Profiling disk usage. |
88856916 | 4528 | * Invoking guix graph:: Visualizing the graph of packages. |
372c4bbc | 4529 | * Invoking guix environment:: Setting up development environments. |
aff8ce7c | 4530 | * Invoking guix publish:: Sharing substitutes. |
d23c20f1 | 4531 | * Invoking guix challenge:: Challenging substitute servers. |
f11c444d | 4532 | * Invoking guix copy:: Copying to and from a remote store. |
32efa254 | 4533 | * Invoking guix container:: Process isolation. |
568717fd LC |
4534 | @end menu |
4535 | ||
e49951eb MW |
4536 | @node Invoking guix build |
4537 | @section Invoking @command{guix build} | |
568717fd | 4538 | |
e32171ee JD |
4539 | @cindex package building |
4540 | @cindex @command{guix build} | |
e49951eb | 4541 | The @command{guix build} command builds packages or derivations and |
6798a8e4 LC |
4542 | their dependencies, and prints the resulting store paths. Note that it |
4543 | does not modify the user's profile---this is the job of the | |
e49951eb | 4544 | @command{guix package} command (@pxref{Invoking guix package}). Thus, |
6798a8e4 LC |
4545 | it is mainly useful for distribution developers. |
4546 | ||
4547 | The general syntax is: | |
c78bd12b LC |
4548 | |
4549 | @example | |
e49951eb | 4550 | guix build @var{options} @var{package-or-derivation}@dots{} |
c78bd12b LC |
4551 | @end example |
4552 | ||
f97c9175 | 4553 | As an example, the following command builds the latest versions of Emacs |
ccd7158d LC |
4554 | and of Guile, displays their build logs, and finally displays the |
4555 | resulting directories: | |
4556 | ||
4557 | @example | |
4558 | guix build emacs guile | |
4559 | @end example | |
4560 | ||
4561 | Similarly, the following command builds all the available packages: | |
4562 | ||
4563 | @example | |
5284339d | 4564 | guix build --quiet --keep-going \ |
ccd7158d LC |
4565 | `guix package -A | cut -f1,2 --output-delimiter=@@` |
4566 | @end example | |
4567 | ||
c78bd12b | 4568 | @var{package-or-derivation} may be either the name of a package found in |
5401dd75 | 4569 | the software distribution such as @code{coreutils} or |
e1a65ae5 | 4570 | @code{coreutils@@8.20}, or a derivation such as |
834129e0 | 4571 | @file{/gnu/store/@dots{}-coreutils-8.19.drv}. In the former case, a |
e7f34eb0 LC |
4572 | package with the corresponding name (and optionally version) is searched |
4573 | for among the GNU distribution modules (@pxref{Package Modules}). | |
4574 | ||
4575 | Alternatively, the @code{--expression} option may be used to specify a | |
4576 | Scheme expression that evaluates to a package; this is useful when | |
b7899749 | 4577 | disambiguating among several same-named packages or package variants is |
e7f34eb0 | 4578 | needed. |
c78bd12b | 4579 | |
ccd7158d LC |
4580 | There may be zero or more @var{options}. The available options are |
4581 | described in the subsections below. | |
4582 | ||
4583 | @menu | |
4584 | * Common Build Options:: Build options for most commands. | |
f11c444d | 4585 | * Package Transformation Options:: Creating variants of packages. |
ccd7158d LC |
4586 | * Additional Build Options:: Options specific to 'guix build'. |
4587 | @end menu | |
4588 | ||
4589 | @node Common Build Options | |
4590 | @subsection Common Build Options | |
4591 | ||
4592 | A number of options that control the build process are common to | |
4593 | @command{guix build} and other commands that can spawn builds, such as | |
4594 | @command{guix package} or @command{guix archive}. These are the | |
4595 | following: | |
4596 | ||
4597 | @table @code | |
4598 | ||
4599 | @item --load-path=@var{directory} | |
4600 | @itemx -L @var{directory} | |
4601 | Add @var{directory} to the front of the package module search path | |
4602 | (@pxref{Package Modules}). | |
4603 | ||
4604 | This allows users to define their own packages and make them visible to | |
4605 | the command-line tools. | |
4606 | ||
4607 | @item --keep-failed | |
4608 | @itemx -K | |
b7899749 | 4609 | Keep the build tree of failed builds. Thus, if a build fails, its build |
ccd7158d LC |
4610 | tree is kept under @file{/tmp}, in a directory whose name is shown at |
4611 | the end of the build log. This is useful when debugging build issues. | |
4612 | ||
4613 | @item --keep-going | |
4614 | @itemx -k | |
4615 | Keep going when some of the derivations fail to build; return only once | |
4616 | all the builds have either completed or failed. | |
4617 | ||
4618 | The default behavior is to stop as soon as one of the specified | |
4619 | derivations has failed. | |
4620 | ||
4621 | @item --dry-run | |
4622 | @itemx -n | |
4623 | Do not build the derivations. | |
4624 | ||
4625 | @item --fallback | |
4626 | When substituting a pre-built binary fails, fall back to building | |
4627 | packages locally. | |
4628 | ||
4629 | @item --substitute-urls=@var{urls} | |
4630 | @anchor{client-substitute-urls} | |
4631 | Consider @var{urls} the whitespace-separated list of substitute source | |
4632 | URLs, overriding the default list of URLs of @command{guix-daemon} | |
4633 | (@pxref{daemon-substitute-urls,, @command{guix-daemon} URLs}). | |
4634 | ||
4635 | This means that substitutes may be downloaded from @var{urls}, provided | |
4636 | they are signed by a key authorized by the system administrator | |
4637 | (@pxref{Substitutes}). | |
4638 | ||
71e2065a LC |
4639 | When @var{urls} is the empty string, substitutes are effectively |
4640 | disabled. | |
4641 | ||
ccd7158d LC |
4642 | @item --no-substitutes |
4643 | Do not use substitutes for build products. That is, always build things | |
4644 | locally instead of allowing downloads of pre-built binaries | |
4645 | (@pxref{Substitutes}). | |
4646 | ||
7573d30f LC |
4647 | @item --no-grafts |
4648 | Do not ``graft'' packages. In practice, this means that package updates | |
4649 | available as grafts are not applied. @xref{Security Updates}, for more | |
4650 | information on grafts. | |
4651 | ||
ccd7158d LC |
4652 | @item --rounds=@var{n} |
4653 | Build each derivation @var{n} times in a row, and raise an error if | |
4654 | consecutive build results are not bit-for-bit identical. | |
4655 | ||
4656 | This is a useful way to detect non-deterministic builds processes. | |
4657 | Non-deterministic build processes are a problem because they make it | |
4658 | practically impossible for users to @emph{verify} whether third-party | |
4659 | binaries are genuine. @xref{Invoking guix challenge}, for more. | |
4660 | ||
4661 | Note that, currently, the differing build results are not kept around, | |
4662 | so you will have to manually investigate in case of an error---e.g., by | |
e66d1f59 ML |
4663 | stashing one of the build results with @code{guix archive --export} |
4664 | (@pxref{Invoking guix archive}), then rebuilding, and finally comparing | |
4665 | the two results. | |
ccd7158d LC |
4666 | |
4667 | @item --no-build-hook | |
f97c9175 | 4668 | Do not attempt to offload builds @i{via} the ``build hook'' of the daemon |
ccd7158d LC |
4669 | (@pxref{Daemon Offload Setup}). That is, always build things locally |
4670 | instead of offloading builds to remote machines. | |
4671 | ||
4672 | @item --max-silent-time=@var{seconds} | |
4673 | When the build or substitution process remains silent for more than | |
4674 | @var{seconds}, terminate it and report a build failure. | |
4675 | ||
4676 | @item --timeout=@var{seconds} | |
4677 | Likewise, when the build or substitution process lasts for more than | |
4678 | @var{seconds}, terminate it and report a build failure. | |
4679 | ||
4680 | By default there is no timeout. This behavior can be restored with | |
4681 | @code{--timeout=0}. | |
4682 | ||
4683 | @item --verbosity=@var{level} | |
4684 | Use the given verbosity level. @var{level} must be an integer between 0 | |
4685 | and 5; higher means more verbose output. Setting a level of 4 or more | |
4686 | may be helpful when debugging setup issues with the build daemon. | |
4687 | ||
4688 | @item --cores=@var{n} | |
4689 | @itemx -c @var{n} | |
4690 | Allow the use of up to @var{n} CPU cores for the build. The special | |
4691 | value @code{0} means to use as many CPU cores as available. | |
4692 | ||
4693 | @item --max-jobs=@var{n} | |
4694 | @itemx -M @var{n} | |
4695 | Allow at most @var{n} build jobs in parallel. @xref{Invoking | |
4696 | guix-daemon, @code{--max-jobs}}, for details about this option and the | |
4697 | equivalent @command{guix-daemon} option. | |
4698 | ||
4699 | @end table | |
4700 | ||
4701 | Behind the scenes, @command{guix build} is essentially an interface to | |
4702 | the @code{package-derivation} procedure of the @code{(guix packages)} | |
4703 | module, and to the @code{build-derivations} procedure of the @code{(guix | |
4704 | derivations)} module. | |
4705 | ||
4706 | In addition to options explicitly passed on the command line, | |
4707 | @command{guix build} and other @command{guix} commands that support | |
4708 | building honor the @code{GUIX_BUILD_OPTIONS} environment variable. | |
4709 | ||
4710 | @defvr {Environment Variable} GUIX_BUILD_OPTIONS | |
4711 | Users can define this variable to a list of command line options that | |
4712 | will automatically be used by @command{guix build} and other | |
4713 | @command{guix} commands that can perform builds, as in the example | |
4714 | below: | |
4715 | ||
4716 | @example | |
4717 | $ export GUIX_BUILD_OPTIONS="--no-substitutes -c 2 -L /foo/bar" | |
4718 | @end example | |
4719 | ||
4720 | These options are parsed independently, and the result is appended to | |
4721 | the parsed command-line options. | |
4722 | @end defvr | |
4723 | ||
88ad6ded LC |
4724 | |
4725 | @node Package Transformation Options | |
4726 | @subsection Package Transformation Options | |
4727 | ||
4728 | @cindex package variants | |
4729 | Another set of command-line options supported by @command{guix build} | |
b8638f03 | 4730 | and also @command{guix package} are @dfn{package transformation |
f97c9175 | 4731 | options}. These are options that make it possible to define @dfn{package |
b8638f03 LC |
4732 | variants}---for instance, packages built from different source code. |
4733 | This is a convenient way to create customized packages on the fly | |
4734 | without having to type in the definitions of package variants | |
4735 | (@pxref{Defining Packages}). | |
88ad6ded LC |
4736 | |
4737 | @table @code | |
4738 | ||
4739 | @item --with-source=@var{source} | |
4740 | Use @var{source} as the source of the corresponding package. | |
4741 | @var{source} must be a file name or a URL, as for @command{guix | |
4742 | download} (@pxref{Invoking guix download}). | |
4743 | ||
f97c9175 AE |
4744 | The ``corresponding package'' is taken to be the one specified on the |
4745 | command line the name of which matches the base of @var{source}---e.g., | |
4746 | if @var{source} is @code{/src/guile-2.0.10.tar.gz}, the corresponding | |
88ad6ded | 4747 | package is @code{guile}. Likewise, the version string is inferred from |
f97c9175 | 4748 | @var{source}; in the previous example, it is @code{2.0.10}. |
88ad6ded LC |
4749 | |
4750 | This option allows users to try out versions of packages other than the | |
4751 | one provided by the distribution. The example below downloads | |
4752 | @file{ed-1.7.tar.gz} from a GNU mirror and uses that as the source for | |
4753 | the @code{ed} package: | |
4754 | ||
4755 | @example | |
4756 | guix build ed --with-source=mirror://gnu/ed/ed-1.7.tar.gz | |
4757 | @end example | |
4758 | ||
4759 | As a developer, @code{--with-source} makes it easy to test release | |
4760 | candidates: | |
4761 | ||
4762 | @example | |
4763 | guix build guile --with-source=../guile-2.0.9.219-e1bb7.tar.xz | |
4764 | @end example | |
4765 | ||
4766 | @dots{} or to build from a checkout in a pristine environment: | |
4767 | ||
4768 | @example | |
4769 | $ git clone git://git.sv.gnu.org/guix.git | |
4770 | $ guix build guix --with-source=./guix | |
4771 | @end example | |
4772 | ||
47c0f92c LC |
4773 | @item --with-input=@var{package}=@var{replacement} |
4774 | Replace dependency on @var{package} by a dependency on | |
4775 | @var{replacement}. @var{package} must be a package name, and | |
4776 | @var{replacement} must be a package specification such as @code{guile} | |
4777 | or @code{guile@@1.8}. | |
4778 | ||
f97c9175 | 4779 | For instance, the following command builds Guix, but replaces its |
47c0f92c LC |
4780 | dependency on the current stable version of Guile with a dependency on |
4781 | the development version of Guile, @code{guile-next}: | |
4782 | ||
4783 | @example | |
4784 | guix build --with-input=guile=guile-next guix | |
4785 | @end example | |
4786 | ||
4787 | This is a recursive, deep replacement. So in this example, both | |
4788 | @code{guix} and its dependency @code{guile-json} (which also depends on | |
4789 | @code{guile}) get rebuilt against @code{guile-next}. | |
4790 | ||
2a75b0b6 LC |
4791 | This is implemented using the @code{package-input-rewriting} Scheme |
4792 | procedure (@pxref{Defining Packages, @code{package-input-rewriting}}). | |
645b9df8 LC |
4793 | |
4794 | @item --with-graft=@var{package}=@var{replacement} | |
4795 | This is similar to @code{--with-input} but with an important difference: | |
9b4ec573 | 4796 | instead of rebuilding the whole dependency chain, @var{replacement} is |
645b9df8 LC |
4797 | built and then @dfn{grafted} onto the binaries that were initially |
4798 | referring to @var{package}. @xref{Security Updates}, for more | |
4799 | information on grafts. | |
4800 | ||
4801 | For example, the command below grafts version 3.5.4 of GnuTLS onto Wget | |
4802 | and all its dependencies, replacing references to the version of GnuTLS | |
4803 | they currently refer to: | |
4804 | ||
4805 | @example | |
4806 | guix build --with-graft=gnutls=gnutls@@3.5.4 wget | |
4807 | @end example | |
4808 | ||
4809 | This has the advantage of being much faster than rebuilding everything. | |
4810 | But there is a caveat: it works if and only if @var{package} and | |
4811 | @var{replacement} are strictly compatible---for example, if they provide | |
4812 | a library, the application binary interface (ABI) of those libraries | |
4813 | must be compatible. If @var{replacement} is somehow incompatible with | |
4814 | @var{package}, then the resulting package may be unusable. Use with | |
4815 | care! | |
4816 | ||
88ad6ded LC |
4817 | @end table |
4818 | ||
ccd7158d LC |
4819 | @node Additional Build Options |
4820 | @subsection Additional Build Options | |
4821 | ||
4822 | The command-line options presented below are specific to @command{guix | |
4823 | build}. | |
c78bd12b LC |
4824 | |
4825 | @table @code | |
4826 | ||
5284339d LC |
4827 | @item --quiet |
4828 | @itemx -q | |
4829 | Build quietly, without displaying the build log. Upon completion, the | |
4830 | build log is kept in @file{/var} (or similar) and can always be | |
4831 | retrieved using the @option{--log-file} option. | |
4832 | ||
34a1783f DT |
4833 | @item --file=@var{file} |
4834 | @itemx -f @var{file} | |
4835 | ||
4836 | Build the package or derivation that the code within @var{file} | |
4837 | evaluates to. | |
4838 | ||
4839 | As an example, @var{file} might contain a package definition like this | |
4840 | (@pxref{Defining Packages}): | |
4841 | ||
4842 | @example | |
4843 | @verbatiminclude package-hello.scm | |
4844 | @end example | |
4845 | ||
c78bd12b LC |
4846 | @item --expression=@var{expr} |
4847 | @itemx -e @var{expr} | |
ac5de156 | 4848 | Build the package or derivation @var{expr} evaluates to. |
c78bd12b | 4849 | |
5401dd75 | 4850 | For example, @var{expr} may be @code{(@@ (gnu packages guile) |
c78bd12b LC |
4851 | guile-1.8)}, which unambiguously designates this specific variant of |
4852 | version 1.8 of Guile. | |
4853 | ||
f97c9175 | 4854 | Alternatively, @var{expr} may be a G-expression, in which case it is used |
56b82106 LC |
4855 | as a build program passed to @code{gexp->derivation} |
4856 | (@pxref{G-Expressions}). | |
4857 | ||
4858 | Lastly, @var{expr} may refer to a zero-argument monadic procedure | |
ac5de156 LC |
4859 | (@pxref{The Store Monad}). The procedure must return a derivation as a |
4860 | monadic value, which is then passed through @code{run-with-store}. | |
4861 | ||
c78bd12b LC |
4862 | @item --source |
4863 | @itemx -S | |
f97c9175 | 4864 | Build the source derivations of the packages, rather than the packages |
c78bd12b LC |
4865 | themselves. |
4866 | ||
e49951eb | 4867 | For instance, @code{guix build -S gcc} returns something like |
f97c9175 AE |
4868 | @file{/gnu/store/@dots{}-gcc-4.7.2.tar.bz2}, which is the GCC |
4869 | source tarball. | |
c78bd12b | 4870 | |
f9cc8971 | 4871 | The returned source tarball is the result of applying any patches and |
f97c9175 | 4872 | code snippets specified in the package @code{origin} (@pxref{Defining |
f9cc8971 LC |
4873 | Packages}). |
4874 | ||
2cdfe13d EB |
4875 | @item --sources |
4876 | Fetch and return the source of @var{package-or-derivation} and all their | |
4877 | dependencies, recursively. This is a handy way to obtain a local copy | |
4878 | of all the source code needed to build @var{packages}, allowing you to | |
4879 | eventually build them even without network access. It is an extension | |
4880 | of the @code{--source} option and can accept one of the following | |
4881 | optional argument values: | |
4882 | ||
4883 | @table @code | |
4884 | @item package | |
4885 | This value causes the @code{--sources} option to behave in the same way | |
4886 | as the @code{--source} option. | |
4887 | ||
4888 | @item all | |
f97c9175 AE |
4889 | Build the source derivations of all packages, including any source that |
4890 | might be listed as @code{inputs}. This is the default value. | |
2cdfe13d EB |
4891 | |
4892 | @example | |
4893 | $ guix build --sources tzdata | |
4894 | The following derivations will be built: | |
4895 | /gnu/store/@dots{}-tzdata2015b.tar.gz.drv | |
4896 | /gnu/store/@dots{}-tzcode2015b.tar.gz.drv | |
4897 | @end example | |
4898 | ||
4899 | @item transitive | |
f97c9175 AE |
4900 | Build the source derivations of all packages, as well of all transitive |
4901 | inputs to the packages. This can be used e.g. to | |
2cdfe13d EB |
4902 | prefetch package source for later offline building. |
4903 | ||
4904 | @example | |
4905 | $ guix build --sources=transitive tzdata | |
4906 | The following derivations will be built: | |
4907 | /gnu/store/@dots{}-tzcode2015b.tar.gz.drv | |
4908 | /gnu/store/@dots{}-findutils-4.4.2.tar.xz.drv | |
4909 | /gnu/store/@dots{}-grep-2.21.tar.xz.drv | |
4910 | /gnu/store/@dots{}-coreutils-8.23.tar.xz.drv | |
4911 | /gnu/store/@dots{}-make-4.1.tar.xz.drv | |
4912 | /gnu/store/@dots{}-bash-4.3.tar.xz.drv | |
4913 | @dots{} | |
4914 | @end example | |
4915 | ||
4916 | @end table | |
4917 | ||
c78bd12b LC |
4918 | @item --system=@var{system} |
4919 | @itemx -s @var{system} | |
4920 | Attempt to build for @var{system}---e.g., @code{i686-linux}---instead of | |
f97c9175 | 4921 | the system type of the build host. |
c78bd12b LC |
4922 | |
4923 | An example use of this is on Linux-based systems, which can emulate | |
4924 | different personalities. For instance, passing | |
4925 | @code{--system=i686-linux} on an @code{x86_64-linux} system allows users | |
4926 | to build packages in a complete 32-bit environment. | |
4927 | ||
e55ec43d LC |
4928 | @item --target=@var{triplet} |
4929 | @cindex cross-compilation | |
4930 | Cross-build for @var{triplet}, which must be a valid GNU triplet, such | |
4931 | as @code{"mips64el-linux-gnu"} (@pxref{Configuration Names, GNU | |
4932 | configuration triplets,, configure, GNU Configure and Build System}). | |
4933 | ||
a8d65643 LC |
4934 | @anchor{build-check} |
4935 | @item --check | |
4936 | @cindex determinism, checking | |
4937 | @cindex reproducibility, checking | |
4938 | Rebuild @var{package-or-derivation}, which are already available in the | |
4939 | store, and raise an error if the build results are not bit-for-bit | |
4940 | identical. | |
4941 | ||
f97c9175 AE |
4942 | This mechanism allows you to check whether previously installed |
4943 | substitutes are genuine (@pxref{Substitutes}), or whether the build result | |
4944 | of a package is deterministic. @xref{Invoking guix challenge}, for more | |
a8d65643 LC |
4945 | background information and tools. |
4946 | ||
7f3b2510 ED |
4947 | When used in conjunction with @option{--keep-failed}, the differing |
4948 | output is kept in the store, under @file{/gnu/store/@dots{}-check}. | |
4949 | This makes it easy to look for differences between the two results. | |
4950 | ||
6da5bb7b LC |
4951 | @item --repair |
4952 | @cindex repairing store items | |
4953 | @cindex corruption, recovering from | |
4954 | Attempt to repair the specified store items, if they are corrupt, by | |
4955 | re-downloading or rebuilding them. | |
4956 | ||
4957 | This operation is not atomic and thus restricted to @code{root}. | |
4958 | ||
c78bd12b LC |
4959 | @item --derivations |
4960 | @itemx -d | |
4961 | Return the derivation paths, not the output paths, of the given | |
4962 | packages. | |
4963 | ||
70ee5642 LC |
4964 | @item --root=@var{file} |
4965 | @itemx -r @var{file} | |
4966 | Make @var{file} a symlink to the result, and register it as a garbage | |
4967 | collector root. | |
4968 | ||
4969 | @item --log-file | |
3f208ad7 | 4970 | Return the build log file names or URLs for the given |
f97c9175 | 4971 | @var{package-or-derivation}, or raise an error if build logs are |
70ee5642 LC |
4972 | missing. |
4973 | ||
4974 | This works regardless of how packages or derivations are specified. For | |
4975 | instance, the following invocations are equivalent: | |
4976 | ||
4977 | @example | |
4978 | guix build --log-file `guix build -d guile` | |
4979 | guix build --log-file `guix build guile` | |
4980 | guix build --log-file guile | |
4981 | guix build --log-file -e '(@@ (gnu packages guile) guile-2.0)' | |
4982 | @end example | |
4983 | ||
3f208ad7 LC |
4984 | If a log is unavailable locally, and unless @code{--no-substitutes} is |
4985 | passed, the command looks for a corresponding log on one of the | |
4986 | substitute servers (as specified with @code{--substitute-urls}.) | |
70ee5642 | 4987 | |
f97c9175 AE |
4988 | So for instance, imagine you want to see the build log of GDB on MIPS, |
4989 | but you are actually on an @code{x86_64} machine: | |
3f208ad7 LC |
4990 | |
4991 | @example | |
a01ad638 | 4992 | $ guix build --log-file gdb -s mips64el-linux |
df061d07 | 4993 | https://hydra.gnu.org/log/@dots{}-gdb-7.10 |
3f208ad7 LC |
4994 | @end example |
4995 | ||
4996 | You can freely access a huge library of build logs! | |
70ee5642 LC |
4997 | @end table |
4998 | ||
16eb115e | 4999 | |
39bee8a2 LC |
5000 | @node Invoking guix edit |
5001 | @section Invoking @command{guix edit} | |
5002 | ||
e32171ee | 5003 | @cindex @command{guix edit} |
39bee8a2 LC |
5004 | @cindex package definition, editing |
5005 | So many packages, so many source files! The @command{guix edit} command | |
424a323e GC |
5006 | facilitates the life of users and packagers by pointing their editor at |
5007 | the source file containing the definition of the specified packages. | |
5008 | For instance: | |
39bee8a2 LC |
5009 | |
5010 | @example | |
7b9a66e5 | 5011 | guix edit gcc@@4.9 vim |
39bee8a2 LC |
5012 | @end example |
5013 | ||
5014 | @noindent | |
6237b9fa | 5015 | launches the program specified in the @code{VISUAL} or in the |
424a323e | 5016 | @code{EDITOR} environment variable to view the recipe of GCC@tie{}4.9.3 |
6237b9fa | 5017 | and that of Vim. |
39bee8a2 | 5018 | |
424a323e GC |
5019 | If you are using a Guix Git checkout (@pxref{Building from Git}), or |
5020 | have created your own packages on @code{GUIX_PACKAGE_PATH} | |
5021 | (@pxref{Defining Packages}), you will be able to edit the package | |
5022 | recipes. Otherwise, you will be able to examine the read-only recipes | |
5023 | for packages currently in the store. | |
5024 | ||
39bee8a2 | 5025 | |
210cc920 LC |
5026 | @node Invoking guix download |
5027 | @section Invoking @command{guix download} | |
5028 | ||
e32171ee JD |
5029 | @cindex @command{guix download} |
5030 | @cindex downloading package sources | |
210cc920 | 5031 | When writing a package definition, developers typically need to download |
f97c9175 | 5032 | a source tarball, compute its SHA256 hash, and write that |
210cc920 LC |
5033 | hash in the package definition (@pxref{Defining Packages}). The |
5034 | @command{guix download} tool helps with this task: it downloads a file | |
5035 | from the given URI, adds it to the store, and prints both its file name | |
5036 | in the store and its SHA256 hash. | |
5037 | ||
5038 | The fact that the downloaded file is added to the store saves bandwidth: | |
5039 | when the developer eventually tries to build the newly defined package | |
5040 | with @command{guix build}, the source tarball will not have to be | |
5041 | downloaded again because it is already in the store. It is also a | |
5042 | convenient way to temporarily stash files, which may be deleted | |
5043 | eventually (@pxref{Invoking guix gc}). | |
5044 | ||
5045 | The @command{guix download} command supports the same URIs as used in | |
5046 | package definitions. In particular, it supports @code{mirror://} URIs. | |
5047 | @code{https} URIs (HTTP over TLS) are supported @emph{provided} the | |
5048 | Guile bindings for GnuTLS are available in the user's environment; when | |
537c8bb3 LC |
5049 | they are not available, an error is raised. @xref{Guile Preparations, |
5050 | how to install the GnuTLS bindings for Guile,, gnutls-guile, | |
5051 | GnuTLS-Guile}, for more information. | |
210cc920 | 5052 | |
bc3c41ce LC |
5053 | @command{guix download} verifies HTTPS server certificates by loading |
5054 | the certificates of X.509 authorities from the directory pointed to by | |
5055 | the @code{SSL_CERT_DIR} environment variable (@pxref{X.509 | |
64b8695c | 5056 | Certificates}), unless @option{--no-check-certificate} is used. |
bc3c41ce | 5057 | |
64b8695c | 5058 | The following options are available: |
210cc920 LC |
5059 | |
5060 | @table @code | |
5061 | @item --format=@var{fmt} | |
5062 | @itemx -f @var{fmt} | |
5063 | Write the hash in the format specified by @var{fmt}. For more | |
081145cf | 5064 | information on the valid values for @var{fmt}, @pxref{Invoking guix hash}. |
64b8695c LC |
5065 | |
5066 | @item --no-check-certificate | |
5067 | Do not validate the X.509 certificates of HTTPS servers. | |
5068 | ||
5069 | When using this option, you have @emph{absolutely no guarantee} that you | |
5070 | are communicating with the authentic server responsible for the given | |
5071 | URL, which makes you vulnerable to ``man-in-the-middle'' attacks. | |
5072 | ||
1bcc87bb LC |
5073 | @item --output=@var{file} |
5074 | @itemx -o @var{file} | |
5075 | Save the downloaded file to @var{file} instead of adding it to the | |
5076 | store. | |
210cc920 LC |
5077 | @end table |
5078 | ||
6c365eca NK |
5079 | @node Invoking guix hash |
5080 | @section Invoking @command{guix hash} | |
5081 | ||
e32171ee | 5082 | @cindex @command{guix hash} |
210cc920 | 5083 | The @command{guix hash} command computes the SHA256 hash of a file. |
6c365eca NK |
5084 | It is primarily a convenience tool for anyone contributing to the |
5085 | distribution: it computes the cryptographic hash of a file, which can be | |
5086 | used in the definition of a package (@pxref{Defining Packages}). | |
5087 | ||
5088 | The general syntax is: | |
5089 | ||
5090 | @example | |
5091 | guix hash @var{option} @var{file} | |
5092 | @end example | |
5093 | ||
343dc117 LC |
5094 | When @var{file} is @code{-} (a hyphen), @command{guix hash} computes the |
5095 | hash of data read from standard input. @command{guix hash} has the | |
5096 | following options: | |
6c365eca NK |
5097 | |
5098 | @table @code | |
5099 | ||
5100 | @item --format=@var{fmt} | |
5101 | @itemx -f @var{fmt} | |
210cc920 | 5102 | Write the hash in the format specified by @var{fmt}. |
6c365eca NK |
5103 | |
5104 | Supported formats: @code{nix-base32}, @code{base32}, @code{base16} | |
5105 | (@code{hex} and @code{hexadecimal} can be used as well). | |
5106 | ||
5107 | If the @option{--format} option is not specified, @command{guix hash} | |
5108 | will output the hash in @code{nix-base32}. This representation is used | |
5109 | in the definitions of packages. | |
5110 | ||
3140f2df LC |
5111 | @item --recursive |
5112 | @itemx -r | |
5113 | Compute the hash on @var{file} recursively. | |
5114 | ||
5115 | In this case, the hash is computed on an archive containing @var{file}, | |
f97c9175 AE |
5116 | including its children if it is a directory. Some of the metadata of |
5117 | @var{file} is part of the archive; for instance, when @var{file} is a | |
3140f2df | 5118 | regular file, the hash is different depending on whether @var{file} is |
f97c9175 | 5119 | executable or not. Metadata such as time stamps has no impact on the |
3140f2df LC |
5120 | hash (@pxref{Invoking guix archive}). |
5121 | @c FIXME: Replace xref above with xref to an ``Archive'' section when | |
5122 | @c it exists. | |
5123 | ||
392a4e12 JN |
5124 | @item --exclude-vcs |
5125 | @itemx -x | |
5126 | When combined with @option{--recursive}, exclude version control system | |
5127 | directories (@file{.bzr}, @file{.git}, @file{.hg}, etc.) | |
5128 | ||
db97a03a LC |
5129 | @vindex git-fetch |
5130 | As an example, here is how you would compute the hash of a Git checkout, | |
5131 | which is useful when using the @code{git-fetch} method (@pxref{origin | |
5132 | Reference}): | |
5133 | ||
5134 | @example | |
5135 | $ git clone http://example.org/foo.git | |
5136 | $ cd foo | |
392a4e12 | 5137 | $ guix hash -rx . |
db97a03a | 5138 | @end example |
6c365eca NK |
5139 | @end table |
5140 | ||
2f7d2d91 LC |
5141 | @node Invoking guix import |
5142 | @section Invoking @command{guix import} | |
5143 | ||
5144 | @cindex importing packages | |
5145 | @cindex package import | |
5146 | @cindex package conversion | |
e32171ee | 5147 | @cindex Invoking @command{guix import} |
f97c9175 AE |
5148 | The @command{guix import} command is useful for people who would like to |
5149 | add a package to the distribution with as little work as | |
5150 | possible---a legitimate demand. The command knows of a few | |
5151 | repositories from which it can ``import'' package metadata. The result | |
2f7d2d91 LC |
5152 | is a package definition, or a template thereof, in the format we know |
5153 | (@pxref{Defining Packages}). | |
5154 | ||
5155 | The general syntax is: | |
5156 | ||
5157 | @example | |
5158 | guix import @var{importer} @var{options}@dots{} | |
5159 | @end example | |
5160 | ||
5161 | @var{importer} specifies the source from which to import package | |
f97c9175 | 5162 | metadata, and @var{options} specifies a package identifier and other |
2f7d2d91 LC |
5163 | options specific to @var{importer}. Currently, the available |
5164 | ``importers'' are: | |
5165 | ||
5166 | @table @code | |
5167 | @item gnu | |
f97c9175 | 5168 | Import metadata for the given GNU package. This provides a template |
2f7d2d91 LC |
5169 | for the latest version of that GNU package, including the hash of its |
5170 | source tarball, and its canonical synopsis and description. | |
5171 | ||
f97c9175 | 5172 | Additional information such as the package dependencies and its |
2f7d2d91 LC |
5173 | license needs to be figured out manually. |
5174 | ||
5175 | For example, the following command returns a package definition for | |
5176 | GNU@tie{}Hello: | |
5177 | ||
5178 | @example | |
5179 | guix import gnu hello | |
5180 | @end example | |
5181 | ||
5182 | Specific command-line options are: | |
5183 | ||
5184 | @table @code | |
5185 | @item --key-download=@var{policy} | |
5186 | As for @code{guix refresh}, specify the policy to handle missing OpenPGP | |
f97c9175 | 5187 | keys when verifying the package signature. @xref{Invoking guix |
2f7d2d91 LC |
5188 | refresh, @code{--key-download}}. |
5189 | @end table | |
5190 | ||
5191 | @item pypi | |
5192 | @cindex pypi | |
f97c9175 | 5193 | Import metadata from the @uref{https://pypi.python.org/, Python Package |
2f7d2d91 LC |
5194 | Index}@footnote{This functionality requires Guile-JSON to be installed. |
5195 | @xref{Requirements}.}. Information is taken from the JSON-formatted | |
5196 | description available at @code{pypi.python.org} and usually includes all | |
266785d2 CR |
5197 | the relevant information, including package dependencies. For maximum |
5198 | efficiency, it is recommended to install the @command{unzip} utility, so | |
5199 | that the importer can unzip Python wheels and gather data from them. | |
2f7d2d91 | 5200 | |
f97c9175 | 5201 | The command below imports metadata for the @code{itsdangerous} Python |
2f7d2d91 LC |
5202 | package: |
5203 | ||
5204 | @example | |
5205 | guix import pypi itsdangerous | |
5206 | @end example | |
5207 | ||
3aae8145 DT |
5208 | @item gem |
5209 | @cindex gem | |
f97c9175 | 5210 | Import metadata from @uref{https://rubygems.org/, |
3aae8145 DT |
5211 | RubyGems}@footnote{This functionality requires Guile-JSON to be |
5212 | installed. @xref{Requirements}.}. Information is taken from the | |
5213 | JSON-formatted description available at @code{rubygems.org} and includes | |
5214 | most relevant information, including runtime dependencies. There are | |
f97c9175 | 5215 | some caveats, however. The metadata doesn't distinguish between |
3aae8145 DT |
5216 | synopses and descriptions, so the same string is used for both fields. |
5217 | Additionally, the details of non-Ruby dependencies required to build | |
5218 | native extensions is unavailable and left as an exercise to the | |
5219 | packager. | |
5220 | ||
f97c9175 | 5221 | The command below imports metadata for the @code{rails} Ruby package: |
3aae8145 DT |
5222 | |
5223 | @example | |
5224 | guix import gem rails | |
5225 | @end example | |
5226 | ||
d45dc6da EB |
5227 | @item cpan |
5228 | @cindex CPAN | |
3c192e4e AE |
5229 | Import metadata from @uref{https://www.metacpan.org/, MetaCPAN}@footnote{This |
5230 | functionality requires Guile-JSON to be installed. | |
5231 | @xref{Requirements}.}. | |
f97c9175 | 5232 | Information is taken from the JSON-formatted metadata provided through |
d45dc6da | 5233 | @uref{https://api.metacpan.org/, MetaCPAN's API} and includes most |
66392e47 EB |
5234 | relevant information, such as module dependencies. License information |
5235 | should be checked closely. If Perl is available in the store, then the | |
5236 | @code{corelist} utility will be used to filter core modules out of the | |
5237 | list of dependencies. | |
d45dc6da | 5238 | |
f97c9175 | 5239 | The command command below imports metadata for the @code{Acme::Boolean} |
d45dc6da EB |
5240 | Perl module: |
5241 | ||
5242 | @example | |
5243 | guix import cpan Acme::Boolean | |
5244 | @end example | |
5245 | ||
e1248602 RW |
5246 | @item cran |
5247 | @cindex CRAN | |
d0bd632f | 5248 | @cindex Bioconductor |
f97c9175 | 5249 | Import metadata from @uref{http://cran.r-project.org/, CRAN}, the |
e1248602 RW |
5250 | central repository for the @uref{http://r-project.org, GNU@tie{}R |
5251 | statistical and graphical environment}. | |
5252 | ||
f97c9175 | 5253 | Information is extracted from the @code{DESCRIPTION} file of the package. |
e1248602 | 5254 | |
f97c9175 | 5255 | The command command below imports metadata for the @code{Cairo} |
e1248602 RW |
5256 | R package: |
5257 | ||
5258 | @example | |
5259 | guix import cran Cairo | |
5260 | @end example | |
5261 | ||
64ce53eb RW |
5262 | When @code{--recursive} is added, the importer will traverse the |
5263 | dependency graph of the given upstream package recursively and generate | |
5264 | package expressions for all those packages that are not yet in Guix. | |
5265 | ||
f97c9175 | 5266 | When @code{--archive=bioconductor} is added, metadata is imported from |
d0bd632f RW |
5267 | @uref{http://www.bioconductor.org/, Bioconductor}, a repository of R |
5268 | packages for for the analysis and comprehension of high-throughput | |
5269 | genomic data in bioinformatics. | |
5270 | ||
f97c9175 | 5271 | Information is extracted from the @code{DESCRIPTION} file of a package |
d0bd632f RW |
5272 | published on the web interface of the Bioconductor SVN repository. |
5273 | ||
f97c9175 | 5274 | The command below imports metadata for the @code{GenomicRanges} |
d0bd632f RW |
5275 | R package: |
5276 | ||
5277 | @example | |
5278 | guix import cran --archive=bioconductor GenomicRanges | |
5279 | @end example | |
5280 | ||
2f7d2d91 | 5281 | @item nix |
f97c9175 | 5282 | Import metadata from a local copy of the source of the |
2f7d2d91 LC |
5283 | @uref{http://nixos.org/nixpkgs/, Nixpkgs distribution}@footnote{This |
5284 | relies on the @command{nix-instantiate} command of | |
5285 | @uref{http://nixos.org/nix/, Nix}.}. Package definitions in Nixpkgs are | |
5286 | typically written in a mixture of Nix-language and Bash code. This | |
5287 | command only imports the high-level package structure that is written in | |
5288 | the Nix language. It normally includes all the basic fields of a | |
5289 | package definition. | |
5290 | ||
5291 | When importing a GNU package, the synopsis and descriptions are replaced | |
5292 | by their canonical upstream variant. | |
5293 | ||
961d0d2d LC |
5294 | Usually, you will first need to do: |
5295 | ||
5296 | @example | |
5297 | export NIX_REMOTE=daemon | |
5298 | @end example | |
5299 | ||
5300 | @noindent | |
5301 | so that @command{nix-instantiate} does not try to open the Nix database. | |
5302 | ||
2f7d2d91 LC |
5303 | As an example, the command below imports the package definition of |
5304 | LibreOffice (more precisely, it imports the definition of the package | |
5305 | bound to the @code{libreoffice} top-level attribute): | |
5306 | ||
5307 | @example | |
5308 | guix import nix ~/path/to/nixpkgs libreoffice | |
5309 | @end example | |
863af4e1 FB |
5310 | |
5311 | @item hackage | |
5312 | @cindex hackage | |
f97c9175 | 5313 | Import metadata from the Haskell community's central package archive |
863af4e1 FB |
5314 | @uref{https://hackage.haskell.org/, Hackage}. Information is taken from |
5315 | Cabal files and includes all the relevant information, including package | |
5316 | dependencies. | |
5317 | ||
5318 | Specific command-line options are: | |
5319 | ||
5320 | @table @code | |
a4154748 FB |
5321 | @item --stdin |
5322 | @itemx -s | |
f97c9175 | 5323 | Read a Cabal file from standard input. |
863af4e1 FB |
5324 | @item --no-test-dependencies |
5325 | @itemx -t | |
f97c9175 | 5326 | Do not include dependencies required only by the test suites. |
a4154748 FB |
5327 | @item --cabal-environment=@var{alist} |
5328 | @itemx -e @var{alist} | |
5329 | @var{alist} is a Scheme alist defining the environment in which the | |
5330 | Cabal conditionals are evaluated. The accepted keys are: @code{os}, | |
5331 | @code{arch}, @code{impl} and a string representing the name of a flag. | |
5332 | The value associated with a flag has to be either the symbol | |
5333 | @code{true} or @code{false}. The value associated with other keys | |
5334 | has to conform to the Cabal file format definition. The default value | |
5335 | associated with the keys @code{os}, @code{arch} and @code{impl} is | |
f97c9175 | 5336 | @samp{linux}, @samp{x86_64} and @samp{ghc}, respectively. |
863af4e1 FB |
5337 | @end table |
5338 | ||
f97c9175 | 5339 | The command below imports metadata for the latest version of the |
a4154748 FB |
5340 | @code{HTTP} Haskell package without including test dependencies and |
5341 | specifying the value of the flag @samp{network-uri} as @code{false}: | |
863af4e1 FB |
5342 | |
5343 | @example | |
a4154748 | 5344 | guix import hackage -t -e "'((\"network-uri\" . false))" HTTP |
863af4e1 FB |
5345 | @end example |
5346 | ||
5347 | A specific package version may optionally be specified by following the | |
1b846da8 | 5348 | package name by an at-sign and a version number as in the following example: |
863af4e1 FB |
5349 | |
5350 | @example | |
1b846da8 | 5351 | guix import hackage mtl@@2.1.3.1 |
863af4e1 | 5352 | @end example |
7f74a931 | 5353 | |
bc5844d1 FB |
5354 | @item stackage |
5355 | @cindex stackage | |
5356 | The @code{stackage} importer is a wrapper around the @code{hackage} one. | |
5357 | It takes a package name, looks up the package version included in a | |
5358 | long-term support (LTS) @uref{https://www.stackage.org, Stackage} | |
5359 | release and uses the @code{hackage} importer to retrieve its metadata. | |
5360 | Note that it is up to you to select an LTS release compatible with the | |
5361 | GHC compiler used by Guix. | |
5362 | ||
5363 | Specific command-line options are: | |
5364 | ||
5365 | @table @code | |
5366 | @item --no-test-dependencies | |
5367 | @itemx -t | |
5368 | Do not include dependencies required only by the test suites. | |
5369 | @item --lts-version=@var{version} | |
5370 | @itemx -r @var{version} | |
5371 | @var{version} is the desired LTS release version. If omitted the latest | |
5372 | release is used. | |
5373 | @end table | |
5374 | ||
5375 | The command below imports metadata for the @code{HTTP} Haskell package | |
5376 | included in the LTS Stackage release version 7.18: | |
5377 | ||
5378 | @example | |
5379 | guix import stackage --lts-version=7.18 HTTP | |
5380 | @end example | |
5381 | ||
7f74a931 FB |
5382 | @item elpa |
5383 | @cindex elpa | |
f97c9175 | 5384 | Import metadata from an Emacs Lisp Package Archive (ELPA) package |
7f74a931 FB |
5385 | repository (@pxref{Packages,,, emacs, The GNU Emacs Manual}). |
5386 | ||
5387 | Specific command-line options are: | |
5388 | ||
5389 | @table @code | |
5390 | @item --archive=@var{repo} | |
5391 | @itemx -a @var{repo} | |
5392 | @var{repo} identifies the archive repository from which to retrieve the | |
5393 | information. Currently the supported repositories and their identifiers | |
5394 | are: | |
5395 | @itemize - | |
5396 | @item | |
840bd1d3 | 5397 | @uref{http://elpa.gnu.org/packages, GNU}, selected by the @code{gnu} |
7f74a931 FB |
5398 | identifier. This is the default. |
5399 | ||
624144e0 LC |
5400 | Packages from @code{elpa.gnu.org} are signed with one of the keys |
5401 | contained in the GnuPG keyring at | |
5402 | @file{share/emacs/25.1/etc/package-keyring.gpg} (or similar) in the | |
5403 | @code{emacs} package (@pxref{Package Installation, ELPA package | |
5404 | signatures,, emacs, The GNU Emacs Manual}). | |
5405 | ||
7f74a931 | 5406 | @item |
840bd1d3 | 5407 | @uref{http://stable.melpa.org/packages, MELPA-Stable}, selected by the |
7f74a931 FB |
5408 | @code{melpa-stable} identifier. |
5409 | ||
5410 | @item | |
840bd1d3 | 5411 | @uref{http://melpa.org/packages, MELPA}, selected by the @code{melpa} |
7f74a931 FB |
5412 | identifier. |
5413 | @end itemize | |
5414 | @end table | |
3e0c0365 DC |
5415 | |
5416 | @item crate | |
5417 | @cindex crate | |
5418 | Import metadata from the crates.io Rust package repository | |
5419 | @uref{https://crates.io, crates.io}. | |
2f7d2d91 LC |
5420 | @end table |
5421 | ||
5422 | The structure of the @command{guix import} code is modular. It would be | |
5423 | useful to have more importers for other package formats, and your help | |
5424 | is welcome here (@pxref{Contributing}). | |
5425 | ||
37166310 LC |
5426 | @node Invoking guix refresh |
5427 | @section Invoking @command{guix refresh} | |
5428 | ||
e32171ee | 5429 | @cindex @command {guix refresh} |
37166310 LC |
5430 | The primary audience of the @command{guix refresh} command is developers |
5431 | of the GNU software distribution. By default, it reports any packages | |
5432 | provided by the distribution that are outdated compared to the latest | |
5433 | upstream version, like this: | |
5434 | ||
5435 | @example | |
5436 | $ guix refresh | |
5437 | gnu/packages/gettext.scm:29:13: gettext would be upgraded from 0.18.1.1 to 0.18.2.1 | |
5438 | gnu/packages/glib.scm:77:12: glib would be upgraded from 2.34.3 to 2.37.0 | |
5439 | @end example | |
5440 | ||
e9c72306 LC |
5441 | Alternately, one can specify packages to consider, in which case a |
5442 | warning is emitted for packages that lack an updater: | |
5443 | ||
5444 | @example | |
5445 | $ guix refresh coreutils guile guile-ssh | |
5446 | gnu/packages/ssh.scm:205:2: warning: no updater for guile-ssh | |
5447 | gnu/packages/guile.scm:136:12: guile would be upgraded from 2.0.12 to 2.0.13 | |
5448 | @end example | |
5449 | ||
5450 | @command{guix refresh} browses the upstream repository of each package and determines | |
5451 | the highest version number of the releases therein. The command | |
bcb571cb | 5452 | knows how to update specific types of packages: GNU packages, ELPA |
e9c72306 | 5453 | packages, etc.---see the documentation for @option{--type} below. There |
bcb571cb LC |
5454 | are many packages, though, for which it lacks a method to determine |
5455 | whether a new upstream release is available. However, the mechanism is | |
5456 | extensible, so feel free to get in touch with us to add a new method! | |
37166310 LC |
5457 | |
5458 | When passed @code{--update}, it modifies distribution source files to | |
f97c9175 | 5459 | update the version numbers and source tarball hashes of those package |
37166310 LC |
5460 | recipes (@pxref{Defining Packages}). This is achieved by downloading |
5461 | each package's latest source tarball and its associated OpenPGP | |
5462 | signature, authenticating the downloaded tarball against its signature | |
5463 | using @command{gpg}, and finally computing its hash. When the public | |
5464 | key used to sign the tarball is missing from the user's keyring, an | |
5465 | attempt is made to automatically retrieve it from a public key server; | |
f97c9175 | 5466 | when this is successful, the key is added to the user's keyring; otherwise, |
37166310 LC |
5467 | @command{guix refresh} reports an error. |
5468 | ||
5469 | The following options are supported: | |
5470 | ||
5471 | @table @code | |
5472 | ||
2d7fc7da LC |
5473 | @item --expression=@var{expr} |
5474 | @itemx -e @var{expr} | |
5475 | Consider the package @var{expr} evaluates to. | |
5476 | ||
5477 | This is useful to precisely refer to a package, as in this example: | |
5478 | ||
5479 | @example | |
5480 | guix refresh -l -e '(@@@@ (gnu packages commencement) glibc-final)' | |
5481 | @end example | |
5482 | ||
5483 | This command lists the dependents of the ``final'' libc (essentially all | |
5484 | the packages.) | |
5485 | ||
37166310 LC |
5486 | @item --update |
5487 | @itemx -u | |
38e16b49 LC |
5488 | Update distribution source files (package recipes) in place. This is |
5489 | usually run from a checkout of the Guix source tree (@pxref{Running | |
5490 | Guix Before It Is Installed}): | |
5491 | ||
5492 | @example | |
e9c72306 | 5493 | $ ./pre-inst-env guix refresh -s non-core -u |
38e16b49 LC |
5494 | @end example |
5495 | ||
081145cf | 5496 | @xref{Defining Packages}, for more information on package definitions. |
37166310 LC |
5497 | |
5498 | @item --select=[@var{subset}] | |
5499 | @itemx -s @var{subset} | |
5500 | Select all the packages in @var{subset}, one of @code{core} or | |
5501 | @code{non-core}. | |
5502 | ||
5503 | The @code{core} subset refers to all the packages at the core of the | |
5504 | distribution---i.e., packages that are used to build ``everything | |
5505 | else''. This includes GCC, libc, Binutils, Bash, etc. Usually, | |
5506 | changing one of these packages in the distribution entails a rebuild of | |
5507 | all the others. Thus, such updates are an inconvenience to users in | |
5508 | terms of build time or bandwidth used to achieve the upgrade. | |
5509 | ||
5510 | The @code{non-core} subset refers to the remaining packages. It is | |
5511 | typically useful in cases where an update of the core packages would be | |
5512 | inconvenient. | |
5513 | ||
bcb571cb LC |
5514 | @item --type=@var{updater} |
5515 | @itemx -t @var{updater} | |
7191adc5 AK |
5516 | Select only packages handled by @var{updater} (may be a comma-separated |
5517 | list of updaters). Currently, @var{updater} may be one of: | |
bcb571cb LC |
5518 | |
5519 | @table @code | |
5520 | @item gnu | |
5521 | the updater for GNU packages; | |
e80c0f85 LC |
5522 | @item gnome |
5523 | the updater for GNOME packages; | |
9c97afe8 DC |
5524 | @item kde |
5525 | the updater for KDE packages; | |
62061d6b AW |
5526 | @item xorg |
5527 | the updater for X.org packages; | |
2fd370e8 LC |
5528 | @item kernel.org |
5529 | the updater for packages hosted on kernel.org; | |
bcb571cb | 5530 | @item elpa |
d882c235 LC |
5531 | the updater for @uref{http://elpa.gnu.org/, ELPA} packages; |
5532 | @item cran | |
b9d044ef | 5533 | the updater for @uref{http://cran.r-project.org/, CRAN} packages; |
d0bd632f RW |
5534 | @item bioconductor |
5535 | the updater for @uref{http://www.bioconductor.org/, Bioconductor} R packages; | |
200cdf81 EB |
5536 | @item cpan |
5537 | the updater for @uref{http://www.cpan.org/, CPAN} packages; | |
bab020d7 | 5538 | @item pypi |
b9d044ef | 5539 | the updater for @uref{https://pypi.python.org, PyPI} packages. |
fbc5b815 BW |
5540 | @item gem |
5541 | the updater for @uref{https://rubygems.org, RubyGems} packages. | |
917a2a58 BW |
5542 | @item github |
5543 | the updater for @uref{https://github.com, GitHub} packages. | |
42efe27a EB |
5544 | @item hackage |
5545 | the updater for @uref{https://hackage.haskell.org, Hackage} packages. | |
bc5844d1 FB |
5546 | @item stackage |
5547 | the updater for @uref{https://www.stackage.org, Stackage} packages. | |
8ac52987 DC |
5548 | @item crate |
5549 | the updater for @uref{https://crates.io, Crates} packages. | |
bcb571cb LC |
5550 | @end table |
5551 | ||
f97c9175 AE |
5552 | For instance, the following command only checks for updates of Emacs |
5553 | packages hosted at @code{elpa.gnu.org} and for updates of CRAN packages: | |
bcb571cb LC |
5554 | |
5555 | @example | |
7191adc5 | 5556 | $ guix refresh --type=elpa,cran |
d882c235 | 5557 | gnu/packages/statistics.scm:819:13: r-testthat would be upgraded from 0.10.0 to 0.11.0 |
bcb571cb LC |
5558 | gnu/packages/emacs.scm:856:13: emacs-auctex would be upgraded from 11.88.6 to 11.88.9 |
5559 | @end example | |
5560 | ||
37166310 LC |
5561 | @end table |
5562 | ||
5563 | In addition, @command{guix refresh} can be passed one or more package | |
5564 | names, as in this example: | |
5565 | ||
5566 | @example | |
e9c72306 | 5567 | $ ./pre-inst-env guix refresh -u emacs idutils gcc@@4.8 |
37166310 LC |
5568 | @end example |
5569 | ||
5570 | @noindent | |
5571 | The command above specifically updates the @code{emacs} and | |
5572 | @code{idutils} packages. The @code{--select} option would have no | |
5573 | effect in this case. | |
5574 | ||
7d193ec3 EB |
5575 | When considering whether to upgrade a package, it is sometimes |
5576 | convenient to know which packages would be affected by the upgrade and | |
5577 | should be checked for compatibility. For this the following option may | |
5578 | be used when passing @command{guix refresh} one or more package names: | |
5579 | ||
5580 | @table @code | |
5581 | ||
6ffa706b AK |
5582 | @item --list-updaters |
5583 | @itemx -L | |
5584 | List available updaters and exit (see @option{--type} above.) | |
5585 | ||
3676f892 LC |
5586 | For each updater, display the fraction of packages it covers; at the |
5587 | end, display the fraction of packages covered by all these updaters. | |
5588 | ||
7d193ec3 EB |
5589 | @item --list-dependent |
5590 | @itemx -l | |
5591 | List top-level dependent packages that would need to be rebuilt as a | |
5592 | result of upgrading one or more packages. | |
5593 | ||
b96a0640 LC |
5594 | @xref{Invoking guix graph, the @code{reverse-package} type of |
5595 | @command{guix graph}}, for information on how to visualize the list of | |
5596 | dependents of a package. | |
5597 | ||
7d193ec3 EB |
5598 | @end table |
5599 | ||
5600 | Be aware that the @code{--list-dependent} option only | |
5601 | @emph{approximates} the rebuilds that would be required as a result of | |
5602 | an upgrade. More rebuilds might be required under some circumstances. | |
5603 | ||
5604 | @example | |
7779ab61 LC |
5605 | $ guix refresh --list-dependent flex |
5606 | Building the following 120 packages would ensure 213 dependent packages are rebuilt: | |
5607 | hop-2.4.0 geiser-0.4 notmuch-0.18 mu-0.9.9.5 cflow-1.4 idutils-4.6 @dots{} | |
7d193ec3 EB |
5608 | @end example |
5609 | ||
5610 | The command above lists a set of packages that could be built to check | |
5611 | for compatibility with an upgraded @code{flex} package. | |
5612 | ||
f9230085 LC |
5613 | The following options can be used to customize GnuPG operation: |
5614 | ||
5615 | @table @code | |
5616 | ||
f9230085 LC |
5617 | @item --gpg=@var{command} |
5618 | Use @var{command} as the GnuPG 2.x command. @var{command} is searched | |
5619 | for in @code{$PATH}. | |
5620 | ||
2bc53ba9 LC |
5621 | @item --key-download=@var{policy} |
5622 | Handle missing OpenPGP keys according to @var{policy}, which may be one | |
5623 | of: | |
5624 | ||
5625 | @table @code | |
5626 | @item always | |
5627 | Always download missing OpenPGP keys from the key server, and add them | |
5628 | to the user's GnuPG keyring. | |
5629 | ||
5630 | @item never | |
5631 | Never try to download missing OpenPGP keys. Instead just bail out. | |
5632 | ||
5633 | @item interactive | |
5634 | When a package signed with an unknown OpenPGP key is encountered, ask | |
5635 | the user whether to download it or not. This is the default behavior. | |
5636 | @end table | |
5637 | ||
5638 | @item --key-server=@var{host} | |
5639 | Use @var{host} as the OpenPGP key server when importing a public key. | |
5640 | ||
f9230085 LC |
5641 | @end table |
5642 | ||
917a2a58 BW |
5643 | The @code{github} updater uses the |
5644 | @uref{https://developer.github.com/v3/, GitHub API} to query for new | |
5645 | releases. When used repeatedly e.g. when refreshing all packages, | |
5646 | GitHub will eventually refuse to answer any further API requests. By | |
5647 | default 60 API requests per hour are allowed, and a full refresh on all | |
5648 | GitHub packages in Guix requires more than this. Authentication with | |
5649 | GitHub through the use of an API token alleviates these limits. To use | |
5650 | an API token, set the environment variable @code{GUIX_GITHUB_TOKEN} to a | |
5651 | token procured from @uref{https://github.com/settings/tokens} or | |
5652 | otherwise. | |
5653 | ||
5654 | ||
b4f5e0e8 CR |
5655 | @node Invoking guix lint |
5656 | @section Invoking @command{guix lint} | |
e32171ee JD |
5657 | |
5658 | @cindex @command{guix lint} | |
5659 | @cindex package, checking for errors | |
f97c9175 AE |
5660 | The @command{guix lint} command is meant to help package developers avoid |
5661 | common errors and use a consistent style. It runs a number of checks on | |
5662 | a given set of packages in order to find common mistakes in their | |
873c4085 LC |
5663 | definitions. Available @dfn{checkers} include (see |
5664 | @code{--list-checkers} for a complete list): | |
5665 | ||
5666 | @table @code | |
5667 | @item synopsis | |
5668 | @itemx description | |
5669 | Validate certain typographical and stylistic rules about package | |
5670 | descriptions and synopses. | |
5671 | ||
5672 | @item inputs-should-be-native | |
5673 | Identify inputs that should most likely be native inputs. | |
5674 | ||
5675 | @item source | |
5676 | @itemx home-page | |
fac46e3f | 5677 | @itemx mirror-url |
50f5c46d | 5678 | @itemx source-file-name |
873c4085 | 5679 | Probe @code{home-page} and @code{source} URLs and report those that are |
fac46e3f LC |
5680 | invalid. Suggest a @code{mirror://} URL when applicable. Check that |
5681 | the source file name is meaningful, e.g. is not | |
f97c9175 AE |
5682 | just a version number or ``git-checkout'', without a declared |
5683 | @code{file-name} (@pxref{origin Reference}). | |
40a7d4e5 | 5684 | |
5432734b | 5685 | @item cve |
09866b39 LC |
5686 | @cindex security vulnerabilities |
5687 | @cindex CVE, Common Vulnerabilities and Exposures | |
5432734b | 5688 | Report known vulnerabilities found in the Common Vulnerabilities and |
09866b39 | 5689 | Exposures (CVE) databases of the current and past year |
5432734b LC |
5690 | @uref{https://nvd.nist.gov/download.cfm#CVE_FEED, published by the US |
5691 | NIST}. | |
5692 | ||
09866b39 LC |
5693 | To view information about a particular vulnerability, visit pages such as: |
5694 | ||
5695 | @itemize | |
5696 | @item | |
5697 | @indicateurl{https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-YYYY-ABCD} | |
5698 | @item | |
5699 | @indicateurl{https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-YYYY-ABCD} | |
5700 | @end itemize | |
5701 | ||
5702 | @noindent | |
5703 | where @code{CVE-YYYY-ABCD} is the CVE identifier---e.g., | |
5704 | @code{CVE-2015-7554}. | |
5705 | ||
99effc8f LC |
5706 | Package developers can specify in package recipes the |
5707 | @uref{https://nvd.nist.gov/cpe.cfm,Common Platform Enumeration (CPE)} | |
5708 | name and version of the package when they differ from the name that Guix | |
5709 | uses, as in this example: | |
5710 | ||
5711 | @example | |
5712 | (package | |
5713 | (name "grub") | |
5714 | ;; @dots{} | |
5715 | ;; CPE calls this package "grub2". | |
5716 | (properties '((cpe-name . "grub2")))) | |
5717 | @end example | |
5718 | ||
40a7d4e5 LC |
5719 | @item formatting |
5720 | Warn about obvious source code formatting issues: trailing white space, | |
5721 | use of tabulations, etc. | |
873c4085 | 5722 | @end table |
b4f5e0e8 CR |
5723 | |
5724 | The general syntax is: | |
5725 | ||
5726 | @example | |
5727 | guix lint @var{options} @var{package}@dots{} | |
5728 | @end example | |
5729 | ||
5730 | If no package is given on the command line, then all packages are checked. | |
5731 | The @var{options} may be zero or more of the following: | |
5732 | ||
5733 | @table @code | |
f97c9175 AE |
5734 | @item --list-checkers |
5735 | @itemx -l | |
5736 | List and describe all the available checkers that will be run on packages | |
5737 | and exit. | |
b4f5e0e8 | 5738 | |
dd7c013d CR |
5739 | @item --checkers |
5740 | @itemx -c | |
5741 | Only enable the checkers specified in a comma-separated list using the | |
5742 | names returned by @code{--list-checkers}. | |
5743 | ||
b4f5e0e8 | 5744 | @end table |
37166310 | 5745 | |
fcc58db6 LC |
5746 | @node Invoking guix size |
5747 | @section Invoking @command{guix size} | |
5748 | ||
e32171ee JD |
5749 | @cindex size |
5750 | @cindex package size | |
5751 | @cindex closure | |
5752 | @cindex @command{guix size} | |
fcc58db6 LC |
5753 | The @command{guix size} command helps package developers profile the |
5754 | disk usage of packages. It is easy to overlook the impact of an | |
5755 | additional dependency added to a package, or the impact of using a | |
5756 | single output for a package that could easily be split (@pxref{Packages | |
f97c9175 | 5757 | with Multiple Outputs}). Such are the typical issues that |
fcc58db6 LC |
5758 | @command{guix size} can highlight. |
5759 | ||
e1a65ae5 | 5760 | The command can be passed a package specification such as @code{gcc@@4.8} |
fcc58db6 LC |
5761 | or @code{guile:debug}, or a file name in the store. Consider this |
5762 | example: | |
5763 | ||
5764 | @example | |
5765 | $ guix size coreutils | |
5766 | store item total self | |
5767 | /gnu/store/@dots{}-coreutils-8.23 70.0 13.9 19.8% | |
5768 | /gnu/store/@dots{}-gmp-6.0.0a 55.3 2.5 3.6% | |
5769 | /gnu/store/@dots{}-acl-2.2.52 53.7 0.5 0.7% | |
5770 | /gnu/store/@dots{}-attr-2.4.46 53.2 0.3 0.5% | |
5771 | /gnu/store/@dots{}-gcc-4.8.4-lib 52.9 15.7 22.4% | |
5772 | /gnu/store/@dots{}-glibc-2.21 37.2 37.2 53.1% | |
5773 | @end example | |
5774 | ||
5775 | @cindex closure | |
5776 | The store items listed here constitute the @dfn{transitive closure} of | |
5777 | Coreutils---i.e., Coreutils and all its dependencies, recursively---as | |
5778 | would be returned by: | |
5779 | ||
5780 | @example | |
5781 | $ guix gc -R /gnu/store/@dots{}-coreutils-8.23 | |
5782 | @end example | |
5783 | ||
f97c9175 | 5784 | Here the output shows three columns next to store items. The first column, |
fcc58db6 LC |
5785 | labeled ``total'', shows the size in mebibytes (MiB) of the closure of |
5786 | the store item---that is, its own size plus the size of all its | |
5787 | dependencies. The next column, labeled ``self'', shows the size of the | |
f97c9175 AE |
5788 | item itself. The last column shows the ratio of the size of the item |
5789 | itself to the space occupied by all the items listed here. | |
fcc58db6 LC |
5790 | |
5791 | In this example, we see that the closure of Coreutils weighs in at | |
5792 | 70@tie{}MiB, half of which is taken by libc. (That libc represents a | |
5793 | large fraction of the closure is not a problem @i{per se} because it is | |
5794 | always available on the system anyway.) | |
5795 | ||
5796 | When the package passed to @command{guix size} is available in the | |
5797 | store, @command{guix size} queries the daemon to determine its | |
5798 | dependencies, and measures its size in the store, similar to @command{du | |
5799 | -ms --apparent-size} (@pxref{du invocation,,, coreutils, GNU | |
5800 | Coreutils}). | |
5801 | ||
5802 | When the given package is @emph{not} in the store, @command{guix size} | |
f97c9175 AE |
5803 | reports information based on the available substitutes |
5804 | (@pxref{Substitutes}). This makes it possible it to profile disk usage of | |
5805 | store items that are not even on disk, only available remotely. | |
fcc58db6 | 5806 | |
db761534 LC |
5807 | You can also specify several package names: |
5808 | ||
5809 | @example | |
5810 | $ guix size coreutils grep sed bash | |
5811 | store item total self | |
5812 | /gnu/store/@dots{}-coreutils-8.24 77.8 13.8 13.4% | |
5813 | /gnu/store/@dots{}-grep-2.22 73.1 0.8 0.8% | |
5814 | /gnu/store/@dots{}-bash-4.3.42 72.3 4.7 4.6% | |
5815 | /gnu/store/@dots{}-readline-6.3 67.6 1.2 1.2% | |
5816 | @dots{} | |
5817 | total: 102.3 MiB | |
5818 | @end example | |
5819 | ||
5820 | @noindent | |
5821 | In this example we see that the combination of the four packages takes | |
5822 | 102.3@tie{}MiB in total, which is much less than the sum of each closure | |
5823 | since they have a lot of dependencies in common. | |
5824 | ||
a8f996c6 | 5825 | The available options are: |
fcc58db6 LC |
5826 | |
5827 | @table @option | |
5828 | ||
d490d06e LC |
5829 | @item --substitute-urls=@var{urls} |
5830 | Use substitute information from @var{urls}. | |
5831 | @xref{client-substitute-urls, the same option for @code{guix build}}. | |
5832 | ||
a8f996c6 | 5833 | @item --map-file=@var{file} |
f97c9175 | 5834 | Write a graphical map of disk usage in PNG format to @var{file}. |
a8f996c6 LC |
5835 | |
5836 | For the example above, the map looks like this: | |
5837 | ||
5838 | @image{images/coreutils-size-map,5in,, map of Coreutils disk usage | |
5839 | produced by @command{guix size}} | |
5840 | ||
5841 | This option requires that | |
5842 | @uref{http://wingolog.org/software/guile-charting/, Guile-Charting} be | |
5843 | installed and visible in Guile's module search path. When that is not | |
5844 | the case, @command{guix size} fails as it tries to load it. | |
5845 | ||
fcc58db6 LC |
5846 | @item --system=@var{system} |
5847 | @itemx -s @var{system} | |
5848 | Consider packages for @var{system}---e.g., @code{x86_64-linux}. | |
5849 | ||
5850 | @end table | |
5851 | ||
88856916 LC |
5852 | @node Invoking guix graph |
5853 | @section Invoking @command{guix graph} | |
5854 | ||
5855 | @cindex DAG | |
e32171ee JD |
5856 | @cindex @command{guix graph} |
5857 | @cindex package dependencies | |
88856916 LC |
5858 | Packages and their dependencies form a @dfn{graph}, specifically a |
5859 | directed acyclic graph (DAG). It can quickly become difficult to have a | |
f97c9175 | 5860 | mental model of the package DAG, so the @command{guix graph} command |
9ea36197 LC |
5861 | provides a visual representation of the DAG. By default, |
5862 | @command{guix graph} emits a DAG representation in the input format of | |
88856916 | 5863 | @uref{http://www.graphviz.org/, Graphviz}, so its output can be passed |
9ea36197 LC |
5864 | directly to the @command{dot} command of Graphviz. It can also emit an |
5865 | HTML page with embedded JavaScript code to display a ``chord diagram'' | |
5866 | in a Web browser, using the @uref{https://d3js.org/, d3.js} library. | |
5867 | The general syntax is: | |
88856916 LC |
5868 | |
5869 | @example | |
5870 | guix graph @var{options} @var{package}@dots{} | |
5871 | @end example | |
5872 | ||
5873 | For example, the following command generates a PDF file representing the | |
5874 | package DAG for the GNU@tie{}Core Utilities, showing its build-time | |
5875 | dependencies: | |
5876 | ||
5877 | @example | |
5878 | guix graph coreutils | dot -Tpdf > dag.pdf | |
5879 | @end example | |
5880 | ||
5881 | The output looks like this: | |
5882 | ||
5883 | @image{images/coreutils-graph,2in,,Dependency graph of the GNU Coreutils} | |
5884 | ||
5885 | Nice little graph, no? | |
5886 | ||
f97c9175 | 5887 | But there is more than one graph! The one above is concise: it is the |
88856916 | 5888 | graph of package objects, omitting implicit inputs such as GCC, libc, |
f97c9175 AE |
5889 | grep, etc. It is often useful to have such a concise graph, but |
5890 | sometimes one may want to see more details. @command{guix graph} supports | |
5891 | several types of graphs, allowing you to choose the level of detail: | |
88856916 LC |
5892 | |
5893 | @table @code | |
5894 | @item package | |
f97c9175 | 5895 | This is the default type used in the example above. It shows the DAG of |
88856916 LC |
5896 | package objects, excluding implicit dependencies. It is concise, but |
5897 | filters out many details. | |
5898 | ||
b96a0640 LC |
5899 | @item reverse-package |
5900 | This shows the @emph{reverse} DAG of packages. For example: | |
5901 | ||
5902 | @example | |
5903 | guix graph --type=reverse-package ocaml | |
5904 | @end example | |
5905 | ||
5906 | ... yields the graph of packages that depend on OCaml. | |
5907 | ||
5908 | Note that for core packages this can yield huge graphs. If all you want | |
5909 | is to know the number of packages that depend on a given package, use | |
5910 | @command{guix refresh --list-dependent} (@pxref{Invoking guix refresh, | |
5911 | @option{--list-dependent}}). | |
5912 | ||
88856916 LC |
5913 | @item bag-emerged |
5914 | This is the package DAG, @emph{including} implicit inputs. | |
5915 | ||
5916 | For instance, the following command: | |
5917 | ||
5918 | @example | |
5919 | guix graph --type=bag-emerged coreutils | dot -Tpdf > dag.pdf | |
5920 | @end example | |
5921 | ||
5922 | ... yields this bigger graph: | |
5923 | ||
5924 | @image{images/coreutils-bag-graph,,5in,Detailed dependency graph of the GNU Coreutils} | |
5925 | ||
5926 | At the bottom of the graph, we see all the implicit inputs of | |
5927 | @var{gnu-build-system} (@pxref{Build Systems, @code{gnu-build-system}}). | |
5928 | ||
f97c9175 | 5929 | Now, note that the dependencies of these implicit inputs---that is, the |
88856916 LC |
5930 | @dfn{bootstrap dependencies} (@pxref{Bootstrapping})---are not shown |
5931 | here, for conciseness. | |
5932 | ||
5933 | @item bag | |
5934 | Similar to @code{bag-emerged}, but this time including all the bootstrap | |
5935 | dependencies. | |
5936 | ||
38b92daa LC |
5937 | @item bag-with-origins |
5938 | Similar to @code{bag}, but also showing origins and their dependencies. | |
5939 | ||
88856916 LC |
5940 | @item derivations |
5941 | This is the most detailed representation: It shows the DAG of | |
5942 | derivations (@pxref{Derivations}) and plain store items. Compared to | |
5943 | the above representation, many additional nodes are visible, including | |
f97c9175 | 5944 | build scripts, patches, Guile modules, etc. |
88856916 | 5945 | |
a773c314 LC |
5946 | For this type of graph, it is also possible to pass a @file{.drv} file |
5947 | name instead of a package name, as in: | |
5948 | ||
5949 | @example | |
5950 | guix graph -t derivation `guix system build -d my-config.scm` | |
5951 | @end example | |
88856916 LC |
5952 | @end table |
5953 | ||
f97c9175 | 5954 | All the types above correspond to @emph{build-time dependencies}. The |
88856916 LC |
5955 | following graph type represents the @emph{run-time dependencies}: |
5956 | ||
5957 | @table @code | |
5958 | @item references | |
5959 | This is the graph of @dfn{references} of a package output, as returned | |
5960 | by @command{guix gc --references} (@pxref{Invoking guix gc}). | |
5961 | ||
5962 | If the given package output is not available in the store, @command{guix | |
5963 | graph} attempts to obtain dependency information from substitutes. | |
a773c314 LC |
5964 | |
5965 | Here you can also pass a store file name instead of a package name. For | |
5966 | example, the command below produces the reference graph of your profile | |
5967 | (which can be big!): | |
5968 | ||
5969 | @example | |
5970 | guix graph -t references `readlink -f ~/.guix-profile` | |
5971 | @end example | |
7f8fec0f LC |
5972 | |
5973 | @item referrers | |
5974 | This is the graph of the @dfn{referrers} of a store item, as returned by | |
5975 | @command{guix gc --referrers} (@pxref{Invoking guix gc}). | |
5976 | ||
5977 | This relies exclusively on local information from your store. For | |
5978 | instance, let us suppose that the current Inkscape is available in 10 | |
5979 | profiles on your machine; @command{guix graph -t referrers inkscape} | |
5980 | will show a graph rooted at Inkscape and with those 10 profiles linked | |
5981 | to it. | |
5982 | ||
5983 | It can help determine what is preventing a store item from being garbage | |
5984 | collected. | |
5985 | ||
88856916 LC |
5986 | @end table |
5987 | ||
5988 | The available options are the following: | |
5989 | ||
5990 | @table @option | |
5991 | @item --type=@var{type} | |
5992 | @itemx -t @var{type} | |
5993 | Produce a graph output of @var{type}, where @var{type} must be one of | |
5994 | the values listed above. | |
5995 | ||
5996 | @item --list-types | |
5997 | List the supported graph types. | |
4c8f997a | 5998 | |
642339dc RW |
5999 | @item --backend=@var{backend} |
6000 | @itemx -b @var{backend} | |
6001 | Produce a graph using the selected @var{backend}. | |
6002 | ||
6003 | @item --list-backends | |
6004 | List the supported graph backends. | |
6005 | ||
9ea36197 LC |
6006 | Currently, the available backends are Graphviz and d3.js. |
6007 | ||
4c8f997a LC |
6008 | @item --expression=@var{expr} |
6009 | @itemx -e @var{expr} | |
6010 | Consider the package @var{expr} evaluates to. | |
6011 | ||
6012 | This is useful to precisely refer to a package, as in this example: | |
6013 | ||
6014 | @example | |
6015 | guix graph -e '(@@@@ (gnu packages commencement) gnu-make-final)' | |
6016 | @end example | |
88856916 LC |
6017 | @end table |
6018 | ||
6019 | ||
372c4bbc DT |
6020 | @node Invoking guix environment |
6021 | @section Invoking @command{guix environment} | |
6022 | ||
f5fd4fd2 | 6023 | @cindex reproducible build environments |
fe36d84e | 6024 | @cindex development environments |
e32171ee JD |
6025 | @cindex @command{guix environment} |
6026 | @cindex environment, package build environment | |
372c4bbc DT |
6027 | The purpose of @command{guix environment} is to assist hackers in |
6028 | creating reproducible development environments without polluting their | |
6029 | package profile. The @command{guix environment} tool takes one or more | |
f97c9175 | 6030 | packages, builds all of their inputs, and creates a shell |
372c4bbc DT |
6031 | environment to use them. |
6032 | ||
6033 | The general syntax is: | |
6034 | ||
6035 | @example | |
6036 | guix environment @var{options} @var{package}@dots{} | |
6037 | @end example | |
6038 | ||
fe36d84e LC |
6039 | The following example spawns a new shell set up for the development of |
6040 | GNU@tie{}Guile: | |
372c4bbc DT |
6041 | |
6042 | @example | |
6043 | guix environment guile | |
6044 | @end example | |
6045 | ||
f97c9175 AE |
6046 | If the needed dependencies are not built yet, @command{guix environment} |
6047 | automatically builds them. The environment of the new shell is an augmented | |
372c4bbc DT |
6048 | version of the environment that @command{guix environment} was run in. |
6049 | It contains the necessary search paths for building the given package | |
6050 | added to the existing environment variables. To create a ``pure'' | |
f97c9175 | 6051 | environment, in which the original environment variables have been unset, |
50500f7c LC |
6052 | use the @code{--pure} option@footnote{Users sometimes wrongfully augment |
6053 | environment variables such as @code{PATH} in their @file{~/.bashrc} | |
6054 | file. As a consequence, when @code{guix environment} launches it, Bash | |
6055 | may read @file{~/.bashrc}, thereby introducing ``impurities'' in these | |
6056 | environment variables. It is an error to define such environment | |
6057 | variables in @file{.bashrc}; instead, they should be defined in | |
6058 | @file{.bash_profile}, which is sourced only by log-in shells. | |
6059 | @xref{Bash Startup Files,,, bash, The GNU Bash Reference Manual}, for | |
6060 | details on Bash start-up files.}. | |
372c4bbc | 6061 | |
28de8d25 LC |
6062 | @vindex GUIX_ENVIRONMENT |
6063 | @command{guix environment} defines the @code{GUIX_ENVIRONMENT} | |
20185522 LC |
6064 | variable in the shell it spawns; its value is the file name of the |
6065 | profile of this environment. This allows users to, say, define a | |
28de8d25 LC |
6066 | specific prompt for development environments in their @file{.bashrc} |
6067 | (@pxref{Bash Startup Files,,, bash, The GNU Bash Reference Manual}): | |
6068 | ||
6069 | @example | |
6070 | if [ -n "$GUIX_ENVIRONMENT" ] | |
6071 | then | |
6072 | export PS1="\u@@\h \w [dev]\$ " | |
6073 | fi | |
6074 | @end example | |
6075 | ||
20185522 LC |
6076 | @noindent |
6077 | ... or to browse the profile: | |
6078 | ||
6079 | @example | |
6080 | $ ls "$GUIX_ENVIRONMENT/bin" | |
6081 | @end example | |
6082 | ||
372c4bbc DT |
6083 | Additionally, more than one package may be specified, in which case the |
6084 | union of the inputs for the given packages are used. For example, the | |
6085 | command below spawns a shell where all of the dependencies of both Guile | |
6086 | and Emacs are available: | |
6087 | ||
6088 | @example | |
6089 | guix environment guile emacs | |
6090 | @end example | |
6091 | ||
1de2fe95 DT |
6092 | Sometimes an interactive shell session is not desired. An arbitrary |
6093 | command may be invoked by placing the @code{--} token to separate the | |
6094 | command from the rest of the arguments: | |
372c4bbc DT |
6095 | |
6096 | @example | |
1de2fe95 | 6097 | guix environment guile -- make -j4 |
372c4bbc DT |
6098 | @end example |
6099 | ||
fe36d84e LC |
6100 | In other situations, it is more convenient to specify the list of |
6101 | packages needed in the environment. For example, the following command | |
6102 | runs @command{python} from an environment containing Python@tie{}2.7 and | |
6103 | NumPy: | |
6104 | ||
6105 | @example | |
1de2fe95 | 6106 | guix environment --ad-hoc python2-numpy python-2.7 -- python |
fe36d84e LC |
6107 | @end example |
6108 | ||
cc90fbbf DT |
6109 | Furthermore, one might want the dependencies of a package and also some |
6110 | additional packages that are not build-time or runtime dependencies, but | |
6111 | are useful when developing nonetheless. Because of this, the | |
6112 | @code{--ad-hoc} flag is positional. Packages appearing before | |
6113 | @code{--ad-hoc} are interpreted as packages whose dependencies will be | |
6114 | added to the environment. Packages appearing after are interpreted as | |
6115 | packages that will be added to the environment directly. For example, | |
6116 | the following command creates a Guix development environment that | |
6117 | additionally includes Git and strace: | |
6118 | ||
6119 | @example | |
6120 | guix environment guix --ad-hoc git strace | |
6121 | @end example | |
6122 | ||
f535dcbe DT |
6123 | Sometimes it is desirable to isolate the environment as much as |
6124 | possible, for maximal purity and reproducibility. In particular, when | |
6125 | using Guix on a host distro that is not GuixSD, it is desirable to | |
6126 | prevent access to @file{/usr/bin} and other system-wide resources from | |
6127 | the development environment. For example, the following command spawns | |
6128 | a Guile REPL in a ``container'' where only the store and the current | |
6129 | working directory are mounted: | |
6130 | ||
6131 | @example | |
6132 | guix environment --ad-hoc --container guile -- guile | |
6133 | @end example | |
6134 | ||
0f252e26 | 6135 | @quotation Note |
cfd35b4e | 6136 | The @code{--container} option requires Linux-libre 3.19 or newer. |
0f252e26 DT |
6137 | @end quotation |
6138 | ||
fe36d84e | 6139 | The available options are summarized below. |
372c4bbc DT |
6140 | |
6141 | @table @code | |
f943c317 LC |
6142 | @item --root=@var{file} |
6143 | @itemx -r @var{file} | |
6144 | @cindex persistent environment | |
6145 | @cindex garbage collector root, for environments | |
6146 | Make @var{file} a symlink to the profile for this environment, and | |
6147 | register it as a garbage collector root. | |
6148 | ||
6149 | This is useful if you want to protect your environment from garbage | |
6150 | collection, to make it ``persistent''. | |
6151 | ||
6152 | When this option is omitted, the environment is protected from garbage | |
6153 | collection only for the duration of the @command{guix environment} | |
6154 | session. This means that next time you recreate the same environment, | |
6155 | you could have to rebuild or re-download packages. | |
6156 | ||
372c4bbc DT |
6157 | @item --expression=@var{expr} |
6158 | @itemx -e @var{expr} | |
c9c282ce DT |
6159 | Create an environment for the package or list of packages that |
6160 | @var{expr} evaluates to. | |
372c4bbc | 6161 | |
fe36d84e LC |
6162 | For example, running: |
6163 | ||
6164 | @example | |
6165 | guix environment -e '(@@ (gnu packages maths) petsc-openmpi)' | |
6166 | @end example | |
6167 | ||
6168 | starts a shell with the environment for this specific variant of the | |
6169 | PETSc package. | |
6170 | ||
c9c282ce DT |
6171 | Running: |
6172 | ||
6173 | @example | |
5c2b2f00 | 6174 | guix environment --ad-hoc -e '(@@ (gnu) %base-packages)' |
c9c282ce DT |
6175 | @end example |
6176 | ||
6177 | starts a shell with all the GuixSD base packages available. | |
6178 | ||
fa445d64 | 6179 | The above commands only use the default output of the given packages. |
779aa003 DT |
6180 | To select other outputs, two element tuples can be specified: |
6181 | ||
6182 | @example | |
6183 | guix environment --ad-hoc -e '(list (@ (gnu packages bash) bash) "include")' | |
6184 | @end example | |
6185 | ||
372c4bbc DT |
6186 | @item --load=@var{file} |
6187 | @itemx -l @var{file} | |
c9c282ce DT |
6188 | Create an environment for the package or list of packages that the code |
6189 | within @var{file} evaluates to. | |
372c4bbc | 6190 | |
fe36d84e LC |
6191 | As an example, @var{file} might contain a definition like this |
6192 | (@pxref{Defining Packages}): | |
6193 | ||
6194 | @example | |
6195 | @verbatiminclude environment-gdb.scm | |
6196 | @end example | |
6197 | ||
a54bd6d7 DT |
6198 | @item --ad-hoc |
6199 | Include all specified packages in the resulting environment, as if an | |
6200 | @i{ad hoc} package were defined with them as inputs. This option is | |
6201 | useful for quickly creating an environment without having to write a | |
6202 | package expression to contain the desired inputs. | |
6203 | ||
6204 | For instance, the command: | |
6205 | ||
6206 | @example | |
1de2fe95 | 6207 | guix environment --ad-hoc guile guile-sdl -- guile |
a54bd6d7 DT |
6208 | @end example |
6209 | ||
6210 | runs @command{guile} in an environment where Guile and Guile-SDL are | |
6211 | available. | |
6212 | ||
417c39f1 | 6213 | Note that this example implicitly asks for the default output of |
f97c9175 | 6214 | @code{guile} and @code{guile-sdl}, but it is possible to ask for a |
417c39f1 LC |
6215 | specific output---e.g., @code{glib:bin} asks for the @code{bin} output |
6216 | of @code{glib} (@pxref{Packages with Multiple Outputs}). | |
6217 | ||
cc90fbbf DT |
6218 | This option may be composed with the default behavior of @command{guix |
6219 | environment}. Packages appearing before @code{--ad-hoc} are interpreted | |
6220 | as packages whose dependencies will be added to the environment, the | |
6221 | default behavior. Packages appearing after are interpreted as packages | |
6222 | that will be added to the environment directly. | |
6223 | ||
372c4bbc DT |
6224 | @item --pure |
6225 | Unset existing environment variables when building the new environment. | |
6226 | This has the effect of creating an environment in which search paths | |
6227 | only contain package inputs. | |
6228 | ||
6229 | @item --search-paths | |
6230 | Display the environment variable definitions that make up the | |
6231 | environment. | |
ce367ef3 LC |
6232 | |
6233 | @item --system=@var{system} | |
6234 | @itemx -s @var{system} | |
6235 | Attempt to build for @var{system}---e.g., @code{i686-linux}. | |
f535dcbe DT |
6236 | |
6237 | @item --container | |
6238 | @itemx -C | |
6239 | @cindex container | |
6240 | Run @var{command} within an isolated container. The current working | |
a01ad638 DT |
6241 | directory outside the container is mapped inside the container. |
6242 | Additionally, a dummy home directory is created that matches the current | |
6243 | user's home directory, and @file{/etc/passwd} is configured accordingly. | |
6244 | The spawned process runs as the current user outside the container, but | |
6245 | has root privileges in the context of the container. | |
f535dcbe DT |
6246 | |
6247 | @item --network | |
6248 | @itemx -N | |
6249 | For containers, share the network namespace with the host system. | |
6250 | Containers created without this flag only have access to the loopback | |
6251 | device. | |
6252 | ||
6253 | @item --expose=@var{source}[=@var{target}] | |
6254 | For containers, expose the file system @var{source} from the host system | |
6255 | as the read-only file system @var{target} within the container. If | |
6256 | @var{target} is not specified, @var{source} is used as the target mount | |
6257 | point in the container. | |
6258 | ||
6259 | The example below spawns a Guile REPL in a container in which the user's | |
6260 | home directory is accessible read-only via the @file{/exchange} | |
6261 | directory: | |
6262 | ||
6263 | @example | |
6264 | guix environment --container --expose=$HOME=/exchange guile -- guile | |
6265 | @end example | |
6266 | ||
5c2b2f00 | 6267 | @item --share=@var{source}[=@var{target}] |
f535dcbe DT |
6268 | For containers, share the file system @var{source} from the host system |
6269 | as the writable file system @var{target} within the container. If | |
6270 | @var{target} is not specified, @var{source} is used as the target mount | |
6271 | point in the container. | |
6272 | ||
6273 | The example below spawns a Guile REPL in a container in which the user's | |
6274 | home directory is accessible for both reading and writing via the | |
6275 | @file{/exchange} directory: | |
6276 | ||
6277 | @example | |
6278 | guix environment --container --share=$HOME=/exchange guile -- guile | |
6279 | @end example | |
372c4bbc DT |
6280 | @end table |
6281 | ||
6282 | It also supports all of the common build options that @command{guix | |
ccd7158d | 6283 | build} supports (@pxref{Common Build Options}). |
372c4bbc | 6284 | |
aff8ce7c DT |
6285 | @node Invoking guix publish |
6286 | @section Invoking @command{guix publish} | |
6287 | ||
e32171ee | 6288 | @cindex @command{guix publish} |
aff8ce7c | 6289 | The purpose of @command{guix publish} is to enable users to easily share |
f97c9175 | 6290 | their store with others, who can then use it as a substitute server |
8ce229fc LC |
6291 | (@pxref{Substitutes}). |
6292 | ||
6293 | When @command{guix publish} runs, it spawns an HTTP server which allows | |
6294 | anyone with network access to obtain substitutes from it. This means | |
6295 | that any machine running Guix can also act as if it were a build farm, | |
6296 | since the HTTP interface is compatible with Hydra, the software behind | |
6297 | the @code{hydra.gnu.org} build farm. | |
aff8ce7c DT |
6298 | |
6299 | For security, each substitute is signed, allowing recipients to check | |
6300 | their authenticity and integrity (@pxref{Substitutes}). Because | |
f97c9175 | 6301 | @command{guix publish} uses the signing key of the system, which is only |
5463fe51 LC |
6302 | readable by the system administrator, it must be started as root; the |
6303 | @code{--user} option makes it drop root privileges early on. | |
aff8ce7c | 6304 | |
b18812b6 LC |
6305 | The signing key pair must be generated before @command{guix publish} is |
6306 | launched, using @command{guix archive --generate-key} (@pxref{Invoking | |
6307 | guix archive}). | |
6308 | ||
aff8ce7c DT |
6309 | The general syntax is: |
6310 | ||
6311 | @example | |
6312 | guix publish @var{options}@dots{} | |
6313 | @end example | |
6314 | ||
6315 | Running @command{guix publish} without any additional arguments will | |
6316 | spawn an HTTP server on port 8080: | |
6317 | ||
6318 | @example | |
6319 | guix publish | |
6320 | @end example | |
6321 | ||
6322 | Once a publishing server has been authorized (@pxref{Invoking guix | |
6323 | archive}), the daemon may download substitutes from it: | |
6324 | ||
6325 | @example | |
6326 | guix-daemon --substitute-urls=http://example.org:8080 | |
6327 | @end example | |
6328 | ||
ff6638d1 LC |
6329 | As a bonus, @command{guix publish} also serves as a content-addressed |
6330 | mirror for source files referenced in @code{origin} records | |
6331 | (@pxref{origin Reference}). For instance, assuming @command{guix | |
6332 | publish} is running on @code{example.org}, the following URL returns the | |
6333 | raw @file{hello-2.10.tar.gz} file with the given SHA256 hash | |
6334 | (represented in @code{nix-base32} format, @pxref{Invoking guix hash}): | |
6335 | ||
6336 | @example | |
6337 | http://example.org/file/hello-2.10.tar.gz/sha256/0ssi1@dots{}ndq1i | |
6338 | @end example | |
6339 | ||
6340 | Obviously, these URLs only work for files that are in the store; in | |
6341 | other cases, they return 404 (``Not Found''). | |
6342 | ||
aff8ce7c DT |
6343 | The following options are available: |
6344 | ||
6345 | @table @code | |
6346 | @item --port=@var{port} | |
6347 | @itemx -p @var{port} | |
6348 | Listen for HTTP requests on @var{port}. | |
6349 | ||
9e2292ef LC |
6350 | @item --listen=@var{host} |
6351 | Listen on the network interface for @var{host}. The default is to | |
6352 | accept connections from any interface. | |
6353 | ||
5463fe51 LC |
6354 | @item --user=@var{user} |
6355 | @itemx -u @var{user} | |
6356 | Change privileges to @var{user} as soon as possible---i.e., once the | |
6357 | server socket is open and the signing key has been read. | |
6358 | ||
4a1fc562 LC |
6359 | @item --compression[=@var{level}] |
6360 | @itemx -C [@var{level}] | |
6361 | Compress data using the given @var{level}. When @var{level} is zero, | |
6362 | disable compression. The range 1 to 9 corresponds to different gzip | |
6363 | compression levels: 1 is the fastest, and 9 is the best (CPU-intensive). | |
6364 | The default is 3. | |
6365 | ||
4591c02e | 6366 | Compression occurs on the fly and the compressed streams are not |
4a1fc562 LC |
6367 | cached. Thus, to reduce load on the machine that runs @command{guix |
6368 | publish}, it may be a good idea to choose a low compression level, or to | |
6369 | run @command{guix publish} behind a caching proxy. | |
6370 | ||
e4c7a5f7 LC |
6371 | @item --ttl=@var{ttl} |
6372 | Produce @code{Cache-Control} HTTP headers that advertise a time-to-live | |
6373 | (TTL) of @var{ttl}. @var{ttl} must denote a duration: @code{5d} means 5 | |
6374 | days, @code{1m} means 1 month, and so on. | |
6375 | ||
6376 | This allows the user's Guix to keep substitute information in cache for | |
6377 | @var{ttl}. However, note that @code{guix publish} does not itself | |
6378 | guarantee that the store items it provides will indeed remain available | |
6379 | for as long as @var{ttl}. | |
6380 | ||
aff8ce7c DT |
6381 | @item --repl[=@var{port}] |
6382 | @itemx -r [@var{port}] | |
6383 | Spawn a Guile REPL server (@pxref{REPL Servers,,, guile, GNU Guile | |
8ce229fc LC |
6384 | Reference Manual}) on @var{port} (37146 by default). This is used |
6385 | primarily for debugging a running @command{guix publish} server. | |
aff8ce7c DT |
6386 | @end table |
6387 | ||
1c52181f LC |
6388 | Enabling @command{guix publish} on a GuixSD system is a one-liner: just |
6389 | add a call to @code{guix-publish-service} in the @code{services} field | |
6390 | of the @code{operating-system} declaration (@pxref{guix-publish-service, | |
6391 | @code{guix-publish-service}}). | |
6392 | ||
332d7903 HG |
6393 | If you are instead running Guix on a ``foreign distro'', follow these |
6394 | instructions:” | |
6395 | ||
6396 | @itemize | |
6397 | @item | |
6398 | If your host distro uses the systemd init system: | |
6399 | ||
6400 | @example | |
6401 | # ln -s ~root/.guix-profile/lib/systemd/system/guix-publish.service \ | |
6402 | /etc/systemd/system/ | |
6403 | # systemctl start guix-publish && systemctl enable guix-publish | |
6404 | @end example | |
6405 | ||
6406 | @item | |
6407 | If your host distro uses the Upstart init system: | |
6408 | ||
6409 | @example | |
6410 | # ln -s ~root/.guix-profile/lib/upstart/system/guix-publish.conf /etc/init/ | |
6411 | # start guix-publish | |
6412 | @end example | |
6413 | ||
6414 | @item | |
6415 | Otherwise, proceed similarly with your distro's init system. | |
6416 | @end itemize | |
d23c20f1 LC |
6417 | |
6418 | @node Invoking guix challenge | |
6419 | @section Invoking @command{guix challenge} | |
6420 | ||
6421 | @cindex reproducible builds | |
6422 | @cindex verifiable builds | |
e32171ee JD |
6423 | @cindex @command{guix challenge} |
6424 | @cindex challenge | |
d23c20f1 | 6425 | Do the binaries provided by this server really correspond to the source |
f97c9175 | 6426 | code it claims to build? Is a package build process deterministic? |
d23c20f1 LC |
6427 | These are the questions the @command{guix challenge} command attempts to |
6428 | answer. | |
6429 | ||
6430 | The former is obviously an important question: Before using a substitute | |
f97c9175 | 6431 | server (@pxref{Substitutes}), one had better @emph{verify} that it |
d23c20f1 LC |
6432 | provides the right binaries, and thus @emph{challenge} it. The latter |
6433 | is what enables the former: If package builds are deterministic, then | |
6434 | independent builds of the package should yield the exact same result, | |
6435 | bit for bit; if a server provides a binary different from the one | |
6436 | obtained locally, it may be either corrupt or malicious. | |
6437 | ||
6438 | We know that the hash that shows up in @file{/gnu/store} file names is | |
6439 | the hash of all the inputs of the process that built the file or | |
6440 | directory---compilers, libraries, build scripts, | |
6441 | etc. (@pxref{Introduction}). Assuming deterministic build processes, | |
6442 | one store file name should map to exactly one build output. | |
6443 | @command{guix challenge} checks whether there is, indeed, a single | |
6444 | mapping by comparing the build outputs of several independent builds of | |
6445 | any given store item. | |
6446 | ||
f97c9175 | 6447 | The command output looks like this: |
d23c20f1 LC |
6448 | |
6449 | @smallexample | |
ddbc7f7d LC |
6450 | $ guix challenge --substitute-urls="https://hydra.gnu.org https://guix.example.org" |
6451 | updating list of substitutes from 'https://hydra.gnu.org'... 100.0% | |
6452 | updating list of substitutes from 'https://guix.example.org'... 100.0% | |
d23c20f1 LC |
6453 | /gnu/store/@dots{}-openssl-1.0.2d contents differ: |
6454 | local hash: 0725l22r5jnzazaacncwsvp9kgf42266ayyp814v7djxs7nk963q | |
ddbc7f7d LC |
6455 | https://hydra.gnu.org/nar/@dots{}-openssl-1.0.2d: 0725l22r5jnzazaacncwsvp9kgf42266ayyp814v7djxs7nk963q |
6456 | https://guix.example.org/nar/@dots{}-openssl-1.0.2d: 1zy4fmaaqcnjrzzajkdn3f5gmjk754b43qkq47llbyak9z0qjyim | |
d23c20f1 LC |
6457 | /gnu/store/@dots{}-git-2.5.0 contents differ: |
6458 | local hash: 00p3bmryhjxrhpn2gxs2fy0a15lnip05l97205pgbk5ra395hyha | |
ddbc7f7d LC |
6459 | https://hydra.gnu.org/nar/@dots{}-git-2.5.0: 069nb85bv4d4a6slrwjdy8v1cn4cwspm3kdbmyb81d6zckj3nq9f |
6460 | https://guix.example.org/nar/@dots{}-git-2.5.0: 0mdqa9w1p6cmli6976v4wi0sw9r4p5prkj7lzfd1877wk11c9c73 | |
d23c20f1 LC |
6461 | /gnu/store/@dots{}-pius-2.1.1 contents differ: |
6462 | local hash: 0k4v3m9z1zp8xzzizb7d8kjj72f9172xv078sq4wl73vnq9ig3ax | |
ddbc7f7d LC |
6463 | https://hydra.gnu.org/nar/@dots{}-pius-2.1.1: 0k4v3m9z1zp8xzzizb7d8kjj72f9172xv078sq4wl73vnq9ig3ax |
6464 | https://guix.example.org/nar/@dots{}-pius-2.1.1: 1cy25x1a4fzq5rk0pmvc8xhwyffnqz95h2bpvqsz2mpvlbccy0gs | |
d23c20f1 LC |
6465 | @end smallexample |
6466 | ||
6467 | @noindent | |
6468 | In this example, @command{guix challenge} first scans the store to | |
6469 | determine the set of locally-built derivations---as opposed to store | |
6470 | items that were downloaded from a substitute server---and then queries | |
6471 | all the substitute servers. It then reports those store items for which | |
6472 | the servers obtained a result different from the local build. | |
6473 | ||
6474 | @cindex non-determinism, in package builds | |
6475 | As an example, @code{guix.example.org} always gets a different answer. | |
6476 | Conversely, @code{hydra.gnu.org} agrees with local builds, except in the | |
6477 | case of Git. This might indicate that the build process of Git is | |
6478 | non-deterministic, meaning that its output varies as a function of | |
6479 | various things that Guix does not fully control, in spite of building | |
6480 | packages in isolated environments (@pxref{Features}). Most common | |
6481 | sources of non-determinism include the addition of timestamps in build | |
6482 | results, the inclusion of random numbers, and directory listings sorted | |
a70a5004 | 6483 | by inode number. See @uref{https://reproducible-builds.org/docs/}, for |
d23c20f1 LC |
6484 | more information. |
6485 | ||
f97c9175 | 6486 | To find out what is wrong with this Git binary, we can do something along |
d23c20f1 LC |
6487 | these lines (@pxref{Invoking guix archive}): |
6488 | ||
6489 | @example | |
ddbc7f7d | 6490 | $ wget -q -O - https://hydra.gnu.org/nar/@dots{}-git-2.5.0 \ |
d23c20f1 | 6491 | | guix archive -x /tmp/git |
043f4698 | 6492 | $ diff -ur --no-dereference /gnu/store/@dots{}-git.2.5.0 /tmp/git |
d23c20f1 LC |
6493 | @end example |
6494 | ||
6495 | This command shows the difference between the files resulting from the | |
6496 | local build, and the files resulting from the build on | |
6497 | @code{hydra.gnu.org} (@pxref{Overview, Comparing and Merging Files,, | |
6498 | diffutils, Comparing and Merging Files}). The @command{diff} command | |
6499 | works great for text files. When binary files differ, a better option | |
ddbc7f7d | 6500 | is @uref{https://diffoscope.org/, Diffoscope}, a tool that helps |
d23c20f1 LC |
6501 | visualize differences for all kinds of files. |
6502 | ||
f97c9175 | 6503 | Once you have done that work, you can tell whether the differences are due |
d23c20f1 LC |
6504 | to a non-deterministic build process or to a malicious server. We try |
6505 | hard to remove sources of non-determinism in packages to make it easier | |
f97c9175 AE |
6506 | to verify substitutes, but of course, this is a process that |
6507 | involves not just Guix, but a large part of the free software community. | |
d23c20f1 LC |
6508 | In the meantime, @command{guix challenge} is one tool to help address |
6509 | the problem. | |
6510 | ||
6511 | If you are writing packages for Guix, you are encouraged to check | |
6512 | whether @code{hydra.gnu.org} and other substitute servers obtain the | |
6513 | same build result as you did with: | |
6514 | ||
6515 | @example | |
6516 | $ guix challenge @var{package} | |
6517 | @end example | |
6518 | ||
6519 | @noindent | |
f97c9175 | 6520 | where @var{package} is a package specification such as |
7cffaeb6 | 6521 | @code{guile@@2.0} or @code{glibc:debug}. |
d23c20f1 LC |
6522 | |
6523 | The general syntax is: | |
6524 | ||
6525 | @example | |
6526 | guix challenge @var{options} [@var{packages}@dots{}] | |
6527 | @end example | |
6528 | ||
7cffaeb6 LC |
6529 | When a difference is found between the hash of a locally-built item and |
6530 | that of a server-provided substitute, or among substitutes provided by | |
6531 | different servers, the command displays it as in the example above and | |
a17417a8 LC |
6532 | its exit code is 2 (other non-zero exit codes denote other kinds of |
6533 | errors.) | |
7cffaeb6 | 6534 | |
d23c20f1 LC |
6535 | The one option that matters is: |
6536 | ||
6537 | @table @code | |
6538 | ||
6539 | @item --substitute-urls=@var{urls} | |
6540 | Consider @var{urls} the whitespace-separated list of substitute source | |
6541 | URLs to compare to. | |
6542 | ||
153b6295 LC |
6543 | @item --verbose |
6544 | @itemx -v | |
6545 | Show details about matches (identical contents) in addition to | |
6546 | information about mismatches. | |
6547 | ||
d23c20f1 LC |
6548 | @end table |
6549 | ||
f11c444d LC |
6550 | @node Invoking guix copy |
6551 | @section Invoking @command{guix copy} | |
6552 | ||
6553 | @cindex copy, of store items, over SSH | |
6554 | @cindex SSH, copy of store items | |
6555 | @cindex sharing store items across machines | |
6556 | @cindex transferring store items across machines | |
6557 | The @command{guix copy} command copies items from the store of one | |
6558 | machine to that of another machine over a secure shell (SSH) | |
6559 | connection@footnote{This command is available only when Guile-SSH was | |
6560 | found. @xref{Requirements}, for details.}. For example, the following | |
6561 | command copies the @code{coreutils} package, the user's profile, and all | |
6562 | their dependencies over to @var{host}, logged in as @var{user}: | |
6563 | ||
6564 | @example | |
6565 | guix copy --to=@var{user}@@@var{host} \ | |
6566 | coreutils `readlink -f ~/.guix-profile` | |
6567 | @end example | |
6568 | ||
6569 | If some of the items to be copied are already present on @var{host}, | |
6570 | they are not actually sent. | |
6571 | ||
6572 | The command below retrieves @code{libreoffice} and @code{gimp} from | |
6573 | @var{host}, assuming they are available there: | |
6574 | ||
6575 | @example | |
6576 | guix copy --from=@var{host} libreoffice gimp | |
6577 | @end example | |
6578 | ||
6579 | The SSH connection is established using the Guile-SSH client, which is | |
6580 | compatible with OpenSSH: it honors @file{~/.ssh/known_hosts} and | |
6581 | @file{~/.ssh/config}, and uses the SSH agent for authentication. | |
6582 | ||
6583 | The key used to sign items that are sent must be accepted by the remote | |
6584 | machine. Likewise, the key used by the remote machine to sign items you | |
6585 | are retrieving must be in @file{/etc/guix/acl} so it is accepted by your | |
6586 | own daemon. @xref{Invoking guix archive}, for more information about | |
6587 | store item authentication. | |
6588 | ||
6589 | The general syntax is: | |
6590 | ||
6591 | @example | |
6592 | guix copy [--to=@var{spec}|--from=@var{spec}] @var{items}@dots{} | |
6593 | @end example | |
6594 | ||
6595 | You must always specify one of the following options: | |
6596 | ||
6597 | @table @code | |
6598 | @item --to=@var{spec} | |
6599 | @itemx --from=@var{spec} | |
6600 | Specify the host to send to or receive from. @var{spec} must be an SSH | |
6601 | spec such as @code{example.org}, @code{charlie@@example.org}, or | |
6602 | @code{charlie@@example.org:2222}. | |
6603 | @end table | |
6604 | ||
6605 | The @var{items} can be either package names, such as @code{gimp}, or | |
6606 | store items, such as @file{/gnu/store/@dots{}-idutils-4.6}. | |
6607 | ||
6608 | When specifying the name of a package to send, it is first built if | |
6609 | needed, unless @option{--dry-run} was specified. Common build options | |
6610 | are supported (@pxref{Common Build Options}). | |
6611 | ||
d23c20f1 | 6612 | |
32efa254 DT |
6613 | @node Invoking guix container |
6614 | @section Invoking @command{guix container} | |
6615 | @cindex container | |
e32171ee | 6616 | @cindex @command{guix container} |
32efa254 DT |
6617 | @quotation Note |
6618 | As of version @value{VERSION}, this tool is experimental. The interface | |
6619 | is subject to radical change in the future. | |
6620 | @end quotation | |
6621 | ||
6622 | The purpose of @command{guix container} is to manipulate processes | |
6623 | running within an isolated environment, commonly known as a | |
46c36586 | 6624 | ``container'', typically created by the @command{guix environment} |
32efa254 DT |
6625 | (@pxref{Invoking guix environment}) and @command{guix system container} |
6626 | (@pxref{Invoking guix system}) commands. | |
6627 | ||
6628 | The general syntax is: | |
6629 | ||
6630 | @example | |
6631 | guix container @var{action} @var{options}@dots{} | |
6632 | @end example | |
6633 | ||
6634 | @var{action} specifies the operation to perform with a container, and | |
6635 | @var{options} specifies the context-specific arguments for the action. | |
6636 | ||
6637 | The following actions are available: | |
6638 | ||
6639 | @table @code | |
6640 | @item exec | |
6641 | Execute a command within the context of a running container. | |
6642 | ||
6643 | The syntax is: | |
6644 | ||
6645 | @example | |
6646 | guix container exec @var{pid} @var{program} @var{arguments}@dots{} | |
6647 | @end example | |
6648 | ||
6649 | @var{pid} specifies the process ID of the running container. | |
f97c9175 AE |
6650 | @var{program} specifies an executable file name within the root file |
6651 | system of the container. @var{arguments} are the additional options that | |
6652 | will be passed to @var{program}. | |
32efa254 DT |
6653 | |
6654 | The following command launches an interactive login shell inside a | |
6655 | GuixSD container, started by @command{guix system container}, and whose | |
6656 | process ID is 9001: | |
6657 | ||
6658 | @example | |
6659 | guix container exec 9001 /run/current-system/profile/bin/bash --login | |
6660 | @end example | |
6661 | ||
6662 | Note that the @var{pid} cannot be the parent process of a container. It | |
f97c9175 | 6663 | must be PID 1 of the container or one of its child processes. |
32efa254 DT |
6664 | |
6665 | @end table | |
6666 | ||
a1ba8475 LC |
6667 | @c ********************************************************************* |
6668 | @node GNU Distribution | |
6669 | @chapter GNU Distribution | |
6670 | ||
3ca2731c | 6671 | @cindex Guix System Distribution |
4705641f | 6672 | @cindex GuixSD |
3ca2731c LC |
6673 | Guix comes with a distribution of the GNU system consisting entirely of |
6674 | free software@footnote{The term ``free'' here refers to the | |
a1ba8475 | 6675 | @url{http://www.gnu.org/philosophy/free-sw.html,freedom provided to |
3ca2731c | 6676 | users of that software}.}. The |
35ed9306 LC |
6677 | distribution can be installed on its own (@pxref{System Installation}), |
6678 | but it is also possible to install Guix as a package manager on top of | |
6679 | an installed GNU/Linux system (@pxref{Installation}). To distinguish | |
3ca2731c | 6680 | between the two, we refer to the standalone distribution as the Guix |
4705641f | 6681 | System Distribution, or GuixSD. |
35ed9306 LC |
6682 | |
6683 | The distribution provides core GNU packages such as GNU libc, GCC, and | |
6684 | Binutils, as well as many GNU and non-GNU applications. The complete | |
6685 | list of available packages can be browsed | |
093ae1be | 6686 | @url{http://www.gnu.org/software/guix/packages,on-line} or by |
d03bb653 | 6687 | running @command{guix package} (@pxref{Invoking guix package}): |
a1ba8475 LC |
6688 | |
6689 | @example | |
e49951eb | 6690 | guix package --list-available |
a1ba8475 LC |
6691 | @end example |
6692 | ||
f97c9175 | 6693 | Our goal is to provide a practical 100% free software distribution of |
401c53c4 LC |
6694 | Linux-based and other variants of GNU, with a focus on the promotion and |
6695 | tight integration of GNU components, and an emphasis on programs and | |
6696 | tools that help users exert that freedom. | |
6697 | ||
3ca2731c | 6698 | Packages are currently available on the following platforms: |
c320011d LC |
6699 | |
6700 | @table @code | |
6701 | ||
6702 | @item x86_64-linux | |
6703 | Intel/AMD @code{x86_64} architecture, Linux-Libre kernel; | |
6704 | ||
6705 | @item i686-linux | |
6706 | Intel 32-bit architecture (IA32), Linux-Libre kernel; | |
6707 | ||
aa1e1947 | 6708 | @item armhf-linux |
aa725117 | 6709 | ARMv7-A architecture with hard float, Thumb-2 and NEON, |
f97c9175 AE |
6710 | using the EABI hard-float application binary interface (ABI), |
6711 | and Linux-Libre kernel. | |
aa1e1947 | 6712 | |
3b88f376 EF |
6713 | @item aarch64-linux |
6714 | little-endian 64-bit ARMv8-A processors, Linux-Libre kernel. This is | |
6715 | currently in an experimental stage, with limited support. See | |
6716 | @xref{Contributing}, for how to help! | |
6717 | ||
c320011d LC |
6718 | @item mips64el-linux |
6719 | little-endian 64-bit MIPS processors, specifically the Loongson series, | |
f97c9175 | 6720 | n32 ABI, and Linux-Libre kernel. |
c320011d LC |
6721 | |
6722 | @end table | |
6723 | ||
4705641f | 6724 | GuixSD itself is currently only available on @code{i686} and @code{x86_64}. |
3ca2731c | 6725 | |
c320011d LC |
6726 | @noindent |
6727 | For information on porting to other architectures or kernels, | |
f97c9175 | 6728 | @pxref{Porting}. |
c320011d | 6729 | |
401c53c4 | 6730 | @menu |
5af6de3e | 6731 | * System Installation:: Installing the whole operating system. |
35ed9306 | 6732 | * System Configuration:: Configuring the operating system. |
91ef73d4 | 6733 | * Installing Debugging Files:: Feeding the debugger. |
05962f29 | 6734 | * Security Updates:: Deploying security fixes quickly. |
401c53c4 | 6735 | * Package Modules:: Packages from the programmer's viewpoint. |
da7cabd4 | 6736 | * Packaging Guidelines:: Growing the distribution. |
401c53c4 | 6737 | * Bootstrapping:: GNU/Linux built from scratch. |
8b315a6d | 6738 | * Porting:: Targeting another platform or kernel. |
401c53c4 LC |
6739 | @end menu |
6740 | ||
6741 | Building this distribution is a cooperative effort, and you are invited | |
081145cf | 6742 | to join! @xref{Contributing}, for information about how you can help. |
401c53c4 | 6743 | |
5af6de3e LC |
6744 | @node System Installation |
6745 | @section System Installation | |
6746 | ||
e32171ee | 6747 | @cindex installing GuixSD |
3ca2731c | 6748 | @cindex Guix System Distribution |
c8b54374 | 6749 | This section explains how to install the Guix System Distribution (GuixSD) |
3ca2731c | 6750 | on a machine. The Guix package manager can |
35ed9306 LC |
6751 | also be installed on top of a running GNU/Linux system, |
6752 | @pxref{Installation}. | |
5af6de3e LC |
6753 | |
6754 | @ifinfo | |
9c18cf9b | 6755 | @quotation Note |
5af6de3e LC |
6756 | @c This paragraph is for people reading this from tty2 of the |
6757 | @c installation image. | |
1068f26b | 6758 | You are reading this documentation with an Info reader. For details on |
5af6de3e | 6759 | how to use it, hit the @key{RET} key (``return'' or ``enter'') on the |
de341e7c LC |
6760 | link that follows: @pxref{Top, Info reader,, info-stnd, Stand-alone GNU |
6761 | Info}. Hit @kbd{l} afterwards to come back here. | |
9c18cf9b LC |
6762 | |
6763 | Alternately, run @command{info info} in another tty to keep the manual | |
6764 | available. | |
6765 | @end quotation | |
5af6de3e LC |
6766 | @end ifinfo |
6767 | ||
dedb8d5e | 6768 | @menu |
e3009f60 LC |
6769 | * Limitations:: What you can expect. |
6770 | * Hardware Considerations:: Supported hardware. | |
6771 | * USB Stick Installation:: Preparing the installation medium. | |
6772 | * Preparing for Installation:: Networking, partitioning, etc. | |
6773 | * Proceeding with the Installation:: The real thing. | |
c8b54374 | 6774 | * Installing GuixSD in a VM:: GuixSD playground. |
e3009f60 | 6775 | * Building the Installation Image:: How this comes to be. |
dedb8d5e LC |
6776 | @end menu |
6777 | ||
6778 | @node Limitations | |
8aaaae38 LC |
6779 | @subsection Limitations |
6780 | ||
4705641f | 6781 | As of version @value{VERSION}, the Guix System Distribution (GuixSD) is |
3ca2731c | 6782 | not production-ready. It may contain bugs and lack important |
8aaaae38 LC |
6783 | features. Thus, if you are looking for a stable production system that |
6784 | respects your freedom as a computer user, a good solution at this point | |
6785 | is to consider @url{http://www.gnu.org/distros/free-distros.html, one of | |
f97c9175 | 6786 | the more established GNU/Linux distributions}. We hope you can soon switch |
4705641f | 6787 | to the GuixSD without fear, of course. In the meantime, you can |
8aaaae38 LC |
6788 | also keep using your distribution and try out the package manager on top |
6789 | of it (@pxref{Installation}). | |
6790 | ||
6791 | Before you proceed with the installation, be aware of the following | |
6792 | noteworthy limitations applicable to version @value{VERSION}: | |
6793 | ||
6794 | @itemize | |
6795 | @item | |
6796 | The installation process does not include a graphical user interface and | |
6797 | requires familiarity with GNU/Linux (see the following subsections to | |
6798 | get a feel of what that means.) | |
6799 | ||
8aaaae38 | 6800 | @item |
dbcb0ab1 | 6801 | Support for the Logical Volume Manager (LVM) is missing. |
8aaaae38 LC |
6802 | |
6803 | @item | |
6804 | Few system services are currently supported out-of-the-box | |
6805 | (@pxref{Services}). | |
6806 | ||
6807 | @item | |
29e53b95 | 6808 | More than 4,000 packages are available, but you may |
8aaaae38 | 6809 | occasionally find that a useful package is missing. |
5fe01c2d LC |
6810 | |
6811 | @item | |
6812 | GNOME, Xfce, and Enlightenment are available (@pxref{Desktop Services}), | |
6813 | as well as a number of X11 window managers. However, some graphical | |
6814 | applications may be missing, as well as KDE. | |
8aaaae38 LC |
6815 | @end itemize |
6816 | ||
f97c9175 AE |
6817 | You have been warned! But more than a disclaimer, this is an invitation |
6818 | to report issues (and success stories!), and to join us in improving it. | |
8aaaae38 | 6819 | @xref{Contributing}, for more info. |
5af6de3e | 6820 | |
e3009f60 LC |
6821 | |
6822 | @node Hardware Considerations | |
6823 | @subsection Hardware Considerations | |
6824 | ||
6825 | @cindex hardware support on GuixSD | |
6826 | GNU@tie{}GuixSD focuses on respecting the user's computing freedom. It | |
6827 | builds around the kernel Linux-libre, which means that only hardware for | |
e0b3f97e | 6828 | which free software drivers and firmware exist is supported. Nowadays, |
e3009f60 LC |
6829 | a wide range of off-the-shelf hardware is supported on |
6830 | GNU/Linux-libre---from keyboards to graphics cards to scanners and | |
6831 | Ethernet controllers. Unfortunately, there are still areas where | |
6832 | hardware vendors deny users control over their own computing, and such | |
6833 | hardware is not supported on GuixSD. | |
6834 | ||
6835 | @cindex WiFi, hardware support | |
e0b3f97e | 6836 | One of the main areas where free drivers or firmware are lacking is WiFi |
e3009f60 LC |
6837 | devices. WiFi devices known to work include those using Atheros chips |
6838 | (AR9271 and AR7010), which corresponds to the @code{ath9k} Linux-libre | |
52db41af EB |
6839 | driver, and those using Broadcom/AirForce chips (BCM43xx with |
6840 | Wireless-Core Revision 5), which corresponds to the @code{b43-open} | |
6841 | Linux-libre driver. Free firmware exists for both and is available | |
e3009f60 LC |
6842 | out-of-the-box on GuixSD, as part of @var{%base-firmware} |
6843 | (@pxref{operating-system Reference, @code{firmware}}). | |
6844 | ||
6845 | @cindex RYF, Respects Your Freedom | |
6846 | The @uref{https://www.fsf.org/, Free Software Foundation} runs | |
e0b3f97e | 6847 | @uref{https://www.fsf.org/ryf, @dfn{Respects Your Freedom}} (RYF), a |
e3009f60 LC |
6848 | certification program for hardware products that respect your freedom |
6849 | and your privacy and ensure that you have control over your device. We | |
e0b3f97e | 6850 | encourage you to check the list of RYF-certified devices. |
e3009f60 LC |
6851 | |
6852 | Another useful resource is the @uref{https://www.h-node.org/, H-Node} | |
6853 | web site. It contains a catalog of hardware devices with information | |
6854 | about their support in GNU/Linux. | |
6855 | ||
6856 | ||
dedb8d5e | 6857 | @node USB Stick Installation |
5af6de3e LC |
6858 | @subsection USB Stick Installation |
6859 | ||
6860 | An installation image for USB sticks can be downloaded from | |
4705641f | 6861 | @indicateurl{ftp://alpha.gnu.org/gnu/guix/guixsd-usb-install-@value{VERSION}.@var{system}.xz}, |
5af6de3e LC |
6862 | where @var{system} is one of: |
6863 | ||
6864 | @table @code | |
6865 | @item x86_64-linux | |
6866 | for a GNU/Linux system on Intel/AMD-compatible 64-bit CPUs; | |
6867 | ||
6868 | @item i686-linux | |
6869 | for a 32-bit GNU/Linux system on Intel-compatible CPUs. | |
6870 | @end table | |
6871 | ||
debc6360 LC |
6872 | @c start duplication of authentication part from ``Binary Installation'' |
6873 | Make sure to download the associated @file{.sig} file and to verify the | |
6874 | authenticity of the image against it, along these lines: | |
6875 | ||
6876 | @example | |
6877 | $ wget ftp://alpha.gnu.org/gnu/guix/guixsd-usb-install-@value{VERSION}.@var{system}.xz.sig | |
6878 | $ gpg --verify guixsd-usb-install-@value{VERSION}.@var{system}.xz.sig | |
6879 | @end example | |
6880 | ||
6881 | If that command fails because you do not have the required public key, | |
6882 | then run this command to import it: | |
6883 | ||
6884 | @example | |
6885 | $ gpg --keyserver pgp.mit.edu --recv-keys @value{OPENPGP-SIGNING-KEY-ID} | |
6886 | @end example | |
6887 | ||
6888 | @noindent | |
6889 | and rerun the @code{gpg --verify} command. | |
6890 | @c end duplication | |
6891 | ||
5af6de3e LC |
6892 | This image contains a single partition with the tools necessary for an |
6893 | installation. It is meant to be copied @emph{as is} to a large-enough | |
6894 | USB stick. | |
6895 | ||
6896 | To copy the image to a USB stick, follow these steps: | |
6897 | ||
6898 | @enumerate | |
6899 | @item | |
6900 | Decompress the image using the @command{xz} command: | |
6901 | ||
6902 | @example | |
4705641f | 6903 | xz -d guixsd-usb-install-@value{VERSION}.@var{system}.xz |
5af6de3e LC |
6904 | @end example |
6905 | ||
6906 | @item | |
f97c9175 AE |
6907 | Insert a USB stick of 1@tie{}GiB or more into your machine, and determine |
6908 | its device name. Assuming that the USB stick is known as @file{/dev/sdX}, | |
5af6de3e LC |
6909 | copy the image with: |
6910 | ||
6911 | @example | |
4705641f | 6912 | dd if=guixsd-usb-install-@value{VERSION}.x86_64 of=/dev/sdX |
5af6de3e LC |
6913 | @end example |
6914 | ||
6915 | Access to @file{/dev/sdX} usually requires root privileges. | |
6916 | @end enumerate | |
6917 | ||
6918 | Once this is done, you should be able to reboot the system and boot from | |
6919 | the USB stick. The latter usually requires you to get in the BIOS' boot | |
6920 | menu, where you can choose to boot from the USB stick. | |
6921 | ||
c8b54374 VL |
6922 | @xref{Installing GuixSD in a VM}, if, instead, you would like to install |
6923 | GuixSD in a virtual machine (VM). | |
6924 | ||
dedb8d5e | 6925 | @node Preparing for Installation |
5af6de3e LC |
6926 | @subsection Preparing for Installation |
6927 | ||
6928 | Once you have successfully booted the image on the USB stick, you should | |
6929 | end up with a root prompt. Several console TTYs are configured and can | |
6930 | be used to run commands as root. TTY2 shows this documentation, | |
de341e7c LC |
6931 | browsable using the Info reader commands (@pxref{Top,,, info-stnd, |
6932 | Stand-alone GNU Info}). The installation system runs the GPM mouse | |
6933 | daemon, which allows you to select text with the left mouse button and | |
6934 | to paste it with the middle button. | |
5af6de3e | 6935 | |
ff925d37 LC |
6936 | @quotation Note |
6937 | Installation requires access to the Internet so that any missing | |
6938 | dependencies of your system configuration can be downloaded. See the | |
6939 | ``Networking'' section below. | |
6940 | @end quotation | |
6941 | ||
0e69cf67 LC |
6942 | The installation system includes many common tools needed for this task. |
6943 | But it is also a full-blown GuixSD system, which means that you can | |
6944 | install additional packages, should you need it, using @command{guix | |
6945 | package} (@pxref{Invoking guix package}). | |
6946 | ||
dedb8d5e | 6947 | @subsubsection Keyboard Layout |
5af6de3e | 6948 | |
dedb8d5e LC |
6949 | @cindex keyboard layout |
6950 | The installation image uses the US qwerty keyboard layout. If you want | |
6951 | to change it, you can use the @command{loadkeys} command. For example, | |
6952 | the following command selects the Dvorak keyboard layout: | |
5af6de3e | 6953 | |
dedb8d5e LC |
6954 | @example |
6955 | loadkeys dvorak | |
6956 | @end example | |
6957 | ||
6958 | See the files under @file{/run/current-system/profile/share/keymaps} for | |
6959 | a list of available keyboard layouts. Run @command{man loadkeys} for | |
6960 | more information. | |
6961 | ||
6962 | @subsubsection Networking | |
6963 | ||
6964 | Run the following command see what your network interfaces are called: | |
235cba85 LC |
6965 | |
6966 | @example | |
dedb8d5e | 6967 | ifconfig -a |
235cba85 LC |
6968 | @end example |
6969 | ||
1713c37f LC |
6970 | @noindent |
6971 | @dots{} or, using the GNU/Linux-specific @command{ip} command: | |
6972 | ||
6973 | @example | |
6974 | ip a | |
6975 | @end example | |
6976 | ||
95c559c1 | 6977 | @c http://cgit.freedesktop.org/systemd/systemd/tree/src/udev/udev-builtin-net_id.c#n20 |
dedb8d5e LC |
6978 | Wired interfaces have a name starting with @samp{e}; for example, the |
6979 | interface corresponding to the first on-board Ethernet controller is | |
6980 | called @samp{eno1}. Wireless interfaces have a name starting with | |
6981 | @samp{w}, like @samp{w1p2s0}. | |
6982 | ||
6983 | @table @asis | |
6984 | @item Wired connection | |
6985 | To configure a wired network run the following command, substituting | |
6986 | @var{interface} with the name of the wired interface you want to use. | |
6987 | ||
6988 | @example | |
6989 | ifconfig @var{interface} up | |
6990 | @end example | |
6991 | ||
6992 | @item Wireless connection | |
e32171ee JD |
6993 | @cindex wireless |
6994 | @cindex WiFi | |
dedb8d5e LC |
6995 | To configure wireless networking, you can create a configuration file |
6996 | for the @command{wpa_supplicant} configuration tool (its location is not | |
6997 | important) using one of the available text editors such as | |
6998 | @command{zile}: | |
6999 | ||
7000 | @example | |
7001 | zile wpa_supplicant.conf | |
7002 | @end example | |
7003 | ||
7004 | As an example, the following stanza can go to this file and will work | |
7005 | for many wireless networks, provided you give the actual SSID and | |
7006 | passphrase for the network you are connecting to: | |
7007 | ||
7008 | @example | |
7009 | network=@{ | |
ae768308 | 7010 | ssid="@var{my-ssid}" |
dedb8d5e LC |
7011 | key_mgmt=WPA-PSK |
7012 | psk="the network's secret passphrase" | |
7013 | @} | |
7014 | @end example | |
7015 | ||
7016 | Start the wireless service and run it in the background with the | |
7017 | following command (substitute @var{interface} with the name of the | |
7018 | network interface you want to use): | |
7019 | ||
7020 | @example | |
7021 | wpa_supplicant -c wpa_supplicant.conf -i @var{interface} -B | |
7022 | @end example | |
7023 | ||
641d0518 | 7024 | Run @command{man wpa_supplicant} for more information. |
dedb8d5e LC |
7025 | @end table |
7026 | ||
e32171ee | 7027 | @cindex DHCP |
dedb8d5e LC |
7028 | At this point, you need to acquire an IP address. On a network where IP |
7029 | addresses are automatically assigned @i{via} DHCP, you can run: | |
7030 | ||
7031 | @example | |
15650ac2 | 7032 | dhclient -v @var{interface} |
dedb8d5e | 7033 | @end example |
5af6de3e | 7034 | |
dedb8d5e LC |
7035 | Try to ping a server to see if networking is up and running: |
7036 | ||
7037 | @example | |
7038 | ping -c 3 gnu.org | |
7039 | @end example | |
5af6de3e LC |
7040 | |
7041 | Setting up network access is almost always a requirement because the | |
7042 | image does not contain all the software and tools that may be needed. | |
7043 | ||
dedb8d5e LC |
7044 | @subsubsection Disk Partitioning |
7045 | ||
7046 | Unless this has already been done, the next step is to partition, and | |
7047 | then format the target partition(s). | |
7048 | ||
7049 | The installation image includes several partitioning tools, including | |
7050 | Parted (@pxref{Overview,,, parted, GNU Parted User Manual}), | |
7051 | @command{fdisk}, and @command{cfdisk}. Run it and set up your disk with | |
7052 | the partition layout you want: | |
7053 | ||
7054 | @example | |
7055 | cfdisk | |
7056 | @end example | |
7057 | ||
d918d79f SB |
7058 | If your disk uses the GUID Partition Table (GPT) format and you plan to |
7059 | install BIOS-based GRUB (which is the default), make sure a BIOS Boot | |
7060 | Partition is available (@pxref{BIOS installation,,, grub, GNU GRUB | |
7061 | manual}). | |
7062 | ||
dedb8d5e LC |
7063 | Once you are done partitioning the target hard disk drive, you have to |
7064 | create a file system on the relevant partition(s)@footnote{Currently | |
b1a505ba DC |
7065 | GuixSD only supports ext4 and btrfs file systems. In particular, code |
7066 | that reads partition UUIDs and labels only works for these file system | |
7067 | types.}. | |
5af6de3e | 7068 | |
7ab44369 LC |
7069 | Preferably, assign partitions a label so that you can easily and |
7070 | reliably refer to them in @code{file-system} declarations (@pxref{File | |
7071 | Systems}). This is typically done using the @code{-L} option of | |
dedb8d5e LC |
7072 | @command{mkfs.ext4} and related commands. So, assuming the target root |
7073 | partition lives at @file{/dev/sda1}, a file system with the label | |
7074 | @code{my-root} can be created with: | |
7ab44369 | 7075 | |
dedb8d5e LC |
7076 | @example |
7077 | mkfs.ext4 -L my-root /dev/sda1 | |
7078 | @end example | |
dd816355 | 7079 | |
13fb1bd9 LC |
7080 | @cindex encrypted disk |
7081 | If you are instead planning to encrypt the root partition, you can use | |
7082 | the Cryptsetup/LUKS utilities to do that (see @inlinefmtifelse{html, | |
7083 | @uref{https://linux.die.net/man/8/cryptsetup, @code{man cryptsetup}}, | |
7084 | @code{man cryptsetup}} for more information.) Assuming you want to | |
7085 | store the root partition on @file{/dev/sda1}, the command sequence would | |
7086 | be along these lines: | |
6d6e6281 | 7087 | |
13fb1bd9 LC |
7088 | @example |
7089 | cryptsetup luksFormat /dev/sda1 | |
7090 | cryptsetup open --type luks /dev/sda1 my-partition | |
7091 | mkfs.ext4 -L my-root /dev/mapper/my-partition | |
7092 | @end example | |
5af6de3e | 7093 | |
dedb8d5e | 7094 | Once that is done, mount the target root partition under @file{/mnt} |
13fb1bd9 LC |
7095 | with a command like (again, assuming @code{my-root} is the label of the |
7096 | root partition): | |
83a17b62 | 7097 | |
dedb8d5e | 7098 | @example |
13fb1bd9 | 7099 | mount LABEL=my-root /mnt |
dedb8d5e | 7100 | @end example |
83a17b62 | 7101 | |
31b6cdf8 LC |
7102 | Finally, if you plan to use one or more swap partitions (@pxref{Memory |
7103 | Concepts, swap space,, libc, The GNU C Library Reference Manual}), make | |
7104 | sure to initialize them with @command{mkswap}. Assuming you have one | |
7105 | swap partition on @file{/dev/sda2}, you would run: | |
7106 | ||
7107 | @example | |
7108 | mkswap /dev/sda2 | |
b2ff76a0 | 7109 | swapon /dev/sda2 |
31b6cdf8 LC |
7110 | @end example |
7111 | ||
a4ca4362 CM |
7112 | Alternatively, you may use a swap file. For example, assuming that in |
7113 | the new system you want to use the file @file{/swapfile} as a swap file, | |
7114 | you would run@footnote{This example will work for many types of file | |
7115 | systems (e.g., ext4). However, for copy-on-write file systems (e.g., | |
7116 | btrfs), the required steps may be different. For details, see the | |
7117 | manual pages for @command{mkswap} and @command{swapon}.}: | |
7118 | ||
7119 | @example | |
7120 | # This is 10 GiB of swap space. Adjust "count" to change the size. | |
7121 | dd if=/dev/zero of=/mnt/swapfile bs=1MiB count=10240 | |
7122 | # For security, make the file readable and writable only by root. | |
7123 | chmod 600 /mnt/swapfile | |
7124 | mkswap /mnt/swapfile | |
7125 | swapon /mnt/swapfile | |
7126 | @end example | |
7127 | ||
7128 | Note that if you have encrypted the root partition and created a swap | |
7129 | file in its file system as described above, then the encryption also | |
7130 | protects the swap file, just like any other file in that file system. | |
7131 | ||
dedb8d5e LC |
7132 | @node Proceeding with the Installation |
7133 | @subsection Proceeding with the Installation | |
83a17b62 | 7134 | |
dedb8d5e LC |
7135 | With the target partitions ready and the target root mounted on |
7136 | @file{/mnt}, we're ready to go. First, run: | |
5af6de3e | 7137 | |
dedb8d5e LC |
7138 | @example |
7139 | herd start cow-store /mnt | |
7140 | @end example | |
5af6de3e | 7141 | |
b397c0d5 LC |
7142 | This makes @file{/gnu/store} copy-on-write, such that packages added to it |
7143 | during the installation phase are written to the target disk on @file{/mnt} | |
7144 | rather than kept in memory. This is necessary because the first phase of | |
7145 | the @command{guix system init} command (see below) entails downloads or | |
7146 | builds to @file{/gnu/store} which, initially, is an in-memory file system. | |
5af6de3e | 7147 | |
dedb8d5e | 7148 | Next, you have to edit a file and |
5af6de3e | 7149 | provide the declaration of the operating system to be installed. To |
a8cb87ab LC |
7150 | that end, the installation system comes with three text editors: GNU nano |
7151 | (@pxref{Top,,, nano, GNU nano Manual}), GNU Zile (an Emacs clone), and | |
7152 | nvi (a clone of the original BSD @command{vi} editor). | |
efa77c6c LC |
7153 | We strongly recommend storing that file on the target root file system, say, |
7154 | as @file{/mnt/etc/config.scm}. Failing to do that, you will have lost your | |
7155 | configuration file once you have rebooted into the newly-installed system. | |
5af6de3e | 7156 | |
dedb8d5e LC |
7157 | @xref{Using the Configuration System}, for an overview of the |
7158 | configuration file. The example configurations discussed in that | |
7159 | section are available under @file{/etc/configuration} in the | |
7160 | installation image. Thus, to get started with a system configuration | |
7161 | providing a graphical display server (a ``desktop'' system), you can run | |
7162 | something along these lines: | |
7163 | ||
7164 | @example | |
7165 | # mkdir /mnt/etc | |
7166 | # cp /etc/configuration/desktop.scm /mnt/etc/config.scm | |
7167 | # zile /mnt/etc/config.scm | |
7168 | @end example | |
7169 | ||
7170 | You should pay attention to what your configuration file contains, and | |
7171 | in particular: | |
7172 | ||
7173 | @itemize | |
7174 | @item | |
7175 | Make sure the @code{grub-configuration} form refers to the device you | |
7176 | want to install GRUB on. | |
7177 | ||
7178 | @item | |
7179 | Be sure that your partition labels match the value of their respective | |
7180 | @code{device} fields in your @code{file-system} configuration, assuming | |
7181 | your @code{file-system} configuration sets the value of @code{title} to | |
7182 | @code{'label}. | |
13fb1bd9 LC |
7183 | |
7184 | @item | |
7185 | If there are encrypted or RAID partitions, make sure to add a | |
7186 | @code{mapped-devices} field to describe them (@pxref{Mapped Devices}). | |
dedb8d5e | 7187 | @end itemize |
5af6de3e | 7188 | |
dd51caac LC |
7189 | Once you are done preparing the configuration file, the new system must |
7190 | be initialized (remember that the target root file system is mounted | |
7191 | under @file{/mnt}): | |
5af6de3e LC |
7192 | |
7193 | @example | |
7194 | guix system init /mnt/etc/config.scm /mnt | |
7195 | @end example | |
7196 | ||
7197 | @noindent | |
dedb8d5e | 7198 | This copies all the necessary files and installs GRUB on |
5af6de3e | 7199 | @file{/dev/sdX}, unless you pass the @option{--no-grub} option. For |
6621cdb6 | 7200 | more information, @pxref{Invoking guix system}. This command may trigger |
5af6de3e LC |
7201 | downloads or builds of missing packages, which can take some time. |
7202 | ||
1bd4e6db LC |
7203 | Once that command has completed---and hopefully succeeded!---you can run |
7204 | @command{reboot} and boot into the new system. The @code{root} password | |
7205 | in the new system is initially empty; other users' passwords need to be | |
7206 | initialized by running the @command{passwd} command as @code{root}, | |
7207 | unless your configuration specifies otherwise | |
7208 | (@pxref{user-account-password, user account passwords}). | |
7209 | ||
7fcf2a0b LC |
7210 | @cindex upgrading GuixSD |
7211 | From then on, you can update GuixSD whenever you want by running | |
7212 | @command{guix pull} as @code{root} (@pxref{Invoking guix pull}), and | |
7213 | then running @command{guix system reconfigure} to build a new system | |
7214 | generation with the latest packages and services (@pxref{Invoking guix | |
7215 | system}). We recommend doing that regularly so that your system | |
7216 | includes the latest security updates (@pxref{Security Updates}). | |
7217 | ||
1bd4e6db | 7218 | Join us on @code{#guix} on the Freenode IRC network or on |
5af6de3e LC |
7219 | @file{guix-devel@@gnu.org} to share your experience---good or not so |
7220 | good. | |
7221 | ||
c8b54374 VL |
7222 | @node Installing GuixSD in a VM |
7223 | @subsection Installing GuixSD in a Virtual Machine | |
7224 | ||
7225 | @cindex virtual machine, GuixSD installation | |
7226 | If you'd like to install GuixSD in a virtual machine (VM) rather than on | |
7227 | your beloved machine, this section is for you. | |
7228 | ||
7229 | To boot a @uref{http://qemu.org/,QEMU} VM for installing GuixSD in a | |
7230 | disk image, follow these steps: | |
7231 | ||
7232 | @enumerate | |
7233 | @item | |
a0885414 LF |
7234 | First, retrieve and decompress the GuixSD installation image as |
7235 | described previously (@pxref{USB Stick Installation}). | |
c8b54374 VL |
7236 | |
7237 | @item | |
7238 | Create a disk image that will hold the installed system. To make a | |
7239 | qcow2-formatted disk image, use the @command{qemu-img} command: | |
7240 | ||
7241 | @example | |
7242 | qemu-img create -f qcow2 guixsd.img 5G | |
7243 | @end example | |
7244 | ||
7245 | This will create a 5GB file. | |
7246 | ||
7247 | @item | |
7248 | Boot the USB installation image in an VM: | |
7249 | ||
7250 | @example | |
7251 | qemu-system-x86_64 -m 1024 -smp 1 \ | |
d36b8457 | 7252 | -net user -net nic,model=virtio -boot menu=on \ |
c8b54374 VL |
7253 | -drive file=guixsd.img \ |
7254 | -drive file=guixsd-usb-install-@value{VERSION}.@var{system} | |
7255 | @end example | |
7256 | ||
7257 | In the VM console, quickly press the @kbd{F12} key to enter the boot | |
7258 | menu. Then press the @kbd{2} key and the @kbd{RET} key to validate your | |
7259 | selection. | |
7260 | ||
7261 | @item | |
7262 | You're now root in the VM, proceed with the installation process. | |
7263 | @xref{Preparing for Installation}, and follow the instructions. | |
7264 | @end enumerate | |
7265 | ||
7266 | Once installation is complete, you can boot the system that's on your | |
7267 | @file{guixsd.img} image. @xref{Running GuixSD in a VM}, for how to do | |
7268 | that. | |
7269 | ||
dedb8d5e | 7270 | @node Building the Installation Image |
5af6de3e LC |
7271 | @subsection Building the Installation Image |
7272 | ||
e32171ee | 7273 | @cindex installation image |
5af6de3e LC |
7274 | The installation image described above was built using the @command{guix |
7275 | system} command, specifically: | |
7276 | ||
622b2304 | 7277 | @c FIXME: 1G is too much; see <http://bugs.gnu.org/23077>. |
5af6de3e | 7278 | @example |
622b2304 | 7279 | guix system disk-image --image-size=1G gnu/system/install.scm |
5af6de3e LC |
7280 | @end example |
7281 | ||
6e6a0401 AE |
7282 | Have a look at @file{gnu/system/install.scm} in the source tree, |
7283 | and see also @ref{Invoking guix system} for more information | |
5af6de3e LC |
7284 | about the installation image. |
7285 | ||
cf4a9129 LC |
7286 | @node System Configuration |
7287 | @section System Configuration | |
b208a005 | 7288 | |
cf4a9129 | 7289 | @cindex system configuration |
3ca2731c | 7290 | The Guix System Distribution supports a consistent whole-system configuration |
cf4a9129 LC |
7291 | mechanism. By that we mean that all aspects of the global system |
7292 | configuration---such as the available system services, timezone and | |
7293 | locale settings, user accounts---are declared in a single place. Such | |
7294 | a @dfn{system configuration} can be @dfn{instantiated}---i.e., effected. | |
91ef73d4 | 7295 | |
cf4a9129 LC |
7296 | One of the advantages of putting all the system configuration under the |
7297 | control of Guix is that it supports transactional system upgrades, and | |
1068f26b | 7298 | makes it possible to roll back to a previous system instantiation, |
cf4a9129 | 7299 | should something go wrong with the new one (@pxref{Features}). Another |
1068f26b | 7300 | advantage is that it makes it easy to replicate the exact same configuration |
cf4a9129 LC |
7301 | across different machines, or at different points in time, without |
7302 | having to resort to additional administration tools layered on top of | |
1068f26b | 7303 | the own tools of the system. |
cf4a9129 | 7304 | @c Yes, we're talking of Puppet, Chef, & co. here. ↑ |
91ef73d4 | 7305 | |
cf4a9129 LC |
7306 | This section describes this mechanism. First we focus on the system |
7307 | administrator's viewpoint---explaining how the system is configured and | |
7308 | instantiated. Then we show how this mechanism can be extended, for | |
7309 | instance to support new system services. | |
91ef73d4 | 7310 | |
cf4a9129 LC |
7311 | @menu |
7312 | * Using the Configuration System:: Customizing your GNU system. | |
7313a52e | 7313 | * operating-system Reference:: Detail of operating-system declarations. |
cf4a9129 | 7314 | * File Systems:: Configuring file system mounts. |
510f9d86 | 7315 | * Mapped Devices:: Block device extra processing. |
cf4a9129 | 7316 | * User Accounts:: Specifying user accounts. |
598e19dc | 7317 | * Locales:: Language and cultural convention settings. |
cf4a9129 | 7318 | * Services:: Specifying system services. |
0ae8c15a | 7319 | * Setuid Programs:: Programs running with root privileges. |
efb5e833 | 7320 | * X.509 Certificates:: Authenticating HTTPS servers. |
996ed739 | 7321 | * Name Service Switch:: Configuring libc's name service switch. |
fd1b1fa2 | 7322 | * Initial RAM Disk:: Linux-Libre bootstrapping. |
88faf933 | 7323 | * GRUB Configuration:: Configuring the boot loader. |
cf4a9129 | 7324 | * Invoking guix system:: Instantiating a system configuration. |
97d76250 | 7325 | * Running GuixSD in a VM:: How to run GuixSD in a virtual machine. |
cf4a9129 LC |
7326 | * Defining Services:: Adding new service definitions. |
7327 | @end menu | |
91ef73d4 | 7328 | |
cf4a9129 LC |
7329 | @node Using the Configuration System |
7330 | @subsection Using the Configuration System | |
64d76fa6 | 7331 | |
cf4a9129 LC |
7332 | The operating system is configured by providing an |
7333 | @code{operating-system} declaration in a file that can then be passed to | |
7334 | the @command{guix system} command (@pxref{Invoking guix system}). A | |
7335 | simple setup, with the default system services, the default Linux-Libre | |
7336 | kernel, initial RAM disk, and boot loader looks like this: | |
91ef73d4 | 7337 | |
cf4a9129 LC |
7338 | @findex operating-system |
7339 | @lisp | |
dd51caac | 7340 | @include os-config-bare-bones.texi |
cf4a9129 | 7341 | @end lisp |
401c53c4 | 7342 | |
cf4a9129 LC |
7343 | This example should be self-describing. Some of the fields defined |
7344 | above, such as @code{host-name} and @code{bootloader}, are mandatory. | |
7345 | Others, such as @code{packages} and @code{services}, can be omitted, in | |
7346 | which case they get a default value. | |
e7f34eb0 | 7347 | |
5d94ac51 LC |
7348 | Below we discuss the effect of some of the most important fields |
7349 | (@pxref{operating-system Reference}, for details about all the available | |
7350 | fields), and how to @dfn{instantiate} the operating system using | |
7351 | @command{guix system}. | |
7352 | ||
7353 | @unnumberedsubsubsec Globally-Visible Packages | |
7354 | ||
cf4a9129 | 7355 | @vindex %base-packages |
5d94ac51 LC |
7356 | The @code{packages} field lists packages that will be globally visible |
7357 | on the system, for all user accounts---i.e., in every user's @code{PATH} | |
7358 | environment variable---in addition to the per-user profiles | |
7359 | (@pxref{Invoking guix package}). The @var{%base-packages} variable | |
7360 | provides all the tools one would expect for basic user and administrator | |
7361 | tasks---including the GNU Core Utilities, the GNU Networking Utilities, | |
7362 | the GNU Zile lightweight text editor, @command{find}, @command{grep}, | |
7363 | etc. The example above adds tcpdump to those, taken from the @code{(gnu | |
7364 | packages admin)} module (@pxref{Package Modules}). | |
e7f34eb0 | 7365 | |
f6c9fb1b LC |
7366 | @findex specification->package |
7367 | Referring to packages by variable name, like @var{tcpdump} above, has | |
7368 | the advantage of being unambiguous; it also allows typos and such to be | |
7369 | diagnosed right away as ``unbound variables''. The downside is that one | |
7370 | needs to know which module defines which package, and to augment the | |
7371 | @code{use-package-modules} line accordingly. To avoid that, one can use | |
7372 | the @code{specification->package} procedure of the @code{(gnu packages)} | |
7373 | module, which returns the best package for a given name or name and | |
7374 | version: | |
7375 | ||
7376 | @lisp | |
7377 | (use-modules (gnu packages)) | |
7378 | ||
7379 | (operating-system | |
7380 | ;; ... | |
7381 | (packages (append (map specification->package | |
d5e59248 | 7382 | '("tcpdump" "htop" "gnupg@@2.0")) |
f6c9fb1b LC |
7383 | %base-packages))) |
7384 | @end lisp | |
7385 | ||
5d94ac51 LC |
7386 | @unnumberedsubsubsec System Services |
7387 | ||
e32171ee | 7388 | @cindex services |
cf4a9129 LC |
7389 | @vindex %base-services |
7390 | The @code{services} field lists @dfn{system services} to be made | |
7391 | available when the system starts (@pxref{Services}). | |
7392 | The @code{operating-system} declaration above specifies that, in | |
7393 | addition to the basic services, we want the @command{lshd} secure shell | |
cd6f6c22 LC |
7394 | daemon listening on port 2222 (@pxref{Networking Services, |
7395 | @code{lsh-service}}). Under the hood, | |
cf4a9129 LC |
7396 | @code{lsh-service} arranges so that @code{lshd} is started with the |
7397 | right command-line options, possibly with supporting configuration files | |
cd6f6c22 LC |
7398 | generated as needed (@pxref{Defining Services}). |
7399 | ||
7400 | @cindex customization, of services | |
7401 | @findex modify-services | |
7402 | Occasionally, instead of using the base services as is, you will want to | |
4d343a14 CM |
7403 | customize them. To do this, use @code{modify-services} (@pxref{Service |
7404 | Reference, @code{modify-services}}) to modify the list. | |
7405 | ||
7406 | For example, suppose you want to modify @code{guix-daemon} and Mingetty | |
7407 | (the console log-in) in the @var{%base-services} list (@pxref{Base | |
7408 | Services, @code{%base-services}}). To do that, you can write the | |
7409 | following in your operating system declaration: | |
cd6f6c22 LC |
7410 | |
7411 | @lisp | |
4d343a14 CM |
7412 | (define %my-services |
7413 | ;; My very own list of services. | |
7414 | (modify-services %base-services | |
7415 | (guix-service-type config => | |
7416 | (guix-configuration | |
7417 | (inherit config) | |
7418 | (use-substitutes? #f) | |
7419 | (extra-options '("--gc-keep-derivations")))) | |
7420 | (mingetty-service-type config => | |
7421 | (mingetty-configuration | |
317d3b47 | 7422 | (inherit config))))) |
4d343a14 CM |
7423 | |
7424 | (operating-system | |
7425 | ;; @dots{} | |
7426 | (services %my-services)) | |
cd6f6c22 LC |
7427 | @end lisp |
7428 | ||
4d343a14 CM |
7429 | This changes the configuration---i.e., the service parameters---of the |
7430 | @code{guix-service-type} instance, and that of all the | |
7431 | @code{mingetty-service-type} instances in the @var{%base-services} list. | |
7432 | Observe how this is accomplished: first, we arrange for the original | |
7433 | configuration to be bound to the identifier @code{config} in the | |
7434 | @var{body}, and then we write the @var{body} so that it evaluates to the | |
7435 | desired configuration. In particular, notice how we use @code{inherit} | |
7436 | to create a new configuration which has the same values as the old | |
7437 | configuration, but with a few modifications. | |
a1ba8475 | 7438 | |
13fb1bd9 LC |
7439 | @cindex encrypted disk |
7440 | The configuration for a typical ``desktop'' usage, with an encrypted | |
7441 | root partition, the X11 display | |
d038b674 LC |
7442 | server, GNOME and Xfce (users can choose which of these desktop |
7443 | environments to use at the log-in screen by pressing @kbd{F1}), network | |
7444 | management, power management, and more, would look like this: | |
dd51caac LC |
7445 | |
7446 | @lisp | |
7447 | @include os-config-desktop.texi | |
7448 | @end lisp | |
7449 | ||
d038b674 LC |
7450 | A graphical environment with a choice of lightweight window managers |
7451 | instead of full-blown desktop environments would look like this: | |
7452 | ||
7453 | @lisp | |
7454 | @include os-config-lightweight-desktop.texi | |
7455 | @end lisp | |
7456 | ||
dd51caac | 7457 | @xref{Desktop Services}, for the exact list of services provided by |
efb5e833 LC |
7458 | @var{%desktop-services}. @xref{X.509 Certificates}, for background |
7459 | information about the @code{nss-certs} package that is used here. | |
dd51caac | 7460 | |
5d94ac51 LC |
7461 | Again, @var{%desktop-services} is just a list of service objects. If |
7462 | you want to remove services from there, you can do so using the | |
7463 | procedures for list filtering (@pxref{SRFI-1 Filtering and | |
7464 | Partitioning,,, guile, GNU Guile Reference Manual}). For instance, the | |
7465 | following expression returns a list that contains all the services in | |
7466 | @var{%desktop-services} minus the Avahi service: | |
7467 | ||
7468 | @example | |
7469 | (remove (lambda (service) | |
7470 | (eq? (service-kind service) avahi-service-type)) | |
7471 | %desktop-services) | |
7472 | @end example | |
7473 | ||
7474 | @unnumberedsubsubsec Instantiating the System | |
7475 | ||
7476 | Assuming the @code{operating-system} declaration | |
7477 | is stored in the @file{my-system-config.scm} | |
cf4a9129 LC |
7478 | file, the @command{guix system reconfigure my-system-config.scm} command |
7479 | instantiates that configuration, and makes it the default GRUB boot | |
65797bff LC |
7480 | entry (@pxref{Invoking guix system}). |
7481 | ||
1068f26b | 7482 | The normal way to change the system configuration is by updating this |
65797bff | 7483 | file and re-running @command{guix system reconfigure}. One should never |
8b499030 | 7484 | have to touch files in @file{/etc} or to run commands that modify the |
65797bff LC |
7485 | system state such as @command{useradd} or @command{grub-install}. In |
7486 | fact, you must avoid that since that would not only void your warranty | |
7487 | but also prevent you from rolling back to previous versions of your | |
7488 | system, should you ever need to. | |
7489 | ||
7490 | @cindex roll-back, of the operating system | |
7491 | Speaking of roll-back, each time you run @command{guix system | |
7492 | reconfigure}, a new @dfn{generation} of the system is created---without | |
7493 | modifying or deleting previous generations. Old system generations get | |
7494 | an entry in the GRUB boot menu, allowing you to boot them in case | |
7495 | something went wrong with the latest generation. Reassuring, no? The | |
7496 | @command{guix system list-generations} command lists the system | |
067a2e2d CM |
7497 | generations available on disk. It is also possible to roll back the |
7498 | system via the commands @command{guix system roll-back} and | |
7499 | @command{guix system switch-generation}. | |
7500 | ||
7501 | Although the command @command{guix system reconfigure} will not modify | |
7502 | previous generations, must take care when the current generation is not | |
7503 | the latest (e.g., after invoking @command{guix system roll-back}), since | |
7504 | the operation might overwrite a later generation (@pxref{Invoking guix | |
7505 | system}). | |
b81e1947 | 7506 | |
5d94ac51 LC |
7507 | @unnumberedsubsubsec The Programming Interface |
7508 | ||
cf4a9129 LC |
7509 | At the Scheme level, the bulk of an @code{operating-system} declaration |
7510 | is instantiated with the following monadic procedure (@pxref{The Store | |
7511 | Monad}): | |
b81e1947 | 7512 | |
cf4a9129 LC |
7513 | @deffn {Monadic Procedure} operating-system-derivation os |
7514 | Return a derivation that builds @var{os}, an @code{operating-system} | |
7515 | object (@pxref{Derivations}). | |
b81e1947 | 7516 | |
cf4a9129 LC |
7517 | The output of the derivation is a single directory that refers to all |
7518 | the packages, configuration files, and other supporting files needed to | |
7519 | instantiate @var{os}. | |
7520 | @end deffn | |
b81e1947 | 7521 | |
5d94ac51 LC |
7522 | This procedure is provided by the @code{(gnu system)} module. Along |
7523 | with @code{(gnu services)} (@pxref{Services}), this module contains the | |
7524 | guts of GuixSD. Make sure to visit it! | |
7525 | ||
7526 | ||
7313a52e LC |
7527 | @node operating-system Reference |
7528 | @subsection @code{operating-system} Reference | |
7529 | ||
7530 | This section summarizes all the options available in | |
7531 | @code{operating-system} declarations (@pxref{Using the Configuration | |
7532 | System}). | |
7533 | ||
7534 | @deftp {Data Type} operating-system | |
7535 | This is the data type representing an operating system configuration. | |
7536 | By that, we mean all the global system configuration, not per-user | |
7537 | configuration (@pxref{Using the Configuration System}). | |
7538 | ||
7539 | @table @asis | |
7540 | @item @code{kernel} (default: @var{linux-libre}) | |
fbb25e56 | 7541 | The package object of the operating system kernel to use@footnote{Currently |
7313a52e LC |
7542 | only the Linux-libre kernel is supported. In the future, it will be |
7543 | possible to use the GNU@tie{}Hurd.}. | |
7544 | ||
ee2a6304 LC |
7545 | @item @code{kernel-arguments} (default: @code{'()}) |
7546 | List of strings or gexps representing additional arguments to pass on | |
1068f26b | 7547 | the command-line of the kernel---e.g., @code{("console=ttyS0")}. |
ee2a6304 | 7548 | |
7313a52e | 7549 | @item @code{bootloader} |
88faf933 | 7550 | The system bootloader configuration object. @xref{GRUB Configuration}. |
7313a52e LC |
7551 | |
7552 | @item @code{initrd} (default: @code{base-initrd}) | |
e32171ee JD |
7553 | @cindex initrd |
7554 | @cindex initial RAM disk | |
7313a52e LC |
7555 | A two-argument monadic procedure that returns an initial RAM disk for |
7556 | the Linux kernel. @xref{Initial RAM Disk}. | |
7557 | ||
f34c56be LC |
7558 | @item @code{firmware} (default: @var{%base-firmware}) |
7559 | @cindex firmware | |
7560 | List of firmware packages loadable by the operating system kernel. | |
7561 | ||
52db41af EB |
7562 | The default includes firmware needed for Atheros- and Broadcom-based |
7563 | WiFi devices (Linux-libre modules @code{ath9k} and @code{b43-open}, | |
7564 | respectively). @xref{Hardware Considerations}, for more info on | |
7565 | supported hardware. | |
f34c56be | 7566 | |
7313a52e LC |
7567 | @item @code{host-name} |
7568 | The host name. | |
7569 | ||
7570 | @item @code{hosts-file} | |
7571 | @cindex hosts file | |
24e02c28 | 7572 | A file-like object (@pxref{G-Expressions, file-like objects}) for use as |
7313a52e | 7573 | @file{/etc/hosts} (@pxref{Host Names,,, libc, The GNU C Library |
24e02c28 | 7574 | Reference Manual}). The default is a file with entries for |
7313a52e LC |
7575 | @code{localhost} and @var{host-name}. |
7576 | ||
7577 | @item @code{mapped-devices} (default: @code{'()}) | |
7578 | A list of mapped devices. @xref{Mapped Devices}. | |
7579 | ||
7580 | @item @code{file-systems} | |
7581 | A list of file systems. @xref{File Systems}. | |
7582 | ||
7583 | @item @code{swap-devices} (default: @code{'()}) | |
7584 | @cindex swap devices | |
a4ca4362 CM |
7585 | A list of strings identifying devices or files to be used for ``swap |
7586 | space'' (@pxref{Memory Concepts,,, libc, The GNU C Library Reference | |
7587 | Manual}). For example, @code{'("/dev/sda3")} or @code{'("/swapfile")}. | |
7588 | It is possible to specify a swap file in a file system on a mapped | |
7589 | device, provided that the necessary device mapping and file system are | |
7590 | also specified. @xref{Mapped Devices} and @ref{File Systems}. | |
7313a52e | 7591 | |
bf87f38a | 7592 | @item @code{users} (default: @code{%base-user-accounts}) |
7313a52e LC |
7593 | @itemx @code{groups} (default: @var{%base-groups}) |
7594 | List of user accounts and groups. @xref{User Accounts}. | |
7595 | ||
7596 | @item @code{skeletons} (default: @code{(default-skeletons)}) | |
e9dffec1 LC |
7597 | A list target file name/file-like object tuples (@pxref{G-Expressions, |
7598 | file-like objects}). These are the skeleton files that will be added to | |
7599 | the home directory of newly-created user accounts. | |
7313a52e LC |
7600 | |
7601 | For instance, a valid value may look like this: | |
7602 | ||
7603 | @example | |
e9dffec1 LC |
7604 | `((".bashrc" ,(plain-file "bashrc" "echo Hello\n")) |
7605 | (".guile" ,(plain-file "guile" | |
7606 | "(use-modules (ice-9 readline)) | |
7607 | (activate-readline)"))) | |
7313a52e LC |
7608 | @end example |
7609 | ||
7610 | @item @code{issue} (default: @var{%default-issue}) | |
7611 | A string denoting the contents of the @file{/etc/issue} file, which is | |
1068f26b | 7612 | displayed when users log in on a text console. |
7313a52e LC |
7613 | |
7614 | @item @code{packages} (default: @var{%base-packages}) | |
7615 | The set of packages installed in the global profile, which is accessible | |
7616 | at @file{/run/current-system/profile}. | |
7617 | ||
1068f26b | 7618 | The default set includes core utilities and it is good practice to |
7313a52e LC |
7619 | install non-core utilities in user profiles (@pxref{Invoking guix |
7620 | package}). | |
7621 | ||
7622 | @item @code{timezone} | |
7623 | A timezone identifying string---e.g., @code{"Europe/Paris"}. | |
7624 | ||
17c20385 LC |
7625 | You can run the @command{tzselect} command to find out which timezone |
7626 | string corresponds to your region. Choosing an invalid timezone name | |
7627 | causes @command{guix system} to fail. | |
7628 | ||
598e19dc LC |
7629 | @item @code{locale} (default: @code{"en_US.utf8"}) |
7630 | The name of the default locale (@pxref{Locale Names,,, libc, The GNU C | |
7631 | Library Reference Manual}). @xref{Locales}, for more information. | |
7632 | ||
7633 | @item @code{locale-definitions} (default: @var{%default-locale-definitions}) | |
7634 | The list of locale definitions to be compiled and that may be used at | |
7635 | run time. @xref{Locales}. | |
7313a52e | 7636 | |
34760ae7 LC |
7637 | @item @code{locale-libcs} (default: @code{(list @var{glibc})}) |
7638 | The list of GNU@tie{}libc packages whose locale data and tools are used | |
7639 | to build the locale definitions. @xref{Locales}, for compatibility | |
7640 | considerations that justify this option. | |
7641 | ||
996ed739 | 7642 | @item @code{name-service-switch} (default: @var{%default-nss}) |
1068f26b | 7643 | Configuration of the libc name service switch (NSS)---a |
996ed739 LC |
7644 | @code{<name-service-switch>} object. @xref{Name Service Switch}, for |
7645 | details. | |
7646 | ||
7313a52e | 7647 | @item @code{services} (default: @var{%base-services}) |
28d939af | 7648 | A list of service objects denoting system services. @xref{Services}. |
7313a52e LC |
7649 | |
7650 | @item @code{pam-services} (default: @code{(base-pam-services)}) | |
7651 | @cindex PAM | |
7652 | @cindex pluggable authentication modules | |
7653 | Linux @dfn{pluggable authentication module} (PAM) services. | |
7654 | @c FIXME: Add xref to PAM services section. | |
7655 | ||
7656 | @item @code{setuid-programs} (default: @var{%setuid-programs}) | |
7657 | List of string-valued G-expressions denoting setuid programs. | |
7658 | @xref{Setuid Programs}. | |
7659 | ||
f5a9ffa0 AK |
7660 | @item @code{sudoers-file} (default: @var{%sudoers-specification}) |
7661 | @cindex sudoers file | |
84765839 LC |
7662 | The contents of the @file{/etc/sudoers} file as a file-like object |
7663 | (@pxref{G-Expressions, @code{local-file} and @code{plain-file}}). | |
7313a52e LC |
7664 | |
7665 | This file specifies which users can use the @command{sudo} command, what | |
7666 | they are allowed to do, and what privileges they may gain. The default | |
7667 | is that only @code{root} and members of the @code{wheel} group may use | |
7668 | @code{sudo}. | |
7669 | ||
7670 | @end table | |
7671 | @end deftp | |
7672 | ||
cf4a9129 LC |
7673 | @node File Systems |
7674 | @subsection File Systems | |
b81e1947 | 7675 | |
cf4a9129 | 7676 | The list of file systems to be mounted is specified in the |
1068f26b | 7677 | @code{file-systems} field of the operating system declaration |
cf4a9129 LC |
7678 | (@pxref{Using the Configuration System}). Each file system is declared |
7679 | using the @code{file-system} form, like this: | |
b81e1947 LC |
7680 | |
7681 | @example | |
cf4a9129 LC |
7682 | (file-system |
7683 | (mount-point "/home") | |
7684 | (device "/dev/sda3") | |
7685 | (type "ext4")) | |
b81e1947 LC |
7686 | @end example |
7687 | ||
cf4a9129 LC |
7688 | As usual, some of the fields are mandatory---those shown in the example |
7689 | above---while others can be omitted. These are described below. | |
b81e1947 | 7690 | |
cf4a9129 LC |
7691 | @deftp {Data Type} file-system |
7692 | Objects of this type represent file systems to be mounted. They | |
7693 | contain the following members: | |
5ff3c4b8 | 7694 | |
cf4a9129 LC |
7695 | @table @asis |
7696 | @item @code{type} | |
7697 | This is a string specifying the type of the file system---e.g., | |
7698 | @code{"ext4"}. | |
5ff3c4b8 | 7699 | |
cf4a9129 LC |
7700 | @item @code{mount-point} |
7701 | This designates the place where the file system is to be mounted. | |
b81e1947 | 7702 | |
cf4a9129 LC |
7703 | @item @code{device} |
7704 | This names the ``source'' of the file system. By default it is the name | |
7705 | of a node under @file{/dev}, but its meaning depends on the @code{title} | |
7706 | field described below. | |
401c53c4 | 7707 | |
cf4a9129 LC |
7708 | @item @code{title} (default: @code{'device}) |
7709 | This is a symbol that specifies how the @code{device} field is to be | |
7710 | interpreted. | |
401c53c4 | 7711 | |
cf4a9129 LC |
7712 | When it is the symbol @code{device}, then the @code{device} field is |
7713 | interpreted as a file name; when it is @code{label}, then @code{device} | |
7714 | is interpreted as a partition label name; when it is @code{uuid}, | |
7715 | @code{device} is interpreted as a partition unique identifier (UUID). | |
da7cabd4 | 7716 | |
661a1d79 | 7717 | UUIDs may be converted from their string representation (as shown by the |
0767f6a6 LC |
7718 | @command{tune2fs -l} command) using the @code{uuid} form@footnote{The |
7719 | @code{uuid} form expects 16-byte UUIDs as defined in | |
7720 | @uref{https://tools.ietf.org/html/rfc4122, RFC@tie{}4122}. This is the | |
7721 | form of UUID used by the ext2 family of file systems and others, but it | |
7722 | is different from ``UUIDs'' found in FAT file systems, for instance.}, | |
7723 | like this: | |
661a1d79 LC |
7724 | |
7725 | @example | |
7726 | (file-system | |
7727 | (mount-point "/home") | |
7728 | (type "ext4") | |
7729 | (title 'uuid) | |
7730 | (device (uuid "4dab5feb-d176-45de-b287-9b0a6e4c01cb"))) | |
7731 | @end example | |
7732 | ||
cf4a9129 | 7733 | The @code{label} and @code{uuid} options offer a way to refer to disk |
661a1d79 LC |
7734 | partitions without having to hard-code their actual device |
7735 | name@footnote{Note that, while it is tempting to use | |
7736 | @file{/dev/disk/by-uuid} and similar device names to achieve the same | |
7737 | result, this is not recommended: These special device nodes are created | |
7738 | by the udev daemon and may be unavailable at the time the device is | |
7739 | mounted.}. | |
da7cabd4 | 7740 | |
1068f26b | 7741 | However, when the source of a file system is a mapped device (@pxref{Mapped |
5f86a66e LC |
7742 | Devices}), its @code{device} field @emph{must} refer to the mapped |
7743 | device name---e.g., @file{/dev/mapper/root-partition}---and consequently | |
7744 | @code{title} must be set to @code{'device}. This is required so that | |
7745 | the system knows that mounting the file system depends on having the | |
7746 | corresponding device mapping established. | |
7747 | ||
cf4a9129 LC |
7748 | @item @code{flags} (default: @code{'()}) |
7749 | This is a list of symbols denoting mount flags. Recognized flags | |
2c071ce9 LC |
7750 | include @code{read-only}, @code{bind-mount}, @code{no-dev} (disallow |
7751 | access to special files), @code{no-suid} (ignore setuid and setgid | |
7752 | bits), and @code{no-exec} (disallow program execution.) | |
da7cabd4 | 7753 | |
cf4a9129 LC |
7754 | @item @code{options} (default: @code{#f}) |
7755 | This is either @code{#f}, or a string denoting mount options. | |
da7cabd4 | 7756 | |
be21979d LC |
7757 | @item @code{mount?} (default: @code{#t}) |
7758 | This value indicates whether to automatically mount the file system when | |
7759 | the system is brought up. When set to @code{#f}, the file system gets | |
7760 | an entry in @file{/etc/fstab} (read by the @command{mount} command) but | |
7761 | is not automatically mounted. | |
7762 | ||
cf4a9129 LC |
7763 | @item @code{needed-for-boot?} (default: @code{#f}) |
7764 | This Boolean value indicates whether the file system is needed when | |
7765 | booting. If that is true, then the file system is mounted when the | |
7766 | initial RAM disk (initrd) is loaded. This is always the case, for | |
7767 | instance, for the root file system. | |
da7cabd4 | 7768 | |
cf4a9129 LC |
7769 | @item @code{check?} (default: @code{#t}) |
7770 | This Boolean indicates whether the file system needs to be checked for | |
7771 | errors before being mounted. | |
f9cc8971 | 7772 | |
4e469051 LC |
7773 | @item @code{create-mount-point?} (default: @code{#f}) |
7774 | When true, the mount point is created if it does not exist yet. | |
7775 | ||
e51710d1 | 7776 | @item @code{dependencies} (default: @code{'()}) |
13fb1bd9 LC |
7777 | This is a list of @code{<file-system>} or @code{<mapped-device>} objects |
7778 | representing file systems that must be mounted or mapped devices that | |
7779 | must be opened before (and unmounted or closed after) this one. | |
e51710d1 LC |
7780 | |
7781 | As an example, consider a hierarchy of mounts: @file{/sys/fs/cgroup} is | |
7782 | a dependency of @file{/sys/fs/cgroup/cpu} and | |
7783 | @file{/sys/fs/cgroup/memory}. | |
7784 | ||
13fb1bd9 LC |
7785 | Another example is a file system that depends on a mapped device, for |
7786 | example for an encrypted partition (@pxref{Mapped Devices}). | |
cf4a9129 LC |
7787 | @end table |
7788 | @end deftp | |
da7cabd4 | 7789 | |
a69576ea LC |
7790 | The @code{(gnu system file-systems)} exports the following useful |
7791 | variables. | |
7792 | ||
7793 | @defvr {Scheme Variable} %base-file-systems | |
7794 | These are essential file systems that are required on normal systems, | |
cc0e575a | 7795 | such as @var{%pseudo-terminal-file-system} and @var{%immutable-store} (see |
3392ce5d LC |
7796 | below.) Operating system declarations should always contain at least |
7797 | these. | |
a69576ea LC |
7798 | @end defvr |
7799 | ||
7f239fd3 LC |
7800 | @defvr {Scheme Variable} %pseudo-terminal-file-system |
7801 | This is the file system to be mounted as @file{/dev/pts}. It supports | |
7802 | @dfn{pseudo-terminals} created @i{via} @code{openpty} and similar | |
7803 | functions (@pxref{Pseudo-Terminals,,, libc, The GNU C Library Reference | |
7804 | Manual}). Pseudo-terminals are used by terminal emulators such as | |
7805 | @command{xterm}. | |
7806 | @end defvr | |
7807 | ||
db17ae5c LC |
7808 | @defvr {Scheme Variable} %shared-memory-file-system |
7809 | This file system is mounted as @file{/dev/shm} and is used to support | |
7810 | memory sharing across processes (@pxref{Memory-mapped I/O, | |
7811 | @code{shm_open},, libc, The GNU C Library Reference Manual}). | |
7812 | @end defvr | |
7813 | ||
3392ce5d LC |
7814 | @defvr {Scheme Variable} %immutable-store |
7815 | This file system performs a read-only ``bind mount'' of | |
7816 | @file{/gnu/store}, making it read-only for all the users including | |
7817 | @code{root}. This prevents against accidental modification by software | |
7818 | running as @code{root} or by system administrators. | |
7819 | ||
7820 | The daemon itself is still able to write to the store: it remounts it | |
7821 | read-write in its own ``name space.'' | |
7822 | @end defvr | |
7823 | ||
a69576ea LC |
7824 | @defvr {Scheme Variable} %binary-format-file-system |
7825 | The @code{binfmt_misc} file system, which allows handling of arbitrary | |
7826 | executable file types to be delegated to user space. This requires the | |
7827 | @code{binfmt.ko} kernel module to be loaded. | |
7828 | @end defvr | |
7829 | ||
7830 | @defvr {Scheme Variable} %fuse-control-file-system | |
7831 | The @code{fusectl} file system, which allows unprivileged users to mount | |
7832 | and unmount user-space FUSE file systems. This requires the | |
7833 | @code{fuse.ko} kernel module to be loaded. | |
7834 | @end defvr | |
7835 | ||
510f9d86 LC |
7836 | @node Mapped Devices |
7837 | @subsection Mapped Devices | |
7838 | ||
7839 | @cindex device mapping | |
7840 | @cindex mapped devices | |
7841 | The Linux kernel has a notion of @dfn{device mapping}: a block device, | |
7842 | such as a hard disk partition, can be @dfn{mapped} into another device, | |
97c8aef1 | 7843 | usually in @code{/dev/mapper/}, |
510f9d86 LC |
7844 | with additional processing over the data that flows through |
7845 | it@footnote{Note that the GNU@tie{}Hurd makes no difference between the | |
7846 | concept of a ``mapped device'' and that of a file system: both boil down | |
7847 | to @emph{translating} input/output operations made on a file to | |
7848 | operations on its backing store. Thus, the Hurd implements mapped | |
7849 | devices, like file systems, using the generic @dfn{translator} mechanism | |
7850 | (@pxref{Translators,,, hurd, The GNU Hurd Reference Manual}).}. A | |
7851 | typical example is encryption device mapping: all writes to the mapped | |
7852 | device are encrypted, and all reads are deciphered, transparently. | |
97c8aef1 AE |
7853 | Guix extends this notion by considering any device or set of devices that |
7854 | are @dfn{transformed} in some way to create a new device; for instance, | |
7855 | RAID devices are obtained by @dfn{assembling} several other devices, such | |
7856 | as hard disks or partitions, into a new one that behaves as one partition. | |
7857 | Other examples, not yet implemented, are LVM logical volumes. | |
510f9d86 | 7858 | |
97c8aef1 AE |
7859 | Mapped devices are declared using the @code{mapped-device} form, |
7860 | defined as follows; for examples, see below. | |
510f9d86 LC |
7861 | |
7862 | @deftp {Data Type} mapped-device | |
7863 | Objects of this type represent device mappings that will be made when | |
7864 | the system boots up. | |
7865 | ||
9cb426b8 LC |
7866 | @table @code |
7867 | @item source | |
97c8aef1 AE |
7868 | This is either a string specifying the name of the block device to be mapped, |
7869 | such as @code{"/dev/sda3"}, or a list of such strings when several devices | |
7870 | need to be assembled for creating a new one. | |
510f9d86 | 7871 | |
9cb426b8 | 7872 | @item target |
97c8aef1 AE |
7873 | This string specifies the name of the resulting mapped device. For |
7874 | kernel mappers such as encrypted devices of type @code{luks-device-mapping}, | |
7875 | specifying @code{"my-partition"} leads to the creation of | |
510f9d86 | 7876 | the @code{"/dev/mapper/my-partition"} device. |
97c8aef1 AE |
7877 | For RAID devices of type @code{raid-device-mapping}, the full device name |
7878 | such as @code{"/dev/md0"} needs to be given. | |
510f9d86 | 7879 | |
9cb426b8 | 7880 | @item type |
510f9d86 LC |
7881 | This must be a @code{mapped-device-kind} object, which specifies how |
7882 | @var{source} is mapped to @var{target}. | |
7883 | @end table | |
7884 | @end deftp | |
7885 | ||
7886 | @defvr {Scheme Variable} luks-device-mapping | |
7887 | This defines LUKS block device encryption using the @command{cryptsetup} | |
1068f26b | 7888 | command from the package with the same name. It relies on the |
510f9d86 LC |
7889 | @code{dm-crypt} Linux kernel module. |
7890 | @end defvr | |
7891 | ||
97c8aef1 AE |
7892 | @defvr {Scheme Variable} raid-device-mapping |
7893 | This defines a RAID device, which is assembled using the @code{mdadm} | |
7894 | command from the package with the same name. It requires a Linux kernel | |
7895 | module for the appropriate RAID level to be loaded, such as @code{raid456} | |
7896 | for RAID-4, RAID-5 or RAID-6, or @code{raid10} for RAID-10. | |
7897 | @end defvr | |
7898 | ||
7899 | @cindex disk encryption | |
7900 | @cindex LUKS | |
7901 | The following example specifies a mapping from @file{/dev/sda3} to | |
7902 | @file{/dev/mapper/home} using LUKS---the | |
ddf1cd51 | 7903 | @url{https://gitlab.com/cryptsetup/cryptsetup,Linux Unified Key Setup}, a |
97c8aef1 AE |
7904 | standard mechanism for disk encryption. |
7905 | The @file{/dev/mapper/home} | |
7906 | device can then be used as the @code{device} of a @code{file-system} | |
7907 | declaration (@pxref{File Systems}). | |
7908 | ||
7909 | @example | |
7910 | (mapped-device | |
7911 | (source "/dev/sda3") | |
7912 | (target "home") | |
7913 | (type luks-device-mapping)) | |
7914 | @end example | |
7915 | ||
7916 | Alternatively, to become independent of device numbering, one may obtain | |
7917 | the LUKS UUID (@dfn{unique identifier}) of the source device by a | |
7918 | command like: | |
7919 | ||
7920 | @example | |
7921 | cryptsetup luksUUID /dev/sda3 | |
7922 | @end example | |
7923 | ||
7924 | and use it as follows: | |
7925 | ||
7926 | @example | |
7927 | (mapped-device | |
7928 | (source (uuid "cb67fc72-0d54-4c88-9d4b-b225f30b0f44")) | |
7929 | (target "home") | |
7930 | (type luks-device-mapping)) | |
7931 | @end example | |
7932 | ||
a4ca4362 CM |
7933 | @cindex swap encryption |
7934 | It is also desirable to encrypt swap space, since swap space may contain | |
7935 | sensitive data. One way to accomplish that is to use a swap file in a | |
7936 | file system on a device mapped via LUKS encryption. In this way, the | |
7937 | swap file is encrypted because the entire device is encrypted. | |
7938 | @xref{Preparing for Installation,,Disk Partitioning}, for an example. | |
7939 | ||
97c8aef1 AE |
7940 | A RAID device formed of the partitions @file{/dev/sda1} and @file{/dev/sdb1} |
7941 | may be declared as follows: | |
7942 | ||
7943 | @example | |
7944 | (mapped-device | |
7945 | (source (list "/dev/sda1" "/dev/sdb1")) | |
7946 | (target "/dev/md0") | |
7947 | (type raid-device-mapping)) | |
7948 | @end example | |
7949 | ||
7950 | The @file{/dev/md0} device can then be used as the @code{device} of a | |
7951 | @code{file-system} declaration (@pxref{File Systems}). | |
7952 | Note that the RAID level need not be given; it is chosen during the | |
7953 | initial creation and formatting of the RAID device and is determined | |
7954 | automatically later. | |
7955 | ||
7956 | ||
cf4a9129 LC |
7957 | @node User Accounts |
7958 | @subsection User Accounts | |
ee85f3db | 7959 | |
e32171ee JD |
7960 | @cindex users |
7961 | @cindex accounts | |
7962 | @cindex user accounts | |
9bea87a5 LC |
7963 | User accounts and groups are entirely managed through the |
7964 | @code{operating-system} declaration. They are specified with the | |
7965 | @code{user-account} and @code{user-group} forms: | |
ee85f3db | 7966 | |
cf4a9129 LC |
7967 | @example |
7968 | (user-account | |
7969 | (name "alice") | |
7970 | (group "users") | |
24e752c0 LC |
7971 | (supplementary-groups '("wheel" ;allow use of sudo, etc. |
7972 | "audio" ;sound card | |
7973 | "video" ;video devices such as webcams | |
7974 | "cdrom")) ;the good ol' CD-ROM | |
cf4a9129 LC |
7975 | (comment "Bob's sister") |
7976 | (home-directory "/home/alice")) | |
7977 | @end example | |
25083588 | 7978 | |
9bea87a5 LC |
7979 | When booting or upon completion of @command{guix system reconfigure}, |
7980 | the system ensures that only the user accounts and groups specified in | |
7981 | the @code{operating-system} declaration exist, and with the specified | |
7982 | properties. Thus, account or group creations or modifications made by | |
7983 | directly invoking commands such as @command{useradd} are lost upon | |
7984 | reconfiguration or reboot. This ensures that the system remains exactly | |
7985 | as declared. | |
7986 | ||
cf4a9129 LC |
7987 | @deftp {Data Type} user-account |
7988 | Objects of this type represent user accounts. The following members may | |
7989 | be specified: | |
ee85f3db | 7990 | |
cf4a9129 LC |
7991 | @table @asis |
7992 | @item @code{name} | |
7993 | The name of the user account. | |
ee85f3db | 7994 | |
cf4a9129 | 7995 | @item @code{group} |
e32171ee | 7996 | @cindex groups |
cf4a9129 LC |
7997 | This is the name (a string) or identifier (a number) of the user group |
7998 | this account belongs to. | |
ee85f3db | 7999 | |
cf4a9129 LC |
8000 | @item @code{supplementary-groups} (default: @code{'()}) |
8001 | Optionally, this can be defined as a list of group names that this | |
8002 | account belongs to. | |
ee85f3db | 8003 | |
cf4a9129 LC |
8004 | @item @code{uid} (default: @code{#f}) |
8005 | This is the user ID for this account (a number), or @code{#f}. In the | |
8006 | latter case, a number is automatically chosen by the system when the | |
8007 | account is created. | |
ee85f3db | 8008 | |
cf4a9129 | 8009 | @item @code{comment} (default: @code{""}) |
1068f26b | 8010 | A comment about the account, such as the account owner's full name. |
c8c871d1 | 8011 | |
cf4a9129 LC |
8012 | @item @code{home-directory} |
8013 | This is the name of the home directory for the account. | |
ee85f3db | 8014 | |
eb56ee02 LC |
8015 | @item @code{create-home-directory?} (default: @code{#t}) |
8016 | Indicates whether the home directory of this account should be created | |
8017 | if it does not exist yet. | |
8018 | ||
cf4a9129 LC |
8019 | @item @code{shell} (default: Bash) |
8020 | This is a G-expression denoting the file name of a program to be used as | |
8021 | the shell (@pxref{G-Expressions}). | |
ee85f3db | 8022 | |
cf4a9129 LC |
8023 | @item @code{system?} (default: @code{#f}) |
8024 | This Boolean value indicates whether the account is a ``system'' | |
8025 | account. System accounts are sometimes treated specially; for instance, | |
8026 | graphical login managers do not list them. | |
ee85f3db | 8027 | |
1bd4e6db | 8028 | @anchor{user-account-password} |
cf4a9129 | 8029 | @item @code{password} (default: @code{#f}) |
eb59595c LC |
8030 | You would normally leave this field to @code{#f}, initialize user |
8031 | passwords as @code{root} with the @command{passwd} command, and then let | |
9bea87a5 LC |
8032 | users change it with @command{passwd}. Passwords set with |
8033 | @command{passwd} are of course preserved across reboot and | |
8034 | reconfiguration. | |
eb59595c LC |
8035 | |
8036 | If you @emph{do} want to have a preset password for an account, then | |
8037 | this field must contain the encrypted password, as a string. | |
5d1f1177 LC |
8038 | @xref{crypt,,, libc, The GNU C Library Reference Manual}, for more information |
8039 | on password encryption, and @ref{Encryption,,, guile, GNU Guile Reference | |
eb59595c | 8040 | Manual}, for information on Guile's @code{crypt} procedure. |
c8c871d1 | 8041 | |
cf4a9129 LC |
8042 | @end table |
8043 | @end deftp | |
ee85f3db | 8044 | |
e32171ee | 8045 | @cindex groups |
cf4a9129 | 8046 | User group declarations are even simpler: |
ee85f3db | 8047 | |
cf4a9129 LC |
8048 | @example |
8049 | (user-group (name "students")) | |
8050 | @end example | |
ee85f3db | 8051 | |
cf4a9129 LC |
8052 | @deftp {Data Type} user-group |
8053 | This type is for, well, user groups. There are just a few fields: | |
af8a56b8 | 8054 | |
cf4a9129 LC |
8055 | @table @asis |
8056 | @item @code{name} | |
1068f26b | 8057 | The name of the group. |
ee85f3db | 8058 | |
cf4a9129 LC |
8059 | @item @code{id} (default: @code{#f}) |
8060 | The group identifier (a number). If @code{#f}, a new number is | |
8061 | automatically allocated when the group is created. | |
ee85f3db | 8062 | |
c8fa3426 LC |
8063 | @item @code{system?} (default: @code{#f}) |
8064 | This Boolean value indicates whether the group is a ``system'' group. | |
8065 | System groups have low numerical IDs. | |
8066 | ||
cf4a9129 LC |
8067 | @item @code{password} (default: @code{#f}) |
8068 | What, user groups can have a password? Well, apparently yes. Unless | |
1068f26b | 8069 | @code{#f}, this field specifies the password of the group. |
ee85f3db | 8070 | |
cf4a9129 LC |
8071 | @end table |
8072 | @end deftp | |
401c53c4 | 8073 | |
cf4a9129 LC |
8074 | For convenience, a variable lists all the basic user groups one may |
8075 | expect: | |
401c53c4 | 8076 | |
cf4a9129 LC |
8077 | @defvr {Scheme Variable} %base-groups |
8078 | This is the list of basic user groups that users and/or packages expect | |
8079 | to be present on the system. This includes groups such as ``root'', | |
8080 | ``wheel'', and ``users'', as well as groups used to control access to | |
8081 | specific devices such as ``audio'', ``disk'', and ``cdrom''. | |
8082 | @end defvr | |
401c53c4 | 8083 | |
bf87f38a LC |
8084 | @defvr {Scheme Variable} %base-user-accounts |
8085 | This is the list of basic system accounts that programs may expect to | |
8086 | find on a GNU/Linux system, such as the ``nobody'' account. | |
8087 | ||
8088 | Note that the ``root'' account is not included here. It is a | |
8089 | special-case and is automatically added whether or not it is specified. | |
8090 | @end defvr | |
8091 | ||
598e19dc LC |
8092 | @node Locales |
8093 | @subsection Locales | |
8094 | ||
8095 | @cindex locale | |
8096 | A @dfn{locale} defines cultural conventions for a particular language | |
8097 | and region of the world (@pxref{Locales,,, libc, The GNU C Library | |
8098 | Reference Manual}). Each locale has a name that typically has the form | |
b2636518 | 8099 | @code{@var{language}_@var{territory}.@var{codeset}}---e.g., |
598e19dc LC |
8100 | @code{fr_LU.utf8} designates the locale for the French language, with |
8101 | cultural conventions from Luxembourg, and using the UTF-8 encoding. | |
8102 | ||
8103 | @cindex locale definition | |
8104 | Usually, you will want to specify the default locale for the machine | |
8105 | using the @code{locale} field of the @code{operating-system} declaration | |
8106 | (@pxref{operating-system Reference, @code{locale}}). | |
8107 | ||
f5582b2c LC |
8108 | The selected locale is automatically added to the @dfn{locale |
8109 | definitions} known to the system if needed, with its codeset inferred | |
8110 | from its name---e.g., @code{bo_CN.utf8} will be assumed to use the | |
8111 | @code{UTF-8} codeset. Additional locale definitions can be specified in | |
8112 | the @code{locale-definitions} slot of @code{operating-system}---this is | |
8113 | useful, for instance, if the codeset could not be inferred from the | |
8114 | locale name. The default set of locale definitions includes some widely | |
8115 | used locales, but not all the available locales, in order to save space. | |
8116 | ||
8117 | For instance, to add the North Frisian locale for Germany, the value of | |
8118 | that field may be: | |
598e19dc LC |
8119 | |
8120 | @example | |
8121 | (cons (locale-definition | |
8122 | (name "fy_DE.utf8") (source "fy_DE")) | |
8123 | %default-locale-definitions) | |
8124 | @end example | |
8125 | ||
8126 | Likewise, to save space, one might want @code{locale-definitions} to | |
8127 | list only the locales that are actually used, as in: | |
8128 | ||
8129 | @example | |
8130 | (list (locale-definition | |
8131 | (name "ja_JP.eucjp") (source "ja_JP") | |
8132 | (charset "EUC-JP"))) | |
8133 | @end example | |
8134 | ||
5c3c1427 LC |
8135 | @vindex LOCPATH |
8136 | The compiled locale definitions are available at | |
46bd6edd LC |
8137 | @file{/run/current-system/locale/X.Y}, where @code{X.Y} is the libc |
8138 | version, which is the default location where the GNU@tie{}libc provided | |
8139 | by Guix looks for locale data. This can be overridden using the | |
8140 | @code{LOCPATH} environment variable (@pxref{locales-and-locpath, | |
5c3c1427 LC |
8141 | @code{LOCPATH} and locale packages}). |
8142 | ||
598e19dc LC |
8143 | The @code{locale-definition} form is provided by the @code{(gnu system |
8144 | locale)} module. Details are given below. | |
8145 | ||
8146 | @deftp {Data Type} locale-definition | |
8147 | This is the data type of a locale definition. | |
8148 | ||
8149 | @table @asis | |
8150 | ||
8151 | @item @code{name} | |
8152 | The name of the locale. @xref{Locale Names,,, libc, The GNU C Library | |
8153 | Reference Manual}, for more information on locale names. | |
8154 | ||
8155 | @item @code{source} | |
8156 | The name of the source for that locale. This is typically the | |
8157 | @code{@var{language}_@var{territory}} part of the locale name. | |
8158 | ||
8159 | @item @code{charset} (default: @code{"UTF-8"}) | |
8160 | The ``character set'' or ``code set'' for that locale, | |
8161 | @uref{http://www.iana.org/assignments/character-sets, as defined by | |
8162 | IANA}. | |
8163 | ||
8164 | @end table | |
8165 | @end deftp | |
8166 | ||
8167 | @defvr {Scheme Variable} %default-locale-definitions | |
1068f26b | 8168 | A list of commonly used UTF-8 locales, used as the default |
b2636518 | 8169 | value of the @code{locale-definitions} field of @code{operating-system} |
598e19dc | 8170 | declarations. |
b2636518 LC |
8171 | |
8172 | @cindex locale name | |
8173 | @cindex normalized codeset in locale names | |
8174 | These locale definitions use the @dfn{normalized codeset} for the part | |
8175 | that follows the dot in the name (@pxref{Using gettextized software, | |
8176 | normalized codeset,, libc, The GNU C Library Reference Manual}). So for | |
8177 | instance it has @code{uk_UA.utf8} but @emph{not}, say, | |
8178 | @code{uk_UA.UTF-8}. | |
598e19dc | 8179 | @end defvr |
401c53c4 | 8180 | |
34760ae7 LC |
8181 | @subsubsection Locale Data Compatibility Considerations |
8182 | ||
8183 | @cindex incompatibility, of locale data | |
8184 | @code{operating-system} declarations provide a @code{locale-libcs} field | |
8185 | to specify the GNU@tie{}libc packages that are used to compile locale | |
8186 | declarations (@pxref{operating-system Reference}). ``Why would I | |
8187 | care?'', you may ask. Well, it turns out that the binary format of | |
8188 | locale data is occasionally incompatible from one libc version to | |
8189 | another. | |
8190 | ||
8191 | @c See <https://sourceware.org/ml/libc-alpha/2015-09/msg00575.html> | |
8192 | @c and <https://lists.gnu.org/archive/html/guix-devel/2015-08/msg00737.html>. | |
8193 | For instance, a program linked against libc version 2.21 is unable to | |
8194 | read locale data produced with libc 2.22; worse, that program | |
8195 | @emph{aborts} instead of simply ignoring the incompatible locale | |
8196 | data@footnote{Versions 2.23 and later of GNU@tie{}libc will simply skip | |
8197 | the incompatible locale data, which is already an improvement.}. | |
8198 | Similarly, a program linked against libc 2.22 can read most, but not | |
201fff9e | 8199 | all, of the locale data from libc 2.21 (specifically, @code{LC_COLLATE} |
34760ae7 LC |
8200 | data is incompatible); thus calls to @code{setlocale} may fail, but |
8201 | programs will not abort. | |
8202 | ||
8203 | The ``problem'' in GuixSD is that users have a lot of freedom: They can | |
8204 | choose whether and when to upgrade software in their profiles, and might | |
8205 | be using a libc version different from the one the system administrator | |
8206 | used to build the system-wide locale data. | |
8207 | ||
8208 | Fortunately, unprivileged users can also install their own locale data | |
8209 | and define @var{GUIX_LOCPATH} accordingly (@pxref{locales-and-locpath, | |
8210 | @code{GUIX_LOCPATH} and locale packages}). | |
8211 | ||
8212 | Still, it is best if the system-wide locale data at | |
8213 | @file{/run/current-system/locale} is built for all the libc versions | |
8214 | actually in use on the system, so that all the programs can access | |
8215 | it---this is especially crucial on a multi-user system. To do that, the | |
8216 | administrator can specify several libc packages in the | |
8217 | @code{locale-libcs} field of @code{operating-system}: | |
8218 | ||
8219 | @example | |
8220 | (use-package-modules base) | |
8221 | ||
8222 | (operating-system | |
8223 | ;; @dots{} | |
8224 | (locale-libcs (list glibc-2.21 (canonical-package glibc)))) | |
8225 | @end example | |
8226 | ||
8227 | This example would lead to a system containing locale definitions for | |
8228 | both libc 2.21 and the current version of libc in | |
8229 | @file{/run/current-system/locale}. | |
8230 | ||
8231 | ||
cf4a9129 LC |
8232 | @node Services |
8233 | @subsection Services | |
401c53c4 | 8234 | |
cf4a9129 LC |
8235 | @cindex system services |
8236 | An important part of preparing an @code{operating-system} declaration is | |
8237 | listing @dfn{system services} and their configuration (@pxref{Using the | |
8238 | Configuration System}). System services are typically daemons launched | |
8239 | when the system boots, or other actions needed at that time---e.g., | |
d8b94dbd LC |
8240 | configuring network access. |
8241 | ||
e8b652d4 LC |
8242 | GuixSD has a broad definition of ``service'' (@pxref{Service |
8243 | Composition}), but many services are managed by the GNU@tie{}Shepherd | |
8244 | (@pxref{Shepherd Services}). On a running system, the @command{herd} | |
8245 | command allows you to list the available services, show their status, | |
8246 | start and stop them, or do other specific operations (@pxref{Jump | |
8247 | Start,,, shepherd, The GNU Shepherd Manual}). For example: | |
d8b94dbd LC |
8248 | |
8249 | @example | |
dd17bc38 | 8250 | # herd status |
d8b94dbd LC |
8251 | @end example |
8252 | ||
8253 | The above command, run as @code{root}, lists the currently defined | |
dd17bc38 | 8254 | services. The @command{herd doc} command shows a synopsis of the given |
d8b94dbd LC |
8255 | service: |
8256 | ||
8257 | @example | |
dd17bc38 | 8258 | # herd doc nscd |
d8b94dbd LC |
8259 | Run libc's name service cache daemon (nscd). |
8260 | @end example | |
8261 | ||
8262 | The @command{start}, @command{stop}, and @command{restart} sub-commands | |
8263 | have the effect you would expect. For instance, the commands below stop | |
8264 | the nscd service and restart the Xorg display server: | |
8265 | ||
8266 | @example | |
dd17bc38 | 8267 | # herd stop nscd |
d8b94dbd | 8268 | Service nscd has been stopped. |
dd17bc38 | 8269 | # herd restart xorg-server |
d8b94dbd LC |
8270 | Service xorg-server has been stopped. |
8271 | Service xorg-server has been started. | |
8272 | @end example | |
401c53c4 | 8273 | |
cf4a9129 | 8274 | The following sections document the available services, starting with |
d8b94dbd LC |
8275 | the core services, that may be used in an @code{operating-system} |
8276 | declaration. | |
401c53c4 | 8277 | |
cf4a9129 LC |
8278 | @menu |
8279 | * Base Services:: Essential system services. | |
c311089b | 8280 | * Scheduled Job Execution:: The mcron service. |
92c03a87 | 8281 | * Log Rotation:: The rottlog service. |
cf4a9129 LC |
8282 | * Networking Services:: Network setup, SSH daemon, etc. |
8283 | * X Window:: Graphical display. | |
f2ec23d1 | 8284 | * Printing Services:: Local and remote printer support. |
fe1a39d3 | 8285 | * Desktop Services:: D-Bus and desktop services. |
105369a4 | 8286 | * Database Services:: SQL databases. |
d8c18af8 | 8287 | * Mail Services:: IMAP, POP3, SMTP, and all that. |
78cef99b | 8288 | * Messaging Services:: Messaging services. |
859e367d | 8289 | * Kerberos Services:: Kerberos services. |
58724c48 | 8290 | * Web Services:: Web servers. |
2be1b471 | 8291 | * VPN Services:: VPN daemons. |
eb419bc9 | 8292 | * Network File System:: NFS related services. |
a7cf4eb6 | 8293 | * Continuous Integration:: The Cuirass service. |
dbc6d370 | 8294 | * Miscellaneous Services:: Other services. |
cf4a9129 | 8295 | @end menu |
401c53c4 | 8296 | |
cf4a9129 LC |
8297 | @node Base Services |
8298 | @subsubsection Base Services | |
a1ba8475 | 8299 | |
cf4a9129 LC |
8300 | The @code{(gnu services base)} module provides definitions for the basic |
8301 | services that one expects from the system. The services exported by | |
8302 | this module are listed below. | |
401c53c4 | 8303 | |
cf4a9129 | 8304 | @defvr {Scheme Variable} %base-services |
31771497 LC |
8305 | This variable contains a list of basic services (@pxref{Service Types |
8306 | and Services}, for more information on service objects) one would | |
cf4a9129 | 8307 | expect from the system: a login service (mingetty) on each tty, syslogd, |
1068f26b | 8308 | the libc name service cache daemon (nscd), the udev device manager, and |
cf4a9129 | 8309 | more. |
401c53c4 | 8310 | |
cf4a9129 LC |
8311 | This is the default value of the @code{services} field of |
8312 | @code{operating-system} declarations. Usually, when customizing a | |
8313 | system, you will want to append services to @var{%base-services}, like | |
8314 | this: | |
401c53c4 | 8315 | |
cf4a9129 | 8316 | @example |
fa1e31b8 | 8317 | (cons* (avahi-service) (lsh-service) %base-services) |
cf4a9129 LC |
8318 | @end example |
8319 | @end defvr | |
401c53c4 | 8320 | |
387e1754 LC |
8321 | @defvr {Scheme Variable} special-files-service-type |
8322 | This is the service that sets up ``special files'' such as | |
8323 | @file{/bin/sh}; an instance of it is part of @code{%base-services}. | |
8324 | ||
8325 | The value associated with @code{special-files-service-type} services | |
8326 | must be a list of tuples where the first element is the ``special file'' | |
8327 | and the second element is its target. By default it is: | |
8328 | ||
8329 | @cindex @file{/bin/sh} | |
8330 | @cindex @file{sh}, in @file{/bin} | |
8331 | @example | |
8332 | `(("/bin/sh" ,(file-append @var{bash} "/bin/sh"))) | |
8333 | @end example | |
8334 | ||
8335 | @cindex @file{/usr/bin/env} | |
8336 | @cindex @file{env}, in @file{/usr/bin} | |
8337 | If you want to add, say, @code{/usr/bin/env} to your system, you can | |
8338 | change it to: | |
8339 | ||
8340 | @example | |
8341 | `(("/bin/sh" ,(file-append @var{bash} "/bin/sh")) | |
8342 | ("/usr/bin/env" ,(file-append @var{coreutils} "/bin/env"))) | |
8343 | @end example | |
8344 | ||
8345 | Since this is part of @code{%base-services}, you can use | |
8346 | @code{modify-services} to customize the set of special files | |
8347 | (@pxref{Service Reference, @code{modify-services}}). But the simple way | |
8348 | to add a special file is @i{via} the @code{extra-special-file} procedure | |
8349 | (see below.) | |
8350 | @end defvr | |
8351 | ||
8352 | @deffn {Scheme Procedure} extra-special-file @var{file} @var{target} | |
8353 | Use @var{target} as the ``special file'' @var{file}. | |
8354 | ||
8355 | For example, adding the following lines to the @code{services} field of | |
8356 | your operating system declaration leads to a @file{/usr/bin/env} | |
8357 | symlink: | |
8358 | ||
8359 | @example | |
8360 | (extra-special-file "/usr/bin/env" | |
8361 | (file-append coreutils "/bin/env")) | |
8362 | @end example | |
8363 | @end deffn | |
8364 | ||
be1c2c54 | 8365 | @deffn {Scheme Procedure} host-name-service @var{name} |
cf4a9129 LC |
8366 | Return a service that sets the host name to @var{name}. |
8367 | @end deffn | |
401c53c4 | 8368 | |
317d3b47 DC |
8369 | @deffn {Scheme Procedure} login-service @var{config} |
8370 | Return a service to run login according to @var{config}, a | |
8371 | @code{<login-configuration>} object, which specifies the message of the day, | |
8372 | among other things. | |
8373 | @end deffn | |
8374 | ||
8375 | @deftp {Data Type} login-configuration | |
8376 | This is the data type representing the configuration of login. | |
8377 | ||
8378 | @table @asis | |
8379 | ||
8380 | @item @code{motd} | |
e32171ee | 8381 | @cindex message of the day |
317d3b47 DC |
8382 | A file-like object containing the ``message of the day''. |
8383 | ||
8384 | @item @code{allow-empty-passwords?} (default: @code{#t}) | |
8385 | Allow empty passwords by default so that first-time users can log in when | |
8386 | the 'root' account has just been created. | |
8387 | ||
8388 | @end table | |
8389 | @end deftp | |
8390 | ||
66e4f01c LC |
8391 | @deffn {Scheme Procedure} mingetty-service @var{config} |
8392 | Return a service to run mingetty according to @var{config}, a | |
8393 | @code{<mingetty-configuration>} object, which specifies the tty to run, among | |
8394 | other things. | |
cf4a9129 | 8395 | @end deffn |
401c53c4 | 8396 | |
66e4f01c LC |
8397 | @deftp {Data Type} mingetty-configuration |
8398 | This is the data type representing the configuration of Mingetty, which | |
8399 | implements console log-in. | |
8400 | ||
8401 | @table @asis | |
8402 | ||
8403 | @item @code{tty} | |
8404 | The name of the console this Mingetty runs on---e.g., @code{"tty1"}. | |
8405 | ||
66e4f01c LC |
8406 | @item @code{auto-login} (default: @code{#f}) |
8407 | When true, this field must be a string denoting the user name under | |
f9b9a033 | 8408 | which the system automatically logs in. When it is @code{#f}, a |
66e4f01c LC |
8409 | user name and password must be entered to log in. |
8410 | ||
8411 | @item @code{login-program} (default: @code{#f}) | |
8412 | This must be either @code{#f}, in which case the default log-in program | |
8413 | is used (@command{login} from the Shadow tool suite), or a gexp denoting | |
8414 | the name of the log-in program. | |
8415 | ||
8416 | @item @code{login-pause?} (default: @code{#f}) | |
8417 | When set to @code{#t} in conjunction with @var{auto-login}, the user | |
8418 | will have to press a key before the log-in shell is launched. | |
8419 | ||
8420 | @item @code{mingetty} (default: @var{mingetty}) | |
8421 | The Mingetty package to use. | |
8422 | ||
8423 | @end table | |
8424 | @end deftp | |
8425 | ||
46ec2707 DC |
8426 | @deffn {Scheme Procedure} kmscon-service-type @var{config} |
8427 | Return a service to run @uref{https://www.freedesktop.org/wiki/Software/kmscon,kmscon} | |
8428 | according to @var{config}, a @code{<kmscon-configuration>} object, which | |
8429 | specifies the tty to run, among other things. | |
8430 | @end deffn | |
8431 | ||
8432 | @deftp {Data Type} kmscon-configuration | |
8433 | This is the data type representing the configuration of Kmscon, which | |
8434 | implements console log-in. | |
8435 | ||
8436 | @table @asis | |
8437 | ||
8438 | @item @code{virtual-terminal} | |
8439 | The name of the console this Kmscon runs on---e.g., @code{"tty1"}. | |
8440 | ||
8441 | @item @code{login-program} (default: @code{#~(string-append #$shadow "/bin/login")}) | |
8442 | A gexp denoting the name of the log-in program. The default log-in program is | |
8443 | @command{login} from the Shadow tool suite. | |
8444 | ||
8445 | @item @code{login-arguments} (default: @code{'("-p")}) | |
8446 | A list of arguments to pass to @command{login}. | |
8447 | ||
8448 | @item @code{hardware-acceleration?} (default: #f) | |
8449 | Whether to use hardware acceleration. | |
8450 | ||
8451 | @item @code{kmscon} (default: @var{kmscon}) | |
8452 | The Kmscon package to use. | |
8453 | ||
8454 | @end table | |
8455 | @end deftp | |
8456 | ||
6454b333 LC |
8457 | @cindex name service cache daemon |
8458 | @cindex nscd | |
be1c2c54 | 8459 | @deffn {Scheme Procedure} nscd-service [@var{config}] [#:glibc glibc] @ |
4aee6e60 | 8460 | [#:name-services '()] |
1068f26b | 8461 | Return a service that runs the libc name service cache daemon (nscd) with the |
b893f1ae LC |
8462 | given @var{config}---an @code{<nscd-configuration>} object. @xref{Name |
8463 | Service Switch}, for an example. | |
cf4a9129 | 8464 | @end deffn |
401c53c4 | 8465 | |
6454b333 LC |
8466 | @defvr {Scheme Variable} %nscd-default-configuration |
8467 | This is the default @code{<nscd-configuration>} value (see below) used | |
1068f26b | 8468 | by @code{nscd-service}. It uses the caches defined by |
6454b333 LC |
8469 | @var{%nscd-default-caches}; see below. |
8470 | @end defvr | |
8471 | ||
8472 | @deftp {Data Type} nscd-configuration | |
1068f26b | 8473 | This is the data type representing the name service cache daemon (nscd) |
6454b333 LC |
8474 | configuration. |
8475 | ||
8476 | @table @asis | |
8477 | ||
b893f1ae LC |
8478 | @item @code{name-services} (default: @code{'()}) |
8479 | List of packages denoting @dfn{name services} that must be visible to | |
8480 | the nscd---e.g., @code{(list @var{nss-mdns})}. | |
8481 | ||
8482 | @item @code{glibc} (default: @var{glibc}) | |
8483 | Package object denoting the GNU C Library providing the @command{nscd} | |
8484 | command. | |
8485 | ||
6454b333 | 8486 | @item @code{log-file} (default: @code{"/var/log/nscd.log"}) |
1068f26b | 8487 | Name of the nscd log file. This is where debugging output goes when |
6454b333 LC |
8488 | @code{debug-level} is strictly positive. |
8489 | ||
8490 | @item @code{debug-level} (default: @code{0}) | |
1068f26b | 8491 | Integer denoting the debugging levels. Higher numbers mean that more |
6454b333 LC |
8492 | debugging output is logged. |
8493 | ||
8494 | @item @code{caches} (default: @var{%nscd-default-caches}) | |
8495 | List of @code{<nscd-cache>} objects denoting things to be cached; see | |
8496 | below. | |
8497 | ||
8498 | @end table | |
8499 | @end deftp | |
8500 | ||
8501 | @deftp {Data Type} nscd-cache | |
8502 | Data type representing a cache database of nscd and its parameters. | |
8503 | ||
8504 | @table @asis | |
8505 | ||
8506 | @item @code{database} | |
8507 | This is a symbol representing the name of the database to be cached. | |
8508 | Valid values are @code{passwd}, @code{group}, @code{hosts}, and | |
8509 | @code{services}, which designate the corresponding NSS database | |
8510 | (@pxref{NSS Basics,,, libc, The GNU C Library Reference Manual}). | |
8511 | ||
8512 | @item @code{positive-time-to-live} | |
8513 | @itemx @code{negative-time-to-live} (default: @code{20}) | |
8514 | A number representing the number of seconds during which a positive or | |
8515 | negative lookup result remains in cache. | |
8516 | ||
8517 | @item @code{check-files?} (default: @code{#t}) | |
8518 | Whether to check for updates of the files corresponding to | |
8519 | @var{database}. | |
8520 | ||
8521 | For instance, when @var{database} is @code{hosts}, setting this flag | |
8522 | instructs nscd to check for updates in @file{/etc/hosts} and to take | |
8523 | them into account. | |
8524 | ||
8525 | @item @code{persistent?} (default: @code{#t}) | |
8526 | Whether the cache should be stored persistently on disk. | |
8527 | ||
8528 | @item @code{shared?} (default: @code{#t}) | |
8529 | Whether the cache should be shared among users. | |
8530 | ||
8531 | @item @code{max-database-size} (default: 32@tie{}MiB) | |
8532 | Maximum size in bytes of the database cache. | |
8533 | ||
8534 | @c XXX: 'suggested-size' and 'auto-propagate?' seem to be expert | |
8535 | @c settings, so leave them out. | |
8536 | ||
8537 | @end table | |
8538 | @end deftp | |
8539 | ||
8540 | @defvr {Scheme Variable} %nscd-default-caches | |
8541 | List of @code{<nscd-cache>} objects used by default by | |
1068f26b | 8542 | @code{nscd-configuration} (see above). |
6454b333 LC |
8543 | |
8544 | It enables persistent and aggressive caching of service and host name | |
8545 | lookups. The latter provides better host name lookup performance, | |
8546 | resilience in the face of unreliable name servers, and also better | |
8547 | privacy---often the result of host name lookups is in local cache, so | |
8548 | external name servers do not even need to be queried. | |
8549 | @end defvr | |
8550 | ||
ec2e2f6c | 8551 | @anchor{syslog-configuration-type} |
e32171ee JD |
8552 | @cindex syslog |
8553 | @cindex logging | |
ec2e2f6c DC |
8554 | @deftp {Data Type} syslog-configuration |
8555 | This data type represents the configuration of the syslog daemon. | |
6454b333 | 8556 | |
ec2e2f6c DC |
8557 | @table @asis |
8558 | @item @code{syslogd} (default: @code{#~(string-append #$inetutils "/libexec/syslogd")}) | |
8559 | The syslog daemon to use. | |
8560 | ||
8561 | @item @code{config-file} (default: @code{%default-syslog.conf}) | |
8562 | The syslog configuration file to use. | |
8563 | ||
8564 | @end table | |
8565 | @end deftp | |
8566 | ||
8567 | @anchor{syslog-service} | |
e32171ee | 8568 | @cindex syslog |
ec2e2f6c DC |
8569 | @deffn {Scheme Procedure} syslog-service @var{config} |
8570 | Return a service that runs a syslog daemon according to @var{config}. | |
44abcb28 LC |
8571 | |
8572 | @xref{syslogd invocation,,, inetutils, GNU Inetutils}, for more | |
8573 | information on the configuration file syntax. | |
cf4a9129 | 8574 | @end deffn |
401c53c4 | 8575 | |
0adfe95a LC |
8576 | @anchor{guix-configuration-type} |
8577 | @deftp {Data Type} guix-configuration | |
8578 | This data type represents the configuration of the Guix build daemon. | |
8579 | @xref{Invoking guix-daemon}, for more information. | |
8580 | ||
8581 | @table @asis | |
8582 | @item @code{guix} (default: @var{guix}) | |
8583 | The Guix package to use. | |
401c53c4 | 8584 | |
0adfe95a LC |
8585 | @item @code{build-group} (default: @code{"guixbuild"}) |
8586 | Name of the group for build user accounts. | |
401c53c4 | 8587 | |
0adfe95a LC |
8588 | @item @code{build-accounts} (default: @code{10}) |
8589 | Number of build user accounts to create. | |
401c53c4 | 8590 | |
0adfe95a | 8591 | @item @code{authorize-key?} (default: @code{#t}) |
e32171ee | 8592 | @cindex substitutes, authorization thereof |
5b58c28b LC |
8593 | Whether to authorize the substitute keys listed in |
8594 | @code{authorized-keys}---by default that of @code{hydra.gnu.org} | |
0adfe95a LC |
8595 | (@pxref{Substitutes}). |
8596 | ||
5b58c28b LC |
8597 | @vindex %default-authorized-guix-keys |
8598 | @item @code{authorized-keys} (default: @var{%default-authorized-guix-keys}) | |
8599 | The list of authorized key files for archive imports, as a list of | |
8600 | string-valued gexps (@pxref{Invoking guix archive}). By default, it | |
8601 | contains that of @code{hydra.gnu.org} (@pxref{Substitutes}). | |
8602 | ||
0adfe95a LC |
8603 | @item @code{use-substitutes?} (default: @code{#t}) |
8604 | Whether to use substitutes. | |
8605 | ||
b0b9f6e0 LC |
8606 | @item @code{substitute-urls} (default: @var{%default-substitute-urls}) |
8607 | The list of URLs where to look for substitutes by default. | |
8608 | ||
0adfe95a LC |
8609 | @item @code{extra-options} (default: @code{'()}) |
8610 | List of extra command-line options for @command{guix-daemon}. | |
8611 | ||
dc0ef095 LC |
8612 | @item @code{log-file} (default: @code{"/var/log/guix-daemon.log"}) |
8613 | File where @command{guix-daemon}'s standard output and standard error | |
8614 | are written. | |
8615 | ||
0adfe95a | 8616 | @item @code{lsof} (default: @var{lsof}) |
f78903f3 | 8617 | The lsof package to use. |
0adfe95a LC |
8618 | |
8619 | @end table | |
8620 | @end deftp | |
8621 | ||
8622 | @deffn {Scheme Procedure} guix-service @var{config} | |
8623 | Return a service that runs the Guix build daemon according to | |
8624 | @var{config}. | |
cf4a9129 | 8625 | @end deffn |
a1ba8475 | 8626 | |
be1c2c54 | 8627 | @deffn {Scheme Procedure} udev-service [#:udev udev] |
cf4a9129 LC |
8628 | Run @var{udev}, which populates the @file{/dev} directory dynamically. |
8629 | @end deffn | |
401c53c4 | 8630 | |
a535e122 LF |
8631 | @deffn {Scheme Procedure} urandom-seed-service @var{#f} |
8632 | Save some entropy in @var{%random-seed-file} to seed @file{/dev/urandom} | |
8633 | when rebooting. | |
8634 | @end deffn | |
8635 | ||
8636 | @defvr {Scheme Variable} %random-seed-file | |
8637 | This is the name of the file where some random bytes are saved by | |
8638 | @var{urandom-seed-service} to seed @file{/dev/urandom} when rebooting. | |
8639 | It defaults to @file{/var/lib/random-seed}. | |
8640 | @end defvr | |
8641 | ||
e32171ee JD |
8642 | @cindex keymap |
8643 | @cindex keyboard | |
b3d05f48 | 8644 | @deffn {Scheme Procedure} console-keymap-service @var{files} ... |
dedb8d5e | 8645 | @cindex keyboard layout |
b3d05f48 AK |
8646 | Return a service to load console keymaps from @var{files} using |
8647 | @command{loadkeys} command. Most likely, you want to load some default | |
8648 | keymap, which can be done like this: | |
8649 | ||
8650 | @example | |
8651 | (console-keymap-service "dvorak") | |
8652 | @end example | |
8653 | ||
8654 | Or, for example, for a Swedish keyboard, you may need to combine | |
8655 | the following keymaps: | |
8656 | @example | |
8657 | (console-keymap-service "se-lat6" "se-fi-lat6") | |
8658 | @end example | |
8659 | ||
8660 | Also you can specify a full file name (or file names) of your keymap(s). | |
8661 | See @code{man loadkeys} for details. | |
8662 | ||
5eca9459 AK |
8663 | @end deffn |
8664 | ||
e32171ee JD |
8665 | @cindex mouse |
8666 | @cindex gpm | |
1aaf116d | 8667 | @deffn {Scheme Procedure} gpm-service [#:gpm @var{gpm}] @ |
8664cc88 LC |
8668 | [#:options] |
8669 | Run @var{gpm}, the general-purpose mouse daemon, with the given | |
8670 | command-line @var{options}. GPM allows users to use the mouse in the console, | |
8671 | notably to select, copy, and paste text. The default value of @var{options} | |
8672 | uses the @code{ps2} protocol, which works for both USB and PS/2 mice. | |
8673 | ||
8674 | This service is not part of @var{%base-services}. | |
8675 | @end deffn | |
8676 | ||
1c52181f LC |
8677 | @anchor{guix-publish-service} |
8678 | @deffn {Scheme Procedure} guix-publish-service [#:guix @var{guix}] @ | |
8679 | [#:port 80] [#:host "localhost"] | |
8680 | Return a service that runs @command{guix publish} listening on @var{host} | |
8681 | and @var{port} (@pxref{Invoking guix publish}). | |
8682 | ||
8683 | This assumes that @file{/etc/guix} already contains a signing key pair as | |
8684 | created by @command{guix archive --generate-key} (@pxref{Invoking guix | |
8685 | archive}). If that is not the case, the service will fail to start. | |
8686 | @end deffn | |
8687 | ||
b58cbf9a DC |
8688 | @anchor{rngd-service} |
8689 | @deffn {Scheme Procedure} rngd-service [#:rng-tools @var{rng-tools}] @ | |
8690 | [#:device "/dev/hwrng"] | |
8691 | Return a service that runs the @command{rngd} program from @var{rng-tools} | |
8692 | to add @var{device} to the kernel's entropy pool. The service will fail if | |
8693 | @var{device} does not exist. | |
8694 | @end deffn | |
a69576ea | 8695 | |
909147e4 RW |
8696 | @anchor{pam-limits-service} |
8697 | @cindex session limits | |
8698 | @cindex ulimit | |
8699 | @cindex priority | |
8700 | @deffn {Scheme Procedure} pam-limits-service [#:limits @var{limits}] | |
8701 | ||
8702 | Return a service that installs a configuration file for the | |
8703 | @uref{http://linux-pam.org/Linux-PAM-html/sag-pam_limits.html, | |
8704 | @code{pam_limits} module}. The procedure optionally takes a list of | |
8705 | @code{pam-limits-entry} values, which can be used to specify | |
8706 | @code{ulimit} limits and nice priority limits to user sessions. | |
8707 | ||
8708 | The following limits definition sets two hard and soft limits for all | |
8709 | login sessions of users in the @code{realtime} group: | |
8710 | ||
8711 | @example | |
8712 | (pam-limits-service | |
8713 | (list | |
8714 | (pam-limits-entry "@@realtime" 'both 'rtprio 99) | |
8715 | (pam-limits-entry "@@realtime" 'both 'memlock 'unlimited))) | |
8716 | @end example | |
8717 | ||
8718 | The first entry increases the maximum realtime priority for | |
8719 | non-privileged processes; the second entry lifts any restriction of the | |
8720 | maximum address space that can be locked in memory. These settings are | |
8721 | commonly used for real-time audio systems. | |
8722 | @end deffn | |
8723 | ||
c311089b LC |
8724 | @node Scheduled Job Execution |
8725 | @subsubsection Scheduled Job Execution | |
8726 | ||
8727 | @cindex cron | |
e32171ee | 8728 | @cindex mcron |
c311089b LC |
8729 | @cindex scheduling jobs |
8730 | The @code{(gnu services mcron)} module provides an interface to | |
8731 | GNU@tie{}mcron, a daemon to run jobs at scheduled times (@pxref{Top,,, | |
8732 | mcron, GNU@tie{}mcron}). GNU@tie{}mcron is similar to the traditional | |
8733 | Unix @command{cron} daemon; the main difference is that it is | |
8734 | implemented in Guile Scheme, which provides a lot of flexibility when | |
8735 | specifying the scheduling of jobs and their actions. | |
8736 | ||
8ac6282c | 8737 | The example below defines an operating system that runs the |
c311089b | 8738 | @command{updatedb} (@pxref{Invoking updatedb,,, find, Finding Files}) |
8ac6282c LC |
8739 | and the @command{guix gc} commands (@pxref{Invoking guix gc}) daily, as |
8740 | well as the @command{mkid} command on behalf of an unprivileged user | |
8741 | (@pxref{mkid invocation,,, idutils, ID Database Utilities}). It uses | |
8742 | gexps to introduce job definitions that are passed to mcron | |
8743 | (@pxref{G-Expressions}). | |
c311089b LC |
8744 | |
8745 | @lisp | |
8746 | (use-modules (guix) (gnu) (gnu services mcron)) | |
8ac6282c | 8747 | (use-package-modules base idutils) |
c311089b LC |
8748 | |
8749 | (define updatedb-job | |
8ac6282c LC |
8750 | ;; Run 'updatedb' at 3AM every day. Here we write the |
8751 | ;; job's action as a Scheme procedure. | |
c311089b | 8752 | #~(job '(next-hour '(3)) |
8ac6282c LC |
8753 | (lambda () |
8754 | (execl (string-append #$findutils "/bin/updatedb") | |
8755 | "updatedb" | |
8756 | "--prunepaths=/tmp /var/tmp /gnu/store")))) | |
c311089b LC |
8757 | |
8758 | (define garbage-collector-job | |
8759 | ;; Collect garbage 5 minutes after midnight every day. | |
8ac6282c | 8760 | ;; The job's action is a shell command. |
c311089b LC |
8761 | #~(job "5 0 * * *" ;Vixie cron syntax |
8762 | "guix gc -F 1G")) | |
8763 | ||
80d944b7 | 8764 | (define idutils-job |
8ac6282c LC |
8765 | ;; Update the index database as user "charlie" at 12:15PM |
8766 | ;; and 19:15PM. This runs from the user's home directory. | |
8767 | #~(job '(next-minute-from (next-hour '(12 19)) '(15)) | |
8768 | (string-append #$idutils "/bin/mkid src") | |
8769 | #:user "charlie")) | |
8770 | ||
c311089b LC |
8771 | (operating-system |
8772 | ;; @dots{} | |
8773 | (services (cons (mcron-service (list garbage-collector-job | |
8ac6282c LC |
8774 | updatedb-job |
8775 | idutils-job)) | |
c311089b LC |
8776 | %base-services))) |
8777 | @end lisp | |
8778 | ||
8779 | @xref{Guile Syntax, mcron job specifications,, mcron, GNU@tie{}mcron}, | |
8780 | for more information on mcron job specifications. Below is the | |
8781 | reference of the mcron service. | |
8782 | ||
8783 | @deffn {Scheme Procedure} mcron-service @var{jobs} [#:mcron @var{mcron2}] | |
8784 | Return an mcron service running @var{mcron} that schedules @var{jobs}, a | |
8785 | list of gexps denoting mcron job specifications. | |
8786 | ||
8787 | This is a shorthand for: | |
8788 | @example | |
80d944b7 LC |
8789 | (service mcron-service-type |
8790 | (mcron-configuration (mcron mcron) (jobs jobs))) | |
c311089b LC |
8791 | @end example |
8792 | @end deffn | |
8793 | ||
8794 | @defvr {Scheme Variable} mcron-service-type | |
8795 | This is the type of the @code{mcron} service, whose value is an | |
8796 | @code{mcron-configuration} object. | |
8797 | ||
8798 | This service type can be the target of a service extension that provides | |
8799 | it additional job specifications (@pxref{Service Composition}). In | |
80d944b7 | 8800 | other words, it is possible to define services that provide additional |
c311089b LC |
8801 | mcron jobs to run. |
8802 | @end defvr | |
8803 | ||
8804 | @deftp {Data Type} mcron-configuration | |
8805 | Data type representing the configuration of mcron. | |
8806 | ||
8807 | @table @asis | |
8808 | @item @code{mcron} (default: @var{mcron2}) | |
8809 | The mcron package to use. | |
8810 | ||
8811 | @item @code{jobs} | |
8812 | This is a list of gexps (@pxref{G-Expressions}), where each gexp | |
8813 | corresponds to an mcron job specification (@pxref{Syntax, mcron job | |
8814 | specifications,, mcron, GNU@tie{}mcron}). | |
8815 | @end table | |
8816 | @end deftp | |
8817 | ||
8818 | ||
92c03a87 JN |
8819 | @node Log Rotation |
8820 | @subsubsection Log Rotation | |
8821 | ||
8822 | @cindex rottlog | |
8823 | @cindex log rotation | |
e32171ee | 8824 | @cindex logging |
92c03a87 JN |
8825 | Log files such as those found in @file{/var/log} tend to grow endlessly, |
8826 | so it's a good idea to @dfn{rotate} them once in a while---i.e., archive | |
8827 | their contents in separate files, possibly compressed. The @code{(gnu | |
8828 | services admin)} module provides an interface to GNU@tie{}Rot[t]log, a | |
8829 | log rotation tool (@pxref{Top,,, rottlog, GNU Rot[t]log Manual}). | |
8830 | ||
8831 | The example below defines an operating system that provides log rotation | |
8832 | with the default settings. | |
8833 | ||
8834 | @lisp | |
8835 | (use-modules (guix) (gnu)) | |
8836 | (use-service-modules admin mcron) | |
8837 | (use-package-modules base idutils) | |
8838 | ||
8839 | (operating-system | |
8840 | ;; @dots{} | |
8841 | (services (cons* (mcron-service) | |
8842 | (service rottlog-service-type (rottlog-configuration)) | |
8843 | %base-services))) | |
8844 | @end lisp | |
8845 | ||
8846 | @defvr {Scheme Variable} rottlog-service-type | |
8847 | This is the type of the Rottlog service, whose value is a | |
8848 | @code{rottlog-configuration} object. | |
8849 | ||
8850 | This service type can define mcron jobs (@pxref{Scheduled Job | |
8851 | Execution}) to run the rottlog service. | |
8852 | @end defvr | |
8853 | ||
8854 | @deftp {Data Type} rottlog-configuration | |
8855 | Data type representing the configuration of rottlog. | |
8856 | ||
8857 | @table @asis | |
8858 | @item @code{rottlog} (default: @code{rottlog}) | |
8859 | The Rottlog package to use. | |
8860 | ||
8861 | @item @code{rc-file} (default: @code{(file-append rottlog "/etc/rc")}) | |
8862 | The Rottlog configuration file to use (@pxref{Mandatory RC Variables,,, | |
8863 | rottlog, GNU Rot[t]log Manual}). | |
8864 | ||
8865 | @item @code{periodic-rotations} (default: @code{`(("weekly" %default-rotatations))}) | |
8866 | A list of Rottlog period-name/period-config tuples. | |
8867 | ||
8868 | For example, taking an example from the Rottlog manual (@pxref{Period | |
8869 | Related File Examples,,, rottlog, GNU Rot[t]log Manual}), a valid tuple | |
8870 | might be: | |
8871 | ||
8872 | @example | |
8873 | ("daily" ,(plain-file "daily" | |
8874 | "\ | |
8875 | /var/log/apache/* @{ | |
8876 | storedir apache-archives | |
8877 | rotate 6 | |
8878 | notifempty | |
8879 | nocompress | |
8880 | @}")) | |
8881 | @end example | |
8882 | ||
8883 | @item @code{jobs} | |
8884 | This is a list of gexps where each gexp corresponds to an mcron job | |
8885 | specification (@pxref{Scheduled Job Execution}). | |
8886 | @end table | |
8887 | @end deftp | |
8888 | ||
8889 | @defvr {Scheme Variable} %default-rotations | |
8890 | Specifies weekly rotation of @var{%rotated-files} and | |
8891 | @code{"/var/log/shepherd.log"}. | |
8892 | @end defvr | |
8893 | ||
8894 | @defvr {Scheme Variable} %rotated-files | |
8895 | The list of syslog-controlled files to be rotated. By default it is: | |
8896 | @code{'("/var/log/messages" "/var/log/secure")}. | |
8897 | @end defvr | |
8898 | ||
cf4a9129 LC |
8899 | @node Networking Services |
8900 | @subsubsection Networking Services | |
401c53c4 | 8901 | |
fa1e31b8 | 8902 | The @code{(gnu services networking)} module provides services to configure |
cf4a9129 | 8903 | the network interface. |
a1ba8475 | 8904 | |
a023cca8 | 8905 | @cindex DHCP, networking service |
be1c2c54 | 8906 | @deffn {Scheme Procedure} dhcp-client-service [#:dhcp @var{isc-dhcp}] |
a023cca8 LC |
8907 | Return a service that runs @var{dhcp}, a Dynamic Host Configuration |
8908 | Protocol (DHCP) client, on all the non-loopback network interfaces. | |
8909 | @end deffn | |
8910 | ||
8de3e4b3 LC |
8911 | @defvr {Scheme Variable} static-networking-service-type |
8912 | This is the type for statically-configured network interfaces. | |
8913 | @c TODO Document <static-networking> data structures. | |
8914 | @end defvr | |
8915 | ||
be1c2c54 | 8916 | @deffn {Scheme Procedure} static-networking-service @var{interface} @var{ip} @ |
1f9803c2 | 8917 | [#:netmask #f] [#:gateway #f] [#:name-servers @code{'()}] |
cf4a9129 | 8918 | Return a service that starts @var{interface} with address @var{ip}. If |
1f9803c2 LC |
8919 | @var{netmask} is true, use it as the network mask. If @var{gateway} is true, |
8920 | it must be a string specifying the default network gateway. | |
8de3e4b3 LC |
8921 | |
8922 | This procedure can be called several times, one for each network | |
8923 | interface of interest. Behind the scenes what it does is extend | |
8924 | @code{static-networking-service-type} with additional network interfaces | |
8925 | to handle. | |
cf4a9129 | 8926 | @end deffn |
8b315a6d | 8927 | |
b7d0c494 | 8928 | @cindex wicd |
e32171ee JD |
8929 | @cindex wireless |
8930 | @cindex WiFi | |
87f40011 | 8931 | @cindex network management |
be1c2c54 | 8932 | @deffn {Scheme Procedure} wicd-service [#:wicd @var{wicd}] |
87f40011 LC |
8933 | Return a service that runs @url{https://launchpad.net/wicd,Wicd}, a network |
8934 | management daemon that aims to simplify wired and wireless networking. | |
8935 | ||
8936 | This service adds the @var{wicd} package to the global profile, providing | |
8937 | several commands to interact with the daemon and configure networking: | |
8938 | @command{wicd-client}, a graphical user interface, and the @command{wicd-cli} | |
8939 | and @command{wicd-curses} user interfaces. | |
b7d0c494 MW |
8940 | @end deffn |
8941 | ||
c0a9589d | 8942 | @cindex NetworkManager |
b726096b CB |
8943 | |
8944 | @defvr {Scheme Variable} network-manager-service-type | |
8945 | This is the service type for the | |
8946 | @uref{https://wiki.gnome.org/Projects/NetworkManager, NetworkManager} | |
8947 | service. The value for this service type is a | |
8948 | @code{network-manager-configuration} record. | |
8949 | @end defvr | |
8950 | ||
8951 | @deftp {Data Type} network-manager-configuration | |
8952 | Data type representing the configuration of NetworkManager. | |
8953 | ||
8954 | @table @asis | |
8955 | @item @code{network-manager} (default: @code{network-manager}) | |
8956 | The NetworkManager package to use. | |
8957 | ||
8958 | @item @code{dns} (default: @code{"default"}) | |
8959 | Processing mode for DNS, which affects how NetworkManager uses the | |
8960 | @code{resolv.conf} configuration file. | |
8961 | ||
8962 | @table @samp | |
8963 | @item default | |
8964 | NetworkManager will update @code{resolv.conf} to reflect the nameservers | |
8965 | provided by currently active connections. | |
8966 | ||
8967 | @item dnsmasq | |
8968 | NetworkManager will run @code{dnsmasq} as a local caching nameserver, | |
8969 | using a "split DNS" configuration if you are connected to a VPN, and | |
8970 | then update @code{resolv.conf} to point to the local nameserver. | |
8971 | ||
8972 | @item none | |
8973 | NetworkManager will not modify @code{resolv.conf}. | |
8974 | @end table | |
8975 | ||
8976 | @end table | |
8977 | @end deftp | |
c0a9589d | 8978 | |
76192896 EF |
8979 | @cindex Connman |
8980 | @deffn {Scheme Procedure} connman-service @ | |
8981 | [#:connman @var{connman}] | |
8982 | Return a service that runs @url{https://01.org/connman,Connman}, a network | |
8983 | connection manager. | |
8984 | ||
8985 | This service adds the @var{connman} package to the global profile, providing | |
8986 | several the @command{connmanctl} command to interact with the daemon and | |
8987 | configure networking." | |
8988 | @end deffn | |
8989 | ||
2cccbc2a | 8990 | @cindex WPA Supplicant |
cbf1024e LC |
8991 | @defvr {Scheme Variable} wpa-supplicant-service-type |
8992 | This is the service type to run @url{https://w1.fi/wpa_supplicant/,WPA | |
2cccbc2a | 8993 | supplicant}, an authentication daemon required to authenticate against |
cbf1024e | 8994 | encrypted WiFi or ethernet networks. It is configured to listen for |
2cccbc2a | 8995 | requests on D-Bus. |
cbf1024e LC |
8996 | |
8997 | The value of this service is the @code{wpa-supplicant} package to use. | |
8998 | Thus, it can be instantiated like this: | |
8999 | ||
9000 | @lisp | |
9001 | (use-modules (gnu services networking) | |
9002 | (gnu packages admin)) | |
9003 | ||
9747d189 | 9004 | (service wpa-supplicant-service-type wpa-supplicant) |
cbf1024e LC |
9005 | @end lisp |
9006 | @end defvr | |
2cccbc2a | 9007 | |
e32171ee JD |
9008 | @cindex NTP |
9009 | @cindex real time clock | |
be1c2c54 | 9010 | @deffn {Scheme Procedure} ntp-service [#:ntp @var{ntp}] @ |
dc0322b5 LC |
9011 | [#:servers @var{%ntp-servers}] @ |
9012 | [#:allow-large-adjustment? #f] | |
63854bcb LC |
9013 | Return a service that runs the daemon from @var{ntp}, the |
9014 | @uref{http://www.ntp.org, Network Time Protocol package}. The daemon will | |
9015 | keep the system clock synchronized with that of @var{servers}. | |
dc0322b5 LC |
9016 | @var{allow-large-adjustment?} determines whether @command{ntpd} is allowed to |
9017 | make an initial adjustment of more than 1,000 seconds. | |
63854bcb LC |
9018 | @end deffn |
9019 | ||
9020 | @defvr {Scheme Variable} %ntp-servers | |
9021 | List of host names used as the default NTP servers. | |
9022 | @end defvr | |
9023 | ||
e32171ee | 9024 | @cindex Tor |
375c6108 LC |
9025 | @deffn {Scheme Procedure} tor-service [@var{config-file}] [#:tor @var{tor}] |
9026 | Return a service to run the @uref{https://torproject.org, Tor} anonymous | |
9027 | networking daemon. | |
8b315a6d | 9028 | |
375c6108 | 9029 | The daemon runs as the @code{tor} unprivileged user. It is passed |
6331bde7 LC |
9030 | @var{config-file}, a file-like object, with an additional @code{User tor} line |
9031 | and lines for hidden services added via @code{tor-hidden-service}. Run | |
9032 | @command{man tor} for information about the configuration file. | |
9033 | @end deffn | |
9034 | ||
24a8ef3b | 9035 | @cindex hidden service |
6331bde7 LC |
9036 | @deffn {Scheme Procedure} tor-hidden-service @var{name} @var{mapping} |
9037 | Define a new Tor @dfn{hidden service} called @var{name} and implementing | |
9038 | @var{mapping}. @var{mapping} is a list of port/host tuples, such as: | |
9039 | ||
9040 | @example | |
24a8ef3b LC |
9041 | '((22 "127.0.0.1:22") |
9042 | (80 "127.0.0.1:8080")) | |
6331bde7 LC |
9043 | @end example |
9044 | ||
9045 | In this example, port 22 of the hidden service is mapped to local port 22, and | |
9046 | port 80 is mapped to local port 8080. | |
9047 | ||
6629099a LC |
9048 | This creates a @file{/var/lib/tor/hidden-services/@var{name}} directory, where |
9049 | the @file{hostname} file contains the @code{.onion} host name for the hidden | |
6331bde7 LC |
9050 | service. |
9051 | ||
9052 | See @uref{https://www.torproject.org/docs/tor-hidden-service.html.en, the Tor | |
9053 | project's documentation} for more information. | |
cf4a9129 | 9054 | @end deffn |
8b315a6d | 9055 | |
be1c2c54 | 9056 | @deffn {Scheme Procedure} bitlbee-service [#:bitlbee bitlbee] @ |
4627a464 LC |
9057 | [#:interface "127.0.0.1"] [#:port 6667] @ |
9058 | [#:extra-settings ""] | |
9059 | Return a service that runs @url{http://bitlbee.org,BitlBee}, a daemon that | |
9060 | acts as a gateway between IRC and chat networks. | |
9061 | ||
9062 | The daemon will listen to the interface corresponding to the IP address | |
9063 | specified in @var{interface}, on @var{port}. @code{127.0.0.1} means that only | |
9064 | local clients can connect, whereas @code{0.0.0.0} means that connections can | |
9065 | come from any networking interface. | |
9066 | ||
9067 | In addition, @var{extra-settings} specifies a string to append to the | |
9068 | configuration file. | |
9069 | @end deffn | |
9070 | ||
71b0601a | 9071 | Furthermore, @code{(gnu services ssh)} provides the following services. |
e32171ee JD |
9072 | @cindex SSH |
9073 | @cindex SSH server | |
8b315a6d | 9074 | |
be1c2c54 | 9075 | @deffn {Scheme Procedure} lsh-service [#:host-key "/etc/lsh/host-key"] @ |
5833bf33 | 9076 | [#:daemonic? #t] [#:interfaces '()] [#:port-number 22] @ |
cf4a9129 LC |
9077 | [#:allow-empty-passwords? #f] [#:root-login? #f] @ |
9078 | [#:syslog-output? #t] [#:x11-forwarding? #t] @ | |
9079 | [#:tcp/ip-forwarding? #t] [#:password-authentication? #t] @ | |
21cc905a | 9080 | [#:public-key-authentication? #t] [#:initialize? #t] |
cf4a9129 LC |
9081 | Run the @command{lshd} program from @var{lsh} to listen on port @var{port-number}. |
9082 | @var{host-key} must designate a file containing the host key, and readable | |
9083 | only by root. | |
72e25e35 | 9084 | |
5833bf33 DP |
9085 | When @var{daemonic?} is true, @command{lshd} will detach from the |
9086 | controlling terminal and log its output to syslogd, unless one sets | |
9087 | @var{syslog-output?} to false. Obviously, it also makes lsh-service | |
9088 | depend on existence of syslogd service. When @var{pid-file?} is true, | |
9089 | @command{lshd} writes its PID to the file called @var{pid-file}. | |
9090 | ||
cf4a9129 LC |
9091 | When @var{initialize?} is true, automatically create the seed and host key |
9092 | upon service activation if they do not exist yet. This may take long and | |
9093 | require interaction. | |
8b315a6d | 9094 | |
20dd519c LC |
9095 | When @var{initialize?} is false, it is up to the user to initialize the |
9096 | randomness generator (@pxref{lsh-make-seed,,, lsh, LSH Manual}), and to create | |
9097 | a key pair with the private key stored in file @var{host-key} (@pxref{lshd | |
9098 | basics,,, lsh, LSH Manual}). | |
9099 | ||
cf4a9129 LC |
9100 | When @var{interfaces} is empty, lshd listens for connections on all the |
9101 | network interfaces; otherwise, @var{interfaces} must be a list of host names | |
9102 | or addresses. | |
9bf3c1a7 | 9103 | |
20dd519c LC |
9104 | @var{allow-empty-passwords?} specifies whether to accept log-ins with empty |
9105 | passwords, and @var{root-login?} specifies whether to accept log-ins as | |
cf4a9129 | 9106 | root. |
4af2447e | 9107 | |
cf4a9129 LC |
9108 | The other options should be self-descriptive. |
9109 | @end deffn | |
4af2447e | 9110 | |
e32171ee JD |
9111 | @cindex SSH |
9112 | @cindex SSH server | |
d8f31281 LC |
9113 | @deffn {Scheme Variable} openssh-service-type |
9114 | This is the type for the @uref{http://www.openssh.org, OpenSSH} secure | |
9115 | shell daemon, @command{sshd}. Its value must be an | |
9116 | @code{openssh-configuration} record as in this example: | |
9117 | ||
9118 | @example | |
9119 | (service openssh-service-type | |
9120 | (openssh-configuration | |
9121 | (x11-forwarding? #t) | |
9122 | (permit-root-login 'without-password))) | |
9123 | @end example | |
9124 | ||
9125 | See below for details about @code{openssh-configuration}. | |
86d8f6d3 JL |
9126 | @end deffn |
9127 | ||
d8f31281 LC |
9128 | @deftp {Data Type} openssh-configuration |
9129 | This is the configuration record for OpenSSH's @command{sshd}. | |
9130 | ||
9131 | @table @asis | |
9132 | @item @code{pid-file} (default: @code{"/var/run/sshd.pid"}) | |
9133 | Name of the file where @command{sshd} writes its PID. | |
9134 | ||
9135 | @item @code{port-number} (default: @code{22}) | |
9136 | TCP port on which @command{sshd} listens for incoming connections. | |
9137 | ||
9138 | @item @code{permit-root-login} (default: @code{#f}) | |
9139 | This field determines whether and when to allow logins as root. If | |
9140 | @code{#f}, root logins are disallowed; if @code{#t}, they are allowed. | |
9141 | If it's the symbol @code{'without-password}, then root logins are | |
9142 | permitted but not with password-based authentication. | |
9143 | ||
9144 | @item @code{allow-empty-passwords?} (default: @code{#f}) | |
9145 | When true, users with empty passwords may log in. When false, they may | |
9146 | not. | |
9147 | ||
9148 | @item @code{password-authentication?} (default: @code{#t}) | |
9149 | When true, users may log in with their password. When false, they have | |
9150 | other authentication methods. | |
9151 | ||
9152 | @item @code{public-key-authentication?} (default: @code{#t}) | |
9153 | When true, users may log in using public key authentication. When | |
9154 | false, users have to use other authentication method. | |
9155 | ||
9156 | Authorized public keys are stored in @file{~/.ssh/authorized_keys}. | |
9157 | This is used only by protocol version 2. | |
9158 | ||
9159 | @item @code{rsa-authentication?} (default: @code{#t}) | |
9160 | When true, users may log in using pure RSA authentication. When false, | |
9161 | users have to use other means of authentication. This is used only by | |
9162 | protocol 1. | |
9163 | ||
9164 | @item @code{x11-forwarding?} (default: @code{#f}) | |
9165 | When true, forwarding of X11 graphical client connections is | |
9166 | enabled---in other words, @command{ssh} options @option{-X} and | |
9167 | @option{-Y} will work. | |
9168 | ||
9169 | @item @code{protocol-number} (default: @code{2}) | |
9170 | The SSH protocol number to use. | |
9171 | @end table | |
9172 | @end deftp | |
9173 | ||
71b0601a DC |
9174 | @deffn {Scheme Procedure} dropbear-service [@var{config}] |
9175 | Run the @uref{https://matt.ucc.asn.au/dropbear/dropbear.html,Dropbear SSH | |
9176 | daemon} with the given @var{config}, a @code{<dropbear-configuration>} | |
9177 | object. | |
9178 | ||
9179 | For example, to specify a Dropbear service listening on port 1234, add | |
9180 | this call to the operating system's @code{services} field: | |
9181 | ||
9182 | @example | |
9183 | (dropbear-service (dropbear-configuration | |
9184 | (port-number 1234))) | |
9185 | @end example | |
9186 | @end deffn | |
9187 | ||
9188 | @deftp {Data Type} dropbear-configuration | |
9189 | This data type represents the configuration of a Dropbear SSH daemon. | |
9190 | ||
9191 | @table @asis | |
9192 | @item @code{dropbear} (default: @var{dropbear}) | |
9193 | The Dropbear package to use. | |
9194 | ||
9195 | @item @code{port-number} (default: 22) | |
9196 | The TCP port where the daemon waits for incoming connections. | |
9197 | ||
9198 | @item @code{syslog-output?} (default: @code{#t}) | |
9199 | Whether to enable syslog output. | |
9200 | ||
9201 | @item @code{pid-file} (default: @code{"/var/run/dropbear.pid"}) | |
9202 | File name of the daemon's PID file. | |
9203 | ||
9204 | @item @code{root-login?} (default: @code{#f}) | |
9205 | Whether to allow @code{root} logins. | |
9206 | ||
9207 | @item @code{allow-empty-passwords?} (default: @code{#f}) | |
9208 | Whether to allow empty passwords. | |
9209 | ||
9210 | @item @code{password-authentication?} (default: @code{#t}) | |
9211 | Whether to enable password-based authentication. | |
9212 | @end table | |
9213 | @end deftp | |
9214 | ||
fa0c1d61 LC |
9215 | @defvr {Scheme Variable} %facebook-host-aliases |
9216 | This variable contains a string for use in @file{/etc/hosts} | |
9217 | (@pxref{Host Names,,, libc, The GNU C Library Reference Manual}). Each | |
9218 | line contains a entry that maps a known server name of the Facebook | |
9219 | on-line service---e.g., @code{www.facebook.com}---to the local | |
9220 | host---@code{127.0.0.1} or its IPv6 equivalent, @code{::1}. | |
9221 | ||
9222 | This variable is typically used in the @code{hosts-file} field of an | |
7313a52e LC |
9223 | @code{operating-system} declaration (@pxref{operating-system Reference, |
9224 | @file{/etc/hosts}}): | |
fa0c1d61 LC |
9225 | |
9226 | @example | |
9227 | (use-modules (gnu) (guix)) | |
9228 | ||
9229 | (operating-system | |
9230 | (host-name "mymachine") | |
9231 | ;; ... | |
9232 | (hosts-file | |
9233 | ;; Create a /etc/hosts file with aliases for "localhost" | |
9234 | ;; and "mymachine", as well as for Facebook servers. | |
24e02c28 LC |
9235 | (plain-file "hosts" |
9236 | (string-append (local-host-aliases host-name) | |
9237 | %facebook-host-aliases)))) | |
fa0c1d61 LC |
9238 | @end example |
9239 | ||
9240 | This mechanism can prevent programs running locally, such as Web | |
9241 | browsers, from accessing Facebook. | |
9242 | @end defvr | |
9243 | ||
965a7332 LC |
9244 | The @code{(gnu services avahi)} provides the following definition. |
9245 | ||
be1c2c54 | 9246 | @deffn {Scheme Procedure} avahi-service [#:avahi @var{avahi}] @ |
965a7332 LC |
9247 | [#:host-name #f] [#:publish? #t] [#:ipv4? #t] @ |
9248 | [#:ipv6? #t] [#:wide-area? #f] @ | |
c8695f32 | 9249 | [#:domains-to-browse '()] [#:debug? #f] |
965a7332 LC |
9250 | Return a service that runs @command{avahi-daemon}, a system-wide |
9251 | mDNS/DNS-SD responder that allows for service discovery and | |
cc9c1f39 LC |
9252 | "zero-configuration" host name lookups (see @uref{http://avahi.org/}), and |
9253 | extends the name service cache daemon (nscd) so that it can resolve | |
9254 | @code{.local} host names using | |
1065bed9 LC |
9255 | @uref{http://0pointer.de/lennart/projects/nss-mdns/, nss-mdns}. Additionally, |
9256 | add the @var{avahi} package to the system profile so that commands such as | |
9257 | @command{avahi-browse} are directly usable. | |
965a7332 LC |
9258 | |
9259 | If @var{host-name} is different from @code{#f}, use that as the host name to | |
9260 | publish for this machine; otherwise, use the machine's actual host name. | |
9261 | ||
9262 | When @var{publish?} is true, publishing of host names and services is allowed; | |
9263 | in particular, avahi-daemon will publish the machine's host name and IP | |
9264 | address via mDNS on the local network. | |
9265 | ||
9266 | When @var{wide-area?} is true, DNS-SD over unicast DNS is enabled. | |
9267 | ||
9268 | Boolean values @var{ipv4?} and @var{ipv6?} determine whether to use IPv4/IPv6 | |
9269 | sockets. | |
9270 | @end deffn | |
9271 | ||
c32d02fe SB |
9272 | @deffn {Scheme Variable} openvswitch-service-type |
9273 | This is the type of the @uref{http://www.openvswitch.org, Open vSwitch} | |
9274 | service, whose value should be an @code{openvswitch-configuration} | |
9275 | object. | |
9276 | @end deffn | |
9277 | ||
9278 | @deftp {Data Type} openvswitch-configuration | |
9279 | Data type representing the configuration of Open vSwitch, a multilayer | |
9280 | virtual switch which is designed to enable massive network automation | |
9281 | through programmatic extension. | |
9282 | ||
9283 | @table @asis | |
9284 | @item @code{package} (default: @var{openvswitch}) | |
9285 | Package object of the Open vSwitch. | |
9286 | ||
9287 | @end table | |
9288 | @end deftp | |
965a7332 | 9289 | |
cf4a9129 LC |
9290 | @node X Window |
9291 | @subsubsection X Window | |
68ad877c | 9292 | |
e32171ee JD |
9293 | @cindex X11 |
9294 | @cindex X Window System | |
cf4a9129 LC |
9295 | Support for the X Window graphical display system---specifically |
9296 | Xorg---is provided by the @code{(gnu services xorg)} module. Note that | |
9297 | there is no @code{xorg-service} procedure. Instead, the X server is | |
9298 | started by the @dfn{login manager}, currently SLiM. | |
4af2447e | 9299 | |
935644c0 DC |
9300 | @deftp {Data Type} sddm-configuration |
9301 | This is the data type representing the sddm service configuration. | |
9302 | ||
9303 | @table @asis | |
9304 | @item @code{display-server} (default: "x11") | |
9305 | Select display server to use for the greeter. Valid values are "x11" | |
9306 | or "wayland". | |
9307 | ||
9308 | @item @code{numlock} (default: "on") | |
9309 | Valid values are "on", "off" or "none". | |
9310 | ||
9311 | @item @code{halt-command} (default @code{#~(string-apppend #$shepherd "/sbin/halt")}) | |
9312 | Command to run when halting. | |
9313 | ||
9314 | @item @code{reboot-command} (default @code{#~(string-append #$shepherd "/sbin/reboot")}) | |
9315 | Command to run when rebooting. | |
9316 | ||
9317 | @item @code{theme} (default "maldives") | |
9318 | Theme to use. Default themes provided by SDDM are "elarun" or "maldives". | |
9319 | ||
9320 | @item @code{themes-directory} (default "/run/current-system/profile/share/sddm/themes") | |
9321 | Directory to look for themes. | |
9322 | ||
9323 | @item @code{faces-directory} (default "/run/current-system/profile/share/sddm/faces") | |
9324 | Directory to look for faces. | |
9325 | ||
9326 | @item @code{default-path} (default "/run/current-system/profile/bin") | |
9327 | Default PATH to use. | |
9328 | ||
9329 | @item @code{minimum-uid} (default 1000) | |
9330 | Minimum UID to display in SDDM. | |
9331 | ||
9332 | @item @code{maximum-uid} (default 2000) | |
9333 | Maximum UID to display in SDDM | |
9334 | ||
9335 | @item @code{remember-last-user?} (default #t) | |
9336 | Remember last user. | |
9337 | ||
9338 | @item @code{remember-last-session?} (default #t) | |
9339 | Remember last session. | |
9340 | ||
9341 | @item @code{hide-users} (default "") | |
9342 | Usernames to hide from SDDM greeter. | |
9343 | ||
9344 | @item @code{hide-shells} (default @code{#~(string-append #$shadow "/sbin/nologin")}) | |
9345 | Users with shells listed will be hidden from the SDDM greeter. | |
9346 | ||
9347 | @item @code{session-command} (default @code{#~(string-append #$sddm "/share/sddm/scripts/wayland-session")}) | |
9348 | Script to run before starting a wayland session. | |
9349 | ||
9350 | @item @code{sessions-directory} (default "/run/current-system/profile/share/wayland-sessions") | |
9351 | Directory to look for desktop files starting wayland sessions. | |
9352 | ||
9353 | @item @code{xorg-server-path} (default @code{xorg-start-command}) | |
9354 | Path to xorg-server. | |
9355 | ||
9356 | @item @code{xauth-path} (default @code{#~(string-append #$xauth "/bin/xauth")}) | |
9357 | Path to xauth. | |
9358 | ||
9359 | @item @code{xephyr-path} (default @code{#~(string-append #$xorg-server "/bin/Xephyr")}) | |
9360 | Path to Xephyr. | |
9361 | ||
9362 | @item @code{xdisplay-start} (default @code{#~(string-append #$sddm "/share/sddm/scripts/Xsetup")}) | |
9363 | Script to run after starting xorg-server. | |
9364 | ||
9365 | @item @code{xdisplay-stop} (default @code{#~(string-append #$sddm "/share/sddm/scripts/Xstop")}) | |
9366 | Script to run before stopping xorg-server. | |
9367 | ||
9368 | @item @code{xsession-command} (default: @code{xinitr }) | |
9369 | Script to run before starting a X session. | |
9370 | ||
9371 | @item @code{xsessions-directory} (default: "/run/current-system/profile/share/xsessions") | |
9372 | Directory to look for desktop files starting X sessions. | |
9373 | ||
9374 | @item @code{minimum-vt} (default: 7) | |
9375 | Minimum VT to use. | |
9376 | ||
9377 | @item @code{xserver-arguments} (default "-nolisten tcp") | |
9378 | Arguments to pass to xorg-server. | |
9379 | ||
9380 | @item @code{auto-login-user} (default "") | |
9381 | User to use for auto-login. | |
9382 | ||
9383 | @item @code{auto-login-session} (default "") | |
9384 | Desktop file to use for auto-login. | |
9385 | ||
9386 | @item @code{relogin?} (default #f) | |
9387 | Relogin after logout. | |
9388 | ||
9389 | @end table | |
9390 | @end deftp | |
9391 | ||
e32171ee | 9392 | @cindex login manager |
935644c0 DC |
9393 | @deffn {Scheme Procedure} sddm-service config |
9394 | Return a service that spawns the SDDM graphical login manager for config of | |
9395 | type @code{<sddm-configuration>}. | |
9396 | ||
9397 | @example | |
9398 | (sddm-service (sddm-configuration | |
9399 | (auto-login-user "Alice") | |
9400 | (auto-login-session "xfce.desktop"))) | |
9401 | @end example | |
9402 | @end deffn | |
9403 | ||
be1c2c54 | 9404 | @deffn {Scheme Procedure} slim-service [#:allow-empty-passwords? #f] @ |
0ecc3bf3 LC |
9405 | [#:auto-login? #f] [#:default-user ""] [#:startx] @ |
9406 | [#:theme @var{%default-slim-theme}] @ | |
4bd43bbe | 9407 | [#:theme-name @var{%default-slim-theme-name}] |
cf4a9129 LC |
9408 | Return a service that spawns the SLiM graphical login manager, which in |
9409 | turn starts the X display server with @var{startx}, a command as returned by | |
9410 | @code{xorg-start-command}. | |
4af2447e | 9411 | |
04e4e6ab LC |
9412 | @cindex X session |
9413 | ||
9414 | SLiM automatically looks for session types described by the @file{.desktop} | |
9415 | files in @file{/run/current-system/profile/share/xsessions} and allows users | |
9416 | to choose a session from the log-in screen using @kbd{F1}. Packages such as | |
9417 | @var{xfce}, @var{sawfish}, and @var{ratpoison} provide @file{.desktop} files; | |
9418 | adding them to the system-wide set of packages automatically makes them | |
9419 | available at the log-in screen. | |
9420 | ||
9421 | In addition, @file{~/.xsession} files are honored. When available, | |
9422 | @file{~/.xsession} must be an executable that starts a window manager | |
9423 | and/or other X clients. | |
9424 | ||
cf4a9129 LC |
9425 | When @var{allow-empty-passwords?} is true, allow logins with an empty |
9426 | password. When @var{auto-login?} is true, log in automatically as | |
9427 | @var{default-user}. | |
0ecc3bf3 | 9428 | |
1068f26b | 9429 | If @var{theme} is @code{#f}, use the default log-in theme; otherwise |
0ecc3bf3 LC |
9430 | @var{theme} must be a gexp denoting the name of a directory containing the |
9431 | theme to use. In that case, @var{theme-name} specifies the name of the | |
9432 | theme. | |
cf4a9129 | 9433 | @end deffn |
4af2447e | 9434 | |
0ecc3bf3 LC |
9435 | @defvr {Scheme Variable} %default-theme |
9436 | @defvrx {Scheme Variable} %default-theme-name | |
9437 | The G-Expression denoting the default SLiM theme and its name. | |
9438 | @end defvr | |
9439 | ||
be1c2c54 | 9440 | @deffn {Scheme Procedure} xorg-start-command [#:guile] @ |
d1cdd7ba | 9441 | [#:configuration-file #f] [#:xorg-server @var{xorg-server}] |
f703413e | 9442 | Return a derivation that builds a @var{guile} script to start the X server |
d1cdd7ba LC |
9443 | from @var{xorg-server}. @var{configuration-file} is the server configuration |
9444 | file or a derivation that builds it; when omitted, the result of | |
9445 | @code{xorg-configuration-file} is used. | |
9446 | ||
9447 | Usually the X server is started by a login manager. | |
9448 | @end deffn | |
9449 | ||
be1c2c54 | 9450 | @deffn {Scheme Procedure} xorg-configuration-file @ |
12422c9d | 9451 | [#:drivers '()] [#:resolutions '()] [#:extra-config '()] |
d1cdd7ba LC |
9452 | Return a configuration file for the Xorg server containing search paths for |
9453 | all the common drivers. | |
f703413e LC |
9454 | |
9455 | @var{drivers} must be either the empty list, in which case Xorg chooses a | |
9456 | graphics driver automatically, or a list of driver names that will be tried in | |
d1cdd7ba | 9457 | this order---e.g., @code{(\"modesetting\" \"vesa\")}. |
d2e59637 LC |
9458 | |
9459 | Likewise, when @var{resolutions} is the empty list, Xorg chooses an | |
9460 | appropriate screen resolution; otherwise, it must be a list of | |
9461 | resolutions---e.g., @code{((1024 768) (640 480))}. | |
12422c9d LC |
9462 | |
9463 | Last, @var{extra-config} is a list of strings or objects appended to the | |
9464 | @code{text-file*} argument list. It is used to pass extra text to be added | |
9465 | verbatim to the configuration file. | |
f703413e | 9466 | @end deffn |
4af2447e | 9467 | |
6726282b LC |
9468 | @deffn {Scheme Procedure} screen-locker-service @var{package} [@var{name}] |
9469 | Add @var{package}, a package for a screen-locker or screen-saver whose | |
9470 | command is @var{program}, to the set of setuid programs and add a PAM entry | |
9471 | for it. For example: | |
9472 | ||
9473 | @lisp | |
9474 | (screen-locker-service xlockmore "xlock") | |
9475 | @end lisp | |
9476 | ||
9477 | makes the good ol' XlockMore usable. | |
9478 | @end deffn | |
9479 | ||
9480 | ||
f2ec23d1 AW |
9481 | @node Printing Services |
9482 | @subsubsection Printing Services | |
9483 | ||
de322a5d | 9484 | @cindex printer support with CUPS |
f2ec23d1 AW |
9485 | The @code{(gnu services cups)} module provides a Guix service definition |
9486 | for the CUPS printing service. To add printer support to a GuixSD | |
9487 | system, add a @code{cups-service} to the operating system definition: | |
9488 | ||
9489 | @deffn {Scheme Variable} cups-service-type | |
9490 | The service type for the CUPS print server. Its value should be a valid | |
9491 | CUPS configuration (see below). For example: | |
9492 | @example | |
9493 | (service cups-service-type (cups-configuration)) | |
9494 | @end example | |
9495 | @end deffn | |
9496 | ||
9497 | The CUPS configuration controls the basic things about your CUPS | |
9498 | installation: what interfaces it listens on, what to do if a print job | |
9499 | fails, how much logging to do, and so on. To actually add a printer, | |
9500 | you have to visit the @url{http://localhost:631} URL, or use a tool such | |
9501 | as GNOME's printer configuration services. By default, configuring a | |
9502 | CUPS service will generate a self-signed certificate if needed, for | |
9503 | secure connections to the print server. | |
9504 | ||
de322a5d LC |
9505 | Suppose you want to enable the Web interface of CUPS and also add |
9506 | support for HP printers @i{via} the @code{hplip} package. You can do | |
9507 | that directly, like this (you need to use the @code{(gnu packages cups)} | |
9508 | module): | |
f2ec23d1 AW |
9509 | |
9510 | @example | |
9511 | (service cups-service-type | |
9512 | (cups-configuration | |
de322a5d LC |
9513 | (web-interface? #t) |
9514 | (extensions | |
9515 | (list cups-filters hplip)))) | |
f2ec23d1 AW |
9516 | @end example |
9517 | ||
9518 | The available configuration parameters follow. Each parameter | |
9519 | definition is preceded by its type; for example, @samp{string-list foo} | |
9520 | indicates that the @code{foo} parameter should be specified as a list of | |
9521 | strings. There is also a way to specify the configuration as a string, | |
9522 | if you have an old @code{cupsd.conf} file that you want to port over | |
9523 | from some other system; see the end for more details. | |
9524 | ||
9525 | @c The following documentation was initially generated by | |
9526 | @c (generate-documentation) in (gnu services cups). Manually maintained | |
9527 | @c documentation is better, so we shouldn't hesitate to edit below as | |
9528 | @c needed. However if the change you want to make to this documentation | |
9529 | @c can be done in an automated way, it's probably easier to change | |
9530 | @c (generate-documentation) than to make it below and have to deal with | |
9531 | @c the churn as CUPS updates. | |
9532 | ||
9533 | ||
9534 | Available @code{cups-configuration} fields are: | |
9535 | ||
9536 | @deftypevr {@code{cups-configuration} parameter} package cups | |
9537 | The CUPS package. | |
9538 | @end deftypevr | |
9539 | ||
9540 | @deftypevr {@code{cups-configuration} parameter} package-list extensions | |
9541 | Drivers and other extensions to the CUPS package. | |
9542 | @end deftypevr | |
9543 | ||
9544 | @deftypevr {@code{cups-configuration} parameter} files-configuration files-configuration | |
9545 | Configuration of where to write logs, what directories to use for print | |
9546 | spools, and related privileged configuration parameters. | |
9547 | ||
9548 | Available @code{files-configuration} fields are: | |
9549 | ||
9550 | @deftypevr {@code{files-configuration} parameter} log-location access-log | |
9551 | Defines the access log filename. Specifying a blank filename disables | |
9552 | access log generation. The value @code{stderr} causes log entries to be | |
9553 | sent to the standard error file when the scheduler is running in the | |
9554 | foreground, or to the system log daemon when run in the background. The | |
9555 | value @code{syslog} causes log entries to be sent to the system log | |
9556 | daemon. The server name may be included in filenames using the string | |
9557 | @code{%s}, as in @code{/var/log/cups/%s-access_log}. | |
9558 | ||
9559 | Defaults to @samp{"/var/log/cups/access_log"}. | |
9560 | @end deftypevr | |
9561 | ||
9562 | @deftypevr {@code{files-configuration} parameter} file-name cache-dir | |
9563 | Where CUPS should cache data. | |
9564 | ||
9565 | Defaults to @samp{"/var/cache/cups"}. | |
9566 | @end deftypevr | |
9567 | ||
9568 | @deftypevr {@code{files-configuration} parameter} string config-file-perm | |
9569 | Specifies the permissions for all configuration files that the scheduler | |
9570 | writes. | |
9571 | ||
9572 | Note that the permissions for the printers.conf file are currently | |
9573 | masked to only allow access from the scheduler user (typically root). | |
9574 | This is done because printer device URIs sometimes contain sensitive | |
9575 | authentication information that should not be generally known on the | |
9576 | system. There is no way to disable this security feature. | |
9577 | ||
9578 | Defaults to @samp{"0640"}. | |
9579 | @end deftypevr | |
9580 | ||
9581 | @deftypevr {@code{files-configuration} parameter} log-location error-log | |
9582 | Defines the error log filename. Specifying a blank filename disables | |
9583 | access log generation. The value @code{stderr} causes log entries to be | |
9584 | sent to the standard error file when the scheduler is running in the | |
9585 | foreground, or to the system log daemon when run in the background. The | |
9586 | value @code{syslog} causes log entries to be sent to the system log | |
9587 | daemon. The server name may be included in filenames using the string | |
9588 | @code{%s}, as in @code{/var/log/cups/%s-error_log}. | |
9589 | ||
9590 | Defaults to @samp{"/var/log/cups/error_log"}. | |
9591 | @end deftypevr | |
9592 | ||
9593 | @deftypevr {@code{files-configuration} parameter} string fatal-errors | |
9594 | Specifies which errors are fatal, causing the scheduler to exit. The | |
9595 | kind strings are: | |
9596 | ||
9597 | @table @code | |
9598 | @item none | |
9599 | No errors are fatal. | |
9600 | ||
9601 | @item all | |
9602 | All of the errors below are fatal. | |
9603 | ||
9604 | @item browse | |
9605 | Browsing initialization errors are fatal, for example failed connections | |
9606 | to the DNS-SD daemon. | |
9607 | ||
9608 | @item config | |
9609 | Configuration file syntax errors are fatal. | |
9610 | ||
9611 | @item listen | |
9612 | Listen or Port errors are fatal, except for IPv6 failures on the | |
9613 | loopback or @code{any} addresses. | |
9614 | ||
9615 | @item log | |
9616 | Log file creation or write errors are fatal. | |
9617 | ||
9618 | @item permissions | |
9619 | Bad startup file permissions are fatal, for example shared TLS | |
9620 | certificate and key files with world-read permissions. | |
9621 | @end table | |
9622 | ||
9623 | Defaults to @samp{"all -browse"}. | |
9624 | @end deftypevr | |
9625 | ||
9626 | @deftypevr {@code{files-configuration} parameter} boolean file-device? | |
9627 | Specifies whether the file pseudo-device can be used for new printer | |
9628 | queues. The URI @uref{file:///dev/null} is always allowed. | |
9629 | ||
9630 | Defaults to @samp{#f}. | |
9631 | @end deftypevr | |
9632 | ||
9633 | @deftypevr {@code{files-configuration} parameter} string group | |
9634 | Specifies the group name or ID that will be used when executing external | |
9635 | programs. | |
9636 | ||
9637 | Defaults to @samp{"lp"}. | |
9638 | @end deftypevr | |
9639 | ||
9640 | @deftypevr {@code{files-configuration} parameter} string log-file-perm | |
9641 | Specifies the permissions for all log files that the scheduler writes. | |
9642 | ||
9643 | Defaults to @samp{"0644"}. | |
9644 | @end deftypevr | |
9645 | ||
9646 | @deftypevr {@code{files-configuration} parameter} log-location page-log | |
9647 | Defines the page log filename. Specifying a blank filename disables | |
9648 | access log generation. The value @code{stderr} causes log entries to be | |
9649 | sent to the standard error file when the scheduler is running in the | |
9650 | foreground, or to the system log daemon when run in the background. The | |
9651 | value @code{syslog} causes log entries to be sent to the system log | |
9652 | daemon. The server name may be included in filenames using the string | |
9653 | @code{%s}, as in @code{/var/log/cups/%s-page_log}. | |
9654 | ||
9655 | Defaults to @samp{"/var/log/cups/page_log"}. | |
9656 | @end deftypevr | |
9657 | ||
9658 | @deftypevr {@code{files-configuration} parameter} string remote-root | |
9659 | Specifies the username that is associated with unauthenticated accesses | |
9660 | by clients claiming to be the root user. The default is @code{remroot}. | |
9661 | ||
9662 | Defaults to @samp{"remroot"}. | |
9663 | @end deftypevr | |
9664 | ||
9665 | @deftypevr {@code{files-configuration} parameter} file-name request-root | |
9666 | Specifies the directory that contains print jobs and other HTTP request | |
9667 | data. | |
9668 | ||
9669 | Defaults to @samp{"/var/spool/cups"}. | |
9670 | @end deftypevr | |
9671 | ||
9672 | @deftypevr {@code{files-configuration} parameter} sandboxing sandboxing | |
9673 | Specifies the level of security sandboxing that is applied to print | |
9674 | filters, backends, and other child processes of the scheduler; either | |
9675 | @code{relaxed} or @code{strict}. This directive is currently only | |
9676 | used/supported on macOS. | |
9677 | ||
9678 | Defaults to @samp{strict}. | |
9679 | @end deftypevr | |
9680 | ||
9681 | @deftypevr {@code{files-configuration} parameter} file-name server-keychain | |
9682 | Specifies the location of TLS certificates and private keys. CUPS will | |
9683 | look for public and private keys in this directory: a @code{.crt} files | |
9684 | for PEM-encoded certificates and corresponding @code{.key} files for | |
9685 | PEM-encoded private keys. | |
9686 | ||
9687 | Defaults to @samp{"/etc/cups/ssl"}. | |
9688 | @end deftypevr | |
9689 | ||
9690 | @deftypevr {@code{files-configuration} parameter} file-name server-root | |
9691 | Specifies the directory containing the server configuration files. | |
9692 | ||
9693 | Defaults to @samp{"/etc/cups"}. | |
9694 | @end deftypevr | |
9695 | ||
9696 | @deftypevr {@code{files-configuration} parameter} boolean sync-on-close? | |
9697 | Specifies whether the scheduler calls fsync(2) after writing | |
9698 | configuration or state files. | |
9699 | ||
9700 | Defaults to @samp{#f}. | |
9701 | @end deftypevr | |
9702 | ||
9703 | @deftypevr {@code{files-configuration} parameter} space-separated-string-list system-group | |
9704 | Specifies the group(s) to use for @code{@@SYSTEM} group authentication. | |
9705 | @end deftypevr | |
9706 | ||
9707 | @deftypevr {@code{files-configuration} parameter} file-name temp-dir | |
9708 | Specifies the directory where temporary files are stored. | |
9709 | ||
9710 | Defaults to @samp{"/var/spool/cups/tmp"}. | |
9711 | @end deftypevr | |
9712 | ||
9713 | @deftypevr {@code{files-configuration} parameter} string user | |
9714 | Specifies the user name or ID that is used when running external | |
9715 | programs. | |
9716 | ||
9717 | Defaults to @samp{"lp"}. | |
9718 | @end deftypevr | |
9719 | @end deftypevr | |
9720 | ||
9721 | @deftypevr {@code{cups-configuration} parameter} access-log-level access-log-level | |
9722 | Specifies the logging level for the AccessLog file. The @code{config} | |
9723 | level logs when printers and classes are added, deleted, or modified and | |
9724 | when configuration files are accessed or updated. The @code{actions} | |
9725 | level logs when print jobs are submitted, held, released, modified, or | |
9726 | canceled, and any of the conditions for @code{config}. The @code{all} | |
9727 | level logs all requests. | |
9728 | ||
9729 | Defaults to @samp{actions}. | |
9730 | @end deftypevr | |
9731 | ||
9732 | @deftypevr {@code{cups-configuration} parameter} boolean auto-purge-jobs? | |
9733 | Specifies whether to purge job history data automatically when it is no | |
9734 | longer required for quotas. | |
9735 | ||
9736 | Defaults to @samp{#f}. | |
9737 | @end deftypevr | |
9738 | ||
9739 | @deftypevr {@code{cups-configuration} parameter} browse-local-protocols browse-local-protocols | |
9740 | Specifies which protocols to use for local printer sharing. | |
9741 | ||
9742 | Defaults to @samp{dnssd}. | |
9743 | @end deftypevr | |
9744 | ||
9745 | @deftypevr {@code{cups-configuration} parameter} boolean browse-web-if? | |
9746 | Specifies whether the CUPS web interface is advertised. | |
9747 | ||
9748 | Defaults to @samp{#f}. | |
9749 | @end deftypevr | |
9750 | ||
9751 | @deftypevr {@code{cups-configuration} parameter} boolean browsing? | |
9752 | Specifies whether shared printers are advertised. | |
9753 | ||
9754 | Defaults to @samp{#f}. | |
9755 | @end deftypevr | |
9756 | ||
9757 | @deftypevr {@code{cups-configuration} parameter} string classification | |
9758 | Specifies the security classification of the server. Any valid banner | |
9759 | name can be used, including "classified", "confidential", "secret", | |
9760 | "topsecret", and "unclassified", or the banner can be omitted to disable | |
9761 | secure printing functions. | |
9762 | ||
9763 | Defaults to @samp{""}. | |
9764 | @end deftypevr | |
9765 | ||
9766 | @deftypevr {@code{cups-configuration} parameter} boolean classify-override? | |
9767 | Specifies whether users may override the classification (cover page) of | |
9768 | individual print jobs using the @code{job-sheets} option. | |
9769 | ||
9770 | Defaults to @samp{#f}. | |
9771 | @end deftypevr | |
9772 | ||
9773 | @deftypevr {@code{cups-configuration} parameter} default-auth-type default-auth-type | |
9774 | Specifies the default type of authentication to use. | |
9775 | ||
9776 | Defaults to @samp{Basic}. | |
9777 | @end deftypevr | |
9778 | ||
9779 | @deftypevr {@code{cups-configuration} parameter} default-encryption default-encryption | |
9780 | Specifies whether encryption will be used for authenticated requests. | |
9781 | ||
9782 | Defaults to @samp{Required}. | |
9783 | @end deftypevr | |
9784 | ||
9785 | @deftypevr {@code{cups-configuration} parameter} string default-language | |
9786 | Specifies the default language to use for text and web content. | |
9787 | ||
9788 | Defaults to @samp{"en"}. | |
9789 | @end deftypevr | |
9790 | ||
9791 | @deftypevr {@code{cups-configuration} parameter} string default-paper-size | |
9792 | Specifies the default paper size for new print queues. @samp{"Auto"} | |
9793 | uses a locale-specific default, while @samp{"None"} specifies there is | |
9794 | no default paper size. Specific size names are typically | |
9795 | @samp{"Letter"} or @samp{"A4"}. | |
9796 | ||
9797 | Defaults to @samp{"Auto"}. | |
9798 | @end deftypevr | |
9799 | ||
9800 | @deftypevr {@code{cups-configuration} parameter} string default-policy | |
9801 | Specifies the default access policy to use. | |
9802 | ||
9803 | Defaults to @samp{"default"}. | |
9804 | @end deftypevr | |
9805 | ||
9806 | @deftypevr {@code{cups-configuration} parameter} boolean default-shared? | |
9807 | Specifies whether local printers are shared by default. | |
9808 | ||
9809 | Defaults to @samp{#t}. | |
9810 | @end deftypevr | |
9811 | ||
9812 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer dirty-clean-interval | |
9813 | Specifies the delay for updating of configuration and state files, in | |
9814 | seconds. A value of 0 causes the update to happen as soon as possible, | |
9815 | typically within a few milliseconds. | |
9816 | ||
9817 | Defaults to @samp{30}. | |
9818 | @end deftypevr | |
9819 | ||
9820 | @deftypevr {@code{cups-configuration} parameter} error-policy error-policy | |
9821 | Specifies what to do when an error occurs. Possible values are | |
9822 | @code{abort-job}, which will discard the failed print job; | |
9823 | @code{retry-job}, which will retry the job at a later time; | |
9824 | @code{retry-this-job}, which retries the failed job immediately; and | |
9825 | @code{stop-printer}, which stops the printer. | |
9826 | ||
9827 | Defaults to @samp{stop-printer}. | |
9828 | @end deftypevr | |
9829 | ||
9830 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer filter-limit | |
9831 | Specifies the maximum cost of filters that are run concurrently, which | |
9832 | can be used to minimize disk, memory, and CPU resource problems. A | |
9833 | limit of 0 disables filter limiting. An average print to a | |
9834 | non-PostScript printer needs a filter limit of about 200. A PostScript | |
9835 | printer needs about half that (100). Setting the limit below these | |
9836 | thresholds will effectively limit the scheduler to printing a single job | |
9837 | at any time. | |
9838 | ||
9839 | Defaults to @samp{0}. | |
9840 | @end deftypevr | |
9841 | ||
9842 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer filter-nice | |
9843 | Specifies the scheduling priority of filters that are run to print a | |
9844 | job. The nice value ranges from 0, the highest priority, to 19, the | |
9845 | lowest priority. | |
9846 | ||
9847 | Defaults to @samp{0}. | |
9848 | @end deftypevr | |
9849 | ||
9850 | @deftypevr {@code{cups-configuration} parameter} host-name-lookups host-name-lookups | |
9851 | Specifies whether to do reverse lookups on connecting clients. The | |
9852 | @code{double} setting causes @code{cupsd} to verify that the hostname | |
9853 | resolved from the address matches one of the addresses returned for that | |
9854 | hostname. Double lookups also prevent clients with unregistered | |
9855 | addresses from connecting to your server. Only set this option to | |
9856 | @code{#t} or @code{double} if absolutely required. | |
9857 | ||
9858 | Defaults to @samp{#f}. | |
9859 | @end deftypevr | |
9860 | ||
9861 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer job-kill-delay | |
9862 | Specifies the number of seconds to wait before killing the filters and | |
9863 | backend associated with a canceled or held job. | |
9864 | ||
9865 | Defaults to @samp{30}. | |
9866 | @end deftypevr | |
9867 | ||
9868 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer job-retry-interval | |
9869 | Specifies the interval between retries of jobs in seconds. This is | |
9870 | typically used for fax queues but can also be used with normal print | |
9871 | queues whose error policy is @code{retry-job} or | |
9872 | @code{retry-current-job}. | |
9873 | ||
9874 | Defaults to @samp{30}. | |
9875 | @end deftypevr | |
9876 | ||
9877 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer job-retry-limit | |
9878 | Specifies the number of retries that are done for jobs. This is | |
9879 | typically used for fax queues but can also be used with normal print | |
9880 | queues whose error policy is @code{retry-job} or | |
9881 | @code{retry-current-job}. | |
9882 | ||
9883 | Defaults to @samp{5}. | |
9884 | @end deftypevr | |
9885 | ||
9886 | @deftypevr {@code{cups-configuration} parameter} boolean keep-alive? | |
9887 | Specifies whether to support HTTP keep-alive connections. | |
9888 | ||
9889 | Defaults to @samp{#t}. | |
9890 | @end deftypevr | |
9891 | ||
9892 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer keep-alive-timeout | |
9893 | Specifies how long an idle client connection remains open, in seconds. | |
9894 | ||
9895 | Defaults to @samp{30}. | |
9896 | @end deftypevr | |
9897 | ||
9898 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer limit-request-body | |
9899 | Specifies the maximum size of print files, IPP requests, and HTML form | |
9900 | data. A limit of 0 disables the limit check. | |
9901 | ||
9902 | Defaults to @samp{0}. | |
9903 | @end deftypevr | |
9904 | ||
9905 | @deftypevr {@code{cups-configuration} parameter} multiline-string-list listen | |
9906 | Listens on the specified interfaces for connections. Valid values are | |
9907 | of the form @var{address}:@var{port}, where @var{address} is either an | |
9908 | IPv6 address enclosed in brackets, an IPv4 address, or @code{*} to | |
9909 | indicate all addresses. Values can also be file names of local UNIX | |
9910 | domain sockets. The Listen directive is similar to the Port directive | |
9911 | but allows you to restrict access to specific interfaces or networks. | |
9912 | @end deftypevr | |
9913 | ||
9914 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer listen-back-log | |
9915 | Specifies the number of pending connections that will be allowed. This | |
9916 | normally only affects very busy servers that have reached the MaxClients | |
9917 | limit, but can also be triggered by large numbers of simultaneous | |
9918 | connections. When the limit is reached, the operating system will | |
9919 | refuse additional connections until the scheduler can accept the pending | |
9920 | ones. | |
9921 | ||
9922 | Defaults to @samp{128}. | |
9923 | @end deftypevr | |
9924 | ||
9925 | @deftypevr {@code{cups-configuration} parameter} location-access-control-list location-access-controls | |
9926 | Specifies a set of additional access controls. | |
9927 | ||
9928 | Available @code{location-access-controls} fields are: | |
9929 | ||
9930 | @deftypevr {@code{location-access-controls} parameter} file-name path | |
9931 | Specifies the URI path to which the access control applies. | |
9932 | @end deftypevr | |
9933 | ||
9934 | @deftypevr {@code{location-access-controls} parameter} access-control-list access-controls | |
9935 | Access controls for all access to this path, in the same format as the | |
9936 | @code{access-controls} of @code{operation-access-control}. | |
9937 | ||
9938 | Defaults to @samp{()}. | |
9939 | @end deftypevr | |
9940 | ||
9941 | @deftypevr {@code{location-access-controls} parameter} method-access-control-list method-access-controls | |
9942 | Access controls for method-specific access to this path. | |
9943 | ||
9944 | Defaults to @samp{()}. | |
9945 | ||
9946 | Available @code{method-access-controls} fields are: | |
9947 | ||
9948 | @deftypevr {@code{method-access-controls} parameter} boolean reverse? | |
9949 | If @code{#t}, apply access controls to all methods except the listed | |
9950 | methods. Otherwise apply to only the listed methods. | |
9951 | ||
9952 | Defaults to @samp{#f}. | |
9953 | @end deftypevr | |
9954 | ||
9955 | @deftypevr {@code{method-access-controls} parameter} method-list methods | |
9956 | Methods to which this access control applies. | |
9957 | ||
9958 | Defaults to @samp{()}. | |
9959 | @end deftypevr | |
9960 | ||
9961 | @deftypevr {@code{method-access-controls} parameter} access-control-list access-controls | |
9962 | Access control directives, as a list of strings. Each string should be | |
9963 | one directive, such as "Order allow,deny". | |
9964 | ||
9965 | Defaults to @samp{()}. | |
9966 | @end deftypevr | |
9967 | @end deftypevr | |
9968 | @end deftypevr | |
9969 | ||
9970 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer log-debug-history | |
9971 | Specifies the number of debugging messages that are retained for logging | |
9972 | if an error occurs in a print job. Debug messages are logged regardless | |
9973 | of the LogLevel setting. | |
9974 | ||
9975 | Defaults to @samp{100}. | |
9976 | @end deftypevr | |
9977 | ||
9978 | @deftypevr {@code{cups-configuration} parameter} log-level log-level | |
9979 | Specifies the level of logging for the ErrorLog file. The value | |
9980 | @code{none} stops all logging while @code{debug2} logs everything. | |
9981 | ||
9982 | Defaults to @samp{info}. | |
9983 | @end deftypevr | |
9984 | ||
9985 | @deftypevr {@code{cups-configuration} parameter} log-time-format log-time-format | |
9986 | Specifies the format of the date and time in the log files. The value | |
9987 | @code{standard} logs whole seconds while @code{usecs} logs microseconds. | |
9988 | ||
9989 | Defaults to @samp{standard}. | |
9990 | @end deftypevr | |
9991 | ||
9992 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-clients | |
9993 | Specifies the maximum number of simultaneous clients that are allowed by | |
9994 | the scheduler. | |
9995 | ||
9996 | Defaults to @samp{100}. | |
9997 | @end deftypevr | |
9998 | ||
9999 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-clients-per-host | |
10000 | Specifies the maximum number of simultaneous clients that are allowed | |
10001 | from a single address. | |
10002 | ||
10003 | Defaults to @samp{100}. | |
10004 | @end deftypevr | |
10005 | ||
10006 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-copies | |
10007 | Specifies the maximum number of copies that a user can print of each | |
10008 | job. | |
10009 | ||
10010 | Defaults to @samp{9999}. | |
10011 | @end deftypevr | |
10012 | ||
10013 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-hold-time | |
10014 | Specifies the maximum time a job may remain in the @code{indefinite} | |
10015 | hold state before it is canceled. A value of 0 disables cancellation of | |
10016 | held jobs. | |
10017 | ||
10018 | Defaults to @samp{0}. | |
10019 | @end deftypevr | |
10020 | ||
10021 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-jobs | |
10022 | Specifies the maximum number of simultaneous jobs that are allowed. Set | |
10023 | to 0 to allow an unlimited number of jobs. | |
10024 | ||
10025 | Defaults to @samp{500}. | |
10026 | @end deftypevr | |
10027 | ||
10028 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-jobs-per-printer | |
10029 | Specifies the maximum number of simultaneous jobs that are allowed per | |
10030 | printer. A value of 0 allows up to MaxJobs jobs per printer. | |
10031 | ||
10032 | Defaults to @samp{0}. | |
10033 | @end deftypevr | |
10034 | ||
10035 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-jobs-per-user | |
10036 | Specifies the maximum number of simultaneous jobs that are allowed per | |
10037 | user. A value of 0 allows up to MaxJobs jobs per user. | |
10038 | ||
10039 | Defaults to @samp{0}. | |
10040 | @end deftypevr | |
10041 | ||
10042 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-job-time | |
10043 | Specifies the maximum time a job may take to print before it is | |
10044 | canceled, in seconds. Set to 0 to disable cancellation of "stuck" jobs. | |
10045 | ||
10046 | Defaults to @samp{10800}. | |
10047 | @end deftypevr | |
10048 | ||
10049 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-log-size | |
10050 | Specifies the maximum size of the log files before they are rotated, in | |
10051 | bytes. The value 0 disables log rotation. | |
10052 | ||
10053 | Defaults to @samp{1048576}. | |
10054 | @end deftypevr | |
10055 | ||
10056 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer multiple-operation-timeout | |
10057 | Specifies the maximum amount of time to allow between files in a | |
10058 | multiple file print job, in seconds. | |
10059 | ||
10060 | Defaults to @samp{300}. | |
10061 | @end deftypevr | |
10062 | ||
10063 | @deftypevr {@code{cups-configuration} parameter} string page-log-format | |
10064 | Specifies the format of PageLog lines. Sequences beginning with percent | |
10065 | (@samp{%}) characters are replaced with the corresponding information, | |
10066 | while all other characters are copied literally. The following percent | |
10067 | sequences are recognized: | |
10068 | ||
10069 | @table @samp | |
10070 | @item %% | |
10071 | insert a single percent character | |
10072 | ||
10073 | @item %@{name@} | |
10074 | insert the value of the specified IPP attribute | |
10075 | ||
10076 | @item %C | |
10077 | insert the number of copies for the current page | |
10078 | ||
10079 | @item %P | |
10080 | insert the current page number | |
10081 | ||
10082 | @item %T | |
10083 | insert the current date and time in common log format | |
10084 | ||
10085 | @item %j | |
10086 | insert the job ID | |
10087 | ||
10088 | @item %p | |
10089 | insert the printer name | |
10090 | ||
10091 | @item %u | |
10092 | insert the username | |
10093 | @end table | |
10094 | ||
10095 | A value of the empty string disables page logging. The string @code{%p | |
10096 | %u %j %T %P %C %@{job-billing@} %@{job-originating-host-name@} | |
10097 | %@{job-name@} %@{media@} %@{sides@}} creates a page log with the | |
10098 | standard items. | |
10099 | ||
10100 | Defaults to @samp{""}. | |
10101 | @end deftypevr | |
10102 | ||
10103 | @deftypevr {@code{cups-configuration} parameter} environment-variables environment-variables | |
10104 | Passes the specified environment variable(s) to child processes; a list | |
10105 | of strings. | |
10106 | ||
10107 | Defaults to @samp{()}. | |
10108 | @end deftypevr | |
10109 | ||
10110 | @deftypevr {@code{cups-configuration} parameter} policy-configuration-list policies | |
10111 | Specifies named access control policies. | |
10112 | ||
10113 | Available @code{policy-configuration} fields are: | |
10114 | ||
10115 | @deftypevr {@code{policy-configuration} parameter} string name | |
10116 | Name of the policy. | |
10117 | @end deftypevr | |
10118 | ||
10119 | @deftypevr {@code{policy-configuration} parameter} string job-private-access | |
10120 | Specifies an access list for a job's private values. @code{@@ACL} maps | |
10121 | to the printer's requesting-user-name-allowed or | |
10122 | requesting-user-name-denied values. @code{@@OWNER} maps to the job's | |
10123 | owner. @code{@@SYSTEM} maps to the groups listed for the | |
10124 | @code{system-group} field of the @code{files-config} configuration, | |
10125 | which is reified into the @code{cups-files.conf(5)} file. Other | |
10126 | possible elements of the access list include specific user names, and | |
10127 | @code{@@@var{group}} to indicate members of a specific group. The | |
10128 | access list may also be simply @code{all} or @code{default}. | |
10129 | ||
10130 | Defaults to @samp{"@@OWNER @@SYSTEM"}. | |
10131 | @end deftypevr | |
10132 | ||
10133 | @deftypevr {@code{policy-configuration} parameter} string job-private-values | |
10134 | Specifies the list of job values to make private, or @code{all}, | |
10135 | @code{default}, or @code{none}. | |
10136 | ||
10137 | Defaults to @samp{"job-name job-originating-host-name | |
10138 | job-originating-user-name phone"}. | |
10139 | @end deftypevr | |
10140 | ||
10141 | @deftypevr {@code{policy-configuration} parameter} string subscription-private-access | |
10142 | Specifies an access list for a subscription's private values. | |
10143 | @code{@@ACL} maps to the printer's requesting-user-name-allowed or | |
10144 | requesting-user-name-denied values. @code{@@OWNER} maps to the job's | |
10145 | owner. @code{@@SYSTEM} maps to the groups listed for the | |
10146 | @code{system-group} field of the @code{files-config} configuration, | |
10147 | which is reified into the @code{cups-files.conf(5)} file. Other | |
10148 | possible elements of the access list include specific user names, and | |
10149 | @code{@@@var{group}} to indicate members of a specific group. The | |
10150 | access list may also be simply @code{all} or @code{default}. | |
10151 | ||
10152 | Defaults to @samp{"@@OWNER @@SYSTEM"}. | |
10153 | @end deftypevr | |
10154 | ||
10155 | @deftypevr {@code{policy-configuration} parameter} string subscription-private-values | |
10156 | Specifies the list of job values to make private, or @code{all}, | |
10157 | @code{default}, or @code{none}. | |
10158 | ||
10159 | Defaults to @samp{"notify-events notify-pull-method notify-recipient-uri | |
10160 | notify-subscriber-user-name notify-user-data"}. | |
10161 | @end deftypevr | |
10162 | ||
10163 | @deftypevr {@code{policy-configuration} parameter} operation-access-control-list access-controls | |
10164 | Access control by IPP operation. | |
10165 | ||
10166 | Defaults to @samp{()}. | |
10167 | @end deftypevr | |
10168 | @end deftypevr | |
10169 | ||
10170 | @deftypevr {@code{cups-configuration} parameter} boolean-or-non-negative-integer preserve-job-files | |
10171 | Specifies whether job files (documents) are preserved after a job is | |
10172 | printed. If a numeric value is specified, job files are preserved for | |
10173 | the indicated number of seconds after printing. Otherwise a boolean | |
10174 | value applies indefinitely. | |
10175 | ||
10176 | Defaults to @samp{86400}. | |
10177 | @end deftypevr | |
10178 | ||
10179 | @deftypevr {@code{cups-configuration} parameter} boolean-or-non-negative-integer preserve-job-history | |
10180 | Specifies whether the job history is preserved after a job is printed. | |
10181 | If a numeric value is specified, the job history is preserved for the | |
10182 | indicated number of seconds after printing. If @code{#t}, the job | |
10183 | history is preserved until the MaxJobs limit is reached. | |
10184 | ||
10185 | Defaults to @samp{#t}. | |
10186 | @end deftypevr | |
10187 | ||
10188 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer reload-timeout | |
10189 | Specifies the amount of time to wait for job completion before | |
10190 | restarting the scheduler. | |
10191 | ||
10192 | Defaults to @samp{30}. | |
10193 | @end deftypevr | |
10194 | ||
10195 | @deftypevr {@code{cups-configuration} parameter} string rip-cache | |
10196 | Specifies the maximum amount of memory to use when converting documents | |
10197 | into bitmaps for a printer. | |
10198 | ||
10199 | Defaults to @samp{"128m"}. | |
10200 | @end deftypevr | |
10201 | ||
10202 | @deftypevr {@code{cups-configuration} parameter} string server-admin | |
10203 | Specifies the email address of the server administrator. | |
10204 | ||
10205 | Defaults to @samp{"root@@localhost.localdomain"}. | |
10206 | @end deftypevr | |
10207 | ||
10208 | @deftypevr {@code{cups-configuration} parameter} host-name-list-or-* server-alias | |
10209 | The ServerAlias directive is used for HTTP Host header validation when | |
10210 | clients connect to the scheduler from external interfaces. Using the | |
10211 | special name @code{*} can expose your system to known browser-based DNS | |
10212 | rebinding attacks, even when accessing sites through a firewall. If the | |
10213 | auto-discovery of alternate names does not work, we recommend listing | |
10214 | each alternate name with a ServerAlias directive instead of using | |
10215 | @code{*}. | |
10216 | ||
10217 | Defaults to @samp{*}. | |
10218 | @end deftypevr | |
10219 | ||
10220 | @deftypevr {@code{cups-configuration} parameter} string server-name | |
10221 | Specifies the fully-qualified host name of the server. | |
10222 | ||
10223 | Defaults to @samp{"localhost"}. | |
10224 | @end deftypevr | |
10225 | ||
10226 | @deftypevr {@code{cups-configuration} parameter} server-tokens server-tokens | |
10227 | Specifies what information is included in the Server header of HTTP | |
10228 | responses. @code{None} disables the Server header. @code{ProductOnly} | |
10229 | reports @code{CUPS}. @code{Major} reports @code{CUPS 2}. @code{Minor} | |
10230 | reports @code{CUPS 2.0}. @code{Minimal} reports @code{CUPS 2.0.0}. | |
10231 | @code{OS} reports @code{CUPS 2.0.0 (@var{uname})} where @var{uname} is | |
10232 | the output of the @code{uname} command. @code{Full} reports @code{CUPS | |
10233 | 2.0.0 (@var{uname}) IPP/2.0}. | |
10234 | ||
10235 | Defaults to @samp{Minimal}. | |
10236 | @end deftypevr | |
10237 | ||
10238 | @deftypevr {@code{cups-configuration} parameter} string set-env | |
10239 | Set the specified environment variable to be passed to child processes. | |
10240 | ||
10241 | Defaults to @samp{"variable value"}. | |
10242 | @end deftypevr | |
10243 | ||
10244 | @deftypevr {@code{cups-configuration} parameter} multiline-string-list ssl-listen | |
10245 | Listens on the specified interfaces for encrypted connections. Valid | |
10246 | values are of the form @var{address}:@var{port}, where @var{address} is | |
10247 | either an IPv6 address enclosed in brackets, an IPv4 address, or | |
10248 | @code{*} to indicate all addresses. | |
10249 | ||
10250 | Defaults to @samp{()}. | |
10251 | @end deftypevr | |
10252 | ||
10253 | @deftypevr {@code{cups-configuration} parameter} ssl-options ssl-options | |
10254 | Sets encryption options. By default, CUPS only supports encryption | |
10255 | using TLS v1.0 or higher using known secure cipher suites. The | |
10256 | @code{AllowRC4} option enables the 128-bit RC4 cipher suites, which are | |
10257 | required for some older clients that do not implement newer ones. The | |
10258 | @code{AllowSSL3} option enables SSL v3.0, which is required for some | |
10259 | older clients that do not support TLS v1.0. | |
10260 | ||
10261 | Defaults to @samp{()}. | |
10262 | @end deftypevr | |
10263 | ||
10264 | @deftypevr {@code{cups-configuration} parameter} boolean strict-conformance? | |
10265 | Specifies whether the scheduler requires clients to strictly adhere to | |
10266 | the IPP specifications. | |
10267 | ||
10268 | Defaults to @samp{#f}. | |
10269 | @end deftypevr | |
10270 | ||
10271 | @deftypevr {@code{cups-configuration} parameter} non-negative-integer timeout | |
10272 | Specifies the HTTP request timeout, in seconds. | |
10273 | ||
10274 | Defaults to @samp{300}. | |
10275 | ||
10276 | @end deftypevr | |
10277 | ||
10278 | @deftypevr {@code{cups-configuration} parameter} boolean web-interface? | |
10279 | Specifies whether the web interface is enabled. | |
10280 | ||
10281 | Defaults to @samp{#f}. | |
10282 | @end deftypevr | |
10283 | ||
10284 | At this point you're probably thinking ``oh dear, Guix manual, I like | |
10285 | you but you can stop already with the configuration options''. Indeed. | |
10286 | However, one more point: it could be that you have an existing | |
10287 | @code{cupsd.conf} that you want to use. In that case, you can pass an | |
10288 | @code{opaque-cups-configuration} as the configuration of a | |
10289 | @code{cups-service-type}. | |
10290 | ||
10291 | Available @code{opaque-cups-configuration} fields are: | |
10292 | ||
10293 | @deftypevr {@code{opaque-cups-configuration} parameter} package cups | |
10294 | The CUPS package. | |
10295 | @end deftypevr | |
10296 | ||
10297 | @deftypevr {@code{opaque-cups-configuration} parameter} string cupsd.conf | |
10298 | The contents of the @code{cupsd.conf}, as a string. | |
10299 | @end deftypevr | |
10300 | ||
10301 | @deftypevr {@code{opaque-cups-configuration} parameter} string cups-files.conf | |
10302 | The contents of the @code{cups-files.conf} file, as a string. | |
10303 | @end deftypevr | |
10304 | ||
10305 | For example, if your @code{cupsd.conf} and @code{cups-files.conf} are in | |
10306 | strings of the same name, you could instantiate a CUPS service like | |
10307 | this: | |
10308 | ||
10309 | @example | |
10310 | (service cups-service-type | |
10311 | (opaque-cups-configuration | |
10312 | (cupsd.conf cupsd.conf) | |
10313 | (cups-files.conf cups-files.conf))) | |
10314 | @end example | |
10315 | ||
10316 | ||
fe1a39d3 LC |
10317 | @node Desktop Services |
10318 | @subsubsection Desktop Services | |
aa4ed923 | 10319 | |
fe1a39d3 LC |
10320 | The @code{(gnu services desktop)} module provides services that are |
10321 | usually useful in the context of a ``desktop'' setup---that is, on a | |
10322 | machine running a graphical display server, possibly with graphical user | |
7a2413e4 AW |
10323 | interfaces, etc. It also defines services that provide specific desktop |
10324 | environments like GNOME and XFCE. | |
aa4ed923 | 10325 | |
4467be21 LC |
10326 | To simplify things, the module defines a variable containing the set of |
10327 | services that users typically expect on a machine with a graphical | |
10328 | environment and networking: | |
10329 | ||
10330 | @defvr {Scheme Variable} %desktop-services | |
10331 | This is a list of services that builds upon @var{%base-services} and | |
1068f26b | 10332 | adds or adjusts services for a typical ``desktop'' setup. |
4467be21 LC |
10333 | |
10334 | In particular, it adds a graphical login manager (@pxref{X Window, | |
6726282b LC |
10335 | @code{slim-service}}), screen lockers, |
10336 | a network management tool (@pxref{Networking | |
4467be21 | 10337 | Services, @code{wicd-service}}), energy and color management services, |
4650a77e | 10338 | the @code{elogind} login and seat manager, the Polkit privilege service, |
cee32ee4 AW |
10339 | the GeoClue location service, an NTP client (@pxref{Networking |
10340 | Services}), the Avahi daemon, and has the name service switch service | |
10341 | configured to be able to use @code{nss-mdns} (@pxref{Name Service | |
10342 | Switch, mDNS}). | |
4467be21 LC |
10343 | @end defvr |
10344 | ||
10345 | The @var{%desktop-services} variable can be used as the @code{services} | |
10346 | field of an @code{operating-system} declaration (@pxref{operating-system | |
10347 | Reference, @code{services}}). | |
10348 | ||
7a2413e4 AW |
10349 | Additionally, the @code{gnome-desktop-service} and |
10350 | @code{xfce-desktop-service} procedures can add GNOME and/or XFCE to a | |
10351 | system. To ``add GNOME'' means that system-level services like the | |
10352 | backlight adjustment helpers and the power management utilities are | |
10353 | added to the system, extending @code{polkit} and @code{dbus} | |
10354 | appropriately, allowing GNOME to operate with elevated privileges on a | |
10355 | limited number of special-purpose system interfaces. Additionally, | |
10356 | adding a service made by @code{gnome-desktop-service} adds the GNOME | |
10357 | metapackage to the system profile. Likewise, adding the XFCE service | |
10358 | not only adds the @code{xfce} metapackage to the system profile, but it | |
10359 | also gives the Thunar file manager the ability to open a ``root-mode'' | |
10360 | file management window, if the user authenticates using the | |
10361 | administrator's password via the standard polkit graphical interface. | |
10362 | ||
10363 | @deffn {Scheme Procedure} gnome-desktop-service | |
10364 | Return a service that adds the @code{gnome} package to the system | |
10365 | profile, and extends polkit with the actions from | |
10366 | @code{gnome-settings-daemon}. | |
10367 | @end deffn | |
10368 | ||
10369 | @deffn {Scheme Procedure} xfce-desktop-service | |
10370 | Return a service that adds the @code{xfce} package to the system profile, | |
5741e3e5 | 10371 | and extends polkit with the ability for @code{thunar} to manipulate the |
7a2413e4 AW |
10372 | file system as root from within a user session, after the user has |
10373 | authenticated with the administrator's password. | |
10374 | @end deffn | |
10375 | ||
10376 | Because the GNOME and XFCE desktop services pull in so many packages, | |
10377 | the default @code{%desktop-services} variable doesn't include either of | |
10378 | them by default. To add GNOME or XFCE, just @code{cons} them onto | |
10379 | @code{%desktop-services} in the @code{services} field of your | |
10380 | @code{operating-system}: | |
10381 | ||
10382 | @example | |
10383 | (use-modules (gnu)) | |
10384 | (use-service-modules desktop) | |
10385 | (operating-system | |
10386 | ... | |
10387 | ;; cons* adds items to the list given as its last argument. | |
10388 | (services (cons* (gnome-desktop-service) | |
10389 | (xfce-desktop-service) | |
10390 | %desktop-services)) | |
10391 | ...) | |
10392 | @end example | |
10393 | ||
10394 | These desktop environments will then be available as options in the | |
10395 | graphical login window. | |
10396 | ||
10397 | The actual service definitions included in @code{%desktop-services} and | |
10398 | provided by @code{(gnu services dbus)} and @code{(gnu services desktop)} | |
10399 | are described below. | |
4467be21 | 10400 | |
0adfe95a | 10401 | @deffn {Scheme Procedure} dbus-service [#:dbus @var{dbus}] [#:services '()] |
fe1a39d3 LC |
10402 | Return a service that runs the ``system bus'', using @var{dbus}, with |
10403 | support for @var{services}. | |
aa4ed923 | 10404 | |
fe1a39d3 LC |
10405 | @uref{http://dbus.freedesktop.org/, D-Bus} is an inter-process communication |
10406 | facility. Its system bus is used to allow system services to communicate | |
1068f26b | 10407 | and to be notified of system-wide events. |
aa4ed923 | 10408 | |
fe1a39d3 LC |
10409 | @var{services} must be a list of packages that provide an |
10410 | @file{etc/dbus-1/system.d} directory containing additional D-Bus configuration | |
10411 | and policy files. For example, to allow avahi-daemon to use the system bus, | |
10412 | @var{services} must be equal to @code{(list avahi)}. | |
aa4ed923 AK |
10413 | @end deffn |
10414 | ||
0adfe95a | 10415 | @deffn {Scheme Procedure} elogind-service [#:config @var{config}] |
4650a77e AW |
10416 | Return a service that runs the @code{elogind} login and |
10417 | seat management daemon. @uref{https://github.com/andywingo/elogind, | |
10418 | Elogind} exposes a D-Bus interface that can be used to know which users | |
10419 | are logged in, know what kind of sessions they have open, suspend the | |
10420 | system, inhibit system suspend, reboot the system, and other tasks. | |
10421 | ||
10422 | Elogind handles most system-level power events for a computer, for | |
10423 | example suspending the system when a lid is closed, or shutting it down | |
10424 | when the power button is pressed. | |
10425 | ||
10426 | The @var{config} keyword argument specifies the configuration for | |
1068f26b | 10427 | elogind, and should be the result of an @code{(elogind-configuration |
4650a77e AW |
10428 | (@var{parameter} @var{value})...)} invocation. Available parameters and |
10429 | their default values are: | |
10430 | ||
10431 | @table @code | |
10432 | @item kill-user-processes? | |
10433 | @code{#f} | |
10434 | @item kill-only-users | |
10435 | @code{()} | |
10436 | @item kill-exclude-users | |
10437 | @code{("root")} | |
10438 | @item inhibit-delay-max-seconds | |
10439 | @code{5} | |
10440 | @item handle-power-key | |
10441 | @code{poweroff} | |
10442 | @item handle-suspend-key | |
10443 | @code{suspend} | |
10444 | @item handle-hibernate-key | |
10445 | @code{hibernate} | |
10446 | @item handle-lid-switch | |
10447 | @code{suspend} | |
10448 | @item handle-lid-switch-docked | |
10449 | @code{ignore} | |
10450 | @item power-key-ignore-inhibited? | |
10451 | @code{#f} | |
10452 | @item suspend-key-ignore-inhibited? | |
10453 | @code{#f} | |
10454 | @item hibernate-key-ignore-inhibited? | |
10455 | @code{#f} | |
10456 | @item lid-switch-ignore-inhibited? | |
10457 | @code{#t} | |
10458 | @item holdoff-timeout-seconds | |
10459 | @code{30} | |
10460 | @item idle-action | |
10461 | @code{ignore} | |
10462 | @item idle-action-seconds | |
10463 | @code{(* 30 60)} | |
10464 | @item runtime-directory-size-percent | |
10465 | @code{10} | |
10466 | @item runtime-directory-size | |
10467 | @code{#f} | |
10468 | @item remove-ipc? | |
10469 | @code{#t} | |
10470 | @item suspend-state | |
10471 | @code{("mem" "standby" "freeze")} | |
10472 | @item suspend-mode | |
10473 | @code{()} | |
10474 | @item hibernate-state | |
10475 | @code{("disk")} | |
10476 | @item hibernate-mode | |
10477 | @code{("platform" "shutdown")} | |
10478 | @item hybrid-sleep-state | |
10479 | @code{("disk")} | |
10480 | @item hybrid-sleep-mode | |
10481 | @code{("suspend" "platform" "shutdown")} | |
10482 | @end table | |
10483 | @end deffn | |
10484 | ||
be1c2c54 | 10485 | @deffn {Scheme Procedure} polkit-service @ |
4650a77e | 10486 | [#:polkit @var{polkit}] |
222e3319 LC |
10487 | Return a service that runs the |
10488 | @uref{http://www.freedesktop.org/wiki/Software/polkit/, Polkit privilege | |
10489 | management service}, which allows system administrators to grant access to | |
10490 | privileged operations in a structured way. By querying the Polkit service, a | |
10491 | privileged system component can know when it should grant additional | |
10492 | capabilities to ordinary users. For example, an ordinary user can be granted | |
10493 | the capability to suspend the system if the user is logged in locally. | |
4650a77e AW |
10494 | @end deffn |
10495 | ||
be1c2c54 | 10496 | @deffn {Scheme Procedure} upower-service [#:upower @var{upower}] @ |
be234128 AW |
10497 | [#:watts-up-pro? #f] @ |
10498 | [#:poll-batteries? #t] @ | |
10499 | [#:ignore-lid? #f] @ | |
10500 | [#:use-percentage-for-policy? #f] @ | |
10501 | [#:percentage-low 10] @ | |
10502 | [#:percentage-critical 3] @ | |
10503 | [#:percentage-action 2] @ | |
10504 | [#:time-low 1200] @ | |
10505 | [#:time-critical 300] @ | |
10506 | [#:time-action 120] @ | |
10507 | [#:critical-power-action 'hybrid-sleep] | |
10508 | Return a service that runs @uref{http://upower.freedesktop.org/, | |
10509 | @command{upowerd}}, a system-wide monitor for power consumption and battery | |
10510 | levels, with the given configuration settings. It implements the | |
10511 | @code{org.freedesktop.UPower} D-Bus interface, and is notably used by | |
10512 | GNOME. | |
10513 | @end deffn | |
10514 | ||
2b9e0a94 LC |
10515 | @deffn {Scheme Procedure} udisks-service [#:udisks @var{udisks}] |
10516 | Return a service for @uref{http://udisks.freedesktop.org/docs/latest/, | |
10517 | UDisks}, a @dfn{disk management} daemon that provides user interfaces with | |
10518 | notifications and ways to mount/unmount disks. Programs that talk to UDisks | |
10519 | include the @command{udisksctl} command, part of UDisks, and GNOME Disks. | |
10520 | @end deffn | |
10521 | ||
be1c2c54 | 10522 | @deffn {Scheme Procedure} colord-service [#:colord @var{colord}] |
7ce597ff AW |
10523 | Return a service that runs @command{colord}, a system service with a D-Bus |
10524 | interface to manage the color profiles of input and output devices such as | |
10525 | screens and scanners. It is notably used by the GNOME Color Manager graphical | |
10526 | tool. See @uref{http://www.freedesktop.org/software/colord/, the colord web | |
10527 | site} for more information. | |
10528 | @end deffn | |
10529 | ||
cee32ee4 | 10530 | @deffn {Scheme Procedure} geoclue-application name [#:allowed? #t] [#:system? #f] [#:users '()] |
1068f26b | 10531 | Return a configuration allowing an application to access GeoClue |
cee32ee4 AW |
10532 | location data. @var{name} is the Desktop ID of the application, without |
10533 | the @code{.desktop} part. If @var{allowed?} is true, the application | |
10534 | will have access to location information by default. The boolean | |
1068f26b | 10535 | @var{system?} value indicates whether an application is a system component |
cee32ee4 AW |
10536 | or not. Finally @var{users} is a list of UIDs of all users for which |
10537 | this application is allowed location info access. An empty users list | |
10538 | means that all users are allowed. | |
10539 | @end deffn | |
10540 | ||
10541 | @defvr {Scheme Variable} %standard-geoclue-applications | |
10542 | The standard list of well-known GeoClue application configurations, | |
1068f26b AE |
10543 | granting authority to the GNOME date-and-time utility to ask for the |
10544 | current location in order to set the time zone, and allowing the | |
10545 | IceCat and Epiphany web browsers to request location information. | |
10546 | IceCat and Epiphany both query the user before allowing a web page to | |
cee32ee4 AW |
10547 | know the user's location. |
10548 | @end defvr | |
10549 | ||
be1c2c54 | 10550 | @deffn {Scheme Procedure} geoclue-service [#:colord @var{colord}] @ |
cee32ee4 AW |
10551 | [#:whitelist '()] @ |
10552 | [#:wifi-geolocation-url "https://location.services.mozilla.com/v1/geolocate?key=geoclue"] @ | |
10553 | [#:submit-data? #f] | |
10554 | [#:wifi-submission-url "https://location.services.mozilla.com/v1/submit?key=geoclue"] @ | |
10555 | [#:submission-nick "geoclue"] @ | |
10556 | [#:applications %standard-geoclue-applications] | |
10557 | Return a service that runs the GeoClue location service. This service | |
10558 | provides a D-Bus interface to allow applications to request access to a | |
10559 | user's physical location, and optionally to add information to online | |
10560 | location databases. See | |
10561 | @uref{https://wiki.freedesktop.org/www/Software/GeoClue/, the GeoClue | |
10562 | web site} for more information. | |
10563 | @end deffn | |
10564 | ||
922e21f4 SB |
10565 | @deffn {Scheme Procedure} bluetooth-service [#:bluez @var{bluez}] |
10566 | Return a service that runs the @command{bluetoothd} daemon, which manages | |
10567 | all the Bluetooth devices and provides a number of D-Bus interfaces. | |
10568 | ||
10569 | Users need to be in the @code{lp} group to access the D-Bus service. | |
10570 | @end deffn | |
10571 | ||
105369a4 DT |
10572 | @node Database Services |
10573 | @subsubsection Database Services | |
10574 | ||
e32171ee JD |
10575 | @cindex database |
10576 | @cindex SQL | |
6575183b | 10577 | The @code{(gnu services databases)} module provides the following services. |
105369a4 | 10578 | |
be1c2c54 | 10579 | @deffn {Scheme Procedure} postgresql-service [#:postgresql postgresql] @ |
2d3d5cc5 | 10580 | [#:config-file] [#:data-directory ``/var/lib/postgresql/data''] @ |
e05b780a | 10581 | [#:port 5432] [#:locale ``en_US.utf8''] |
105369a4 DT |
10582 | Return a service that runs @var{postgresql}, the PostgreSQL database |
10583 | server. | |
10584 | ||
e05b780a CB |
10585 | The PostgreSQL daemon loads its runtime configuration from @var{config-file}, |
10586 | creates a database cluster with @var{locale} as the default | |
10587 | locale, stored in @var{data-directory}. It then listens on @var{port}. | |
105369a4 | 10588 | @end deffn |
fe1a39d3 | 10589 | |
6575183b SB |
10590 | @deffn {Scheme Procedure} mysql-service [#:config (mysql-configuration)] |
10591 | Return a service that runs @command{mysqld}, the MySQL or MariaDB | |
10592 | database server. | |
10593 | ||
10594 | The optional @var{config} argument specifies the configuration for | |
c940b8e6 | 10595 | @command{mysqld}, which should be a @code{<mysql-configuration>} object. |
6575183b SB |
10596 | @end deffn |
10597 | ||
10598 | @deftp {Data Type} mysql-configuration | |
10599 | Data type representing the configuration of @var{mysql-service}. | |
10600 | ||
10601 | @table @asis | |
10602 | @item @code{mysql} (default: @var{mariadb}) | |
10603 | Package object of the MySQL database server, can be either @var{mariadb} | |
10604 | or @var{mysql}. | |
10605 | ||
7414de0a | 10606 | For MySQL, a temporary root password will be displayed at activation time. |
6575183b | 10607 | For MariaDB, the root password is empty. |
4b41febf CB |
10608 | |
10609 | @item @code{port} (default: @code{3306}) | |
10610 | TCP port on which the database server listens for incoming connections. | |
6575183b SB |
10611 | @end table |
10612 | @end deftp | |
10613 | ||
67cadaca CB |
10614 | @defvr {Scheme Variable} redis-service-type |
10615 | This is the service type for the @uref{https://redis.io/, Redis} | |
10616 | key/value store, whose value is a @code{redis-configuration} object. | |
10617 | @end defvr | |
10618 | ||
10619 | @deftp {Data Type} redis-configuration | |
10620 | Data type representing the configuration of redis. | |
10621 | ||
10622 | @table @asis | |
10623 | @item @code{redis} (default: @code{redis}) | |
10624 | The Redis package to use. | |
10625 | ||
10626 | @item @code{bind} (default: @code{"127.0.0.1"}) | |
10627 | Network interface on which to listen. | |
10628 | ||
10629 | @item @code{port} (default: @code{6379}) | |
10630 | Port on which to accept connections on, a value of 0 will disable | |
10631 | listining on a TCP socket. | |
10632 | ||
10633 | @item @code{working-directory} (default: @code{"/var/lib/redis"}) | |
10634 | Directory in which to store the database and related files. | |
10635 | @end table | |
10636 | @end deftp | |
10637 | ||
d8c18af8 AW |
10638 | @node Mail Services |
10639 | @subsubsection Mail Services | |
10640 | ||
e32171ee JD |
10641 | @cindex mail |
10642 | @cindex email | |
d8c18af8 | 10643 | The @code{(gnu services mail)} module provides Guix service definitions |
f88371e8 SB |
10644 | for email services: IMAP, POP3, and LMTP servers, as well as mail |
10645 | transport agents (MTAs). Lots of acronyms! These services are detailed | |
10646 | in the subsections below. | |
d8c18af8 | 10647 | |
f88371e8 | 10648 | @subsubheading Dovecot Service |
d8c18af8 AW |
10649 | |
10650 | @deffn {Scheme Procedure} dovecot-service [#:config (dovecot-configuration)] | |
10651 | Return a service that runs the Dovecot IMAP/POP3/LMTP mail server. | |
10652 | @end deffn | |
10653 | ||
1068f26b | 10654 | By default, Dovecot does not need much configuration; the default |
d8c18af8 AW |
10655 | configuration object created by @code{(dovecot-configuration)} will |
10656 | suffice if your mail is delivered to @code{~/Maildir}. A self-signed | |
10657 | certificate will be generated for TLS-protected connections, though | |
10658 | Dovecot will also listen on cleartext ports by default. There are a | |
1068f26b | 10659 | number of options, though, which mail administrators might need to change, |
d8c18af8 AW |
10660 | and as is the case with other services, Guix allows the system |
10661 | administrator to specify these parameters via a uniform Scheme interface. | |
10662 | ||
10663 | For example, to specify that mail is located at @code{maildir~/.mail}, | |
10664 | one would instantiate the Dovecot service like this: | |
10665 | ||
10666 | @example | |
10667 | (dovecot-service #:config | |
10668 | (dovecot-configuration | |
10669 | (mail-location "maildir:~/.mail"))) | |
10670 | @end example | |
10671 | ||
10672 | The available configuration parameters follow. Each parameter | |
10673 | definition is preceded by its type; for example, @samp{string-list foo} | |
10674 | indicates that the @code{foo} parameter should be specified as a list of | |
10675 | strings. There is also a way to specify the configuration as a string, | |
10676 | if you have an old @code{dovecot.conf} file that you want to port over | |
10677 | from some other system; see the end for more details. | |
10678 | ||
10679 | @c The following documentation was initially generated by | |
10680 | @c (generate-documentation) in (gnu services mail). Manually maintained | |
10681 | @c documentation is better, so we shouldn't hesitate to edit below as | |
10682 | @c needed. However if the change you want to make to this documentation | |
10683 | @c can be done in an automated way, it's probably easier to change | |
10684 | @c (generate-documentation) than to make it below and have to deal with | |
10685 | @c the churn as dovecot updates. | |
10686 | ||
10687 | Available @code{dovecot-configuration} fields are: | |
10688 | ||
10689 | @deftypevr {@code{dovecot-configuration} parameter} package dovecot | |
10690 | The dovecot package. | |
10691 | @end deftypevr | |
10692 | ||
10693 | @deftypevr {@code{dovecot-configuration} parameter} comma-separated-string-list listen | |
1068f26b AE |
10694 | A list of IPs or hosts where to listen for connections. @samp{*} |
10695 | listens on all IPv4 interfaces, @samp{::} listens on all IPv6 | |
d8c18af8 AW |
10696 | interfaces. If you want to specify non-default ports or anything more |
10697 | complex, customize the address and port fields of the | |
10698 | @samp{inet-listener} of the specific services you are interested in. | |
10699 | @end deftypevr | |
10700 | ||
10701 | @deftypevr {@code{dovecot-configuration} parameter} protocol-configuration-list protocols | |
10702 | List of protocols we want to serve. Available protocols include | |
10703 | @samp{imap}, @samp{pop3}, and @samp{lmtp}. | |
10704 | ||
10705 | Available @code{protocol-configuration} fields are: | |
10706 | ||
10707 | @deftypevr {@code{protocol-configuration} parameter} string name | |
10708 | The name of the protocol. | |
10709 | @end deftypevr | |
10710 | ||
10711 | @deftypevr {@code{protocol-configuration} parameter} string auth-socket-path | |
1068f26b | 10712 | UNIX socket path to the master authentication server to find users. |
d8c18af8 | 10713 | This is used by imap (for shared users) and lda. |
1068f26b | 10714 | It defaults to @samp{"/var/run/dovecot/auth-userdb"}. |
d8c18af8 AW |
10715 | @end deftypevr |
10716 | ||
10717 | @deftypevr {@code{protocol-configuration} parameter} space-separated-string-list mail-plugins | |
10718 | Space separated list of plugins to load. | |
10719 | @end deftypevr | |
10720 | ||
10721 | @deftypevr {@code{protocol-configuration} parameter} non-negative-integer mail-max-userip-connections | |
10722 | Maximum number of IMAP connections allowed for a user from each IP | |
10723 | address. NOTE: The username is compared case-sensitively. | |
10724 | Defaults to @samp{10}. | |
10725 | @end deftypevr | |
10726 | ||
10727 | @end deftypevr | |
10728 | ||
10729 | @deftypevr {@code{dovecot-configuration} parameter} service-configuration-list services | |
10730 | List of services to enable. Available services include @samp{imap}, | |
10731 | @samp{imap-login}, @samp{pop3}, @samp{pop3-login}, @samp{auth}, and | |
10732 | @samp{lmtp}. | |
10733 | ||
10734 | Available @code{service-configuration} fields are: | |
10735 | ||
10736 | @deftypevr {@code{service-configuration} parameter} string kind | |
10737 | The service kind. Valid values include @code{director}, | |
10738 | @code{imap-login}, @code{pop3-login}, @code{lmtp}, @code{imap}, | |
10739 | @code{pop3}, @code{auth}, @code{auth-worker}, @code{dict}, | |
10740 | @code{tcpwrap}, @code{quota-warning}, or anything else. | |
10741 | @end deftypevr | |
10742 | ||
10743 | @deftypevr {@code{service-configuration} parameter} listener-configuration-list listeners | |
1068f26b | 10744 | Listeners for the service. A listener is either a |
d8c18af8 AW |
10745 | @code{unix-listener-configuration}, a @code{fifo-listener-configuration}, or |
10746 | an @code{inet-listener-configuration}. | |
10747 | Defaults to @samp{()}. | |
10748 | ||
10749 | Available @code{unix-listener-configuration} fields are: | |
10750 | ||
10751 | @deftypevr {@code{unix-listener-configuration} parameter} file-name path | |
10752 | The file name on which to listen. | |
10753 | @end deftypevr | |
10754 | ||
10755 | @deftypevr {@code{unix-listener-configuration} parameter} string mode | |
10756 | The access mode for the socket. | |
10757 | Defaults to @samp{"0600"}. | |
10758 | @end deftypevr | |
10759 | ||
10760 | @deftypevr {@code{unix-listener-configuration} parameter} string user | |
f9b9a033 | 10761 | The user to own the socket. |
d8c18af8 AW |
10762 | Defaults to @samp{""}. |
10763 | @end deftypevr | |
10764 | ||
10765 | @deftypevr {@code{unix-listener-configuration} parameter} string group | |
10766 | The group to own the socket. | |
10767 | Defaults to @samp{""}. | |
10768 | @end deftypevr | |
10769 | ||
10770 | ||
10771 | Available @code{fifo-listener-configuration} fields are: | |
10772 | ||
10773 | @deftypevr {@code{fifo-listener-configuration} parameter} file-name path | |
10774 | The file name on which to listen. | |
10775 | @end deftypevr | |
10776 | ||
10777 | @deftypevr {@code{fifo-listener-configuration} parameter} string mode | |
10778 | The access mode for the socket. | |
10779 | Defaults to @samp{"0600"}. | |
10780 | @end deftypevr | |
10781 | ||
10782 | @deftypevr {@code{fifo-listener-configuration} parameter} string user | |
f9b9a033 | 10783 | The user to own the socket. |
d8c18af8 AW |
10784 | Defaults to @samp{""}. |
10785 | @end deftypevr | |
10786 | ||
10787 | @deftypevr {@code{fifo-listener-configuration} parameter} string group | |
10788 | The group to own the socket. | |
10789 | Defaults to @samp{""}. | |
10790 | @end deftypevr | |
10791 | ||
10792 | ||
10793 | Available @code{inet-listener-configuration} fields are: | |
10794 | ||
10795 | @deftypevr {@code{inet-listener-configuration} parameter} string protocol | |
10796 | The protocol to listen for. | |
10797 | @end deftypevr | |
10798 | ||
10799 | @deftypevr {@code{inet-listener-configuration} parameter} string address | |
10800 | The address on which to listen, or empty for all addresses. | |
10801 | Defaults to @samp{""}. | |
10802 | @end deftypevr | |
10803 | ||
10804 | @deftypevr {@code{inet-listener-configuration} parameter} non-negative-integer port | |
10805 | The port on which to listen. | |
10806 | @end deftypevr | |
10807 | ||
10808 | @deftypevr {@code{inet-listener-configuration} parameter} boolean ssl? | |
10809 | Whether to use SSL for this service; @samp{yes}, @samp{no}, or | |
10810 | @samp{required}. | |
10811 | Defaults to @samp{#t}. | |
10812 | @end deftypevr | |
10813 | ||
10814 | @end deftypevr | |
10815 | ||
10816 | @deftypevr {@code{service-configuration} parameter} non-negative-integer service-count | |
10817 | Number of connections to handle before starting a new process. | |
10818 | Typically the only useful values are 0 (unlimited) or 1. 1 is more | |
10819 | secure, but 0 is faster. <doc/wiki/LoginProcess.txt>. | |
10820 | Defaults to @samp{1}. | |
10821 | @end deftypevr | |
10822 | ||
10823 | @deftypevr {@code{service-configuration} parameter} non-negative-integer process-min-avail | |
10824 | Number of processes to always keep waiting for more connections. | |
10825 | Defaults to @samp{0}. | |
10826 | @end deftypevr | |
10827 | ||
10828 | @deftypevr {@code{service-configuration} parameter} non-negative-integer vsz-limit | |
10829 | If you set @samp{service-count 0}, you probably need to grow | |
10830 | this. | |
10831 | Defaults to @samp{256000000}. | |
10832 | @end deftypevr | |
10833 | ||
10834 | @end deftypevr | |
10835 | ||
10836 | @deftypevr {@code{dovecot-configuration} parameter} dict-configuration dict | |
10837 | Dict configuration, as created by the @code{dict-configuration} | |
10838 | constructor. | |
10839 | ||
10840 | Available @code{dict-configuration} fields are: | |
10841 | ||
10842 | @deftypevr {@code{dict-configuration} parameter} free-form-fields entries | |
10843 | A list of key-value pairs that this dict should hold. | |
10844 | Defaults to @samp{()}. | |
10845 | @end deftypevr | |
10846 | ||
10847 | @end deftypevr | |
10848 | ||
10849 | @deftypevr {@code{dovecot-configuration} parameter} passdb-configuration-list passdbs | |
1068f26b | 10850 | A list of passdb configurations, each one created by the |
d8c18af8 AW |
10851 | @code{passdb-configuration} constructor. |
10852 | ||
10853 | Available @code{passdb-configuration} fields are: | |
10854 | ||
10855 | @deftypevr {@code{passdb-configuration} parameter} string driver | |
10856 | The driver that the passdb should use. Valid values include | |
10857 | @samp{pam}, @samp{passwd}, @samp{shadow}, @samp{bsdauth}, and | |
10858 | @samp{static}. | |
10859 | Defaults to @samp{"pam"}. | |
10860 | @end deftypevr | |
10861 | ||
10862 | @deftypevr {@code{passdb-configuration} parameter} free-form-args args | |
10863 | A list of key-value args to the passdb driver. | |
10864 | Defaults to @samp{()}. | |
10865 | @end deftypevr | |
10866 | ||
10867 | @end deftypevr | |
10868 | ||
10869 | @deftypevr {@code{dovecot-configuration} parameter} userdb-configuration-list userdbs | |
10870 | List of userdb configurations, each one created by the | |
10871 | @code{userdb-configuration} constructor. | |
10872 | ||
10873 | Available @code{userdb-configuration} fields are: | |
10874 | ||
10875 | @deftypevr {@code{userdb-configuration} parameter} string driver | |
10876 | The driver that the userdb should use. Valid values include | |
10877 | @samp{passwd} and @samp{static}. | |
10878 | Defaults to @samp{"passwd"}. | |
10879 | @end deftypevr | |
10880 | ||
10881 | @deftypevr {@code{userdb-configuration} parameter} free-form-args args | |
10882 | A list of key-value args to the userdb driver. | |
10883 | Defaults to @samp{()}. | |
10884 | @end deftypevr | |
10885 | ||
10886 | @deftypevr {@code{userdb-configuration} parameter} free-form-args override-fields | |
10887 | Override fields from passwd. | |
10888 | Defaults to @samp{()}. | |
10889 | @end deftypevr | |
10890 | ||
10891 | @end deftypevr | |
10892 | ||
10893 | @deftypevr {@code{dovecot-configuration} parameter} plugin-configuration plugin-configuration | |
10894 | Plug-in configuration, created by the @code{plugin-configuration} | |
10895 | constructor. | |
10896 | @end deftypevr | |
10897 | ||
10898 | @deftypevr {@code{dovecot-configuration} parameter} list-of-namespace-configuration namespaces | |
10899 | List of namespaces. Each item in the list is created by the | |
10900 | @code{namespace-configuration} constructor. | |
10901 | ||
10902 | Available @code{namespace-configuration} fields are: | |
10903 | ||
10904 | @deftypevr {@code{namespace-configuration} parameter} string name | |
10905 | Name for this namespace. | |
10906 | @end deftypevr | |
10907 | ||
10908 | @deftypevr {@code{namespace-configuration} parameter} string type | |
10909 | Namespace type: @samp{private}, @samp{shared} or @samp{public}. | |
10910 | Defaults to @samp{"private"}. | |
10911 | @end deftypevr | |
10912 | ||
10913 | @deftypevr {@code{namespace-configuration} parameter} string separator | |
10914 | Hierarchy separator to use. You should use the same separator for | |
10915 | all namespaces or some clients get confused. @samp{/} is usually a good | |
10916 | one. The default however depends on the underlying mail storage | |
10917 | format. | |
10918 | Defaults to @samp{""}. | |
10919 | @end deftypevr | |
10920 | ||
10921 | @deftypevr {@code{namespace-configuration} parameter} string prefix | |
10922 | Prefix required to access this namespace. This needs to be | |
10923 | different for all namespaces. For example @samp{Public/}. | |
10924 | Defaults to @samp{""}. | |
10925 | @end deftypevr | |
10926 | ||
10927 | @deftypevr {@code{namespace-configuration} parameter} string location | |
1068f26b | 10928 | Physical location of the mailbox. This is in the same format as |
d8c18af8 AW |
10929 | mail_location, which is also the default for it. |
10930 | Defaults to @samp{""}. | |
10931 | @end deftypevr | |
10932 | ||
10933 | @deftypevr {@code{namespace-configuration} parameter} boolean inbox? | |
10934 | There can be only one INBOX, and this setting defines which | |
10935 | namespace has it. | |
10936 | Defaults to @samp{#f}. | |
10937 | @end deftypevr | |
10938 | ||
10939 | @deftypevr {@code{namespace-configuration} parameter} boolean hidden? | |
10940 | If namespace is hidden, it's not advertised to clients via NAMESPACE | |
10941 | extension. You'll most likely also want to set @samp{list? #f}. This is mostly | |
10942 | useful when converting from another server with different namespaces | |
10943 | which you want to deprecate but still keep working. For example you can | |
10944 | create hidden namespaces with prefixes @samp{~/mail/}, @samp{~%u/mail/} | |
10945 | and @samp{mail/}. | |
10946 | Defaults to @samp{#f}. | |
10947 | @end deftypevr | |
10948 | ||
10949 | @deftypevr {@code{namespace-configuration} parameter} boolean list? | |
1068f26b AE |
10950 | Show the mailboxes under this namespace with the LIST command. This |
10951 | makes the namespace visible for clients that do not support the NAMESPACE | |
d8c18af8 AW |
10952 | extension. The special @code{children} value lists child mailboxes, but |
10953 | hides the namespace prefix. | |
10954 | Defaults to @samp{#t}. | |
10955 | @end deftypevr | |
10956 | ||
10957 | @deftypevr {@code{namespace-configuration} parameter} boolean subscriptions? | |
10958 | Namespace handles its own subscriptions. If set to @code{#f}, the | |
10959 | parent namespace handles them. The empty prefix should always have this | |
1068f26b | 10960 | as @code{#t}). |
d8c18af8 AW |
10961 | Defaults to @samp{#t}. |
10962 | @end deftypevr | |
10963 | ||
10964 | @deftypevr {@code{namespace-configuration} parameter} mailbox-configuration-list mailboxes | |
10965 | List of predefined mailboxes in this namespace. | |
10966 | Defaults to @samp{()}. | |
10967 | ||
10968 | Available @code{mailbox-configuration} fields are: | |
10969 | ||
10970 | @deftypevr {@code{mailbox-configuration} parameter} string name | |
10971 | Name for this mailbox. | |
10972 | @end deftypevr | |
10973 | ||
10974 | @deftypevr {@code{mailbox-configuration} parameter} string auto | |
10975 | @samp{create} will automatically create this mailbox. | |
10976 | @samp{subscribe} will both create and subscribe to the mailbox. | |
10977 | Defaults to @samp{"no"}. | |
10978 | @end deftypevr | |
10979 | ||
10980 | @deftypevr {@code{mailbox-configuration} parameter} space-separated-string-list special-use | |
10981 | List of IMAP @code{SPECIAL-USE} attributes as specified by RFC 6154. | |
10982 | Valid values are @code{\All}, @code{\Archive}, @code{\Drafts}, | |
10983 | @code{\Flagged}, @code{\Junk}, @code{\Sent}, and @code{\Trash}. | |
10984 | Defaults to @samp{()}. | |
10985 | @end deftypevr | |
10986 | ||
10987 | @end deftypevr | |
10988 | ||
10989 | @end deftypevr | |
10990 | ||
10991 | @deftypevr {@code{dovecot-configuration} parameter} file-name base-dir | |
10992 | Base directory where to store runtime data. | |
10993 | Defaults to @samp{"/var/run/dovecot/"}. | |
10994 | @end deftypevr | |
10995 | ||
10996 | @deftypevr {@code{dovecot-configuration} parameter} string login-greeting | |
10997 | Greeting message for clients. | |
10998 | Defaults to @samp{"Dovecot ready."}. | |
10999 | @end deftypevr | |
11000 | ||
11001 | @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list login-trusted-networks | |
11002 | List of trusted network ranges. Connections from these IPs are | |
11003 | allowed to override their IP addresses and ports (for logging and for | |
11004 | authentication checks). @samp{disable-plaintext-auth} is also ignored | |
1068f26b | 11005 | for these networks. Typically you would specify your IMAP proxy servers |
d8c18af8 AW |
11006 | here. |
11007 | Defaults to @samp{()}. | |
11008 | @end deftypevr | |
11009 | ||
11010 | @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list login-access-sockets | |
11011 | List of login access check sockets (e.g. tcpwrap). | |
11012 | Defaults to @samp{()}. | |
11013 | @end deftypevr | |
11014 | ||
11015 | @deftypevr {@code{dovecot-configuration} parameter} boolean verbose-proctitle? | |
11016 | Show more verbose process titles (in ps). Currently shows user name | |
1068f26b AE |
11017 | and IP address. Useful for seeing who is actually using the IMAP |
11018 | processes (e.g. shared mailboxes or if the same uid is used for multiple | |
d8c18af8 AW |
11019 | accounts). |
11020 | Defaults to @samp{#f}. | |
11021 | @end deftypevr | |
11022 | ||
11023 | @deftypevr {@code{dovecot-configuration} parameter} boolean shutdown-clients? | |
11024 | Should all processes be killed when Dovecot master process shuts down. | |
11025 | Setting this to @code{#f} means that Dovecot can be upgraded without | |
11026 | forcing existing client connections to close (although that could also | |
1068f26b | 11027 | be a problem if the upgrade is e.g. due to a security fix). |
d8c18af8 AW |
11028 | Defaults to @samp{#t}. |
11029 | @end deftypevr | |
11030 | ||
11031 | @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer doveadm-worker-count | |
11032 | If non-zero, run mail commands via this many connections to doveadm | |
11033 | server, instead of running them directly in the same process. | |
11034 | Defaults to @samp{0}. | |
11035 | @end deftypevr | |
11036 | ||
11037 | @deftypevr {@code{dovecot-configuration} parameter} string doveadm-socket-path | |
11038 | UNIX socket or host:port used for connecting to doveadm server. | |
11039 | Defaults to @samp{"doveadm-server"}. | |
11040 | @end deftypevr | |
11041 | ||
11042 | @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list import-environment | |
11043 | List of environment variables that are preserved on Dovecot startup | |
11044 | and passed down to all of its child processes. You can also give | |
11045 | key=value pairs to always set specific settings. | |
11046 | @end deftypevr | |
11047 | ||
11048 | @deftypevr {@code{dovecot-configuration} parameter} boolean disable-plaintext-auth? | |
11049 | Disable LOGIN command and all other plaintext authentications unless | |
11050 | SSL/TLS is used (LOGINDISABLED capability). Note that if the remote IP | |
11051 | matches the local IP (i.e. you're connecting from the same computer), | |
11052 | the connection is considered secure and plaintext authentication is | |
11053 | allowed. See also ssl=required setting. | |
11054 | Defaults to @samp{#t}. | |
11055 | @end deftypevr | |
11056 | ||
11057 | @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer auth-cache-size | |
11058 | Authentication cache size (e.g. @samp{#e10e6}). 0 means it's disabled. | |
11059 | Note that bsdauth, PAM and vpopmail require @samp{cache-key} to be set | |
11060 | for caching to be used. | |
11061 | Defaults to @samp{0}. | |
11062 | @end deftypevr | |
11063 | ||
11064 | @deftypevr {@code{dovecot-configuration} parameter} string auth-cache-ttl | |
11065 | Time to live for cached data. After TTL expires the cached record | |
11066 | is no longer used, *except* if the main database lookup returns internal | |
11067 | failure. We also try to handle password changes automatically: If | |
11068 | user's previous authentication was successful, but this one wasn't, the | |
11069 | cache isn't used. For now this works only with plaintext | |
11070 | authentication. | |
11071 | Defaults to @samp{"1 hour"}. | |
11072 | @end deftypevr | |
11073 | ||
11074 | @deftypevr {@code{dovecot-configuration} parameter} string auth-cache-negative-ttl | |
11075 | TTL for negative hits (user not found, password mismatch). | |
11076 | 0 disables caching them completely. | |
11077 | Defaults to @samp{"1 hour"}. | |
11078 | @end deftypevr | |
11079 | ||
11080 | @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list auth-realms | |
11081 | List of realms for SASL authentication mechanisms that need them. | |
11082 | You can leave it empty if you don't want to support multiple realms. | |
11083 | Many clients simply use the first one listed here, so keep the default | |
11084 | realm first. | |
11085 | Defaults to @samp{()}. | |
11086 | @end deftypevr | |
11087 | ||
11088 | @deftypevr {@code{dovecot-configuration} parameter} string auth-default-realm | |
11089 | Default realm/domain to use if none was specified. This is used for | |
11090 | both SASL realms and appending @@domain to username in plaintext | |
11091 | logins. | |
11092 | Defaults to @samp{""}. | |
11093 | @end deftypevr | |
11094 | ||
11095 | @deftypevr {@code{dovecot-configuration} parameter} string auth-username-chars | |
11096 | List of allowed characters in username. If the user-given username | |
11097 | contains a character not listed in here, the login automatically fails. | |
11098 | This is just an extra check to make sure user can't exploit any | |
11099 | potential quote escaping vulnerabilities with SQL/LDAP databases. If | |
11100 | you want to allow all characters, set this value to empty. | |
11101 | Defaults to @samp{"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890.-_@@"}. | |
11102 | @end deftypevr | |
11103 | ||
11104 | @deftypevr {@code{dovecot-configuration} parameter} string auth-username-translation | |
11105 | Username character translations before it's looked up from | |
11106 | databases. The value contains series of from -> to characters. For | |
11107 | example @samp{#@@/@@} means that @samp{#} and @samp{/} characters are | |
11108 | translated to @samp{@@}. | |
11109 | Defaults to @samp{""}. | |
11110 | @end deftypevr | |
11111 | ||
11112 | @deftypevr {@code{dovecot-configuration} parameter} string auth-username-format | |
11113 | Username formatting before it's looked up from databases. You can | |
11114 | use the standard variables here, e.g. %Lu would lowercase the username, | |
11115 | %n would drop away the domain if it was given, or @samp{%n-AT-%d} would | |
11116 | change the @samp{@@} into @samp{-AT-}. This translation is done after | |
11117 | @samp{auth-username-translation} changes. | |
11118 | Defaults to @samp{"%Lu"}. | |
11119 | @end deftypevr | |
11120 | ||
11121 | @deftypevr {@code{dovecot-configuration} parameter} string auth-master-user-separator | |
11122 | If you want to allow master users to log in by specifying the master | |
11123 | username within the normal username string (i.e. not using SASL | |
11124 | mechanism's support for it), you can specify the separator character | |
11125 | here. The format is then <username><separator><master username>. | |
11126 | UW-IMAP uses @samp{*} as the separator, so that could be a good | |
11127 | choice. | |
11128 | Defaults to @samp{""}. | |
11129 | @end deftypevr | |
11130 | ||
11131 | @deftypevr {@code{dovecot-configuration} parameter} string auth-anonymous-username | |
11132 | Username to use for users logging in with ANONYMOUS SASL | |
11133 | mechanism. | |
11134 | Defaults to @samp{"anonymous"}. | |
11135 | @end deftypevr | |
11136 | ||
11137 | @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer auth-worker-max-count | |
11138 | Maximum number of dovecot-auth worker processes. They're used to | |
11139 | execute blocking passdb and userdb queries (e.g. MySQL and PAM). | |
11140 | They're automatically created and destroyed as needed. | |
11141 | Defaults to @samp{30}. | |
11142 | @end deftypevr | |
11143 | ||
11144 | @deftypevr {@code{dovecot-configuration} parameter} string auth-gssapi-hostname | |
11145 | Host name to use in GSSAPI principal names. The default is to use | |
11146 | the name returned by gethostname(). Use @samp{$ALL} (with quotes) to | |
11147 | allow all keytab entries. | |
11148 | Defaults to @samp{""}. | |
11149 | @end deftypevr | |
11150 | ||
11151 | @deftypevr {@code{dovecot-configuration} parameter} string auth-krb5-keytab | |
11152 | Kerberos keytab to use for the GSSAPI mechanism. Will use the | |
8b499030 | 11153 | system default (usually @file{/etc/krb5.keytab}) if not specified. You may |
d8c18af8 AW |
11154 | need to change the auth service to run as root to be able to read this |
11155 | file. | |
11156 | Defaults to @samp{""}. | |
11157 | @end deftypevr | |
11158 | ||
11159 | @deftypevr {@code{dovecot-configuration} parameter} boolean auth-use-winbind? | |
11160 | Do NTLM and GSS-SPNEGO authentication using Samba's winbind daemon | |
11161 | and @samp{ntlm-auth} helper. | |
11162 | <doc/wiki/Authentication/Mechanisms/Winbind.txt>. | |
11163 | Defaults to @samp{#f}. | |
11164 | @end deftypevr | |
11165 | ||
11166 | @deftypevr {@code{dovecot-configuration} parameter} file-name auth-winbind-helper-path | |
11167 | Path for Samba's @samp{ntlm-auth} helper binary. | |
11168 | Defaults to @samp{"/usr/bin/ntlm_auth"}. | |
11169 | @end deftypevr | |
11170 | ||
11171 | @deftypevr {@code{dovecot-configuration} parameter} string auth-failure-delay | |
11172 | Time to delay before replying to failed authentications. | |
11173 | Defaults to @samp{"2 secs"}. | |
11174 | @end deftypevr | |
11175 | ||
11176 | @deftypevr {@code{dovecot-configuration} parameter} boolean auth-ssl-require-client-cert? | |
11177 | Require a valid SSL client certificate or the authentication | |
11178 | fails. | |
11179 | Defaults to @samp{#f}. | |
11180 | @end deftypevr | |
11181 | ||
11182 | @deftypevr {@code{dovecot-configuration} parameter} boolean auth-ssl-username-from-cert? | |
11183 | Take the username from client's SSL certificate, using | |
11184 | @code{X509_NAME_get_text_by_NID()} which returns the subject's DN's | |
11185 | CommonName. | |
11186 | Defaults to @samp{#f}. | |
11187 | @end deftypevr | |
11188 | ||
11189 | @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list auth-mechanisms | |
11190 | List of wanted authentication mechanisms. Supported mechanisms are: | |
11191 | @samp{plain}, @samp{login}, @samp{digest-md5}, @samp{cram-md5}, | |
11192 | @samp{ntlm}, @samp{rpa}, @samp{apop}, @samp{anonymous}, @samp{gssapi}, | |
11193 | @samp{otp}, @samp{skey}, and @samp{gss-spnego}. NOTE: See also | |
11194 | @samp{disable-plaintext-auth} setting. | |
11195 | @end deftypevr | |
11196 | ||
11197 | @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list director-servers | |
11198 | List of IPs or hostnames to all director servers, including ourself. | |
11199 | Ports can be specified as ip:port. The default port is the same as what | |
11200 | director service's @samp{inet-listener} is using. | |
11201 | Defaults to @samp{()}. | |
11202 | @end deftypevr | |
11203 | ||
11204 | @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list director-mail-servers | |
11205 | List of IPs or hostnames to all backend mail servers. Ranges are | |
11206 | allowed too, like 10.0.0.10-10.0.0.30. | |
11207 | Defaults to @samp{()}. | |
11208 | @end deftypevr | |
11209 | ||
11210 | @deftypevr {@code{dovecot-configuration} parameter} string director-user-expire | |
11211 | How long to redirect users to a specific server after it no longer | |
11212 | has any connections. | |
11213 | Defaults to @samp{"15 min"}. | |
11214 | @end deftypevr | |
11215 | ||
11216 | @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer director-doveadm-port | |
11217 | TCP/IP port that accepts doveadm connections (instead of director | |
11218 | connections) If you enable this, you'll also need to add | |
11219 | @samp{inet-listener} for the port. | |
11220 | Defaults to @samp{0}. | |
11221 | @end deftypevr | |
11222 | ||
11223 | @deftypevr {@code{dovecot-configuration} parameter} string director-username-hash | |
11224 | How the username is translated before being hashed. Useful values | |
11225 | include %Ln if user can log in with or without @@domain, %Ld if mailboxes | |
11226 | are shared within domain. | |
11227 | Defaults to @samp{"%Lu"}. | |
11228 | @end deftypevr | |
11229 | ||
11230 | @deftypevr {@code{dovecot-configuration} parameter} string log-path | |
11231 | Log file to use for error messages. @samp{syslog} logs to syslog, | |
11232 | @samp{/dev/stderr} logs to stderr. | |
11233 | Defaults to @samp{"syslog"}. | |
11234 | @end deftypevr | |
11235 | ||
11236 | @deftypevr {@code{dovecot-configuration} parameter} string info-log-path | |
11237 | Log file to use for informational messages. Defaults to | |
11238 | @samp{log-path}. | |
11239 | Defaults to @samp{""}. | |
11240 | @end deftypevr | |
11241 | ||
11242 | @deftypevr {@code{dovecot-configuration} parameter} string debug-log-path | |
11243 | Log file to use for debug messages. Defaults to | |
11244 | @samp{info-log-path}. | |
11245 | Defaults to @samp{""}. | |
11246 | @end deftypevr | |
11247 | ||
11248 | @deftypevr {@code{dovecot-configuration} parameter} string syslog-facility | |
11249 | Syslog facility to use if you're logging to syslog. Usually if you | |
11250 | don't want to use @samp{mail}, you'll use local0..local7. Also other | |
11251 | standard facilities are supported. | |
11252 | Defaults to @samp{"mail"}. | |
11253 | @end deftypevr | |
11254 | ||
11255 | @deftypevr {@code{dovecot-configuration} parameter} boolean auth-verbose? | |
11256 | Log unsuccessful authentication attempts and the reasons why they | |
11257 | failed. | |
11258 | Defaults to @samp{#f}. | |
11259 | @end deftypevr | |
11260 | ||
11261 | @deftypevr {@code{dovecot-configuration} parameter} boolean auth-verbose-passwords? | |
11262 | In case of password mismatches, log the attempted password. Valid | |
11263 | values are no, plain and sha1. sha1 can be useful for detecting brute | |
11264 | force password attempts vs. user simply trying the same password over | |
11265 | and over again. You can also truncate the value to n chars by appending | |
11266 | ":n" (e.g. sha1:6). | |
11267 | Defaults to @samp{#f}. | |
11268 | @end deftypevr | |
11269 | ||
11270 | @deftypevr {@code{dovecot-configuration} parameter} boolean auth-debug? | |
11271 | Even more verbose logging for debugging purposes. Shows for example | |
11272 | SQL queries. | |
11273 | Defaults to @samp{#f}. | |
11274 | @end deftypevr | |
11275 | ||
11276 | @deftypevr {@code{dovecot-configuration} parameter} boolean auth-debug-passwords? | |
11277 | In case of password mismatches, log the passwords and used scheme so | |
11278 | the problem can be debugged. Enabling this also enables | |
11279 | @samp{auth-debug}. | |
11280 | Defaults to @samp{#f}. | |
11281 | @end deftypevr | |
11282 | ||
11283 | @deftypevr {@code{dovecot-configuration} parameter} boolean mail-debug? | |
11284 | Enable mail process debugging. This can help you figure out why | |
11285 | Dovecot isn't finding your mails. | |
11286 | Defaults to @samp{#f}. | |
11287 | @end deftypevr | |
11288 | ||
11289 | @deftypevr {@code{dovecot-configuration} parameter} boolean verbose-ssl? | |
11290 | Show protocol level SSL errors. | |
11291 | Defaults to @samp{#f}. | |
11292 | @end deftypevr | |
11293 | ||
11294 | @deftypevr {@code{dovecot-configuration} parameter} string log-timestamp | |
11295 | Prefix for each line written to log file. % codes are in | |
11296 | strftime(3) format. | |
11297 | Defaults to @samp{"\"%b %d %H:%M:%S \""}. | |
11298 | @end deftypevr | |
11299 | ||
11300 | @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list login-log-format-elements | |
11301 | List of elements we want to log. The elements which have a | |
11302 | non-empty variable value are joined together to form a comma-separated | |
11303 | string. | |
11304 | @end deftypevr | |
11305 | ||
11306 | @deftypevr {@code{dovecot-configuration} parameter} string login-log-format | |
11307 | Login log format. %s contains @samp{login-log-format-elements} | |
11308 | string, %$ contains the data we want to log. | |
11309 | Defaults to @samp{"%$: %s"}. | |
11310 | @end deftypevr | |
11311 | ||
11312 | @deftypevr {@code{dovecot-configuration} parameter} string mail-log-prefix | |
11313 | Log prefix for mail processes. See doc/wiki/Variables.txt for list | |
11314 | of possible variables you can use. | |
11315 | Defaults to @samp{"\"%s(%u): \""}. | |
11316 | @end deftypevr | |
11317 | ||
11318 | @deftypevr {@code{dovecot-configuration} parameter} string deliver-log-format | |
11319 | Format to use for logging mail deliveries. You can use variables: | |
11320 | @table @code | |
11321 | @item %$ | |
11322 | Delivery status message (e.g. @samp{saved to INBOX}) | |
11323 | @item %m | |
11324 | Message-ID | |
11325 | @item %s | |
11326 | Subject | |
11327 | @item %f | |
11328 | From address | |
11329 | @item %p | |
11330 | Physical size | |
11331 | @item %w | |
11332 | Virtual size. | |
11333 | @end table | |
11334 | Defaults to @samp{"msgid=%m: %$"}. | |
11335 | @end deftypevr | |
11336 | ||
11337 | @deftypevr {@code{dovecot-configuration} parameter} string mail-location | |
11338 | Location for users' mailboxes. The default is empty, which means | |
11339 | that Dovecot tries to find the mailboxes automatically. This won't work | |
11340 | if the user doesn't yet have any mail, so you should explicitly tell | |
11341 | Dovecot the full location. | |
11342 | ||
11343 | If you're using mbox, giving a path to the INBOX | |
11344 | file (e.g. /var/mail/%u) isn't enough. You'll also need to tell Dovecot | |
11345 | where the other mailboxes are kept. This is called the "root mail | |
11346 | directory", and it must be the first path given in the | |
11347 | @samp{mail-location} setting. | |
11348 | ||
11349 | There are a few special variables you can use, eg.: | |
11350 | ||
11351 | @table @samp | |
11352 | @item %u | |
11353 | username | |
11354 | @item %n | |
11355 | user part in user@@domain, same as %u if there's no domain | |
11356 | @item %d | |
11357 | domain part in user@@domain, empty if there's no domain | |
11358 | @item %h | |
11359 | home director | |
11360 | @end table | |
11361 | ||
11362 | See doc/wiki/Variables.txt for full list. Some examples: | |
11363 | @table @samp | |
11364 | @item maildir:~/Maildir | |
11365 | @item mbox:~/mail:INBOX=/var/mail/%u | |
11366 | @item mbox:/var/mail/%d/%1n/%n:INDEX=/var/indexes/%d/%1n/% | |
11367 | @end table | |
11368 | Defaults to @samp{""}. | |
11369 | @end deftypevr | |
11370 | ||
11371 | @deftypevr {@code{dovecot-configuration} parameter} string mail-uid | |
11372 | System user and group used to access mails. If you use multiple, | |
11373 | userdb can override these by returning uid or gid fields. You can use | |
11374 | either numbers or names. <doc/wiki/UserIds.txt>. | |
11375 | Defaults to @samp{""}. | |
11376 | @end deftypevr | |
11377 | ||
11378 | @deftypevr {@code{dovecot-configuration} parameter} string mail-gid | |
11379 | ||
11380 | Defaults to @samp{""}. | |
11381 | @end deftypevr | |
11382 | ||
11383 | @deftypevr {@code{dovecot-configuration} parameter} string mail-privileged-group | |
11384 | Group to enable temporarily for privileged operations. Currently | |
11385 | this is used only with INBOX when either its initial creation or | |
11386 | dotlocking fails. Typically this is set to "mail" to give access to | |
11387 | /var/mail. | |
11388 | Defaults to @samp{""}. | |
11389 | @end deftypevr | |
11390 | ||
11391 | @deftypevr {@code{dovecot-configuration} parameter} string mail-access-groups | |
11392 | Grant access to these supplementary groups for mail processes. | |
11393 | Typically these are used to set up access to shared mailboxes. Note | |
11394 | that it may be dangerous to set these if users can create | |
11395 | symlinks (e.g. if "mail" group is set here, ln -s /var/mail ~/mail/var | |
11396 | could allow a user to delete others' mailboxes, or ln -s | |
11397 | /secret/shared/box ~/mail/mybox would allow reading it). | |
11398 | Defaults to @samp{""}. | |
11399 | @end deftypevr | |
11400 | ||
11401 | @deftypevr {@code{dovecot-configuration} parameter} boolean mail-full-filesystem-access? | |
8f65585b | 11402 | Allow full file system access to clients. There's no access checks |
d8c18af8 AW |
11403 | other than what the operating system does for the active UID/GID. It |
11404 | works with both maildir and mboxes, allowing you to prefix mailboxes | |
11405 | names with e.g. /path/ or ~user/. | |
11406 | Defaults to @samp{#f}. | |
11407 | @end deftypevr | |
11408 | ||
11409 | @deftypevr {@code{dovecot-configuration} parameter} boolean mmap-disable? | |
11410 | Don't use mmap() at all. This is required if you store indexes to | |
8f65585b | 11411 | shared file systems (NFS or clustered file system). |
d8c18af8 AW |
11412 | Defaults to @samp{#f}. |
11413 | @end deftypevr | |
11414 | ||
11415 | @deftypevr {@code{dovecot-configuration} parameter} boolean dotlock-use-excl? | |
11416 | Rely on @samp{O_EXCL} to work when creating dotlock files. NFS | |
11417 | supports @samp{O_EXCL} since version 3, so this should be safe to use | |
11418 | nowadays by default. | |
11419 | Defaults to @samp{#t}. | |
11420 | @end deftypevr | |
11421 | ||
11422 | @deftypevr {@code{dovecot-configuration} parameter} string mail-fsync | |
11423 | When to use fsync() or fdatasync() calls: | |
11424 | @table @code | |
11425 | @item optimized | |
11426 | Whenever necessary to avoid losing important data | |
11427 | @item always | |
11428 | Useful with e.g. NFS when write()s are delayed | |
11429 | @item never | |
11430 | Never use it (best performance, but crashes can lose data). | |
11431 | @end table | |
11432 | Defaults to @samp{"optimized"}. | |
11433 | @end deftypevr | |
11434 | ||
11435 | @deftypevr {@code{dovecot-configuration} parameter} boolean mail-nfs-storage? | |
11436 | Mail storage exists in NFS. Set this to yes to make Dovecot flush | |
11437 | NFS caches whenever needed. If you're using only a single mail server | |
11438 | this isn't needed. | |
11439 | Defaults to @samp{#f}. | |
11440 | @end deftypevr | |
11441 | ||
11442 | @deftypevr {@code{dovecot-configuration} parameter} boolean mail-nfs-index? | |
11443 | Mail index files also exist in NFS. Setting this to yes requires | |
11444 | @samp{mmap-disable? #t} and @samp{fsync-disable? #f}. | |
11445 | Defaults to @samp{#f}. | |
11446 | @end deftypevr | |
11447 | ||
11448 | @deftypevr {@code{dovecot-configuration} parameter} string lock-method | |
11449 | Locking method for index files. Alternatives are fcntl, flock and | |
11450 | dotlock. Dotlocking uses some tricks which may create more disk I/O | |
11451 | than other locking methods. NFS users: flock doesn't work, remember to | |
11452 | change @samp{mmap-disable}. | |
11453 | Defaults to @samp{"fcntl"}. | |
11454 | @end deftypevr | |
11455 | ||
11456 | @deftypevr {@code{dovecot-configuration} parameter} file-name mail-temp-dir | |
11457 | Directory in which LDA/LMTP temporarily stores incoming mails >128 | |
11458 | kB. | |
11459 | Defaults to @samp{"/tmp"}. | |
11460 | @end deftypevr | |
11461 | ||
11462 | @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer first-valid-uid | |
11463 | Valid UID range for users. This is mostly to make sure that users can't | |
11464 | log in as daemons or other system users. Note that denying root logins is | |
11465 | hardcoded to dovecot binary and can't be done even if @samp{first-valid-uid} | |
11466 | is set to 0. | |
11467 | Defaults to @samp{500}. | |
11468 | @end deftypevr | |
11469 | ||
11470 | @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer last-valid-uid | |
11471 | ||
11472 | Defaults to @samp{0}. | |
11473 | @end deftypevr | |
11474 | ||
11475 | @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer first-valid-gid | |
11476 | Valid GID range for users. Users having non-valid GID as primary group ID | |
11477 | aren't allowed to log in. If user belongs to supplementary groups with | |
11478 | non-valid GIDs, those groups are not set. | |
11479 | Defaults to @samp{1}. | |
11480 | @end deftypevr | |
11481 | ||
11482 | @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer last-valid-gid | |
11483 | ||
11484 | Defaults to @samp{0}. | |
11485 | @end deftypevr | |
11486 | ||
11487 | @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mail-max-keyword-length | |
11488 | Maximum allowed length for mail keyword name. It's only forced when | |
11489 | trying to create new keywords. | |
11490 | Defaults to @samp{50}. | |
11491 | @end deftypevr | |
11492 | ||
11493 | @deftypevr {@code{dovecot-configuration} parameter} colon-separated-file-name-list valid-chroot-dirs | |
11494 | List of directories under which chrooting is allowed for mail | |
11495 | processes (i.e. /var/mail will allow chrooting to /var/mail/foo/bar | |
11496 | too). This setting doesn't affect @samp{login-chroot} | |
11497 | @samp{mail-chroot} or auth chroot settings. If this setting is empty, | |
11498 | "/./" in home dirs are ignored. WARNING: Never add directories here | |
11499 | which local users can modify, that may lead to root exploit. Usually | |
11500 | this should be done only if you don't allow shell access for users. | |
11501 | <doc/wiki/Chrooting.txt>. | |
11502 | Defaults to @samp{()}. | |
11503 | @end deftypevr | |
11504 | ||
11505 | @deftypevr {@code{dovecot-configuration} parameter} string mail-chroot | |
11506 | Default chroot directory for mail processes. This can be overridden | |
11507 | for specific users in user database by giving /./ in user's home | |
11508 | directory (e.g. /home/./user chroots into /home). Note that usually | |
11509 | there is no real need to do chrooting, Dovecot doesn't allow users to | |
11510 | access files outside their mail directory anyway. If your home | |
11511 | directories are prefixed with the chroot directory, append "/." to | |
11512 | @samp{mail-chroot}. <doc/wiki/Chrooting.txt>. | |
11513 | Defaults to @samp{""}. | |
11514 | @end deftypevr | |
11515 | ||
11516 | @deftypevr {@code{dovecot-configuration} parameter} file-name auth-socket-path | |
11517 | UNIX socket path to master authentication server to find users. | |
11518 | This is used by imap (for shared users) and lda. | |
11519 | Defaults to @samp{"/var/run/dovecot/auth-userdb"}. | |
11520 | @end deftypevr | |
11521 | ||
11522 | @deftypevr {@code{dovecot-configuration} parameter} file-name mail-plugin-dir | |
11523 | Directory where to look up mail plugins. | |
11524 | Defaults to @samp{"/usr/lib/dovecot"}. | |
11525 | @end deftypevr | |
11526 | ||
11527 | @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list mail-plugins | |
11528 | List of plugins to load for all services. Plugins specific to IMAP, | |
11529 | LDA, etc. are added to this list in their own .conf files. | |
11530 | Defaults to @samp{()}. | |
11531 | @end deftypevr | |
11532 | ||
11533 | @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mail-cache-min-mail-count | |
11534 | The minimum number of mails in a mailbox before updates are done to | |
11535 | cache file. This allows optimizing Dovecot's behavior to do less disk | |
11536 | writes at the cost of more disk reads. | |
11537 | Defaults to @samp{0}. | |
11538 | @end deftypevr | |
11539 | ||
11540 | @deftypevr {@code{dovecot-configuration} parameter} string mailbox-idle-check-interval | |
11541 | When IDLE command is running, mailbox is checked once in a while to | |
11542 | see if there are any new mails or other changes. This setting defines | |
11543 | the minimum time to wait between those checks. Dovecot can also use | |
11544 | dnotify, inotify and kqueue to find out immediately when changes | |
11545 | occur. | |
11546 | Defaults to @samp{"30 secs"}. | |
11547 | @end deftypevr | |
11548 | ||
11549 | @deftypevr {@code{dovecot-configuration} parameter} boolean mail-save-crlf? | |
11550 | Save mails with CR+LF instead of plain LF. This makes sending those | |
11551 | mails take less CPU, especially with sendfile() syscall with Linux and | |
11552 | FreeBSD. But it also creates a bit more disk I/O which may just make it | |
11553 | slower. Also note that if other software reads the mboxes/maildirs, | |
11554 | they may handle the extra CRs wrong and cause problems. | |
11555 | Defaults to @samp{#f}. | |
11556 | @end deftypevr | |
11557 | ||
11558 | @deftypevr {@code{dovecot-configuration} parameter} boolean maildir-stat-dirs? | |
11559 | By default LIST command returns all entries in maildir beginning | |
11560 | with a dot. Enabling this option makes Dovecot return only entries | |
11561 | which are directories. This is done by stat()ing each entry, so it | |
11562 | causes more disk I/O. | |
11563 | (For systems setting struct @samp{dirent->d_type} this check is free | |
11564 | and it's done always regardless of this setting). | |
11565 | Defaults to @samp{#f}. | |
11566 | @end deftypevr | |
11567 | ||
11568 | @deftypevr {@code{dovecot-configuration} parameter} boolean maildir-copy-with-hardlinks? | |
11569 | When copying a message, do it with hard links whenever possible. | |
11570 | This makes the performance much better, and it's unlikely to have any | |
11571 | side effects. | |
11572 | Defaults to @samp{#t}. | |
11573 | @end deftypevr | |
11574 | ||
11575 | @deftypevr {@code{dovecot-configuration} parameter} boolean maildir-very-dirty-syncs? | |
11576 | Assume Dovecot is the only MUA accessing Maildir: Scan cur/ | |
11577 | directory only when its mtime changes unexpectedly or when we can't find | |
11578 | the mail otherwise. | |
11579 | Defaults to @samp{#f}. | |
11580 | @end deftypevr | |
11581 | ||
11582 | @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list mbox-read-locks | |
11583 | Which locking methods to use for locking mbox. There are four | |
11584 | available: | |
11585 | ||
11586 | @table @code | |
11587 | @item dotlock | |
11588 | Create <mailbox>.lock file. This is the oldest and most NFS-safe | |
11589 | solution. If you want to use /var/mail/ like directory, the users will | |
11590 | need write access to that directory. | |
11591 | @item dotlock-try | |
11592 | Same as dotlock, but if it fails because of permissions or because there | |
11593 | isn't enough disk space, just skip it. | |
11594 | @item fcntl | |
11595 | Use this if possible. Works with NFS too if lockd is used. | |
11596 | @item flock | |
a01ad638 | 11597 | May not exist in all systems. Doesn't work with NFS. |
d8c18af8 AW |
11598 | @item lockf |
11599 | May not exist in all systems. Doesn't work with NFS. | |
11600 | @end table | |
11601 | ||
11602 | You can use multiple locking methods; if you do the order they're declared | |
11603 | in is important to avoid deadlocks if other MTAs/MUAs are using multiple | |
11604 | locking methods as well. Some operating systems don't allow using some of | |
11605 | them simultaneously. | |
11606 | @end deftypevr | |
11607 | ||
11608 | @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list mbox-write-locks | |
11609 | ||
11610 | @end deftypevr | |
11611 | ||
11612 | @deftypevr {@code{dovecot-configuration} parameter} string mbox-lock-timeout | |
11613 | Maximum time to wait for lock (all of them) before aborting. | |
11614 | Defaults to @samp{"5 mins"}. | |
11615 | @end deftypevr | |
11616 | ||
11617 | @deftypevr {@code{dovecot-configuration} parameter} string mbox-dotlock-change-timeout | |
11618 | If dotlock exists but the mailbox isn't modified in any way, | |
11619 | override the lock file after this much time. | |
11620 | Defaults to @samp{"2 mins"}. | |
11621 | @end deftypevr | |
11622 | ||
11623 | @deftypevr {@code{dovecot-configuration} parameter} boolean mbox-dirty-syncs? | |
11624 | When mbox changes unexpectedly we have to fully read it to find out | |
11625 | what changed. If the mbox is large this can take a long time. Since | |
11626 | the change is usually just a newly appended mail, it'd be faster to | |
11627 | simply read the new mails. If this setting is enabled, Dovecot does | |
11628 | this but still safely fallbacks to re-reading the whole mbox file | |
11629 | whenever something in mbox isn't how it's expected to be. The only real | |
11630 | downside to this setting is that if some other MUA changes message | |
11631 | flags, Dovecot doesn't notice it immediately. Note that a full sync is | |
11632 | done with SELECT, EXAMINE, EXPUNGE and CHECK commands. | |
11633 | Defaults to @samp{#t}. | |
11634 | @end deftypevr | |
11635 | ||
11636 | @deftypevr {@code{dovecot-configuration} parameter} boolean mbox-very-dirty-syncs? | |
11637 | Like @samp{mbox-dirty-syncs}, but don't do full syncs even with SELECT, | |
11638 | EXAMINE, EXPUNGE or CHECK commands. If this is set, | |
11639 | @samp{mbox-dirty-syncs} is ignored. | |
11640 | Defaults to @samp{#f}. | |
11641 | @end deftypevr | |
11642 | ||
11643 | @deftypevr {@code{dovecot-configuration} parameter} boolean mbox-lazy-writes? | |
11644 | Delay writing mbox headers until doing a full write sync (EXPUNGE | |
11645 | and CHECK commands and when closing the mailbox). This is especially | |
11646 | useful for POP3 where clients often delete all mails. The downside is | |
11647 | that our changes aren't immediately visible to other MUAs. | |
11648 | Defaults to @samp{#t}. | |
11649 | @end deftypevr | |
11650 | ||
11651 | @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mbox-min-index-size | |
11652 | If mbox size is smaller than this (e.g. 100k), don't write index | |
11653 | files. If an index file already exists it's still read, just not | |
11654 | updated. | |
11655 | Defaults to @samp{0}. | |
11656 | @end deftypevr | |
11657 | ||
11658 | @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mdbox-rotate-size | |
11659 | Maximum dbox file size until it's rotated. | |
11660 | Defaults to @samp{2000000}. | |
11661 | @end deftypevr | |
11662 | ||
11663 | @deftypevr {@code{dovecot-configuration} parameter} string mdbox-rotate-interval | |
11664 | Maximum dbox file age until it's rotated. Typically in days. Day | |
11665 | begins from midnight, so 1d = today, 2d = yesterday, etc. 0 = check | |
11666 | disabled. | |
11667 | Defaults to @samp{"1d"}. | |
11668 | @end deftypevr | |
11669 | ||
11670 | @deftypevr {@code{dovecot-configuration} parameter} boolean mdbox-preallocate-space? | |
11671 | When creating new mdbox files, immediately preallocate their size to | |
11672 | @samp{mdbox-rotate-size}. This setting currently works only in Linux | |
8f65585b | 11673 | with some file systems (ext4, xfs). |
d8c18af8 AW |
11674 | Defaults to @samp{#f}. |
11675 | @end deftypevr | |
11676 | ||
11677 | @deftypevr {@code{dovecot-configuration} parameter} string mail-attachment-dir | |
11678 | sdbox and mdbox support saving mail attachments to external files, | |
11679 | which also allows single instance storage for them. Other backends | |
11680 | don't support this for now. | |
11681 | ||
11682 | WARNING: This feature hasn't been tested much yet. Use at your own risk. | |
11683 | ||
11684 | Directory root where to store mail attachments. Disabled, if empty. | |
11685 | Defaults to @samp{""}. | |
11686 | @end deftypevr | |
11687 | ||
11688 | @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mail-attachment-min-size | |
11689 | Attachments smaller than this aren't saved externally. It's also | |
11690 | possible to write a plugin to disable saving specific attachments | |
11691 | externally. | |
11692 | Defaults to @samp{128000}. | |
11693 | @end deftypevr | |
11694 | ||
11695 | @deftypevr {@code{dovecot-configuration} parameter} string mail-attachment-fs | |
8f65585b | 11696 | File system backend to use for saving attachments: |
d8c18af8 AW |
11697 | @table @code |
11698 | @item posix | |
11699 | No SiS done by Dovecot (but this might help FS's own deduplication) | |
11700 | @item sis posix | |
11701 | SiS with immediate byte-by-byte comparison during saving | |
11702 | @item sis-queue posix | |
11703 | SiS with delayed comparison and deduplication. | |
11704 | @end table | |
11705 | Defaults to @samp{"sis posix"}. | |
11706 | @end deftypevr | |
11707 | ||
11708 | @deftypevr {@code{dovecot-configuration} parameter} string mail-attachment-hash | |
11709 | Hash format to use in attachment filenames. You can add any text and | |
11710 | variables: @code{%@{md4@}}, @code{%@{md5@}}, @code{%@{sha1@}}, | |
11711 | @code{%@{sha256@}}, @code{%@{sha512@}}, @code{%@{size@}}. Variables can be | |
11712 | truncated, e.g. @code{%@{sha256:80@}} returns only first 80 bits. | |
11713 | Defaults to @samp{"%@{sha1@}"}. | |
11714 | @end deftypevr | |
11715 | ||
11716 | @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer default-process-limit | |
11717 | ||
11718 | Defaults to @samp{100}. | |
11719 | @end deftypevr | |
11720 | ||
11721 | @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer default-client-limit | |
11722 | ||
11723 | Defaults to @samp{1000}. | |
11724 | @end deftypevr | |
11725 | ||
11726 | @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer default-vsz-limit | |
11727 | Default VSZ (virtual memory size) limit for service processes. | |
11728 | This is mainly intended to catch and kill processes that leak memory | |
11729 | before they eat up everything. | |
11730 | Defaults to @samp{256000000}. | |
11731 | @end deftypevr | |
11732 | ||
11733 | @deftypevr {@code{dovecot-configuration} parameter} string default-login-user | |
11734 | Login user is internally used by login processes. This is the most | |
11735 | untrusted user in Dovecot system. It shouldn't have access to anything | |
11736 | at all. | |
11737 | Defaults to @samp{"dovenull"}. | |
11738 | @end deftypevr | |
11739 | ||
11740 | @deftypevr {@code{dovecot-configuration} parameter} string default-internal-user | |
11741 | Internal user is used by unprivileged processes. It should be | |
11742 | separate from login user, so that login processes can't disturb other | |
11743 | processes. | |
11744 | Defaults to @samp{"dovecot"}. | |
11745 | @end deftypevr | |
11746 | ||
11747 | @deftypevr {@code{dovecot-configuration} parameter} string ssl? | |
11748 | SSL/TLS support: yes, no, required. <doc/wiki/SSL.txt>. | |
11749 | Defaults to @samp{"required"}. | |
11750 | @end deftypevr | |
11751 | ||
11752 | @deftypevr {@code{dovecot-configuration} parameter} string ssl-cert | |
11753 | PEM encoded X.509 SSL/TLS certificate (public key). | |
11754 | Defaults to @samp{"</etc/dovecot/default.pem"}. | |
11755 | @end deftypevr | |
11756 | ||
11757 | @deftypevr {@code{dovecot-configuration} parameter} string ssl-key | |
11758 | PEM encoded SSL/TLS private key. The key is opened before | |
11759 | dropping root privileges, so keep the key file unreadable by anyone but | |
11760 | root. | |
11761 | Defaults to @samp{"</etc/dovecot/private/default.pem"}. | |
11762 | @end deftypevr | |
11763 | ||
11764 | @deftypevr {@code{dovecot-configuration} parameter} string ssl-key-password | |
11765 | If key file is password protected, give the password here. | |
11766 | Alternatively give it when starting dovecot with -p parameter. Since | |
11767 | this file is often world-readable, you may want to place this setting | |
11768 | instead to a different. | |
11769 | Defaults to @samp{""}. | |
11770 | @end deftypevr | |
11771 | ||
11772 | @deftypevr {@code{dovecot-configuration} parameter} string ssl-ca | |
11773 | PEM encoded trusted certificate authority. Set this only if you | |
11774 | intend to use @samp{ssl-verify-client-cert? #t}. The file should | |
11775 | contain the CA certificate(s) followed by the matching | |
11776 | CRL(s). (e.g. @samp{ssl-ca </etc/ssl/certs/ca.pem}). | |
11777 | Defaults to @samp{""}. | |
11778 | @end deftypevr | |
11779 | ||
11780 | @deftypevr {@code{dovecot-configuration} parameter} boolean ssl-require-crl? | |
11781 | Require that CRL check succeeds for client certificates. | |
11782 | Defaults to @samp{#t}. | |
11783 | @end deftypevr | |
11784 | ||
11785 | @deftypevr {@code{dovecot-configuration} parameter} boolean ssl-verify-client-cert? | |
11786 | Request client to send a certificate. If you also want to require | |
11787 | it, set @samp{auth-ssl-require-client-cert? #t} in auth section. | |
11788 | Defaults to @samp{#f}. | |
11789 | @end deftypevr | |
11790 | ||
11791 | @deftypevr {@code{dovecot-configuration} parameter} string ssl-cert-username-field | |
11792 | Which field from certificate to use for username. commonName and | |
11793 | x500UniqueIdentifier are the usual choices. You'll also need to set | |
11794 | @samp{auth-ssl-username-from-cert? #t}. | |
11795 | Defaults to @samp{"commonName"}. | |
11796 | @end deftypevr | |
11797 | ||
11798 | @deftypevr {@code{dovecot-configuration} parameter} hours ssl-parameters-regenerate | |
11799 | How often to regenerate the SSL parameters file. Generation is | |
11800 | quite CPU intensive operation. The value is in hours, 0 disables | |
11801 | regeneration entirely. | |
11802 | Defaults to @samp{168}. | |
11803 | @end deftypevr | |
11804 | ||
11805 | @deftypevr {@code{dovecot-configuration} parameter} string ssl-protocols | |
11806 | SSL protocols to use. | |
11807 | Defaults to @samp{"!SSLv2"}. | |
11808 | @end deftypevr | |
11809 | ||
11810 | @deftypevr {@code{dovecot-configuration} parameter} string ssl-cipher-list | |
11811 | SSL ciphers to use. | |
11812 | Defaults to @samp{"ALL:!LOW:!SSLv2:!EXP:!aNULL"}. | |
11813 | @end deftypevr | |
11814 | ||
11815 | @deftypevr {@code{dovecot-configuration} parameter} string ssl-crypto-device | |
11816 | SSL crypto device to use, for valid values run "openssl engine". | |
11817 | Defaults to @samp{""}. | |
11818 | @end deftypevr | |
11819 | ||
11820 | @deftypevr {@code{dovecot-configuration} parameter} string postmaster-address | |
11821 | Address to use when sending rejection mails. | |
66329c23 AW |
11822 | %d expands to recipient domain. |
11823 | Defaults to @samp{"postmaster@@%d"}. | |
d8c18af8 AW |
11824 | @end deftypevr |
11825 | ||
11826 | @deftypevr {@code{dovecot-configuration} parameter} string hostname | |
11827 | Hostname to use in various parts of sent mails (e.g. in Message-Id) | |
11828 | and in LMTP replies. Default is the system's real hostname@@domain. | |
11829 | Defaults to @samp{""}. | |
11830 | @end deftypevr | |
11831 | ||
11832 | @deftypevr {@code{dovecot-configuration} parameter} boolean quota-full-tempfail? | |
11833 | If user is over quota, return with temporary failure instead of | |
11834 | bouncing the mail. | |
11835 | Defaults to @samp{#f}. | |
11836 | @end deftypevr | |
11837 | ||
11838 | @deftypevr {@code{dovecot-configuration} parameter} file-name sendmail-path | |
11839 | Binary to use for sending mails. | |
11840 | Defaults to @samp{"/usr/sbin/sendmail"}. | |
11841 | @end deftypevr | |
11842 | ||
11843 | @deftypevr {@code{dovecot-configuration} parameter} string submission-host | |
11844 | If non-empty, send mails via this SMTP host[:port] instead of | |
11845 | sendmail. | |
11846 | Defaults to @samp{""}. | |
11847 | @end deftypevr | |
11848 | ||
11849 | @deftypevr {@code{dovecot-configuration} parameter} string rejection-subject | |
11850 | Subject: header to use for rejection mails. You can use the same | |
11851 | variables as for @samp{rejection-reason} below. | |
11852 | Defaults to @samp{"Rejected: %s"}. | |
11853 | @end deftypevr | |
11854 | ||
11855 | @deftypevr {@code{dovecot-configuration} parameter} string rejection-reason | |
11856 | Human readable error message for rejection mails. You can use | |
11857 | variables: | |
11858 | ||
11859 | @table @code | |
11860 | @item %n | |
11861 | CRLF | |
11862 | @item %r | |
11863 | reason | |
11864 | @item %s | |
11865 | original subject | |
11866 | @item %t | |
11867 | recipient | |
11868 | @end table | |
11869 | Defaults to @samp{"Your message to <%t> was automatically rejected:%n%r"}. | |
11870 | @end deftypevr | |
11871 | ||
11872 | @deftypevr {@code{dovecot-configuration} parameter} string recipient-delimiter | |
11873 | Delimiter character between local-part and detail in email | |
11874 | address. | |
11875 | Defaults to @samp{"+"}. | |
11876 | @end deftypevr | |
11877 | ||
11878 | @deftypevr {@code{dovecot-configuration} parameter} string lda-original-recipient-header | |
11879 | Header where the original recipient address (SMTP's RCPT TO: | |
11880 | address) is taken from if not available elsewhere. With dovecot-lda -a | |
11881 | parameter overrides this. A commonly used header for this is | |
11882 | X-Original-To. | |
11883 | Defaults to @samp{""}. | |
11884 | @end deftypevr | |
11885 | ||
11886 | @deftypevr {@code{dovecot-configuration} parameter} boolean lda-mailbox-autocreate? | |
11887 | Should saving a mail to a nonexistent mailbox automatically create | |
11888 | it?. | |
11889 | Defaults to @samp{#f}. | |
11890 | @end deftypevr | |
11891 | ||
11892 | @deftypevr {@code{dovecot-configuration} parameter} boolean lda-mailbox-autosubscribe? | |
11893 | Should automatically created mailboxes be also automatically | |
11894 | subscribed?. | |
11895 | Defaults to @samp{#f}. | |
11896 | @end deftypevr | |
11897 | ||
11898 | @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer imap-max-line-length | |
11899 | Maximum IMAP command line length. Some clients generate very long | |
11900 | command lines with huge mailboxes, so you may need to raise this if you | |
11901 | get "Too long argument" or "IMAP command line too large" errors | |
11902 | often. | |
11903 | Defaults to @samp{64000}. | |
11904 | @end deftypevr | |
11905 | ||
11906 | @deftypevr {@code{dovecot-configuration} parameter} string imap-logout-format | |
11907 | IMAP logout format string: | |
11908 | @table @code | |
11909 | @item %i | |
11910 | total number of bytes read from client | |
11911 | @item %o | |
11912 | total number of bytes sent to client. | |
11913 | @end table | |
11914 | Defaults to @samp{"in=%i out=%o"}. | |
11915 | @end deftypevr | |
11916 | ||
11917 | @deftypevr {@code{dovecot-configuration} parameter} string imap-capability | |
11918 | Override the IMAP CAPABILITY response. If the value begins with '+', | |
11919 | add the given capabilities on top of the defaults (e.g. +XFOO XBAR). | |
11920 | Defaults to @samp{""}. | |
11921 | @end deftypevr | |
11922 | ||
11923 | @deftypevr {@code{dovecot-configuration} parameter} string imap-idle-notify-interval | |
11924 | How long to wait between "OK Still here" notifications when client | |
11925 | is IDLEing. | |
11926 | Defaults to @samp{"2 mins"}. | |
11927 | @end deftypevr | |
11928 | ||
11929 | @deftypevr {@code{dovecot-configuration} parameter} string imap-id-send | |
11930 | ID field names and values to send to clients. Using * as the value | |
11931 | makes Dovecot use the default value. The following fields have default | |
11932 | values currently: name, version, os, os-version, support-url, | |
11933 | support-email. | |
11934 | Defaults to @samp{""}. | |
11935 | @end deftypevr | |
11936 | ||
11937 | @deftypevr {@code{dovecot-configuration} parameter} string imap-id-log | |
11938 | ID fields sent by client to log. * means everything. | |
11939 | Defaults to @samp{""}. | |
11940 | @end deftypevr | |
11941 | ||
11942 | @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list imap-client-workarounds | |
11943 | Workarounds for various client bugs: | |
11944 | ||
11945 | @table @code | |
11946 | @item delay-newmail | |
11947 | Send EXISTS/RECENT new mail notifications only when replying to NOOP and | |
11948 | CHECK commands. Some clients ignore them otherwise, for example OSX | |
11949 | Mail (<v2.1). Outlook Express breaks more badly though, without this it | |
11950 | may show user "Message no longer in server" errors. Note that OE6 | |
11951 | still breaks even with this workaround if synchronization is set to | |
11952 | "Headers Only". | |
11953 | ||
11954 | @item tb-extra-mailbox-sep | |
11955 | Thunderbird gets somehow confused with LAYOUT=fs (mbox and dbox) and | |
11956 | adds extra @samp{/} suffixes to mailbox names. This option causes Dovecot to | |
11957 | ignore the extra @samp{/} instead of treating it as invalid mailbox name. | |
11958 | ||
11959 | @item tb-lsub-flags | |
11960 | Show \Noselect flags for LSUB replies with LAYOUT=fs (e.g. mbox). | |
11961 | This makes Thunderbird realize they aren't selectable and show them | |
11962 | greyed out, instead of only later giving "not selectable" popup error. | |
11963 | @end table | |
11964 | Defaults to @samp{()}. | |
11965 | @end deftypevr | |
11966 | ||
11967 | @deftypevr {@code{dovecot-configuration} parameter} string imap-urlauth-host | |
11968 | Host allowed in URLAUTH URLs sent by client. "*" allows all. | |
11969 | Defaults to @samp{""}. | |
11970 | @end deftypevr | |
11971 | ||
11972 | ||
11973 | Whew! Lots of configuration options. The nice thing about it though is | |
11974 | that GuixSD has a complete interface to Dovecot's configuration | |
11975 | language. This allows not only a nice way to declare configurations, | |
11976 | but also offers reflective capabilities as well: users can write code to | |
11977 | inspect and transform configurations from within Scheme. | |
11978 | ||
11979 | However, it could be that you just want to get a @code{dovecot.conf} up | |
11980 | and running. In that case, you can pass an | |
7414de0a | 11981 | @code{opaque-dovecot-configuration} as the @code{#:config} parameter to |
d8c18af8 AW |
11982 | @code{dovecot-service}. As its name indicates, an opaque configuration |
11983 | does not have easy reflective capabilities. | |
11984 | ||
11985 | Available @code{opaque-dovecot-configuration} fields are: | |
11986 | ||
11987 | @deftypevr {@code{opaque-dovecot-configuration} parameter} package dovecot | |
11988 | The dovecot package. | |
11989 | @end deftypevr | |
11990 | ||
11991 | @deftypevr {@code{opaque-dovecot-configuration} parameter} string string | |
11992 | The contents of the @code{dovecot.conf}, as a string. | |
11993 | @end deftypevr | |
11994 | ||
11995 | For example, if your @code{dovecot.conf} is just the empty string, you | |
11996 | could instantiate a dovecot service like this: | |
11997 | ||
11998 | @example | |
11999 | (dovecot-service #:config | |
12000 | (opaque-dovecot-configuration | |
12001 | (string ""))) | |
12002 | @end example | |
12003 | ||
f88371e8 SB |
12004 | @subsubheading OpenSMTPD Service |
12005 | ||
12006 | @deffn {Scheme Variable} opensmtpd-service-type | |
12007 | This is the type of the @uref{https://www.opensmtpd.org, OpenSMTPD} | |
12008 | service, whose value should be an @code{opensmtpd-configuration} object | |
12009 | as in this example: | |
12010 | ||
12011 | @example | |
12012 | (service opensmtpd-service-type | |
12013 | (opensmtpd-configuration | |
12014 | (config-file (local-file "./my-smtpd.conf")))) | |
12015 | @end example | |
12016 | @end deffn | |
12017 | ||
12018 | @deftp {Data Type} opensmtpd-configuration | |
12019 | Data type regresenting the configuration of opensmtpd. | |
12020 | ||
12021 | @table @asis | |
12022 | @item @code{package} (default: @var{opensmtpd}) | |
12023 | Package object of the OpenSMTPD SMTP server. | |
12024 | ||
12025 | @item @code{config-file} (default: @var{%default-opensmtpd-file}) | |
12026 | File-like object of the OpenSMTPD configuration file to use. By default | |
12027 | it listens on the loopback network interface, and allows for mail from | |
12028 | users and daemons on the local machine, as well as permitting email to | |
12029 | remote servers. Run @command{man smtpd.conf} for more information. | |
12030 | ||
12031 | @end table | |
12032 | @end deftp | |
859e367d | 12033 | |
78cef99b CL |
12034 | @node Messaging Services |
12035 | @subsubsection Messaging Services | |
12036 | ||
12037 | @cindex messaging | |
12038 | @cindex jabber | |
12039 | @cindex XMPP | |
12040 | The @code{(gnu services messaging)} module provides Guix service | |
12041 | definitions for messaging services: currently only Prosody is supported. | |
12042 | ||
12043 | @subsubheading Prosody Service | |
12044 | ||
12045 | @deffn {Scheme Variable} prosody-service-type | |
12046 | This is the type for the @uref{http://prosody.im, Prosody XMPP | |
12047 | communication server}. Its value must be a @code{prosody-configuration} | |
12048 | record as in this example: | |
12049 | ||
12050 | @example | |
12051 | (service prosody-service-type | |
12052 | (prosody-configuration | |
12053 | (modules-enabled (cons "groups" %default-modules-enabled)) | |
12054 | (int-components | |
12055 | (list | |
12056 | (int-component-configuration | |
12057 | (hostname "conference.example.net") | |
12058 | (plugin "muc") | |
12059 | (mod-muc (mod-muc-configuration))))) | |
12060 | (virtualhosts | |
12061 | (list | |
12062 | (virtualhost-configuration | |
12063 | (domain "example.net")))))) | |
12064 | @end example | |
12065 | ||
12066 | See below for details about @code{prosody-configuration}. | |
12067 | ||
12068 | @end deffn | |
12069 | ||
12070 | By default, Prosody does not need much configuration. Only one | |
12071 | @code{virtualhosts} field is needed: it specifies the domain you wish | |
12072 | Prosody to serve. | |
12073 | ||
12074 | Prosodyctl will help you generate X.509 certificates and keys: | |
12075 | ||
12076 | @example | |
12077 | prosodyctl cert request example.net | |
12078 | @end example | |
12079 | ||
12080 | The available configuration parameters follow. Each parameter | |
12081 | definition is preceded by its type; for example, @samp{string-list foo} | |
12082 | indicates that the @code{foo} parameter should be specified as a list of | |
12083 | strings. Types starting with @code{maybe-} denote parameters that won't | |
12084 | show up in @code{prosody.cfg.lua} when their value is @code{'disabled}. | |
12085 | ||
12086 | There is also a way to specify the configuration as a string, if you | |
12087 | have an old @code{prosody.cfg.lua} file that you want to port over from | |
12088 | some other system; see the end for more details. | |
12089 | ||
12090 | @c The following documentation was initially generated by | |
12091 | @c (generate-documentation) in (gnu services messaging). Manually maintained | |
12092 | @c documentation is better, so we shouldn't hesitate to edit below as | |
12093 | @c needed. However if the change you want to make to this documentation | |
12094 | @c can be done in an automated way, it's probably easier to change | |
12095 | @c (generate-documentation) than to make it below and have to deal with | |
12096 | @c the churn as Prosody updates. | |
12097 | ||
12098 | Available @code{prosody-configuration} fields are: | |
12099 | ||
12100 | @deftypevr {@code{prosody-configuration} parameter} package prosody | |
12101 | The Prosody package. | |
12102 | @end deftypevr | |
12103 | ||
12104 | @deftypevr {@code{prosody-configuration} parameter} file-name data-path | |
12105 | Location of the Prosody data storage directory. See | |
12106 | @url{http://prosody.im/doc/configure}. | |
12107 | Defaults to @samp{"/var/lib/prosody"}. | |
12108 | @end deftypevr | |
12109 | ||
12110 | @deftypevr {@code{prosody-configuration} parameter} file-name-list plugin-paths | |
12111 | Additional plugin directories. They are searched in all the specified | |
12112 | paths in order. See @url{http://prosody.im/doc/plugins_directory}. | |
12113 | Defaults to @samp{()}. | |
12114 | @end deftypevr | |
12115 | ||
12116 | @deftypevr {@code{prosody-configuration} parameter} string-list admins | |
12117 | This is a list of accounts that are admins for the server. Note that you | |
12118 | must create the accounts separately. See @url{http://prosody.im/doc/admins} and | |
12119 | @url{http://prosody.im/doc/creating_accounts}. | |
12120 | Example: @code{(admins '("user1@@example.com" "user2@@example.net"))} | |
12121 | Defaults to @samp{()}. | |
12122 | @end deftypevr | |
12123 | ||
12124 | @deftypevr {@code{prosody-configuration} parameter} boolean use-libevent? | |
12125 | Enable use of libevent for better performance under high load. See | |
12126 | @url{http://prosody.im/doc/libevent}. | |
12127 | Defaults to @samp{#f}. | |
12128 | @end deftypevr | |
12129 | ||
12130 | @deftypevr {@code{prosody-configuration} parameter} module-list modules-enabled | |
12131 | This is the list of modules Prosody will load on startup. It looks for | |
12132 | @code{mod_modulename.lua} in the plugins folder, so make sure that exists too. | |
12133 | Documentation on modules can be found at: @url{http://prosody.im/doc/modules}. | |
12134 | Defaults to @samp{%default-modules-enabled}. | |
12135 | @end deftypevr | |
12136 | ||
12137 | @deftypevr {@code{prosody-configuration} parameter} string-list modules-disabled | |
12138 | @samp{"offline"}, @samp{"c2s"} and @samp{"s2s"} are auto-loaded, but | |
12139 | should you want to disable them then add them to this list. | |
12140 | Defaults to @samp{()}. | |
12141 | @end deftypevr | |
12142 | ||
12143 | @deftypevr {@code{prosody-configuration} parameter} file-name groups-file | |
12144 | Path to a text file where the shared groups are defined. If this path is | |
12145 | empty then @samp{mod_groups} does nothing. See | |
12146 | @url{http://prosody.im/doc/modules/mod_groups}. | |
12147 | Defaults to @samp{"/var/lib/prosody/sharedgroups.txt"}. | |
12148 | @end deftypevr | |
12149 | ||
12150 | @deftypevr {@code{prosody-configuration} parameter} boolean allow-registration? | |
12151 | Disable account creation by default, for security. See | |
12152 | @url{http://prosody.im/doc/creating_accounts}. | |
12153 | Defaults to @samp{#f}. | |
12154 | @end deftypevr | |
12155 | ||
12156 | @deftypevr {@code{prosody-configuration} parameter} maybe-ssl-configuration ssl | |
12157 | These are the SSL/TLS-related settings. Most of them are disabled so to | |
12158 | use Prosody's defaults. If you do not completely understand these options, do | |
12159 | not add them to your config, it is easy to lower the security of your server | |
12160 | using them. See @url{http://prosody.im/doc/advanced_ssl_config}. | |
12161 | ||
12162 | Available @code{ssl-configuration} fields are: | |
12163 | ||
12164 | @deftypevr {@code{ssl-configuration} parameter} maybe-string protocol | |
12165 | This determines what handshake to use. | |
12166 | @end deftypevr | |
12167 | ||
12168 | @deftypevr {@code{ssl-configuration} parameter} file-name key | |
12169 | Path to your private key file, relative to @code{/etc/prosody}. | |
12170 | Defaults to @samp{"/etc/prosody/certs/key.pem"}. | |
12171 | @end deftypevr | |
12172 | ||
12173 | @deftypevr {@code{ssl-configuration} parameter} file-name certificate | |
12174 | Path to your certificate file, relative to @code{/etc/prosody}. | |
12175 | Defaults to @samp{"/etc/prosody/certs/cert.pem"}. | |
12176 | @end deftypevr | |
12177 | ||
12178 | @deftypevr {@code{ssl-configuration} parameter} file-name capath | |
12179 | Path to directory containing root certificates that you wish Prosody to | |
12180 | trust when verifying the certificates of remote servers. | |
12181 | Defaults to @samp{"/etc/ssl/certs"}. | |
12182 | @end deftypevr | |
12183 | ||
12184 | @deftypevr {@code{ssl-configuration} parameter} maybe-file-name cafile | |
12185 | Path to a file containing root certificates that you wish Prosody to trust. | |
12186 | Similar to @code{capath} but with all certificates concatenated together. | |
12187 | @end deftypevr | |
12188 | ||
12189 | @deftypevr {@code{ssl-configuration} parameter} maybe-string-list verify | |
12190 | A list of verification options (these mostly map to OpenSSL's | |
12191 | @code{set_verify()} flags). | |
12192 | @end deftypevr | |
12193 | ||
12194 | @deftypevr {@code{ssl-configuration} parameter} maybe-string-list options | |
12195 | A list of general options relating to SSL/TLS. These map to OpenSSL's | |
12196 | @code{set_options()}. For a full list of options available in LuaSec, see the | |
12197 | LuaSec source. | |
12198 | @end deftypevr | |
12199 | ||
12200 | @deftypevr {@code{ssl-configuration} parameter} maybe-non-negative-integer depth | |
12201 | How long a chain of certificate authorities to check when looking for a | |
12202 | trusted root certificate. | |
12203 | @end deftypevr | |
12204 | ||
12205 | @deftypevr {@code{ssl-configuration} parameter} maybe-string ciphers | |
12206 | An OpenSSL cipher string. This selects what ciphers Prosody will offer to | |
12207 | clients, and in what order. | |
12208 | @end deftypevr | |
12209 | ||
12210 | @deftypevr {@code{ssl-configuration} parameter} maybe-file-name dhparam | |
12211 | A path to a file containing parameters for Diffie-Hellman key exchange. You | |
12212 | can create such a file with: | |
12213 | @code{openssl dhparam -out /etc/prosody/certs/dh-2048.pem 2048} | |
12214 | @end deftypevr | |
12215 | ||
12216 | @deftypevr {@code{ssl-configuration} parameter} maybe-string curve | |
12217 | Curve for Elliptic curve Diffie-Hellman. Prosody's default is | |
12218 | @samp{"secp384r1"}. | |
12219 | @end deftypevr | |
12220 | ||
12221 | @deftypevr {@code{ssl-configuration} parameter} maybe-string-list verifyext | |
12222 | A list of "extra" verification options. | |
12223 | @end deftypevr | |
12224 | ||
12225 | @deftypevr {@code{ssl-configuration} parameter} maybe-string password | |
12226 | Password for encrypted private keys. | |
12227 | @end deftypevr | |
12228 | ||
12229 | @end deftypevr | |
12230 | ||
12231 | @deftypevr {@code{prosody-configuration} parameter} boolean c2s-require-encryption? | |
12232 | Whether to force all client-to-server connections to be encrypted or not. | |
12233 | See @url{http://prosody.im/doc/modules/mod_tls}. | |
12234 | Defaults to @samp{#f}. | |
12235 | @end deftypevr | |
12236 | ||
12237 | @deftypevr {@code{prosody-configuration} parameter} boolean s2s-require-encryption? | |
12238 | Whether to force all server-to-server connections to be encrypted or not. | |
12239 | See @url{http://prosody.im/doc/modules/mod_tls}. | |
12240 | Defaults to @samp{#f}. | |
12241 | @end deftypevr | |
12242 | ||
12243 | @deftypevr {@code{prosody-configuration} parameter} boolean s2s-secure-auth? | |
12244 | Whether to require encryption and certificate authentication. This | |
12245 | provides ideal security, but requires servers you communicate with to support | |
12246 | encryption AND present valid, trusted certificates. See | |
12247 | @url{http://prosody.im/doc/s2s#security}. | |
12248 | Defaults to @samp{#f}. | |
12249 | @end deftypevr | |
12250 | ||
12251 | @deftypevr {@code{prosody-configuration} parameter} string-list s2s-insecure-domains | |
12252 | Many servers don't support encryption or have invalid or self-signed | |
12253 | certificates. You can list domains here that will not be required to | |
12254 | authenticate using certificates. They will be authenticated using DNS. See | |
12255 | @url{http://prosody.im/doc/s2s#security}. | |
12256 | Defaults to @samp{()}. | |
12257 | @end deftypevr | |
12258 | ||
12259 | @deftypevr {@code{prosody-configuration} parameter} string-list s2s-secure-domains | |
12260 | Even if you leave @code{s2s-secure-auth?} disabled, you can still require | |
12261 | valid certificates for some domains by specifying a list here. See | |
12262 | @url{http://prosody.im/doc/s2s#security}. | |
12263 | Defaults to @samp{()}. | |
12264 | @end deftypevr | |
12265 | ||
12266 | @deftypevr {@code{prosody-configuration} parameter} string authentication | |
12267 | Select the authentication backend to use. The default provider stores | |
12268 | passwords in plaintext and uses Prosody's configured data storage to store the | |
12269 | authentication data. If you do not trust your server please see | |
12270 | @url{http://prosody.im/doc/modules/mod_auth_internal_hashed} for information | |
12271 | about using the hashed backend. See also | |
12272 | @url{http://prosody.im/doc/authentication} | |
12273 | Defaults to @samp{"internal_plain"}. | |
12274 | @end deftypevr | |
12275 | ||
12276 | @deftypevr {@code{prosody-configuration} parameter} maybe-string log | |
12277 | Set logging options. Advanced logging configuration is not yet supported | |
12278 | by the GuixSD Prosody Service. See @url{http://prosody.im/doc/logging}. | |
12279 | Defaults to @samp{"*syslog"}. | |
12280 | @end deftypevr | |
12281 | ||
12282 | @deftypevr {@code{prosody-configuration} parameter} file-name pidfile | |
12283 | File to write pid in. See @url{http://prosody.im/doc/modules/mod_posix}. | |
12284 | Defaults to @samp{"/var/run/prosody/prosody.pid"}. | |
12285 | @end deftypevr | |
12286 | ||
12287 | @deftypevr {@code{prosody-configuration} parameter} virtualhost-configuration-list virtualhosts | |
12288 | A host in Prosody is a domain on which user accounts can be created. For | |
12289 | example if you want your users to have addresses like | |
12290 | @samp{"john.smith@@example.com"} then you need to add a host | |
12291 | @samp{"example.com"}. All options in this list will apply only to this host. | |
12292 | ||
12293 | Note: the name "virtual" host is used in configuration to avoid confusion with | |
12294 | the actual physical host that Prosody is installed on. A single Prosody | |
12295 | instance can serve many domains, each one defined as a VirtualHost entry in | |
12296 | Prosody's configuration. Conversely a server that hosts a single domain would | |
12297 | have just one VirtualHost entry. | |
12298 | ||
12299 | See @url{http://prosody.im/doc/configure#virtual_host_settings}. | |
12300 | ||
12301 | Available @code{virtualhost-configuration} fields are: | |
12302 | ||
12303 | all these @code{prosody-configuration} fields: @code{admins}, @code{use-libevent?}, @code{modules-enabled}, @code{modules-disabled}, @code{groups-file}, @code{allow-registration?}, @code{ssl}, @code{c2s-require-encryption?}, @code{s2s-require-encryption?}, @code{s2s-secure-auth?}, @code{s2s-insecure-domains}, @code{s2s-secure-domains}, @code{authentication}, @code{log}, plus: | |
12304 | @deftypevr {@code{virtualhost-configuration} parameter} string domain | |
12305 | Domain you wish Prosody to serve. | |
12306 | @end deftypevr | |
12307 | ||
12308 | @end deftypevr | |
12309 | ||
12310 | @deftypevr {@code{prosody-configuration} parameter} int-component-configuration-list int-components | |
12311 | Components are extra services on a server which are available to clients, | |
12312 | usually on a subdomain of the main server (such as | |
12313 | @samp{"mycomponent.example.com"}). Example components might be chatroom | |
12314 | servers, user directories, or gateways to other protocols. | |
12315 | ||
12316 | Internal components are implemented with Prosody-specific plugins. To add an | |
12317 | internal component, you simply fill the hostname field, and the plugin you wish | |
12318 | to use for the component. | |
12319 | ||
12320 | See @url{http://prosody.im/doc/components}. | |
12321 | Defaults to @samp{()}. | |
12322 | ||
12323 | Available @code{int-component-configuration} fields are: | |
12324 | ||
12325 | all these @code{prosody-configuration} fields: @code{admins}, @code{use-libevent?}, @code{modules-enabled}, @code{modules-disabled}, @code{groups-file}, @code{allow-registration?}, @code{ssl}, @code{c2s-require-encryption?}, @code{s2s-require-encryption?}, @code{s2s-secure-auth?}, @code{s2s-insecure-domains}, @code{s2s-secure-domains}, @code{authentication}, @code{log}, plus: | |
12326 | @deftypevr {@code{int-component-configuration} parameter} string hostname | |
12327 | Hostname of the component. | |
12328 | @end deftypevr | |
12329 | ||
12330 | @deftypevr {@code{int-component-configuration} parameter} string plugin | |
12331 | Plugin you wish to use for the component. | |
12332 | @end deftypevr | |
12333 | ||
12334 | @deftypevr {@code{int-component-configuration} parameter} maybe-mod-muc-configuration mod-muc | |
12335 | Multi-user chat (MUC) is Prosody's module for allowing you to create | |
12336 | hosted chatrooms/conferences for XMPP users. | |
12337 | ||
12338 | General information on setting up and using multi-user chatrooms can be found | |
12339 | in the "Chatrooms" documentation (@url{http://prosody.im/doc/chatrooms}), | |
12340 | which you should read if you are new to XMPP chatrooms. | |
12341 | ||
12342 | See also @url{http://prosody.im/doc/modules/mod_muc}. | |
12343 | ||
12344 | Available @code{mod-muc-configuration} fields are: | |
12345 | ||
12346 | @deftypevr {@code{mod-muc-configuration} parameter} string name | |
12347 | The name to return in service discovery responses. | |
12348 | Defaults to @samp{"Prosody Chatrooms"}. | |
12349 | @end deftypevr | |
12350 | ||
12351 | @deftypevr {@code{mod-muc-configuration} parameter} string-or-boolean restrict-room-creation | |
12352 | If @samp{#t}, this will only allow admins to create new chatrooms. | |
12353 | Otherwise anyone can create a room. The value @samp{"local"} restricts room | |
12354 | creation to users on the service's parent domain. E.g. @samp{user@@example.com} | |
12355 | can create rooms on @samp{rooms.example.com}. The value @samp{"admin"} | |
12356 | restricts to service administrators only. | |
12357 | Defaults to @samp{#f}. | |
12358 | @end deftypevr | |
12359 | ||
12360 | @deftypevr {@code{mod-muc-configuration} parameter} non-negative-integer max-history-messages | |
12361 | Maximum number of history messages that will be sent to the member that has | |
12362 | just joined the room. | |
12363 | Defaults to @samp{20}. | |
12364 | @end deftypevr | |
12365 | ||
12366 | @end deftypevr | |
12367 | ||
12368 | @end deftypevr | |
12369 | ||
12370 | @deftypevr {@code{prosody-configuration} parameter} ext-component-configuration-list ext-components | |
12371 | External components use XEP-0114, which most standalone components | |
12372 | support. To add an external component, you simply fill the hostname field. See | |
12373 | @url{http://prosody.im/doc/components}. | |
12374 | Defaults to @samp{()}. | |
12375 | ||
12376 | Available @code{ext-component-configuration} fields are: | |
12377 | ||
12378 | all these @code{prosody-configuration} fields: @code{admins}, @code{use-libevent?}, @code{modules-enabled}, @code{modules-disabled}, @code{groups-file}, @code{allow-registration?}, @code{ssl}, @code{c2s-require-encryption?}, @code{s2s-require-encryption?}, @code{s2s-secure-auth?}, @code{s2s-insecure-domains}, @code{s2s-secure-domains}, @code{authentication}, @code{log}, plus: | |
12379 | @deftypevr {@code{ext-component-configuration} parameter} string component-secret | |
12380 | Password which the component will use to log in. | |
12381 | @end deftypevr | |
12382 | ||
12383 | @deftypevr {@code{ext-component-configuration} parameter} string hostname | |
12384 | Hostname of the component. | |
12385 | @end deftypevr | |
12386 | ||
12387 | @end deftypevr | |
12388 | ||
12389 | @deftypevr {@code{prosody-configuration} parameter} non-negative-integer-list component-ports | |
12390 | Port(s) Prosody listens on for component connections. | |
12391 | @end deftypevr | |
12392 | ||
12393 | @deftypevr {@code{prosody-configuration} parameter} string component-interface | |
12394 | Interface Prosody listens on for component connections. | |
12395 | Defaults to @samp{"127.0.0.1"}. | |
12396 | @end deftypevr | |
12397 | ||
12398 | It could be that you just want to get a @code{prosody.cfg.lua} | |
12399 | up and running. In that case, you can pass an | |
12400 | @code{opaque-prosody-configuration} record as the value of | |
12401 | @code{prosody-service-type}. As its name indicates, an opaque configuration | |
12402 | does not have easy reflective capabilities. | |
12403 | Available @code{opaque-prosody-configuration} fields are: | |
12404 | ||
12405 | @deftypevr {@code{opaque-prosody-configuration} parameter} package prosody | |
12406 | The prosody package. | |
12407 | @end deftypevr | |
12408 | ||
12409 | @deftypevr {@code{opaque-prosody-configuration} parameter} string prosody.cfg.lua | |
12410 | The contents of the @code{prosody.cfg.lua} to use. | |
12411 | @end deftypevr | |
12412 | ||
12413 | For example, if your @code{prosody.cfg.lua} is just the empty | |
12414 | string, you could instantiate a prosody service like this: | |
12415 | ||
12416 | @example | |
12417 | (service prosody-service-type | |
12418 | (opaque-prosody-configuration | |
12419 | (prosody.cfg.lua ""))) | |
12420 | @end example | |
12421 | ||
859e367d JD |
12422 | @node Kerberos Services |
12423 | @subsubsection Kerberos Services | |
12424 | @cindex Kerberos | |
12425 | ||
df31e36a | 12426 | The @code{(gnu services kerberos)} module provides services relating to |
859e367d JD |
12427 | the authentication protocol @dfn{Kerberos}. |
12428 | ||
8e3f813f JD |
12429 | @subsubheading Krb5 Service |
12430 | ||
12431 | Programs using a Kerberos client library normally | |
12432 | expect a configuration file in @file{/etc/krb5.conf}. | |
12433 | This service generates such a file from a definition provided in the | |
12434 | operating system declaration. | |
12435 | It does not cause any daemon to be started. | |
12436 | ||
12437 | No ``keytab'' files are provided by this service---you must explicitly create them. | |
12438 | This service is known to work with the MIT client library, @code{mit-krb5}. | |
12439 | Other implementations have not been tested. | |
12440 | ||
12441 | @defvr {Scheme Variable} krb5-service-type | |
12442 | A service type for Kerberos 5 clients. | |
12443 | @end defvr | |
12444 | ||
12445 | @noindent | |
12446 | Here is an example of its use: | |
12447 | @lisp | |
12448 | (service krb5-service-type | |
12449 | (krb5-configuration | |
12450 | (default-realm "EXAMPLE.COM") | |
12451 | (allow-weak-crypto? #t) | |
12452 | (realms (list | |
12453 | (krb5-realm | |
12454 | (name "EXAMPLE.COM") | |
12455 | (admin-server "groucho.example.com") | |
12456 | (kdc "karl.example.com")) | |
12457 | (krb5-realm | |
12458 | (name "ARGRX.EDU") | |
12459 | (admin-server "kerb-admin.argrx.edu") | |
12460 | (kdc "keys.argrx.edu")))))) | |
12461 | @end lisp | |
12462 | ||
12463 | @noindent | |
12464 | This example provides a Kerberos@tie{}5 client configuration which: | |
12465 | @itemize | |
12466 | @item Recognizes two realms, @i{viz:} ``EXAMPLE.COM'' and ``ARGRX.EDU'', both | |
12467 | of which have distinct administration servers and key distribution centers; | |
12468 | @item Will default to the realm ``EXAMPLE.COM'' if the realm is not explicitly | |
12469 | specified by clients; | |
12470 | @item Accepts services which only support encryption types known to be weak. | |
12471 | @end itemize | |
12472 | ||
12473 | The @code{krb5-realm} and @code{krb5-configuration} types have many fields. | |
12474 | Only the most commonly used ones are described here. | |
12475 | For a full list, and more detailed explanation of each, see the MIT | |
12476 | @uref{http://web.mit.edu/kerberos/krb5-devel/doc/admin/conf_files/krb5_conf.html,,krb5.conf} | |
12477 | documentation. | |
12478 | ||
12479 | ||
12480 | @deftp {Data Type} krb5-realm | |
12481 | @cindex realm, kerberos | |
12482 | @table @asis | |
12483 | @item @code{name} | |
12484 | This field is a string identifying the name of the realm. | |
12485 | A common convention is to use the fully qualified DNS name of your organization, | |
12486 | converted to upper case. | |
12487 | ||
12488 | @item @code{admin-server} | |
12489 | This field is a string identifying the host where the administration server is | |
12490 | running. | |
12491 | ||
12492 | @item @code{kdc} | |
12493 | This field is a string identifying the key distribution center | |
12494 | for the realm. | |
12495 | @end table | |
12496 | @end deftp | |
12497 | ||
12498 | @deftp {Data Type} krb5-configuration | |
12499 | ||
12500 | @table @asis | |
12501 | @item @code{allow-weak-crypto?} (default: @code{#f}) | |
12502 | If this flag is @code{#t} then services which only offer encryption algorithms | |
12503 | known to be weak will be accepted. | |
12504 | ||
12505 | @item @code{default-realm} (default: @code{#f}) | |
12506 | This field should be a string identifying the default Kerberos | |
12507 | realm for the client. | |
12508 | You should set this field to the name of your Kerberos realm. | |
12509 | If this value is @code{#f} | |
12510 | then a realm must be specified with every Kerberos principal when invoking programs | |
12511 | such as @command{kinit}. | |
12512 | ||
12513 | @item @code{realms} | |
12514 | This should be a non-empty list of @code{krb5-realm} objects, which clients may | |
12515 | access. | |
12516 | Normally, one of them will have a @code{name} field matching the @code{default-realm} | |
12517 | field. | |
12518 | @end table | |
12519 | @end deftp | |
12520 | ||
12521 | ||
859e367d JD |
12522 | @subsubheading PAM krb5 Service |
12523 | @cindex pam-krb5 | |
12524 | ||
df31e36a | 12525 | The @code{pam-krb5} service allows for login authentication and password |
859e367d JD |
12526 | management via Kerberos. |
12527 | You will need this service if you want PAM enabled applications to authenticate | |
12528 | users using Kerberos. | |
12529 | ||
12530 | @defvr {Scheme Variable} pam-krb5-service-type | |
12531 | A service type for the Kerberos 5 PAM module. | |
12532 | @end defvr | |
12533 | ||
12534 | @deftp {Data Type} pam-krb5-configuration | |
12535 | Data type representing the configuration of the Kerberos 5 PAM module | |
12536 | This type has the following parameters: | |
12537 | @table @asis | |
12538 | @item @code{pam-krb5} (default: @code{pam-krb5}) | |
12539 | The pam-krb5 package to use. | |
12540 | ||
12541 | @item @code{minimum-uid} (default: @code{1000}) | |
12542 | The smallest user ID for which Kerberos authentications should be attempted. | |
12543 | Local accounts with lower values will silently fail to authenticate. | |
12544 | @end table | |
12545 | @end deftp | |
12546 | ||
12547 | ||
58724c48 DT |
12548 | @node Web Services |
12549 | @subsubsection Web Services | |
12550 | ||
e32171ee JD |
12551 | @cindex web |
12552 | @cindex www | |
12553 | @cindex HTTP | |
58724c48 DT |
12554 | The @code{(gnu services web)} module provides the following service: |
12555 | ||
be1c2c54 | 12556 | @deffn {Scheme Procedure} nginx-service [#:nginx nginx] @ |
58724c48 DT |
12557 | [#:log-directory ``/var/log/nginx''] @ |
12558 | [#:run-directory ``/var/run/nginx''] @ | |
d338237d | 12559 | [#:server-list '()] @ |
cb341293 | 12560 | [#:upstream-list '()] @ |
d338237d | 12561 | [#:config-file @code{#f}] |
58724c48 DT |
12562 | |
12563 | Return a service that runs @var{nginx}, the nginx web server. | |
12564 | ||
12565 | The nginx daemon loads its runtime configuration from @var{config-file}. | |
12566 | Log files are written to @var{log-directory} and temporary runtime data | |
12567 | files are written to @var{run-directory}. For proper operation, these | |
12568 | arguments should match what is in @var{config-file} to ensure that the | |
12569 | directories are created when the service is activated. | |
12570 | ||
3b9b12ef | 12571 | As an alternative to using a @var{config-file}, @var{server-list} can be |
cb341293 CB |
12572 | used to specify the list of @dfn{server blocks} required on the host and |
12573 | @var{upstream-list} can be used to specify a list of @dfn{upstream | |
12574 | blocks} to configure. For this to work, use the default value for | |
12575 | @var{config-file}. | |
8c00b838 | 12576 | |
58724c48 DT |
12577 | @end deffn |
12578 | ||
d338237d JL |
12579 | @deffn {Scheme Variable} nginx-service-type |
12580 | This is type for the nginx web server. | |
12581 | ||
12582 | This service can be extended to add server blocks in addition to the | |
12583 | default one, as in this example: | |
12584 | ||
12585 | @example | |
12586 | (simple-service 'my-extra-server nginx-service-type | |
12587 | (list (nginx-server-configuration | |
12588 | (https-port #f) | |
12589 | (root "/srv/http/extra-website")))) | |
12590 | @end example | |
12591 | @end deffn | |
12592 | ||
3b9b12ef JL |
12593 | @deftp {Data Type} nginx-server-configuration |
12594 | Data type representing the configuration of an nginx server block. | |
8c00b838 JL |
12595 | This type has the following parameters: |
12596 | ||
12597 | @table @asis | |
12598 | @item @code{http-port} (default: @code{80}) | |
12599 | Nginx will listen for HTTP connection on this port. Set it at @code{#f} if | |
12600 | nginx should not listen for HTTP (non secure) connection for this | |
3b9b12ef | 12601 | @dfn{server block}. |
8c00b838 JL |
12602 | |
12603 | @item @code{https-port} (default: @code{443}) | |
12604 | Nginx will listen for HTTPS connection on this port. Set it at @code{#f} if | |
3b9b12ef | 12605 | nginx should not listen for HTTPS (secure) connection for this @dfn{server block}. |
8c00b838 JL |
12606 | |
12607 | Note that nginx can listen for HTTP and HTTPS connections in the same | |
3b9b12ef | 12608 | @dfn{server block}. |
8c00b838 JL |
12609 | |
12610 | @item @code{server-name} (default: @code{(list 'default)}) | |
3b9b12ef JL |
12611 | A list of server names this server represents. @code{'default} represents the |
12612 | default server for connections matching no other server. | |
8c00b838 JL |
12613 | |
12614 | @item @code{root} (default: @code{"/srv/http"}) | |
12615 | Root of the website nginx will serve. | |
12616 | ||
9c557a69 CB |
12617 | @item @code{locations} (default: @code{'()}) |
12618 | A list of @dfn{nginx-location-configuration} or | |
12619 | @dfn{nginx-named-location-configuration} records to use within this | |
12620 | server block. | |
12621 | ||
8c00b838 JL |
12622 | @item @code{index} (default: @code{(list "index.html")}) |
12623 | Index files to look for when clients ask for a directory. If it cannot be found, | |
12624 | Nginx will send the list of files in the directory. | |
12625 | ||
12626 | @item @code{ssl-certificate} (default: @code{"/etc/nginx/cert.pem"}) | |
12627 | Where to find the certificate for secure connections. Set it to @code{#f} if | |
12628 | you don't have a certificate or you don't want to use HTTPS. | |
12629 | ||
12630 | @item @code{ssl-certificate-key} (default: @code{"/etc/nginx/key.pem"}) | |
12631 | Where to find the private key for secure connections. Set it to @code{#f} if | |
12632 | you don't have a key or you don't want to use HTTPS. | |
12633 | ||
12634 | @item @code{server-tokens?} (default: @code{#f}) | |
12635 | Whether the server should add its configuration to response. | |
12636 | ||
12637 | @end table | |
12638 | @end deftp | |
12639 | ||
2be1b471 JL |
12640 | @node VPN Services |
12641 | @subsubsection VPN Services | |
12642 | @cindex VPN (virtual private network) | |
12643 | @cindex virtual private network (VPN) | |
12644 | ||
12645 | The @code{(gnu services vpn)} module provides services related to | |
12646 | @dfn{virtual private networks} (VPNs). It provides a @emph{client} service for | |
12647 | your machine to connect to a VPN, and a @emph{servire} service for your machine | |
12648 | to host a VPN. Both services use @uref{https://openvpn.net/, OpenVPN}. | |
12649 | ||
12650 | @deffn {Scheme Procedure} openvpn-client-service @ | |
12651 | [#:config (openvpn-client-configuration)] | |
12652 | ||
12653 | Return a service that runs @command{openvpn}, a VPN daemon, as a client. | |
12654 | @end deffn | |
12655 | ||
12656 | @deffn {Scheme Procedure} openvpn-server-service @ | |
12657 | [#:config (openvpn-server-configuration)] | |
12658 | ||
12659 | Return a service that runs @command{openvpn}, a VPN daemon, as a server. | |
12660 | ||
12661 | Both can be run simultaneously. | |
12662 | @end deffn | |
12663 | ||
12664 | @c %automatically generated documentation | |
12665 | ||
12666 | Available @code{openvpn-client-configuration} fields are: | |
12667 | ||
12668 | @deftypevr @code{openvpn-client-configuration} parameter package openvpn | |
12669 | The OpenVPN package. | |
12670 | ||
12671 | @end deftypevr | |
12672 | ||
12673 | @deftypevr @code{openvpn-client-configuration} parameter string pid-file | |
12674 | The OpenVPN pid file. | |
12675 | ||
12676 | Defaults to @samp{"/var/run/openvpn/openvpn.pid"}. | |
12677 | ||
12678 | @end deftypevr | |
12679 | ||
12680 | @deftypevr @code{openvpn-client-configuration} parameter proto proto | |
12681 | The protocol (UDP or TCP) used to open a channel between clients and | |
12682 | servers. | |
12683 | ||
12684 | Defaults to @samp{udp}. | |
12685 | ||
12686 | @end deftypevr | |
12687 | ||
12688 | @deftypevr @code{openvpn-client-configuration} parameter dev dev | |
12689 | The device type used to represent the VPN connection. | |
12690 | ||
12691 | Defaults to @samp{tun}. | |
12692 | ||
12693 | @end deftypevr | |
12694 | ||
12695 | @deftypevr @code{openvpn-client-configuration} parameter string ca | |
12696 | The certificate authority to check connections against. | |
12697 | ||
12698 | Defaults to @samp{"/etc/openvpn/ca.crt"}. | |
12699 | ||
12700 | @end deftypevr | |
12701 | ||
12702 | @deftypevr @code{openvpn-client-configuration} parameter string cert | |
12703 | The certificate of the machine the daemon is running on. It should be | |
12704 | signed by the authority given in @code{ca}. | |
12705 | ||
12706 | Defaults to @samp{"/etc/openvpn/client.crt"}. | |
12707 | ||
12708 | @end deftypevr | |
12709 | ||
12710 | @deftypevr @code{openvpn-client-configuration} parameter string key | |
12711 | The key of the machine the daemon is running on. It must be the key whose | |
12712 | certificate is @code{cert}. | |
12713 | ||
12714 | Defaults to @samp{"/etc/openvpn/client.key"}. | |
12715 | ||
12716 | @end deftypevr | |
12717 | ||
12718 | @deftypevr @code{openvpn-client-configuration} parameter boolean comp-lzo? | |
12719 | Whether to use the lzo compression algorithm. | |
12720 | ||
12721 | Defaults to @samp{#t}. | |
12722 | ||
12723 | @end deftypevr | |
12724 | ||
12725 | @deftypevr @code{openvpn-client-configuration} parameter boolean persist-key? | |
12726 | Don't re-read key files across SIGUSR1 or --ping-restart. | |
12727 | ||
12728 | Defaults to @samp{#t}. | |
12729 | ||
12730 | @end deftypevr | |
12731 | ||
12732 | @deftypevr @code{openvpn-client-configuration} parameter boolean persist-tun? | |
12733 | Don't close and reopen TUN/TAP device or run up/down scripts across | |
12734 | SIGUSR1 or --ping-restart restarts. | |
12735 | ||
12736 | Defaults to @samp{#t}. | |
12737 | ||
12738 | @end deftypevr | |
12739 | ||
12740 | @deftypevr @code{openvpn-client-configuration} parameter number verbosity | |
12741 | Verbosity level. | |
12742 | ||
12743 | Defaults to @samp{3}. | |
12744 | ||
12745 | @end deftypevr | |
12746 | ||
12747 | @deftypevr @code{openvpn-client-configuration} parameter tls-auth-client tls-auth | |
12748 | Add an additional layer of HMAC authentication on top of the TLS control | |
12749 | channel to protect against DoS attacks. | |
12750 | ||
12751 | Defaults to @samp{#f}. | |
12752 | ||
12753 | @end deftypevr | |
12754 | ||
12755 | @deftypevr @code{openvpn-client-configuration} parameter key-usage verify-key-usage? | |
12756 | Whether to check the server certificate has server usage extension. | |
12757 | ||
12758 | Defaults to @samp{#t}. | |
12759 | ||
12760 | @end deftypevr | |
12761 | ||
12762 | @deftypevr @code{openvpn-client-configuration} parameter bind bind? | |
12763 | Bind to a specific local port number. | |
12764 | ||
12765 | Defaults to @samp{#f}. | |
12766 | ||
12767 | @end deftypevr | |
12768 | ||
12769 | @deftypevr @code{openvpn-client-configuration} parameter resolv-retry resolv-retry? | |
12770 | Retry resolving server address. | |
12771 | ||
12772 | Defaults to @samp{#t}. | |
12773 | ||
12774 | @end deftypevr | |
12775 | ||
12776 | @deftypevr @code{openvpn-client-configuration} parameter openvpn-remote-list remote | |
12777 | A list of remote servers to connect to. | |
12778 | ||
12779 | Defaults to @samp{()}. | |
12780 | ||
12781 | Available @code{openvpn-remote-configuration} fields are: | |
12782 | ||
12783 | @deftypevr @code{openvpn-remote-configuration} parameter string name | |
12784 | Server name. | |
12785 | ||
12786 | Defaults to @samp{"my-server"}. | |
12787 | ||
12788 | @end deftypevr | |
12789 | ||
12790 | @deftypevr @code{openvpn-remote-configuration} parameter number port | |
12791 | Port number the server listens to. | |
12792 | ||
12793 | Defaults to @samp{1194}. | |
12794 | ||
12795 | @end deftypevr | |
12796 | ||
12797 | @end deftypevr | |
12798 | @c %end of automatic openvpn-client documentation | |
12799 | ||
12800 | @c %automatically generated documentation | |
12801 | ||
12802 | Available @code{openvpn-server-configuration} fields are: | |
12803 | ||
12804 | @deftypevr @code{openvpn-server-configuration} parameter package openvpn | |
12805 | The OpenVPN package. | |
12806 | ||
12807 | @end deftypevr | |
12808 | ||
12809 | @deftypevr @code{openvpn-server-configuration} parameter string pid-file | |
12810 | The OpenVPN pid file. | |
12811 | ||
12812 | Defaults to @samp{"/var/run/openvpn/openvpn.pid"}. | |
12813 | ||
12814 | @end deftypevr | |
12815 | ||
12816 | @deftypevr @code{openvpn-server-configuration} parameter proto proto | |
12817 | The protocol (UDP or TCP) used to open a channel between clients and | |
12818 | servers. | |
12819 | ||
12820 | Defaults to @samp{udp}. | |
12821 | ||
12822 | @end deftypevr | |
12823 | ||
12824 | @deftypevr @code{openvpn-server-configuration} parameter dev dev | |
12825 | The device type used to represent the VPN connection. | |
12826 | ||
12827 | Defaults to @samp{tun}. | |
12828 | ||
12829 | @end deftypevr | |
12830 | ||
12831 | @deftypevr @code{openvpn-server-configuration} parameter string ca | |
12832 | The certificate authority to check connections against. | |
12833 | ||
12834 | Defaults to @samp{"/etc/openvpn/ca.crt"}. | |
12835 | ||
12836 | @end deftypevr | |
12837 | ||
12838 | @deftypevr @code{openvpn-server-configuration} parameter string cert | |
12839 | The certificate of the machine the daemon is running on. It should be | |
12840 | signed by the authority given in @code{ca}. | |
12841 | ||
12842 | Defaults to @samp{"/etc/openvpn/client.crt"}. | |
12843 | ||
12844 | @end deftypevr | |
12845 | ||
12846 | @deftypevr @code{openvpn-server-configuration} parameter string key | |
12847 | The key of the machine the daemon is running on. It must be the key whose | |
12848 | certificate is @code{cert}. | |
12849 | ||
12850 | Defaults to @samp{"/etc/openvpn/client.key"}. | |
12851 | ||
12852 | @end deftypevr | |
12853 | ||
12854 | @deftypevr @code{openvpn-server-configuration} parameter boolean comp-lzo? | |
12855 | Whether to use the lzo compression algorithm. | |
12856 | ||
12857 | Defaults to @samp{#t}. | |
12858 | ||
12859 | @end deftypevr | |
12860 | ||
12861 | @deftypevr @code{openvpn-server-configuration} parameter boolean persist-key? | |
12862 | Don't re-read key files across SIGUSR1 or --ping-restart. | |
12863 | ||
12864 | Defaults to @samp{#t}. | |
12865 | ||
12866 | @end deftypevr | |
12867 | ||
12868 | @deftypevr @code{openvpn-server-configuration} parameter boolean persist-tun? | |
12869 | Don't close and reopen TUN/TAP device or run up/down scripts across | |
12870 | SIGUSR1 or --ping-restart restarts. | |
12871 | ||
12872 | Defaults to @samp{#t}. | |
12873 | ||
12874 | @end deftypevr | |
12875 | ||
12876 | @deftypevr @code{openvpn-server-configuration} parameter number verbosity | |
12877 | Verbosity level. | |
12878 | ||
12879 | Defaults to @samp{3}. | |
12880 | ||
12881 | @end deftypevr | |
12882 | ||
12883 | @deftypevr @code{openvpn-server-configuration} parameter tls-auth-server tls-auth | |
12884 | Add an additional layer of HMAC authentication on top of the TLS control | |
12885 | channel to protect against DoS attacks. | |
12886 | ||
12887 | Defaults to @samp{#f}. | |
12888 | ||
12889 | @end deftypevr | |
12890 | ||
12891 | @deftypevr @code{openvpn-server-configuration} parameter number port | |
12892 | Specifies the port number on which the server listens. | |
12893 | ||
12894 | Defaults to @samp{1194}. | |
12895 | ||
12896 | @end deftypevr | |
12897 | ||
12898 | @deftypevr @code{openvpn-server-configuration} parameter ip-mask server | |
12899 | An ip and mask specifying the subnet inside the virtual network. | |
12900 | ||
12901 | Defaults to @samp{"10.8.0.0 255.255.255.0"}. | |
12902 | ||
12903 | @end deftypevr | |
12904 | ||
12905 | @deftypevr @code{openvpn-server-configuration} parameter cidr6 server-ipv6 | |
12906 | A CIDR notation specifying the IPv6 subnet inside the virtual network. | |
12907 | ||
12908 | Defaults to @samp{#f}. | |
12909 | ||
12910 | @end deftypevr | |
12911 | ||
12912 | @deftypevr @code{openvpn-server-configuration} parameter string dh | |
12913 | The Diffie-Hellman parameters file. | |
12914 | ||
12915 | Defaults to @samp{"/etc/openvpn/dh2048.pem"}. | |
12916 | ||
12917 | @end deftypevr | |
12918 | ||
12919 | @deftypevr @code{openvpn-server-configuration} parameter string ifconfig-pool-persist | |
12920 | The file that records client IPs. | |
12921 | ||
12922 | Defaults to @samp{"/etc/openvpn/ipp.txt"}. | |
12923 | ||
12924 | @end deftypevr | |
12925 | ||
12926 | @deftypevr @code{openvpn-server-configuration} parameter gateway redirect-gateway? | |
12927 | When true, the server will act as a gateway for its clients. | |
12928 | ||
12929 | Defaults to @samp{#f}. | |
12930 | ||
12931 | @end deftypevr | |
12932 | ||
12933 | @deftypevr @code{openvpn-server-configuration} parameter boolean client-to-client? | |
12934 | When true, clients are alowed to talk to each other inside the VPN. | |
12935 | ||
12936 | Defaults to @samp{#f}. | |
12937 | ||
12938 | @end deftypevr | |
12939 | ||
12940 | @deftypevr @code{openvpn-server-configuration} parameter keepalive keepalive | |
12941 | Causes ping-like messages to be sent back and forth over the link so | |
12942 | that each side knows when the other side has gone down. @code{keepalive} | |
12943 | requires a pair. The first element is the period of the ping sending, | |
12944 | and the second element is the timeout before considering the other side | |
12945 | down. | |
12946 | ||
12947 | @end deftypevr | |
12948 | ||
12949 | @deftypevr @code{openvpn-server-configuration} parameter number max-clients | |
12950 | The maximum number of clients. | |
12951 | ||
12952 | Defaults to @samp{100}. | |
12953 | ||
12954 | @end deftypevr | |
12955 | ||
12956 | @deftypevr @code{openvpn-server-configuration} parameter string status | |
12957 | The status file. This file shows a small report on current connection. | |
12958 | It is trunkated and rewritten every minute. | |
12959 | ||
12960 | Defaults to @samp{"/var/run/openvpn/status"}. | |
12961 | ||
12962 | @end deftypevr | |
12963 | ||
12964 | @deftypevr @code{openvpn-server-configuration} parameter openvpn-ccd-list client-config-dir | |
12965 | The list of configuration for some clients. | |
12966 | ||
12967 | Defaults to @samp{()}. | |
12968 | ||
12969 | Available @code{openvpn-ccd-configuration} fields are: | |
12970 | ||
12971 | @deftypevr @code{openvpn-ccd-configuration} parameter string name | |
12972 | Client name. | |
12973 | ||
12974 | Defaults to @samp{"client"}. | |
12975 | ||
12976 | @end deftypevr | |
12977 | ||
12978 | @deftypevr @code{openvpn-ccd-configuration} parameter ip-mask iroute | |
12979 | Client own network | |
12980 | ||
12981 | Defaults to @samp{#f}. | |
12982 | ||
12983 | @end deftypevr | |
12984 | ||
12985 | @deftypevr @code{openvpn-ccd-configuration} parameter ip-mask ifconfig-push | |
12986 | Client VPN IP. | |
12987 | ||
12988 | Defaults to @samp{#f}. | |
12989 | ||
12990 | @end deftypevr | |
12991 | ||
12992 | @end deftypevr | |
12993 | ||
12994 | ||
12995 | @c %end of automatic openvpn-server documentation | |
12996 | ||
12997 | ||
cb341293 CB |
12998 | @deftp {Data Type} nginx-upstream-configuration |
12999 | Data type representing the configuration of an nginx @code{upstream} | |
13000 | block. This type has the following parameters: | |
13001 | ||
13002 | @table @asis | |
13003 | @item @code{name} | |
13004 | Name for this group of servers. | |
13005 | ||
13006 | @item @code{servers} | |
13007 | Specify the addresses of the servers in the group. The address can be | |
13008 | specified as a IP address (e.g. @samp{127.0.0.1}), domain name | |
13009 | (e.g. @samp{backend1.example.com}) or a path to a UNIX socket using the | |
13010 | prefix @samp{unix:}. For addresses using an IP address or domain name, | |
13011 | the default port is 80, and a different port can be specified | |
13012 | explicitly. | |
13013 | ||
13014 | @end table | |
13015 | @end deftp | |
13016 | ||
9c557a69 CB |
13017 | @deftp {Data Type} nginx-location-configuration |
13018 | Data type representing the configuration of an nginx @code{location} | |
13019 | block. This type has the following parameters: | |
13020 | ||
13021 | @table @asis | |
13022 | @item @code{uri} | |
13023 | URI which this location block matches. | |
13024 | ||
13025 | @anchor{nginx-location-configuration body} | |
13026 | @item @code{body} | |
13027 | Body of the location block, specified as a string. This can contain many | |
13028 | configuration directives. For example, to pass requests to a upstream | |
13029 | server group defined using an @code{nginx-upstream-configuration} block, | |
13030 | the following directive would be specified in the body @samp{proxy_pass | |
13031 | http://upstream-name;}. | |
13032 | ||
13033 | @end table | |
13034 | @end deftp | |
13035 | ||
13036 | @deftp {Data Type} nginx-named-location-configuration | |
13037 | Data type representing the configuration of an nginx named location | |
13038 | block. Named location blocks are used for request redirection, and not | |
13039 | used for regular request processing. This type has the following | |
13040 | parameters: | |
13041 | ||
13042 | @table @asis | |
13043 | @item @code{name} | |
13044 | Name to identify this location block. | |
13045 | ||
13046 | @item @code{body} | |
13047 | @xref{nginx-location-configuration body}, as the body for named location | |
13048 | blocks can be used in a similar way to the | |
13049 | @code{nginx-location-configuration body}. One restriction is that the | |
13050 | body of a named location block cannot contain location blocks. | |
13051 | ||
13052 | @end table | |
13053 | @end deftp | |
13054 | ||
eb419bc9 JD |
13055 | @node Network File System |
13056 | @subsubsection Network File System | |
13057 | @cindex NFS | |
fe1a39d3 | 13058 | |
eb419bc9 JD |
13059 | The @code{(gnu services nfs)} module provides the following services, |
13060 | which are most commonly used in relation to mounting or exporting | |
13061 | directory trees as @dfn{network file systems} (NFS). | |
d6a07ee6 JD |
13062 | |
13063 | @subsubheading RPC Bind Service | |
13064 | @cindex rpcbind | |
13065 | ||
eb419bc9 JD |
13066 | The RPC Bind service provides a facility to map program numbers into |
13067 | universal addresses. | |
13068 | Many NFS related services use this facility. Hence it is automatically | |
13069 | started when a dependent service starts. | |
d6a07ee6 JD |
13070 | |
13071 | @defvr {Scheme Variable} rpcbind-service-type | |
13072 | A service type for the RPC portmapper daemon. | |
13073 | @end defvr | |
13074 | ||
13075 | ||
13076 | @deftp {Data Type} rpcbind-configuration | |
13077 | Data type representing the configuration of the RPC Bind Service. | |
13078 | This type has the following parameters: | |
13079 | @table @asis | |
13080 | @item @code{rpcbind} (default: @code{rpcbind}) | |
13081 | The rpcbind package to use. | |
13082 | ||
13083 | @item @code{warm-start?} (default: @code{#t}) | |
13084 | If this parameter is @code{#t}, then the daemon will read a | |
13085 | state file on startup thus reloading state information saved by a previous | |
13086 | instance. | |
13087 | @end table | |
13088 | @end deftp | |
13089 | ||
eb419bc9 JD |
13090 | |
13091 | @subsubheading Pipefs Pseudo File System | |
13092 | @cindex pipefs | |
13093 | @cindex rpc_pipefs | |
13094 | ||
13095 | The pipefs file system is used to transfer NFS related data | |
13096 | between the kernel and user space programs. | |
13097 | ||
13098 | @defvr {Scheme Variable} pipefs-service-type | |
13099 | A service type for the pipefs pseudo file system. | |
13100 | @end defvr | |
13101 | ||
13102 | @deftp {Data Type} pipefs-configuration | |
13103 | Data type representing the configuration of the pipefs pseudo file system service. | |
13104 | This type has the following parameters: | |
13105 | @table @asis | |
13106 | @item @code{mount-point} (default: @code{"/var/lib/nfs/rpc_pipefs"}) | |
13107 | The directory to which the file system is to be attached. | |
13108 | @end table | |
13109 | @end deftp | |
13110 | ||
13111 | ||
13112 | @subsubheading GSS Daemon Service | |
13113 | @cindex GSSD | |
13114 | @cindex GSS | |
13115 | @cindex global security system | |
13116 | ||
13117 | The @dfn{global security system} (GSS) daemon provides strong security for RPC | |
13118 | based protocols. | |
13119 | Before exchanging RPC requests an RPC client must establish a security | |
13120 | context. Typically this is done using the Kerberos command @command{kinit} | |
859e367d | 13121 | or automatically at login time using PAM services (@pxref{Kerberos Services}). |
eb419bc9 JD |
13122 | |
13123 | @defvr {Scheme Variable} gss-service-type | |
13124 | A service type for the Global Security System (GSS) daemon. | |
13125 | @end defvr | |
13126 | ||
13127 | @deftp {Data Type} gss-configuration | |
13128 | Data type representing the configuration of the GSS daemon service. | |
13129 | This type has the following parameters: | |
13130 | @table @asis | |
13131 | @item @code{nfs-utils} (default: @code{nfs-utils}) | |
13132 | The package in which the @command{rpc.gssd} command is to be found. | |
13133 | ||
13134 | @item @code{pipefs-directory} (default: @code{"/var/lib/nfs/rpc_pipefs"}) | |
13135 | The directory where the pipefs file system is mounted. | |
13136 | ||
13137 | @end table | |
13138 | @end deftp | |
13139 | ||
13140 | ||
13141 | @subsubheading IDMAP Daemon Service | |
13142 | @cindex idmapd | |
13143 | @cindex name mapper | |
13144 | ||
13145 | The idmap daemon service provides mapping between user IDs and user names. | |
13146 | Typically it is required in order to access file systems mounted via NFSv4. | |
13147 | ||
13148 | @defvr {Scheme Variable} idmap-service-type | |
13149 | A service type for the Identity Mapper (IDMAP) daemon. | |
13150 | @end defvr | |
13151 | ||
13152 | @deftp {Data Type} idmap-configuration | |
13153 | Data type representing the configuration of the IDMAP daemon service. | |
13154 | This type has the following parameters: | |
13155 | @table @asis | |
13156 | @item @code{nfs-utils} (default: @code{nfs-utils}) | |
13157 | The package in which the @command{rpc.idmapd} command is to be found. | |
13158 | ||
13159 | @item @code{pipefs-directory} (default: @code{"/var/lib/nfs/rpc_pipefs"}) | |
13160 | The directory where the pipefs file system is mounted. | |
13161 | ||
13162 | @item @code{domain} (default: @code{#f}) | |
13163 | The local NFSv4 domain name. | |
13164 | This must be a string or @code{#f}. | |
13165 | If it is @code{#f} then the daemon will use the host's fully qualified domain name. | |
13166 | ||
13167 | @end table | |
13168 | @end deftp | |
13169 | ||
a7cf4eb6 ML |
13170 | @node Continuous Integration |
13171 | @subsubsection Continuous Integration | |
13172 | ||
13173 | @cindex continuous integration | |
13174 | @uref{https://notabug.org/mthl/cuirass, Cuirass} is a continuous | |
13175 | integration tool for Guix. It can be used both for development and for | |
13176 | providing substitutes to others (@pxref{Substitutes}). | |
13177 | ||
13178 | The @code{(gnu services cuirass)} module provides the following service. | |
13179 | ||
231eddc8 LC |
13180 | @defvr {Scheme Procedure} cuirass-service-type |
13181 | The type of the Cuirass service. Its value must be a | |
13182 | @code{cuirass-configuration} object, as described below. | |
13183 | @end defvr | |
a7cf4eb6 | 13184 | |
231eddc8 LC |
13185 | To add build jobs, you have to set the @code{specifications} field of |
13186 | the configuration. Here is an example of a service defining a build job | |
13187 | based on a specification that can be found in Cuirass source tree. This | |
13188 | service polls the Guix repository and builds a subset of the Guix | |
13189 | packages, as prescribed in the @file{gnu-system.scm} example spec: | |
a7cf4eb6 ML |
13190 | |
13191 | @example | |
8de938d5 LC |
13192 | (let ((spec #~((#:name . "guix") |
13193 | (#:url . "git://git.savannah.gnu.org/guix.git") | |
13194 | (#:load-path . ".") | |
13195 | ||
13196 | ;; Here we must provide an absolute file name. | |
13197 | ;; We take jobs from one of the examples provided | |
13198 | ;; by Cuirass. | |
13199 | (#:file . #$(file-append | |
13200 | cuirass | |
13201 | "/tests/gnu-system.scm")) | |
13202 | ||
13203 | (#:proc . hydra-jobs) | |
13204 | (#:arguments (subset . "hello")) | |
13205 | (#:branch . "master")))) | |
231eddc8 LC |
13206 | (service cuirass-service-type |
13207 | (cuirass-configuration | |
13208 | (specifications #~(list #$spec))))) | |
a7cf4eb6 ML |
13209 | @end example |
13210 | ||
231eddc8 | 13211 | While information related to build jobs is located directly in the |
a7cf4eb6 ML |
13212 | specifications, global settings for the @command{cuirass} process are |
13213 | accessible in other @code{cuirass-configuration} fields. | |
13214 | ||
13215 | @deftp {Data Type} cuirass-configuration | |
13216 | Data type representing the configuration of Cuirass. | |
13217 | ||
13218 | @table @asis | |
b17e326f LC |
13219 | @item @code{log-file} (default: @code{"/var/log/cuirass.log"}) |
13220 | Location of the log file. | |
13221 | ||
463995da | 13222 | @item @code{cache-directory} (default: @code{"/var/cache/cuirass"}) |
a7cf4eb6 ML |
13223 | Location of the repository cache. |
13224 | ||
13225 | @item @code{user} (default: @code{"cuirass"}) | |
13226 | Owner of the @code{cuirass} process. | |
13227 | ||
13228 | @item @code{group} (default: @code{"cuirass"}) | |
13229 | Owner's group of the @code{cuirass} process. | |
13230 | ||
13231 | @item @code{interval} (default: @code{60}) | |
13232 | Number of seconds between the poll of the repositories followed by the | |
13233 | Cuirass jobs. | |
13234 | ||
13235 | @item @code{database} (default: @code{"/var/run/cuirass/cuirass.db"}) | |
13236 | Location of sqlite database which contains the build results and previously | |
13237 | added specifications. | |
13238 | ||
11b7717d MO |
13239 | @item @code{port} (default: @code{8080}) |
13240 | Port number used by the HTTP server. | |
13241 | ||
8de938d5 LC |
13242 | @item @code{specifications} (default: @code{#~'()}) |
13243 | A gexp (@pxref{G-Expressions}) that evaluates to a list of specifications, | |
13244 | where a specification is an association list | |
a7cf4eb6 ML |
13245 | (@pxref{Associations Lists,,, guile, GNU Guile Reference Manual}) whose |
13246 | keys are keywords (@code{#:keyword-example}) as shown in the example | |
13247 | above. | |
13248 | ||
13249 | @item @code{use-substitutes?} (default: @code{#f}) | |
13250 | This allows using substitutes to avoid building every dependencies of a job | |
13251 | from source. | |
13252 | ||
13253 | @item @code{one-shot?} (default: @code{#f}) | |
13254 | Only evaluate specifications and build derivations once. | |
379b6ba5 | 13255 | |
eb122280 MO |
13256 | @item @code{load-path} (default: @code{'()}) |
13257 | This allows users to define their own packages and make them visible to | |
13258 | cuirass as in @command{guix build} command. | |
13259 | ||
379b6ba5 LC |
13260 | @item @code{cuirass} (default: @code{cuirass}) |
13261 | The Cuirass package to use. | |
a7cf4eb6 ML |
13262 | @end table |
13263 | @end deftp | |
eb419bc9 JD |
13264 | |
13265 | @node Miscellaneous Services | |
13266 | @subsubsection Miscellaneous Services | |
13267 | ||
13268 | ||
8ff4dcbe DC |
13269 | @cindex lirc |
13270 | @subsubheading Lirc Service | |
13271 | ||
fe1a39d3 LC |
13272 | The @code{(gnu services lirc)} module provides the following service. |
13273 | ||
be1c2c54 | 13274 | @deffn {Scheme Procedure} lirc-service [#:lirc lirc] @ |
fe1a39d3 LC |
13275 | [#:device #f] [#:driver #f] [#:config-file #f] @ |
13276 | [#:extra-options '()] | |
13277 | Return a service that runs @url{http://www.lirc.org,LIRC}, a daemon that | |
13278 | decodes infrared signals from remote controls. | |
13279 | ||
13280 | Optionally, @var{device}, @var{driver} and @var{config-file} | |
13281 | (configuration file name) may be specified. See @command{lircd} manual | |
13282 | for details. | |
13283 | ||
13284 | Finally, @var{extra-options} is a list of additional command-line options | |
13285 | passed to @command{lircd}. | |
13286 | @end deffn | |
13287 | ||
00f46905 DC |
13288 | @cindex spice |
13289 | @subsubheading Spice Service | |
13290 | ||
13291 | The @code{(gnu services spice)} module provides the following service. | |
13292 | ||
13293 | @deffn {Scheme Procedure} spice-vdagent-service [#:spice-vdagent] | |
13294 | Returns a service that runs @url{http://www.spice-space.org,VDAGENT}, a daemon | |
13295 | that enables sharing the clipboard with a vm and setting the guest display | |
13296 | resolution when the graphical console window resizes. | |
13297 | @end deffn | |
13298 | ||
c3d38b2b | 13299 | @subsubsection Dictionary Services |
e32171ee | 13300 | @cindex dictionary |
c3d38b2b SB |
13301 | The @code{(gnu services dict)} module provides the following service: |
13302 | ||
13303 | @deffn {Scheme Procedure} dicod-service [#:config (dicod-configuration)] | |
13304 | Return a service that runs the @command{dicod} daemon, an implementation | |
13305 | of DICT server (@pxref{Dicod,,, dico, GNU Dico Manual}). | |
13306 | ||
13307 | The optional @var{config} argument specifies the configuration for | |
13308 | @command{dicod}, which should be a @code{<dicod-configuration>} object, by | |
13309 | default it serves the GNU Collaborative International Dictonary of English. | |
13310 | ||
13311 | You can add @command{open localhost} to your @file{~/.dico} file to make | |
13312 | @code{localhost} the default server for @command{dico} client | |
13313 | (@pxref{Initialization File,,, dico, GNU Dico Manual}). | |
13314 | @end deffn | |
13315 | ||
13316 | @deftp {Data Type} dicod-configuration | |
13317 | Data type representing the configuration of dicod. | |
13318 | ||
13319 | @table @asis | |
13320 | @item @code{dico} (default: @var{dico}) | |
13321 | Package object of the GNU Dico dictionary server. | |
13322 | ||
a1b48465 LC |
13323 | @item @code{interfaces} (default: @var{'("localhost")}) |
13324 | This is the list of IP addresses and ports and possibly socket file | |
13325 | names to listen to (@pxref{Server Settings, @code{listen} directive,, | |
13326 | dico, GNU Dico Manual}). | |
13327 | ||
c3d38b2b SB |
13328 | @item @code{databases} (default: @var{(list %dicod-database:gcide)}) |
13329 | List of @code{<dicod-database>} objects denoting dictionaries to be served. | |
13330 | @end table | |
13331 | @end deftp | |
13332 | ||
13333 | @deftp {Data Type} dicod-database | |
13334 | Data type representing a dictionary database. | |
13335 | ||
13336 | @table @asis | |
13337 | @item @code{name} | |
13338 | Name of the database, will be used in DICT commands. | |
13339 | ||
13340 | @item @code{module} | |
13341 | Name of the dicod module used by this database | |
13342 | (@pxref{Modules,,, dico, GNU Dico Manual}). | |
13343 | ||
13344 | @item @code{options} | |
13345 | List of strings or gexps representing the arguments for the module handler | |
13346 | (@pxref{Handlers,,, dico, GNU Dico Manual}). | |
13347 | @end table | |
13348 | @end deftp | |
13349 | ||
13350 | @defvr {Scheme Variable} %dicod-database:gcide | |
13351 | A @code{<dicod-database>} object serving the GNU Collaborative International | |
13352 | Dictonary of English using the @code{gcide} package. | |
13353 | @end defvr | |
fe1a39d3 | 13354 | |
e01e2c6c | 13355 | @subsubsection Version Control |
13356 | ||
13357 | The @code{(gnu services version-control)} module provides the following services: | |
13358 | ||
13359 | @subsubheading Git daemon service | |
13360 | ||
13361 | @deffn {Scheme Procedure} git-daemon-service [#:config (git-daemon-configuration)] | |
13362 | ||
13363 | Return a service that runs @command{git daemon}, a simple TCP server to | |
13364 | expose repositiories over the Git protocol for annoymous access. | |
13365 | ||
13366 | The optional @var{config} argument should be a | |
13367 | @code{<git-daemon-configuration>} object, by default it allows read-only | |
13368 | access to exported@footnote{By creating the magic file | |
13369 | "git-daemon-export-ok" in the repository directory.} repositories under | |
13370 | @file{/srv/git}. | |
13371 | ||
13372 | @end deffn | |
13373 | ||
13374 | @deftp {Data Type} git-daemon-configuration | |
13375 | Data type representing the configuration for @code{git-daemon-service}. | |
13376 | ||
13377 | @table @asis | |
13378 | @item @code{package} (default: @var{git}) | |
13379 | Package object of the Git distributed version control system. | |
13380 | ||
13381 | @item @code{export-all?} (default: @var{#f}) | |
13382 | Whether to allow access for all Git repositories, even if they do not | |
13383 | have the @file{git-daemon-export-ok} file. | |
13384 | ||
13385 | @item @code{base-path} (default: @file{/srv/git}) | |
13386 | Whether to remap all the path requests as relative to the given path. | |
13387 | If you run git daemon with @var{(base-path "/srv/git")} on example.com, | |
13388 | then if you later try to pull @code{git://example.com/hello.git}, git | |
13389 | daemon will interpret the path as @code{/srv/git/hello.git}. | |
13390 | ||
13391 | @item @code{user-path} (default: @var{#f}) | |
13392 | Whether to allow @code{~user} notation to be used in requests. When | |
13393 | specified with empty string, requests to @code{git://host/~alice/foo} is | |
13394 | taken as a request to access @code{foo} repository in the home directory | |
13395 | of user @code{alice}. If @var{(user-path "path")} is specified, the | |
13396 | same request is taken as a request to access @code{path/foo} repository | |
13397 | in the home directory of user @code{alice}. | |
13398 | ||
13399 | @item @code{listen} (default: @var{'()}) | |
13400 | Whether to listen on specific IP addresses or hostnames, defaults to | |
13401 | all. | |
13402 | ||
13403 | @item @code{port} (default: @var{#f}) | |
13404 | Whether to listen on an alternative port, which defaults to 9418. | |
13405 | ||
13406 | @item @code{whitelist} (default: @var{'()}) | |
13407 | If not empty, only allow access to this list of directories. | |
13408 | ||
13409 | @item @code{extra-options} (default: @var{'()}) | |
13410 | Extra options will be passed to @code{git daemon}, please run | |
13411 | @command{man git-daemon} for more information. | |
13412 | ||
13413 | @end table | |
13414 | @end deftp | |
13415 | ||
0ae8c15a LC |
13416 | @node Setuid Programs |
13417 | @subsection Setuid Programs | |
13418 | ||
13419 | @cindex setuid programs | |
13420 | Some programs need to run with ``root'' privileges, even when they are | |
13421 | launched by unprivileged users. A notorious example is the | |
4d40227c LC |
13422 | @command{passwd} program, which users can run to change their |
13423 | password, and which needs to access the @file{/etc/passwd} and | |
0ae8c15a LC |
13424 | @file{/etc/shadow} files---something normally restricted to root, for |
13425 | obvious security reasons. To address that, these executables are | |
13426 | @dfn{setuid-root}, meaning that they always run with root privileges | |
13427 | (@pxref{How Change Persona,,, libc, The GNU C Library Reference Manual}, | |
f7e4ae7f | 13428 | for more info about the setuid mechanism.) |
0ae8c15a LC |
13429 | |
13430 | The store itself @emph{cannot} contain setuid programs: that would be a | |
13431 | security issue since any user on the system can write derivations that | |
13432 | populate the store (@pxref{The Store}). Thus, a different mechanism is | |
13433 | used: instead of changing the setuid bit directly on files that are in | |
13434 | the store, we let the system administrator @emph{declare} which programs | |
13435 | should be setuid root. | |
13436 | ||
13437 | The @code{setuid-programs} field of an @code{operating-system} | |
13438 | declaration contains a list of G-expressions denoting the names of | |
13439 | programs to be setuid-root (@pxref{Using the Configuration System}). | |
13440 | For instance, the @command{passwd} program, which is part of the Shadow | |
13441 | package, can be designated by this G-expression (@pxref{G-Expressions}): | |
13442 | ||
13443 | @example | |
13444 | #~(string-append #$shadow "/bin/passwd") | |
13445 | @end example | |
13446 | ||
13447 | A default set of setuid programs is defined by the | |
13448 | @code{%setuid-programs} variable of the @code{(gnu system)} module. | |
13449 | ||
13450 | @defvr {Scheme Variable} %setuid-programs | |
13451 | A list of G-expressions denoting common programs that are setuid-root. | |
13452 | ||
13453 | The list includes commands such as @command{passwd}, @command{ping}, | |
13454 | @command{su}, and @command{sudo}. | |
13455 | @end defvr | |
13456 | ||
13457 | Under the hood, the actual setuid programs are created in the | |
13458 | @file{/run/setuid-programs} directory at system activation time. The | |
13459 | files in this directory refer to the ``real'' binaries, which are in the | |
13460 | store. | |
13461 | ||
efb5e833 LC |
13462 | @node X.509 Certificates |
13463 | @subsection X.509 Certificates | |
13464 | ||
13465 | @cindex HTTPS, certificates | |
13466 | @cindex X.509 certificates | |
13467 | @cindex TLS | |
13468 | Web servers available over HTTPS (that is, HTTP over the transport-layer | |
13469 | security mechanism, TLS) send client programs an @dfn{X.509 certificate} | |
13470 | that the client can then use to @emph{authenticate} the server. To do | |
13471 | that, clients verify that the server's certificate is signed by a | |
13472 | so-called @dfn{certificate authority} (CA). But to verify the CA's | |
13473 | signature, clients must have first acquired the CA's certificate. | |
13474 | ||
13475 | Web browsers such as GNU@tie{}IceCat include their own set of CA | |
13476 | certificates, such that they are able to verify CA signatures | |
13477 | out-of-the-box. | |
13478 | ||
13479 | However, most other programs that can talk HTTPS---@command{wget}, | |
13480 | @command{git}, @command{w3m}, etc.---need to be told where CA | |
13481 | certificates can be found. | |
13482 | ||
13483 | @cindex @code{nss-certs} | |
13484 | In GuixSD, this is done by adding a package that provides certificates | |
13485 | to the @code{packages} field of the @code{operating-system} declaration | |
13486 | (@pxref{operating-system Reference}). GuixSD includes one such package, | |
13487 | @code{nss-certs}, which is a set of CA certificates provided as part of | |
13488 | Mozilla's Network Security Services. | |
13489 | ||
13490 | Note that it is @emph{not} part of @var{%base-packages}, so you need to | |
13491 | explicitly add it. The @file{/etc/ssl/certs} directory, which is where | |
13492 | most applications and libraries look for certificates by default, points | |
13493 | to the certificates installed globally. | |
13494 | ||
b3129f2b LC |
13495 | Unprivileged users, including users of Guix on a foreign distro, |
13496 | can also install their own certificate package in | |
efb5e833 LC |
13497 | their profile. A number of environment variables need to be defined so |
13498 | that applications and libraries know where to find them. Namely, the | |
13499 | OpenSSL library honors the @code{SSL_CERT_DIR} and @code{SSL_CERT_FILE} | |
13500 | variables. Some applications add their own environment variables; for | |
13501 | instance, the Git version control system honors the certificate bundle | |
b3129f2b LC |
13502 | pointed to by the @code{GIT_SSL_CAINFO} environment variable. Thus, you |
13503 | would typically run something like: | |
efb5e833 | 13504 | |
b3129f2b LC |
13505 | @example |
13506 | $ guix package -i nss-certs | |
13507 | $ export SSL_CERT_DIR="$HOME/.guix-profile/etc/ssl/certs" | |
13508 | $ export SSL_CERT_FILE="$HOME/.guix-profile/etc/ssl/certs/ca-certificates.crt" | |
13509 | $ export GIT_SSL_CAINFO="$SSL_CERT_FILE" | |
13510 | @end example | |
efb5e833 | 13511 | |
996ed739 LC |
13512 | @node Name Service Switch |
13513 | @subsection Name Service Switch | |
13514 | ||
13515 | @cindex name service switch | |
13516 | @cindex NSS | |
13517 | The @code{(gnu system nss)} module provides bindings to the | |
1068f26b | 13518 | configuration file of the libc @dfn{name service switch} or @dfn{NSS} |
996ed739 LC |
13519 | (@pxref{NSS Configuration File,,, libc, The GNU C Library Reference |
13520 | Manual}). In a nutshell, the NSS is a mechanism that allows libc to be | |
13521 | extended with new ``name'' lookup methods for system databases, which | |
13522 | includes host names, service names, user accounts, and more (@pxref{Name | |
13523 | Service Switch, System Databases and Name Service Switch,, libc, The GNU | |
13524 | C Library Reference Manual}). | |
13525 | ||
13526 | The NSS configuration specifies, for each system database, which lookup | |
13527 | method is to be used, and how the various methods are chained | |
13528 | together---for instance, under which circumstances NSS should try the | |
13529 | next method in the list. The NSS configuration is given in the | |
13530 | @code{name-service-switch} field of @code{operating-system} declarations | |
13531 | (@pxref{operating-system Reference, @code{name-service-switch}}). | |
13532 | ||
4c9050c6 LC |
13533 | @cindex nss-mdns |
13534 | @cindex .local, host name lookup | |
996ed739 | 13535 | As an example, the declaration below configures the NSS to use the |
4c9050c6 LC |
13536 | @uref{http://0pointer.de/lennart/projects/nss-mdns/, @code{nss-mdns} |
13537 | back-end}, which supports host name lookups over multicast DNS (mDNS) | |
13538 | for host names ending in @code{.local}: | |
996ed739 LC |
13539 | |
13540 | @example | |
13541 | (name-service-switch | |
13542 | (hosts (list %files ;first, check /etc/hosts | |
13543 | ||
13544 | ;; If the above did not succeed, try | |
13545 | ;; with 'mdns_minimal'. | |
13546 | (name-service | |
13547 | (name "mdns_minimal") | |
13548 | ||
13549 | ;; 'mdns_minimal' is authoritative for | |
13550 | ;; '.local'. When it returns "not found", | |
13551 | ;; no need to try the next methods. | |
13552 | (reaction (lookup-specification | |
13553 | (not-found => return)))) | |
13554 | ||
13555 | ;; Then fall back to DNS. | |
13556 | (name-service | |
13557 | (name "dns")) | |
13558 | ||
13559 | ;; Finally, try with the "full" 'mdns'. | |
13560 | (name-service | |
13561 | (name "mdns"))))) | |
13562 | @end example | |
13563 | ||
1068f26b AE |
13564 | Do not worry: the @code{%mdns-host-lookup-nss} variable (see below) |
13565 | contains this configuration, so you will not have to type it if all you | |
15137a29 LC |
13566 | want is to have @code{.local} host lookup working. |
13567 | ||
4c9050c6 LC |
13568 | Note that, in this case, in addition to setting the |
13569 | @code{name-service-switch} of the @code{operating-system} declaration, | |
cc9c1f39 LC |
13570 | you also need to use @code{avahi-service} (@pxref{Networking Services, |
13571 | @code{avahi-service}}), or @var{%desktop-services}, which includes it | |
13572 | (@pxref{Desktop Services}). Doing this makes @code{nss-mdns} accessible | |
13573 | to the name service cache daemon (@pxref{Base Services, | |
13574 | @code{nscd-service}}). | |
15137a29 LC |
13575 | |
13576 | For convenience, the following variables provide typical NSS | |
13577 | configurations. | |
13578 | ||
13579 | @defvr {Scheme Variable} %default-nss | |
13580 | This is the default name service switch configuration, a | |
13581 | @code{name-service-switch} object. | |
13582 | @end defvr | |
13583 | ||
13584 | @defvr {Scheme Variable} %mdns-host-lookup-nss | |
13585 | This is the name service switch configuration with support for host name | |
13586 | lookup over multicast DNS (mDNS) for host names ending in @code{.local}. | |
13587 | @end defvr | |
4c9050c6 | 13588 | |
996ed739 | 13589 | The reference for name service switch configuration is given below. It |
1068f26b | 13590 | is a direct mapping of the configuration file format of the C library , so |
996ed739 LC |
13591 | please refer to the C library manual for more information (@pxref{NSS |
13592 | Configuration File,,, libc, The GNU C Library Reference Manual}). | |
1068f26b | 13593 | Compared to the configuration file format of libc NSS, it has the advantage |
996ed739 | 13594 | not only of adding this warm parenthetic feel that we like, but also |
1068f26b | 13595 | static checks: you will know about syntax errors and typos as soon as you |
996ed739 LC |
13596 | run @command{guix system}. |
13597 | ||
996ed739 LC |
13598 | @deftp {Data Type} name-service-switch |
13599 | ||
13600 | This is the data type representation the configuration of libc's name | |
13601 | service switch (NSS). Each field below represents one of the supported | |
13602 | system databases. | |
13603 | ||
13604 | @table @code | |
13605 | @item aliases | |
13606 | @itemx ethers | |
13607 | @itemx group | |
13608 | @itemx gshadow | |
13609 | @itemx hosts | |
13610 | @itemx initgroups | |
13611 | @itemx netgroup | |
13612 | @itemx networks | |
13613 | @itemx password | |
13614 | @itemx public-key | |
13615 | @itemx rpc | |
13616 | @itemx services | |
13617 | @itemx shadow | |
13618 | The system databases handled by the NSS. Each of these fields must be a | |
1068f26b | 13619 | list of @code{<name-service>} objects (see below). |
996ed739 LC |
13620 | @end table |
13621 | @end deftp | |
13622 | ||
13623 | @deftp {Data Type} name-service | |
13624 | ||
13625 | This is the data type representing an actual name service and the | |
13626 | associated lookup action. | |
13627 | ||
13628 | @table @code | |
13629 | @item name | |
13630 | A string denoting the name service (@pxref{Services in the NSS | |
13631 | configuration,,, libc, The GNU C Library Reference Manual}). | |
13632 | ||
4aee6e60 LC |
13633 | Note that name services listed here must be visible to nscd. This is |
13634 | achieved by passing the @code{#:name-services} argument to | |
13635 | @code{nscd-service} the list of packages providing the needed name | |
13636 | services (@pxref{Base Services, @code{nscd-service}}). | |
13637 | ||
996ed739 LC |
13638 | @item reaction |
13639 | An action specified using the @code{lookup-specification} macro | |
13640 | (@pxref{Actions in the NSS configuration,,, libc, The GNU C Library | |
13641 | Reference Manual}). For example: | |
13642 | ||
13643 | @example | |
13644 | (lookup-specification (unavailable => continue) | |
13645 | (success => return)) | |
13646 | @end example | |
13647 | @end table | |
13648 | @end deftp | |
0ae8c15a | 13649 | |
fd1b1fa2 LC |
13650 | @node Initial RAM Disk |
13651 | @subsection Initial RAM Disk | |
13652 | ||
e32171ee JD |
13653 | @cindex initrd |
13654 | @cindex initial RAM disk | |
fd1b1fa2 LC |
13655 | For bootstrapping purposes, the Linux-Libre kernel is passed an |
13656 | @dfn{initial RAM disk}, or @dfn{initrd}. An initrd contains a temporary | |
1068f26b | 13657 | root file system as well as an initialization script. The latter is |
fd1b1fa2 LC |
13658 | responsible for mounting the real root file system, and for loading any |
13659 | kernel modules that may be needed to achieve that. | |
13660 | ||
13661 | The @code{initrd} field of an @code{operating-system} declaration allows | |
13662 | you to specify which initrd you would like to use. The @code{(gnu | |
13663 | system linux-initrd)} module provides two ways to build an initrd: the | |
13664 | high-level @code{base-initrd} procedure, and the low-level | |
13665 | @code{expression->initrd} procedure. | |
13666 | ||
13667 | The @code{base-initrd} procedure is intended to cover most common uses. | |
13668 | For example, if you want to add a bunch of kernel modules to be loaded | |
13669 | at boot time, you can define the @code{initrd} field of the operating | |
13670 | system declaration like this: | |
13671 | ||
13672 | @example | |
52ac153e | 13673 | (initrd (lambda (file-systems . rest) |
027981d6 LC |
13674 | ;; Create a standard initrd that has modules "foo.ko" |
13675 | ;; and "bar.ko", as well as their dependencies, in | |
13676 | ;; addition to the modules available by default. | |
52ac153e | 13677 | (apply base-initrd file-systems |
027981d6 | 13678 | #:extra-modules '("foo" "bar") |
52ac153e | 13679 | rest))) |
fd1b1fa2 LC |
13680 | @end example |
13681 | ||
52ac153e | 13682 | The @code{base-initrd} procedure also handles common use cases that |
1068f26b AE |
13683 | involves using the system as a QEMU guest, or as a ``live'' system with |
13684 | volatile root file system. | |
fd1b1fa2 | 13685 | |
e90cf6c1 LC |
13686 | The initial RAM disk produced by @code{base-initrd} honors several |
13687 | options passed on the Linux kernel command line (that is, arguments | |
1068f26b | 13688 | passed @i{via} the @code{linux} command of GRUB, or the |
4af2fafd | 13689 | @code{-append} option of QEMU), notably: |
e90cf6c1 LC |
13690 | |
13691 | @table @code | |
13692 | @item --load=@var{boot} | |
13693 | Tell the initial RAM disk to load @var{boot}, a file containing a Scheme | |
13694 | program, once it has mounted the root file system. | |
13695 | ||
13696 | GuixSD uses this option to yield control to a boot program that runs the | |
dd17bc38 | 13697 | service activation programs and then spawns the GNU@tie{}Shepherd, the |
e90cf6c1 LC |
13698 | initialization system. |
13699 | ||
13700 | @item --root=@var{root} | |
1068f26b | 13701 | Mount @var{root} as the root file system. @var{root} can be a |
e90cf6c1 LC |
13702 | device name like @code{/dev/sda1}, a partition label, or a partition |
13703 | UUID. | |
13704 | ||
13705 | @item --system=@var{system} | |
13706 | Have @file{/run/booted-system} and @file{/run/current-system} point to | |
13707 | @var{system}. | |
13708 | ||
13709 | @item modprobe.blacklist=@var{modules}@dots{} | |
13710 | @cindex module, black-listing | |
13711 | @cindex black list, of kernel modules | |
13712 | Instruct the initial RAM disk as well as the @command{modprobe} command | |
13713 | (from the kmod package) to refuse to load @var{modules}. @var{modules} | |
13714 | must be a comma-separated list of module names---e.g., | |
13715 | @code{usbkbd,9pnet}. | |
13716 | ||
13717 | @item --repl | |
13718 | Start a read-eval-print loop (REPL) from the initial RAM disk before it | |
13719 | tries to load kernel modules and to mount the root file system. Our | |
13720 | marketing team calls it @dfn{boot-to-Guile}. The Schemer in you will | |
13721 | love it. @xref{Using Guile Interactively,,, guile, GNU Guile Reference | |
13722 | Manual}, for more information on Guile's REPL. | |
13723 | ||
13724 | @end table | |
13725 | ||
13726 | Now that you know all the features that initial RAM disks produced by | |
13727 | @code{base-initrd} provide, here is how to use it and customize it | |
13728 | further. | |
13729 | ||
e32171ee JD |
13730 | @cindex initrd |
13731 | @cindex initial RAM disk | |
fd1b1fa2 | 13732 | @deffn {Monadic Procedure} base-initrd @var{file-systems} @ |
9059b97d | 13733 | [#:qemu-networking? #f] [#:virtio? #t] [#:volatile-root? #f] @ |
52ac153e | 13734 | [#:extra-modules '()] [#:mapped-devices '()] |
fd1b1fa2 | 13735 | Return a monadic derivation that builds a generic initrd. @var{file-systems} is |
1068f26b | 13736 | a list of file systems to be mounted by the initrd, possibly in addition to |
fd1b1fa2 | 13737 | the root file system specified on the kernel command line via @code{--root}. |
52ac153e LC |
13738 | @var{mapped-devices} is a list of device mappings to realize before |
13739 | @var{file-systems} are mounted (@pxref{Mapped Devices}). | |
fd1b1fa2 LC |
13740 | |
13741 | When @var{qemu-networking?} is true, set up networking with the standard QEMU | |
1068f26b AE |
13742 | parameters. When @var{virtio?} is true, load additional modules so that the |
13743 | initrd can be used as a QEMU guest with para-virtualized I/O drivers. | |
fd1b1fa2 LC |
13744 | |
13745 | When @var{volatile-root?} is true, the root file system is writable but any changes | |
13746 | to it are lost. | |
13747 | ||
13748 | The initrd is automatically populated with all the kernel modules necessary | |
13749 | for @var{file-systems} and for the given options. However, additional kernel | |
13750 | modules can be listed in @var{extra-modules}. They will be added to the initrd, and | |
13751 | loaded at boot time in the order in which they appear. | |
13752 | @end deffn | |
13753 | ||
13754 | Needless to say, the initrds we produce and use embed a | |
13755 | statically-linked Guile, and the initialization program is a Guile | |
13756 | program. That gives a lot of flexibility. The | |
13757 | @code{expression->initrd} procedure builds such an initrd, given the | |
13758 | program to run in that initrd. | |
13759 | ||
13760 | @deffn {Monadic Procedure} expression->initrd @var{exp} @ | |
4ee96a79 | 13761 | [#:guile %guile-static-stripped] [#:name "guile-initrd"] |
fd1b1fa2 LC |
13762 | Return a derivation that builds a Linux initrd (a gzipped cpio archive) |
13763 | containing @var{guile} and that evaluates @var{exp}, a G-expression, | |
df650fa8 LC |
13764 | upon booting. All the derivations referenced by @var{exp} are |
13765 | automatically copied to the initrd. | |
fd1b1fa2 LC |
13766 | @end deffn |
13767 | ||
88faf933 LC |
13768 | @node GRUB Configuration |
13769 | @subsection GRUB Configuration | |
13770 | ||
13771 | @cindex GRUB | |
13772 | @cindex boot loader | |
13773 | ||
13774 | The operating system uses GNU@tie{}GRUB as its boot loader | |
13775 | (@pxref{Overview, overview of GRUB,, grub, GNU GRUB Manual}). It is | |
1068f26b AE |
13776 | configured using a @code{grub-configuration} declaration. This data type |
13777 | is exported by the @code{(gnu system grub)} module and described below. | |
88faf933 LC |
13778 | |
13779 | @deftp {Data Type} grub-configuration | |
13780 | The type of a GRUB configuration declaration. | |
13781 | ||
13782 | @table @asis | |
13783 | ||
13784 | @item @code{device} | |
13785 | This is a string denoting the boot device. It must be a device name | |
13786 | understood by the @command{grub-install} command, such as | |
13787 | @code{/dev/sda} or @code{(hd0)} (@pxref{Invoking grub-install,,, grub, | |
13788 | GNU GRUB Manual}). | |
13789 | ||
13790 | @item @code{menu-entries} (default: @code{()}) | |
13791 | A possibly empty list of @code{menu-entry} objects (see below), denoting | |
13792 | entries to appear in the GRUB boot menu, in addition to the current | |
13793 | system entry and the entry pointing to previous system generations. | |
13794 | ||
13795 | @item @code{default-entry} (default: @code{0}) | |
1068f26b AE |
13796 | The index of the default boot menu entry. Index 0 is for the entry of the |
13797 | current system. | |
88faf933 LC |
13798 | |
13799 | @item @code{timeout} (default: @code{5}) | |
13800 | The number of seconds to wait for keyboard input before booting. Set to | |
13801 | 0 to boot immediately, and to -1 to wait indefinitely. | |
13802 | ||
13803 | @item @code{theme} (default: @var{%default-theme}) | |
13804 | The @code{grub-theme} object describing the theme to use. | |
9b06f503 LC |
13805 | |
13806 | @item @code{grub} (default: @code{grub}) | |
13807 | The GRUB package to use. | |
88faf933 LC |
13808 | @end table |
13809 | ||
13810 | @end deftp | |
13811 | ||
44d5f54e LC |
13812 | @cindex dual boot |
13813 | @cindex boot menu | |
88faf933 LC |
13814 | Should you want to list additional boot menu entries @i{via} the |
13815 | @code{menu-entries} field above, you will need to create them with the | |
44d5f54e LC |
13816 | @code{menu-entry} form. For example, imagine you want to be able to |
13817 | boot another distro (hard to imagine!), you can define a menu entry | |
13818 | along these lines: | |
13819 | ||
13820 | @example | |
13821 | (menu-entry | |
13822 | (label "The Other Distro") | |
13823 | (linux "/boot/old/vmlinux-2.6.32") | |
13824 | (linux-arguments '("root=/dev/sda2")) | |
13825 | (initrd "/boot/old/initrd")) | |
13826 | @end example | |
13827 | ||
13828 | Details below. | |
88faf933 LC |
13829 | |
13830 | @deftp {Data Type} menu-entry | |
13831 | The type of an entry in the GRUB boot menu. | |
13832 | ||
13833 | @table @asis | |
13834 | ||
13835 | @item @code{label} | |
35ed9306 | 13836 | The label to show in the menu---e.g., @code{"GNU"}. |
88faf933 LC |
13837 | |
13838 | @item @code{linux} | |
44d5f54e LC |
13839 | The Linux kernel image to boot, for example: |
13840 | ||
13841 | @example | |
13842 | (file-append linux-libre "/bzImage") | |
13843 | @end example | |
88faf933 | 13844 | |
1ef8b72a CM |
13845 | It is also possible to specify a device explicitly in the file path |
13846 | using GRUB's device naming convention (@pxref{Naming convention,,, grub, | |
13847 | GNU GRUB manual}), for example: | |
13848 | ||
13849 | @example | |
13850 | "(hd0,msdos1)/boot/vmlinuz" | |
13851 | @end example | |
13852 | ||
13853 | If the device is specified explicitly as above, then the @code{device} | |
13854 | field is ignored entirely. | |
13855 | ||
88faf933 LC |
13856 | @item @code{linux-arguments} (default: @code{()}) |
13857 | The list of extra Linux kernel command-line arguments---e.g., | |
13858 | @code{("console=ttyS0")}. | |
13859 | ||
13860 | @item @code{initrd} | |
13861 | A G-Expression or string denoting the file name of the initial RAM disk | |
13862 | to use (@pxref{G-Expressions}). | |
13863 | ||
1ef8b72a CM |
13864 | @item @code{device} (default: @code{#f}) |
13865 | The device where the kernel and initrd are to be found---i.e., the GRUB | |
13866 | @dfn{root} for this menu entry (@pxref{root,,, grub, GNU GRUB manual}). | |
13867 | ||
13868 | This may be a file system label (a string), a file system UUID (a | |
13869 | bytevector, @pxref{File Systems}), or @code{#f}, in which case GRUB will | |
13870 | search the device containing the file specified by the @code{linux} | |
13871 | field (@pxref{search,,, grub, GNU GRUB manual}). It must @emph{not} be | |
13872 | an OS device name such as @file{/dev/sda1}. | |
13873 | ||
13874 | @item @code{device-mount-point} (default: @code{"/"}) | |
13875 | The mount point of the above device on the system. You probably do not | |
13876 | need to change the default value. GuixSD uses it to strip the prefix of | |
13877 | store file names for systems where @file{/gnu} or @file{/gnu/store} is | |
13878 | on a separate partition. | |
13879 | ||
88faf933 LC |
13880 | @end table |
13881 | @end deftp | |
13882 | ||
13883 | @c FIXME: Write documentation once it's stable. | |
13884 | Themes are created using the @code{grub-theme} form, which is not | |
13885 | documented yet. | |
13886 | ||
13887 | @defvr {Scheme Variable} %default-theme | |
13888 | This is the default GRUB theme used by the operating system, with a | |
13889 | fancy background image displaying the GNU and Guix logos. | |
13890 | @end defvr | |
13891 | ||
13892 | ||
cf4a9129 LC |
13893 | @node Invoking guix system |
13894 | @subsection Invoking @code{guix system} | |
0918e64a | 13895 | |
1068f26b | 13896 | Once you have written an operating system declaration as seen in the |
cf4a9129 LC |
13897 | previous section, it can be @dfn{instantiated} using the @command{guix |
13898 | system} command. The synopsis is: | |
4af2447e | 13899 | |
cf4a9129 LC |
13900 | @example |
13901 | guix system @var{options}@dots{} @var{action} @var{file} | |
13902 | @end example | |
4af2447e | 13903 | |
cf4a9129 LC |
13904 | @var{file} must be the name of a file containing an |
13905 | @code{operating-system} declaration. @var{action} specifies how the | |
a40424bd | 13906 | operating system is instantiated. Currently the following values are |
cf4a9129 | 13907 | supported: |
4af2447e | 13908 | |
cf4a9129 LC |
13909 | @table @code |
13910 | @item reconfigure | |
13911 | Build the operating system described in @var{file}, activate it, and | |
8074b330 CM |
13912 | switch to it@footnote{This action (and the related actions |
13913 | @code{switch-generation} and @code{roll-back}) are usable only on | |
13914 | systems already running GuixSD.}. | |
4af2447e | 13915 | |
cf4a9129 LC |
13916 | This effects all the configuration specified in @var{file}: user |
13917 | accounts, system services, global package list, setuid programs, etc. | |
240b57f0 LC |
13918 | The command starts system services specified in @var{file} that are not |
13919 | currently running; if a service is currently running, it does not | |
1068f26b | 13920 | attempt to upgrade it since this would not be possible without stopping it |
240b57f0 | 13921 | first. |
4af2447e | 13922 | |
067a2e2d CM |
13923 | This command creates a new generation whose number is one greater than |
13924 | the current generation (as reported by @command{guix system | |
13925 | list-generations}). If that generation already exists, it will be | |
13926 | overwritten. This behavior mirrors that of @command{guix package} | |
13927 | (@pxref{Invoking guix package}). | |
13928 | ||
cf4a9129 LC |
13929 | It also adds a GRUB menu entry for the new OS configuration, and moves |
13930 | entries for older configurations to a submenu---unless | |
13931 | @option{--no-grub} is passed. | |
4af2447e | 13932 | |
240b57f0 | 13933 | @quotation Note |
bf2479c7 LC |
13934 | @c The paragraph below refers to the problem discussed at |
13935 | @c <http://lists.gnu.org/archive/html/guix-devel/2014-08/msg00057.html>. | |
13936 | It is highly recommended to run @command{guix pull} once before you run | |
13937 | @command{guix system reconfigure} for the first time (@pxref{Invoking | |
13938 | guix pull}). Failing to do that you would see an older version of Guix | |
13939 | once @command{reconfigure} has completed. | |
240b57f0 | 13940 | @end quotation |
bf2479c7 | 13941 | |
8074b330 | 13942 | @item switch-generation |
e32171ee | 13943 | @cindex generations |
8074b330 CM |
13944 | Switch to an existing system generation. This action atomically |
13945 | switches the system profile to the specified system generation. It also | |
13946 | rearranges the system's existing GRUB menu entries. It makes the menu | |
13947 | entry for the specified system generation the default, and it moves the | |
13948 | entries for the other generations to a submenu. The next time the | |
13949 | system boots, it will use the specified system generation. | |
13950 | ||
13951 | The target generation can be specified explicitly by its generation | |
13952 | number. For example, the following invocation would switch to system | |
13953 | generation 7: | |
13954 | ||
13955 | @example | |
13956 | guix system switch-generation 7 | |
13957 | @end example | |
13958 | ||
13959 | The target generation can also be specified relative to the current | |
13960 | generation with the form @code{+N} or @code{-N}, where @code{+3} means | |
13961 | ``3 generations ahead of the current generation,'' and @code{-1} means | |
13962 | ``1 generation prior to the current generation.'' When specifying a | |
13963 | negative value such as @code{-1}, you must precede it with @code{--} to | |
13964 | prevent it from being parsed as an option. For example: | |
13965 | ||
13966 | @example | |
13967 | guix system switch-generation -- -1 | |
13968 | @end example | |
13969 | ||
13970 | Currently, the effect of invoking this action is @emph{only} to switch | |
13971 | the system profile to an existing generation and rearrange the GRUB menu | |
13972 | entries. To actually start using the target system generation, you must | |
13973 | reboot after running this action. In the future, it will be updated to | |
13974 | do the same things as @command{reconfigure}, like activating and | |
13975 | deactivating services. | |
13976 | ||
13977 | This action will fail if the specified generation does not exist. | |
13978 | ||
13979 | @item roll-back | |
e32171ee | 13980 | @cindex rolling back |
8074b330 CM |
13981 | Switch to the preceding system generation. The next time the system |
13982 | boots, it will use the preceding system generation. This is the inverse | |
13983 | of @command{reconfigure}, and it is exactly the same as invoking | |
13984 | @command{switch-generation} with an argument of @code{-1}. | |
13985 | ||
13986 | Currently, as with @command{switch-generation}, you must reboot after | |
13987 | running this action to actually start using the preceding system | |
13988 | generation. | |
13989 | ||
cf4a9129 | 13990 | @item build |
1068f26b | 13991 | Build the derivation of the operating system, which includes all the |
cf4a9129 LC |
13992 | configuration files and programs needed to boot and run the system. |
13993 | This action does not actually install anything. | |
113daf62 | 13994 | |
cf4a9129 LC |
13995 | @item init |
13996 | Populate the given directory with all the files necessary to run the | |
13997 | operating system specified in @var{file}. This is useful for first-time | |
4705641f | 13998 | installations of GuixSD. For instance: |
113daf62 LC |
13999 | |
14000 | @example | |
cf4a9129 | 14001 | guix system init my-os-config.scm /mnt |
113daf62 LC |
14002 | @end example |
14003 | ||
cf4a9129 LC |
14004 | copies to @file{/mnt} all the store items required by the configuration |
14005 | specified in @file{my-os-config.scm}. This includes configuration | |
14006 | files, packages, and so on. It also creates other essential files | |
14007 | needed for the system to operate correctly---e.g., the @file{/etc}, | |
14008 | @file{/var}, and @file{/run} directories, and the @file{/bin/sh} file. | |
113daf62 | 14009 | |
cf4a9129 LC |
14010 | This command also installs GRUB on the device specified in |
14011 | @file{my-os-config}, unless the @option{--no-grub} option was passed. | |
113daf62 | 14012 | |
cf4a9129 LC |
14013 | @item vm |
14014 | @cindex virtual machine | |
0276f697 | 14015 | @cindex VM |
f535dcbe | 14016 | @anchor{guix system vm} |
1068f26b | 14017 | Build a virtual machine that contains the operating system declared in |
cf4a9129 | 14018 | @var{file}, and return a script to run that virtual machine (VM). |
1068f26b | 14019 | Arguments given to the script are passed to QEMU. |
113daf62 | 14020 | |
cf4a9129 | 14021 | The VM shares its store with the host system. |
113daf62 | 14022 | |
0276f697 LC |
14023 | Additional file systems can be shared between the host and the VM using |
14024 | the @code{--share} and @code{--expose} command-line options: the former | |
14025 | specifies a directory to be shared with write access, while the latter | |
14026 | provides read-only access to the shared directory. | |
14027 | ||
14028 | The example below creates a VM in which the user's home directory is | |
14029 | accessible read-only, and where the @file{/exchange} directory is a | |
1068f26b | 14030 | read-write mapping of @file{$HOME/tmp} on the host: |
0276f697 LC |
14031 | |
14032 | @example | |
14033 | guix system vm my-config.scm \ | |
14034 | --expose=$HOME --share=$HOME/tmp=/exchange | |
14035 | @end example | |
14036 | ||
6aa260af LC |
14037 | On GNU/Linux, the default is to boot directly to the kernel; this has |
14038 | the advantage of requiring only a very tiny root disk image since the | |
1068f26b | 14039 | store of the host can then be mounted. |
6aa260af LC |
14040 | |
14041 | The @code{--full-boot} option forces a complete boot sequence, starting | |
14042 | with the bootloader. This requires more disk space since a root image | |
14043 | containing at least the kernel, initrd, and bootloader data files must | |
14044 | be created. The @code{--image-size} option can be used to specify the | |
1068f26b | 14045 | size of the image. |
ab11f0be | 14046 | |
cf4a9129 LC |
14047 | @item vm-image |
14048 | @itemx disk-image | |
14049 | Return a virtual machine or disk image of the operating system declared | |
14050 | in @var{file} that stands alone. Use the @option{--image-size} option | |
14051 | to specify the size of the image. | |
113daf62 | 14052 | |
cf4a9129 | 14053 | When using @code{vm-image}, the returned image is in qcow2 format, which |
97d76250 LF |
14054 | the QEMU emulator can efficiently use. @xref{Running GuixSD in a VM}, |
14055 | for more information on how to run the image in a virtual machine. | |
113daf62 | 14056 | |
cf4a9129 LC |
14057 | When using @code{disk-image}, a raw disk image is produced; it can be |
14058 | copied as is to a USB stick, for instance. Assuming @code{/dev/sdc} is | |
1068f26b | 14059 | the device corresponding to a USB stick, one can copy the image to it |
cf4a9129 | 14060 | using the following command: |
113daf62 | 14061 | |
cf4a9129 LC |
14062 | @example |
14063 | # dd if=$(guix system disk-image my-os.scm) of=/dev/sdc | |
14064 | @end example | |
113daf62 | 14065 | |
1c8a81b1 DT |
14066 | @item container |
14067 | Return a script to run the operating system declared in @var{file} | |
14068 | within a container. Containers are a set of lightweight isolation | |
14069 | mechanisms provided by the kernel Linux-libre. Containers are | |
14070 | substantially less resource-demanding than full virtual machines since | |
14071 | the kernel, shared objects, and other resources can be shared with the | |
14072 | host system; this also means they provide thinner isolation. | |
14073 | ||
14074 | Currently, the script must be run as root in order to support more than | |
14075 | a single user and group. The container shares its store with the host | |
14076 | system. | |
14077 | ||
14078 | As with the @code{vm} action (@pxref{guix system vm}), additional file | |
14079 | systems to be shared between the host and container can be specified | |
14080 | using the @option{--share} and @option{--expose} options: | |
14081 | ||
14082 | @example | |
14083 | guix system container my-config.scm \ | |
14084 | --expose=$HOME --share=$HOME/tmp=/exchange | |
14085 | @end example | |
14086 | ||
0f252e26 | 14087 | @quotation Note |
cfd35b4e | 14088 | This option requires Linux-libre 3.19 or newer. |
0f252e26 DT |
14089 | @end quotation |
14090 | ||
cf4a9129 | 14091 | @end table |
113daf62 | 14092 | |
ccd7158d LC |
14093 | @var{options} can contain any of the common build options (@pxref{Common |
14094 | Build Options}). In addition, @var{options} can contain one of the | |
14095 | following: | |
113daf62 | 14096 | |
cf4a9129 LC |
14097 | @table @option |
14098 | @item --system=@var{system} | |
14099 | @itemx -s @var{system} | |
1068f26b | 14100 | Attempt to build for @var{system} instead of the host system type. |
cf4a9129 | 14101 | This works as per @command{guix build} (@pxref{Invoking guix build}). |
113daf62 | 14102 | |
f3f427c2 LC |
14103 | @item --derivation |
14104 | @itemx -d | |
14105 | Return the derivation file name of the given operating system without | |
14106 | building anything. | |
14107 | ||
cf4a9129 LC |
14108 | @item --image-size=@var{size} |
14109 | For the @code{vm-image} and @code{disk-image} actions, create an image | |
14110 | of the given @var{size}. @var{size} may be a number of bytes, or it may | |
4a44d7bb LC |
14111 | include a unit as a suffix (@pxref{Block size, size specifications,, |
14112 | coreutils, GNU Coreutils}). | |
db030303 LC |
14113 | |
14114 | @item --on-error=@var{strategy} | |
14115 | Apply @var{strategy} when an error occurs when reading @var{file}. | |
14116 | @var{strategy} may be one of the following: | |
14117 | ||
14118 | @table @code | |
14119 | @item nothing-special | |
14120 | Report the error concisely and exit. This is the default strategy. | |
14121 | ||
14122 | @item backtrace | |
14123 | Likewise, but also display a backtrace. | |
14124 | ||
14125 | @item debug | |
14126 | Report the error and enter Guile's debugger. From there, you can run | |
14127 | commands such as @code{,bt} to get a backtrace, @code{,locals} to | |
1068f26b AE |
14128 | display local variable values, and more generally inspect the state of the |
14129 | program. @xref{Debug Commands,,, guile, GNU Guile Reference Manual}, for | |
db030303 LC |
14130 | a list of available debugging commands. |
14131 | @end table | |
113daf62 | 14132 | @end table |
113daf62 | 14133 | |
eca69fc0 LC |
14134 | @quotation Note |
14135 | All the actions above, except @code{build} and @code{init}, | |
14136 | can use KVM support in the Linux-libre kernel. Specifically, if the | |
14137 | machine has hardware virtualization support, the corresponding | |
cf4a9129 | 14138 | KVM kernel module should be loaded, and the @file{/dev/kvm} device node |
1068f26b | 14139 | must exist and be readable and writable by the user and by the |
eca69fc0 LC |
14140 | build users of the daemon (@pxref{Build Environment Setup}). |
14141 | @end quotation | |
8451a568 | 14142 | |
65797bff LC |
14143 | Once you have built, configured, re-configured, and re-re-configured |
14144 | your GuixSD installation, you may find it useful to list the operating | |
14145 | system generations available on disk---and that you can choose from the | |
14146 | GRUB boot menu: | |
14147 | ||
14148 | @table @code | |
14149 | ||
14150 | @item list-generations | |
14151 | List a summary of each generation of the operating system available on | |
14152 | disk, in a human-readable way. This is similar to the | |
14153 | @option{--list-generations} option of @command{guix package} | |
14154 | (@pxref{Invoking guix package}). | |
14155 | ||
14156 | Optionally, one can specify a pattern, with the same syntax that is used | |
14157 | in @command{guix package --list-generations}, to restrict the list of | |
14158 | generations displayed. For instance, the following command displays | |
1068f26b | 14159 | generations that are up to 10 days old: |
65797bff LC |
14160 | |
14161 | @example | |
14162 | $ guix system list-generations 10d | |
14163 | @end example | |
14164 | ||
14165 | @end table | |
14166 | ||
d6c3267a LC |
14167 | The @command{guix system} command has even more to offer! The following |
14168 | sub-commands allow you to visualize how your system services relate to | |
14169 | each other: | |
14170 | ||
14171 | @anchor{system-extension-graph} | |
14172 | @table @code | |
14173 | ||
14174 | @item extension-graph | |
14175 | Emit in Dot/Graphviz format to standard output the @dfn{service | |
14176 | extension graph} of the operating system defined in @var{file} | |
14177 | (@pxref{Service Composition}, for more information on service | |
14178 | extensions.) | |
14179 | ||
14180 | The command: | |
14181 | ||
14182 | @example | |
14183 | $ guix system extension-graph @var{file} | dot -Tpdf > services.pdf | |
14184 | @end example | |
14185 | ||
14186 | produces a PDF file showing the extension relations among services. | |
14187 | ||
710fa231 AK |
14188 | @anchor{system-shepherd-graph} |
14189 | @item shepherd-graph | |
6f305ea5 | 14190 | Emit in Dot/Graphviz format to standard output the @dfn{dependency |
dd17bc38 AK |
14191 | graph} of shepherd services of the operating system defined in |
14192 | @var{file}. @xref{Shepherd Services}, for more information and for an | |
14193 | example graph. | |
6f305ea5 | 14194 | |
d6c3267a LC |
14195 | @end table |
14196 | ||
97d76250 | 14197 | @node Running GuixSD in a VM |
70ac09a5 | 14198 | @subsection Running GuixSD in a Virtual Machine |
97d76250 | 14199 | |
e32171ee | 14200 | @cindex virtual machine |
97d76250 LF |
14201 | One way to run GuixSD in a virtual machine (VM) is to build a GuixSD |
14202 | virtual machine image using @command{guix system vm-image} | |
14203 | (@pxref{Invoking guix system}). The returned image is in qcow2 format, | |
14204 | which the @uref{http://qemu.org/, QEMU emulator} can efficiently use. | |
14205 | ||
e32171ee | 14206 | @cindex QEMU |
97d76250 LF |
14207 | To run the image in QEMU, copy it out of the store (@pxref{The Store}) |
14208 | and give yourself permission to write to the copy. When invoking QEMU, | |
14209 | you must choose a system emulator that is suitable for your hardware | |
14210 | platform. Here is a minimal QEMU invocation that will boot the result | |
14211 | of @command{guix system vm-image} on x86_64 hardware: | |
14212 | ||
14213 | @example | |
14214 | $ qemu-system-x86_64 \ | |
14215 | -net user -net nic,model=virtio \ | |
14216 | -enable-kvm -m 256 /tmp/qemu-image | |
14217 | @end example | |
14218 | ||
14219 | Here is what each of these options means: | |
14220 | ||
14221 | @table @code | |
14222 | @item qemu-system-x86_64 | |
14223 | This specifies the hardware platform to emulate. This should match the | |
14224 | host. | |
14225 | ||
14226 | @item -net user | |
14227 | Enable the unprivileged user-mode network stack. The guest OS can | |
14228 | access the host but not vice versa. This is the simplest way to get the | |
58806e6f | 14229 | guest OS online. |
97d76250 LF |
14230 | |
14231 | @item -net nic,model=virtio | |
1068f26b | 14232 | You must create a network interface of a given model. If you do not |
97d76250 LF |
14233 | create a NIC, the boot will fail. Assuming your hardware platform is |
14234 | x86_64, you can get a list of available NIC models by running | |
14235 | @command{qemu-system-x86_64 -net nic,model=help}. | |
14236 | ||
14237 | @item -enable-kvm | |
14238 | If your system has hardware virtualization extensions, enabling the | |
1068f26b | 14239 | virtual machine support (KVM) of the Linux kernel will make things run |
97d76250 LF |
14240 | faster. |
14241 | ||
14242 | @item -m 256 | |
14243 | RAM available to the guest OS, in mebibytes. Defaults to 128@tie{}MiB, | |
7414de0a | 14244 | which may be insufficient for some operations. |
97d76250 LF |
14245 | |
14246 | @item /tmp/qemu-image | |
14247 | The file name of the qcow2 image. | |
14248 | @end table | |
d6c3267a | 14249 | |
3ddc50db DC |
14250 | The default @command{run-vm.sh} script that is returned by an invokation of |
14251 | @command{guix system vm} does not add a @command{-net user} flag by default. | |
14252 | To get network access from within the vm add the @code{(dhcp-client-service)} | |
14253 | to your system definition and start the VM using | |
14254 | @command{`guix system vm config.scm` -net user}. An important caveat of using | |
14255 | @command{-net user} for networking is that @command{ping} will not work, because | |
14256 | it uses the ICMP protocol. You'll have to use a different command to check for | |
14257 | network connectivity, like for example @command{curl}. | |
14258 | ||
14259 | @subsubsection Connecting Through SSH | |
14260 | ||
e32171ee JD |
14261 | @cindex SSH |
14262 | @cindex SSH server | |
3ddc50db DC |
14263 | To enable SSH inside a VM you need to add a SSH server like @code{(dropbear-service)} |
14264 | or @code{(lsh-service)} to your VM. The @code{(lsh-service}) doesn't currently | |
14265 | boot unsupervised. It requires you to type some characters to initialize the | |
14266 | randomness generator. In addition you need to forward the SSH port, 22 by | |
14267 | default, to the host. You can do this with | |
14268 | ||
14269 | @example | |
14270 | `guix system vm config.scm` -net user,hostfwd=tcp::10022-:22 | |
14271 | @end example | |
14272 | ||
14273 | To connect to the VM you can run | |
14274 | ||
14275 | @example | |
14276 | ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 10022 | |
14277 | @end example | |
14278 | ||
14279 | The @command{-p} tells @command{ssh} the port you want to connect to. | |
14280 | @command{-o UserKnownHostsFile=/dev/null} prevents @command{ssh} from complaining | |
14281 | every time you modify your @command{config.scm} file and the | |
14282 | @command{-o StrictHostKeyChecking=no} prevents you from having to allow a | |
14283 | connection to an unknown host every time you connect. | |
14284 | ||
14285 | @subsubsection Using @command{virt-viewer} with Spice | |
14286 | ||
14287 | As an alternative to the default @command{qemu} graphical client you can | |
14288 | use the @command{remote-viewer} from the @command{virt-viewer} package. To | |
14289 | connect pass the @command{-spice port=5930,disable-ticketing} flag to | |
14290 | @command{qemu}. See previous section for further information on how to do this. | |
14291 | ||
14292 | Spice also allows you to do some nice stuff like share your clipboard with your | |
14293 | VM. To enable that you'll also have to pass the following flags to @command{qemu}: | |
14294 | ||
14295 | @example | |
14296 | -device virtio-serial-pci,id=virtio-serial0,max_ports=16,bus=pci.0,addr=0x5 | |
14297 | -chardev spicevmc,name=vdagent,id=vdagent | |
14298 | -device virtserialport,nr=1,bus=virtio-serial0.0,chardev=vdagent, | |
14299 | name=com.redhat.spice.0 | |
14300 | @end example | |
14301 | ||
14302 | You'll also need to add the @pxref{Miscellaneous Services, Spice service}. | |
14303 | ||
cf4a9129 LC |
14304 | @node Defining Services |
14305 | @subsection Defining Services | |
8451a568 | 14306 | |
eb524192 | 14307 | The previous sections show the available services and how one can combine |
0adfe95a LC |
14308 | them in an @code{operating-system} declaration. But how do we define |
14309 | them in the first place? And what is a service anyway? | |
8451a568 | 14310 | |
0adfe95a LC |
14311 | @menu |
14312 | * Service Composition:: The model for composing services. | |
14313 | * Service Types and Services:: Types and services. | |
14314 | * Service Reference:: API reference. | |
dd17bc38 | 14315 | * Shepherd Services:: A particular type of service. |
0adfe95a LC |
14316 | @end menu |
14317 | ||
14318 | @node Service Composition | |
14319 | @subsubsection Service Composition | |
14320 | ||
14321 | @cindex services | |
14322 | @cindex daemons | |
14323 | Here we define a @dfn{service} as, broadly, something that extends the | |
1068f26b | 14324 | functionality of the operating system. Often a service is a process---a |
0adfe95a LC |
14325 | @dfn{daemon}---started when the system boots: a secure shell server, a |
14326 | Web server, the Guix build daemon, etc. Sometimes a service is a daemon | |
14327 | whose execution can be triggered by another daemon---e.g., an FTP server | |
14328 | started by @command{inetd} or a D-Bus service activated by | |
14329 | @command{dbus-daemon}. Occasionally, a service does not map to a | |
14330 | daemon. For instance, the ``account'' service collects user accounts | |
14331 | and makes sure they exist when the system runs; the ``udev'' service | |
14332 | collects device management rules and makes them available to the eudev | |
1068f26b AE |
14333 | daemon; the @file{/etc} service populates the @file{/etc} directory |
14334 | of the system. | |
0adfe95a | 14335 | |
d6c3267a | 14336 | @cindex service extensions |
0adfe95a | 14337 | GuixSD services are connected by @dfn{extensions}. For instance, the |
1068f26b | 14338 | secure shell service @emph{extends} the Shepherd---the GuixSD |
dd17bc38 AK |
14339 | initialization system, running as PID@tie{}1---by giving it the command |
14340 | lines to start and stop the secure shell daemon (@pxref{Networking | |
14341 | Services, @code{lsh-service}}); the UPower service extends the D-Bus | |
14342 | service by passing it its @file{.service} specification, and extends the | |
14343 | udev service by passing it device management rules (@pxref{Desktop | |
14344 | Services, @code{upower-service}}); the Guix daemon service extends the | |
14345 | Shepherd by passing it the command lines to start and stop the daemon, | |
14346 | and extends the account service by passing it a list of required build | |
14347 | user accounts (@pxref{Base Services}). | |
0adfe95a LC |
14348 | |
14349 | All in all, services and their ``extends'' relations form a directed | |
14350 | acyclic graph (DAG). If we represent services as boxes and extensions | |
14351 | as arrows, a typical system might provide something like this: | |
14352 | ||
14353 | @image{images/service-graph,,5in,Typical service extension graph.} | |
14354 | ||
d62e201c LC |
14355 | @cindex system service |
14356 | At the bottom, we see the @dfn{system service}, which produces the | |
14357 | directory containing everything to run and boot the system, as returned | |
14358 | by the @command{guix system build} command. @xref{Service Reference}, | |
14359 | to learn about the other service types shown here. | |
d6c3267a LC |
14360 | @xref{system-extension-graph, the @command{guix system extension-graph} |
14361 | command}, for information on how to generate this representation for a | |
14362 | particular operating system definition. | |
0adfe95a LC |
14363 | |
14364 | @cindex service types | |
14365 | Technically, developers can define @dfn{service types} to express these | |
14366 | relations. There can be any number of services of a given type on the | |
14367 | system---for instance, a system running two instances of the GNU secure | |
14368 | shell server (lsh) has two instances of @var{lsh-service-type}, with | |
14369 | different parameters. | |
14370 | ||
14371 | The following section describes the programming interface for service | |
14372 | types and services. | |
14373 | ||
14374 | @node Service Types and Services | |
14375 | @subsubsection Service Types and Services | |
14376 | ||
14377 | A @dfn{service type} is a node in the DAG described above. Let us start | |
14378 | with a simple example, the service type for the Guix build daemon | |
14379 | (@pxref{Invoking guix-daemon}): | |
14380 | ||
14381 | @example | |
14382 | (define guix-service-type | |
14383 | (service-type | |
14384 | (name 'guix) | |
14385 | (extensions | |
d4053c71 | 14386 | (list (service-extension shepherd-root-service-type guix-shepherd-service) |
0adfe95a LC |
14387 | (service-extension account-service-type guix-accounts) |
14388 | (service-extension activation-service-type guix-activation))))) | |
14389 | @end example | |
8451a568 | 14390 | |
cf4a9129 | 14391 | @noindent |
1068f26b | 14392 | It defines two things: |
0adfe95a LC |
14393 | |
14394 | @enumerate | |
14395 | @item | |
14396 | A name, whose sole purpose is to make inspection and debugging easier. | |
14397 | ||
14398 | @item | |
14399 | A list of @dfn{service extensions}, where each extension designates the | |
1068f26b AE |
14400 | target service type and a procedure that, given the parameters of the |
14401 | service, returns a list of objects to extend the service of that type. | |
0adfe95a LC |
14402 | |
14403 | Every service type has at least one service extension. The only | |
14404 | exception is the @dfn{boot service type}, which is the ultimate service. | |
14405 | @end enumerate | |
14406 | ||
14407 | In this example, @var{guix-service-type} extends three services: | |
14408 | ||
14409 | @table @var | |
d4053c71 AK |
14410 | @item shepherd-root-service-type |
14411 | The @var{guix-shepherd-service} procedure defines how the Shepherd | |
14412 | service is extended. Namely, it returns a @code{<shepherd-service>} | |
14413 | object that defines how @command{guix-daemon} is started and stopped | |
14414 | (@pxref{Shepherd Services}). | |
0adfe95a LC |
14415 | |
14416 | @item account-service-type | |
14417 | This extension for this service is computed by @var{guix-accounts}, | |
14418 | which returns a list of @code{user-group} and @code{user-account} | |
14419 | objects representing the build user accounts (@pxref{Invoking | |
14420 | guix-daemon}). | |
14421 | ||
14422 | @item activation-service-type | |
14423 | Here @var{guix-activation} is a procedure that returns a gexp, which is | |
14424 | a code snippet to run at ``activation time''---e.g., when the service is | |
14425 | booted. | |
14426 | @end table | |
14427 | ||
14428 | A service of this type is instantiated like this: | |
14429 | ||
14430 | @example | |
14431 | (service guix-service-type | |
14432 | (guix-configuration | |
14433 | (build-accounts 5) | |
14434 | (use-substitutes? #f))) | |
14435 | @end example | |
14436 | ||
14437 | The second argument to the @code{service} form is a value representing | |
14438 | the parameters of this specific service instance. | |
14439 | @xref{guix-configuration-type, @code{guix-configuration}}, for | |
14440 | information about the @code{guix-configuration} data type. | |
14441 | ||
14442 | @var{guix-service-type} is quite simple because it extends other | |
14443 | services but is not extensible itself. | |
14444 | ||
14445 | @c @subsubsubsection Extensible Service Types | |
14446 | ||
14447 | The service type for an @emph{extensible} service looks like this: | |
14448 | ||
14449 | @example | |
14450 | (define udev-service-type | |
14451 | (service-type (name 'udev) | |
14452 | (extensions | |
d4053c71 AK |
14453 | (list (service-extension shepherd-root-service-type |
14454 | udev-shepherd-service))) | |
0adfe95a LC |
14455 | |
14456 | (compose concatenate) ;concatenate the list of rules | |
14457 | (extend (lambda (config rules) | |
14458 | (match config | |
14459 | (($ <udev-configuration> udev initial-rules) | |
14460 | (udev-configuration | |
14461 | (udev udev) ;the udev package to use | |
14462 | (rules (append initial-rules rules))))))))) | |
14463 | @end example | |
14464 | ||
14465 | This is the service type for the | |
14466 | @uref{https://wiki.gentoo.org/wiki/Project:Eudev, eudev device | |
14467 | management daemon}. Compared to the previous example, in addition to an | |
d4053c71 | 14468 | extension of @var{shepherd-root-service-type}, we see two new fields: |
0adfe95a LC |
14469 | |
14470 | @table @code | |
14471 | @item compose | |
14472 | This is the procedure to @dfn{compose} the list of extensions to | |
14473 | services of this type. | |
14474 | ||
14475 | Services can extend the udev service by passing it lists of rules; we | |
14476 | compose those extensions simply by concatenating them. | |
14477 | ||
14478 | @item extend | |
1068f26b | 14479 | This procedure defines how the value of the service is @dfn{extended} with |
0adfe95a LC |
14480 | the composition of the extensions. |
14481 | ||
14482 | Udev extensions are composed into a list of rules, but the udev service | |
14483 | value is itself a @code{<udev-configuration>} record. So here, we | |
a40424bd | 14484 | extend that record by appending the list of rules it contains to the |
0adfe95a LC |
14485 | list of contributed rules. |
14486 | @end table | |
14487 | ||
14488 | There can be only one instance of an extensible service type such as | |
14489 | @var{udev-service-type}. If there were more, the | |
14490 | @code{service-extension} specifications would be ambiguous. | |
14491 | ||
14492 | Still here? The next section provides a reference of the programming | |
14493 | interface for services. | |
14494 | ||
14495 | @node Service Reference | |
14496 | @subsubsection Service Reference | |
14497 | ||
14498 | We have seen an overview of service types (@pxref{Service Types and | |
14499 | Services}). This section provides a reference on how to manipulate | |
14500 | services and service types. This interface is provided by the | |
14501 | @code{(gnu services)} module. | |
14502 | ||
14503 | @deffn {Scheme Procedure} service @var{type} @var{value} | |
14504 | Return a new service of @var{type}, a @code{<service-type>} object (see | |
14505 | below.) @var{value} can be any object; it represents the parameters of | |
14506 | this particular service instance. | |
14507 | @end deffn | |
14508 | ||
14509 | @deffn {Scheme Procedure} service? @var{obj} | |
14510 | Return true if @var{obj} is a service. | |
14511 | @end deffn | |
8451a568 | 14512 | |
0adfe95a LC |
14513 | @deffn {Scheme Procedure} service-kind @var{service} |
14514 | Return the type of @var{service}---i.e., a @code{<service-type>} object. | |
14515 | @end deffn | |
14516 | ||
14517 | @deffn {Scheme Procedure} service-parameters @var{service} | |
14518 | Return the value associated with @var{service}. It represents its | |
14519 | parameters. | |
14520 | @end deffn | |
14521 | ||
14522 | Here is an example of how a service is created and manipulated: | |
14523 | ||
14524 | @example | |
14525 | (define s | |
14526 | (service nginx-service-type | |
14527 | (nginx-configuration | |
14528 | (nginx nginx) | |
14529 | (log-directory log-directory) | |
14530 | (run-directory run-directory) | |
14531 | (file config-file)))) | |
14532 | ||
14533 | (service? s) | |
14534 | @result{} #t | |
14535 | ||
14536 | (eq? (service-kind s) nginx-service-type) | |
14537 | @result{} #t | |
14538 | @end example | |
14539 | ||
cd6f6c22 LC |
14540 | The @code{modify-services} form provides a handy way to change the |
14541 | parameters of some of the services of a list such as | |
4d343a14 | 14542 | @var{%base-services} (@pxref{Base Services, @code{%base-services}}). It |
7414de0a | 14543 | evaluates to a list of services. Of course, you could always use |
4d343a14 CM |
14544 | standard list combinators such as @code{map} and @code{fold} to do that |
14545 | (@pxref{SRFI-1, List Library,, guile, GNU Guile Reference Manual}); | |
14546 | @code{modify-services} simply provides a more concise form for this | |
14547 | common pattern. | |
cd6f6c22 LC |
14548 | |
14549 | @deffn {Scheme Syntax} modify-services @var{services} @ | |
14550 | (@var{type} @var{variable} => @var{body}) @dots{} | |
14551 | ||
14552 | Modify the services listed in @var{services} according to the given | |
14553 | clauses. Each clause has the form: | |
14554 | ||
14555 | @example | |
14556 | (@var{type} @var{variable} => @var{body}) | |
14557 | @end example | |
14558 | ||
4d343a14 CM |
14559 | where @var{type} is a service type---e.g., |
14560 | @code{guix-service-type}---and @var{variable} is an identifier that is | |
14561 | bound within the @var{body} to the service parameters---e.g., a | |
14562 | @code{guix-configuration} instance---of the original service of that | |
14563 | @var{type}. | |
cd6f6c22 | 14564 | |
4d343a14 CM |
14565 | The @var{body} should evaluate to the new service parameters, which will |
14566 | be used to configure the new service. This new service will replace the | |
14567 | original in the resulting list. Because a service's service parameters | |
7414de0a | 14568 | are created using @code{define-record-type*}, you can write a succinct |
4d343a14 CM |
14569 | @var{body} that evaluates to the new service parameters by using the |
14570 | @code{inherit} feature that @code{define-record-type*} provides. | |
14571 | ||
b53daad0 | 14572 | @xref{Using the Configuration System}, for example usage. |
cd6f6c22 | 14573 | |
cd6f6c22 LC |
14574 | @end deffn |
14575 | ||
14576 | Next comes the programming interface for service types. This is | |
14577 | something you want to know when writing new service definitions, but not | |
14578 | necessarily when simply looking for ways to customize your | |
14579 | @code{operating-system} declaration. | |
14580 | ||
0adfe95a LC |
14581 | @deftp {Data Type} service-type |
14582 | @cindex service type | |
14583 | This is the representation of a @dfn{service type} (@pxref{Service Types | |
14584 | and Services}). | |
14585 | ||
14586 | @table @asis | |
14587 | @item @code{name} | |
14588 | This is a symbol, used only to simplify inspection and debugging. | |
14589 | ||
14590 | @item @code{extensions} | |
1068f26b | 14591 | A non-empty list of @code{<service-extension>} objects (see below). |
0adfe95a LC |
14592 | |
14593 | @item @code{compose} (default: @code{#f}) | |
14594 | If this is @code{#f}, then the service type denotes services that cannot | |
14595 | be extended---i.e., services that do not receive ``values'' from other | |
14596 | services. | |
14597 | ||
14598 | Otherwise, it must be a one-argument procedure. The procedure is called | |
14599 | by @code{fold-services} and is passed a list of values collected from | |
14600 | extensions. It must return a value that is a valid parameter value for | |
14601 | the service instance. | |
14602 | ||
14603 | @item @code{extend} (default: @code{#f}) | |
14604 | If this is @code{#f}, services of this type cannot be extended. | |
14605 | ||
14606 | Otherwise, it must be a two-argument procedure: @code{fold-services} | |
1068f26b | 14607 | calls it, passing it the initial value of the service as the first argument |
0adfe95a LC |
14608 | and the result of applying @code{compose} to the extension values as the |
14609 | second argument. | |
14610 | @end table | |
14611 | ||
14612 | @xref{Service Types and Services}, for examples. | |
14613 | @end deftp | |
14614 | ||
14615 | @deffn {Scheme Procedure} service-extension @var{target-type} @ | |
14616 | @var{compute} | |
14617 | Return a new extension for services of type @var{target-type}. | |
14618 | @var{compute} must be a one-argument procedure: @code{fold-services} | |
14619 | calls it, passing it the value associated with the service that provides | |
14620 | the extension; it must return a valid value for the target service. | |
14621 | @end deffn | |
14622 | ||
14623 | @deffn {Scheme Procedure} service-extension? @var{obj} | |
14624 | Return true if @var{obj} is a service extension. | |
14625 | @end deffn | |
14626 | ||
71654dfd LC |
14627 | Occasionally, you might want to simply extend an existing service. This |
14628 | involves creating a new service type and specifying the extension of | |
14629 | interest, which can be verbose; the @code{simple-service} procedure | |
14630 | provides a shorthand for this. | |
14631 | ||
14632 | @deffn {Scheme Procedure} simple-service @var{name} @var{target} @var{value} | |
14633 | Return a service that extends @var{target} with @var{value}. This works | |
14634 | by creating a singleton service type @var{name}, of which the returned | |
14635 | service is an instance. | |
14636 | ||
14637 | For example, this extends mcron (@pxref{Scheduled Job Execution}) with | |
14638 | an additional job: | |
14639 | ||
14640 | @example | |
14641 | (simple-service 'my-mcron-job mcron-service-type | |
14642 | #~(job '(next-hour (3)) "guix gc -F 2G")) | |
14643 | @end example | |
14644 | @end deffn | |
14645 | ||
0adfe95a LC |
14646 | At the core of the service abstraction lies the @code{fold-services} |
14647 | procedure, which is responsible for ``compiling'' a list of services | |
d62e201c LC |
14648 | down to a single directory that contains everything needed to boot and |
14649 | run the system---the directory shown by the @command{guix system build} | |
14650 | command (@pxref{Invoking guix system}). In essence, it propagates | |
14651 | service extensions down the service graph, updating each node parameters | |
14652 | on the way, until it reaches the root node. | |
0adfe95a LC |
14653 | |
14654 | @deffn {Scheme Procedure} fold-services @var{services} @ | |
d62e201c | 14655 | [#:target-type @var{system-service-type}] |
0adfe95a LC |
14656 | Fold @var{services} by propagating their extensions down to the root of |
14657 | type @var{target-type}; return the root service adjusted accordingly. | |
14658 | @end deffn | |
14659 | ||
14660 | Lastly, the @code{(gnu services)} module also defines several essential | |
14661 | service types, some of which are listed below. | |
14662 | ||
d62e201c LC |
14663 | @defvr {Scheme Variable} system-service-type |
14664 | This is the root of the service graph. It produces the system directory | |
14665 | as returned by the @command{guix system build} command. | |
14666 | @end defvr | |
14667 | ||
0adfe95a | 14668 | @defvr {Scheme Variable} boot-service-type |
d62e201c LC |
14669 | The type of the ``boot service'', which produces the @dfn{boot script}. |
14670 | The boot script is what the initial RAM disk runs when booting. | |
0adfe95a LC |
14671 | @end defvr |
14672 | ||
14673 | @defvr {Scheme Variable} etc-service-type | |
14674 | The type of the @file{/etc} service. This service can be extended by | |
14675 | passing it name/file tuples such as: | |
14676 | ||
14677 | @example | |
14678 | (list `("issue" ,(plain-file "issue" "Welcome!\n"))) | |
14679 | @end example | |
14680 | ||
14681 | In this example, the effect would be to add an @file{/etc/issue} file | |
14682 | pointing to the given file. | |
14683 | @end defvr | |
14684 | ||
14685 | @defvr {Scheme Variable} setuid-program-service-type | |
14686 | Type for the ``setuid-program service''. This service collects lists of | |
14687 | executable file names, passed as gexps, and adds them to the set of | |
14688 | setuid-root programs on the system (@pxref{Setuid Programs}). | |
14689 | @end defvr | |
14690 | ||
af4c3fd5 LC |
14691 | @defvr {Scheme Variable} profile-service-type |
14692 | Type of the service that populates the @dfn{system profile}---i.e., the | |
14693 | programs under @file{/run/current-system/profile}. Other services can | |
14694 | extend it by passing it lists of packages to add to the system profile. | |
14695 | @end defvr | |
14696 | ||
0adfe95a | 14697 | |
dd17bc38 AK |
14698 | @node Shepherd Services |
14699 | @subsubsection Shepherd Services | |
0adfe95a | 14700 | |
e32171ee | 14701 | @cindex shepherd services |
0adfe95a LC |
14702 | @cindex PID 1 |
14703 | @cindex init system | |
a40424bd CM |
14704 | The @code{(gnu services shepherd)} module provides a way to define |
14705 | services managed by the GNU@tie{}Shepherd, which is the GuixSD | |
14706 | initialization system---the first process that is started when the | |
1068f26b AE |
14707 | system boots, also known as PID@tie{}1 |
14708 | (@pxref{Introduction,,, shepherd, The GNU Shepherd Manual}). | |
6f305ea5 | 14709 | |
dd17bc38 AK |
14710 | Services in the Shepherd can depend on each other. For instance, the |
14711 | SSH daemon may need to be started after the syslog daemon has been | |
14712 | started, which in turn can only happen once all the file systems have | |
14713 | been mounted. The simple operating system defined earlier (@pxref{Using | |
14714 | the Configuration System}) results in a service graph like this: | |
6f305ea5 | 14715 | |
710fa231 | 14716 | @image{images/shepherd-graph,,5in,Typical shepherd service graph.} |
6f305ea5 LC |
14717 | |
14718 | You can actually generate such a graph for any operating system | |
710fa231 AK |
14719 | definition using the @command{guix system shepherd-graph} command |
14720 | (@pxref{system-shepherd-graph, @command{guix system shepherd-graph}}). | |
6f305ea5 | 14721 | |
d4053c71 AK |
14722 | The @var{%shepherd-root-service} is a service object representing |
14723 | PID@tie{}1, of type @var{shepherd-root-service-type}; it can be extended | |
14724 | by passing it lists of @code{<shepherd-service>} objects. | |
0adfe95a | 14725 | |
d4053c71 | 14726 | @deftp {Data Type} shepherd-service |
dd17bc38 | 14727 | The data type representing a service managed by the Shepherd. |
0adfe95a LC |
14728 | |
14729 | @table @asis | |
14730 | @item @code{provision} | |
14731 | This is a list of symbols denoting what the service provides. | |
14732 | ||
dd17bc38 AK |
14733 | These are the names that may be passed to @command{herd start}, |
14734 | @command{herd status}, and similar commands (@pxref{Invoking herd,,, | |
14735 | shepherd, The GNU Shepherd Manual}). @xref{Slots of services, the | |
14736 | @code{provides} slot,, shepherd, The GNU Shepherd Manual}, for details. | |
0adfe95a LC |
14737 | |
14738 | @item @code{requirements} (default: @code{'()}) | |
dd17bc38 | 14739 | List of symbols denoting the Shepherd services this one depends on. |
0adfe95a LC |
14740 | |
14741 | @item @code{respawn?} (default: @code{#t}) | |
14742 | Whether to restart the service when it stops, for instance when the | |
14743 | underlying process dies. | |
14744 | ||
14745 | @item @code{start} | |
14746 | @itemx @code{stop} (default: @code{#~(const #f)}) | |
dd17bc38 AK |
14747 | The @code{start} and @code{stop} fields refer to the Shepherd's |
14748 | facilities to start and stop processes (@pxref{Service De- and | |
14749 | Constructors,,, shepherd, The GNU Shepherd Manual}). They are given as | |
14750 | G-expressions that get expanded in the Shepherd configuration file | |
14751 | (@pxref{G-Expressions}). | |
0adfe95a LC |
14752 | |
14753 | @item @code{documentation} | |
14754 | A documentation string, as shown when running: | |
14755 | ||
14756 | @example | |
dd17bc38 | 14757 | herd doc @var{service-name} |
0adfe95a LC |
14758 | @end example |
14759 | ||
14760 | where @var{service-name} is one of the symbols in @var{provision} | |
dd17bc38 | 14761 | (@pxref{Invoking herd,,, shepherd, The GNU Shepherd Manual}). |
fae685b9 LC |
14762 | |
14763 | @item @code{modules} (default: @var{%default-modules}) | |
14764 | This is the list of modules that must be in scope when @code{start} and | |
14765 | @code{stop} are evaluated. | |
14766 | ||
0adfe95a LC |
14767 | @end table |
14768 | @end deftp | |
14769 | ||
d4053c71 | 14770 | @defvr {Scheme Variable} shepherd-root-service-type |
dd17bc38 | 14771 | The service type for the Shepherd ``root service''---i.e., PID@tie{}1. |
0adfe95a LC |
14772 | |
14773 | This is the service type that extensions target when they want to create | |
dd17bc38 | 14774 | shepherd services (@pxref{Service Types and Services}, for an example). |
d4053c71 | 14775 | Each extension must pass a list of @code{<shepherd-service>}. |
0adfe95a LC |
14776 | @end defvr |
14777 | ||
d4053c71 | 14778 | @defvr {Scheme Variable} %shepherd-root-service |
0adfe95a LC |
14779 | This service represents PID@tie{}1. |
14780 | @end defvr | |
8451a568 | 14781 | |
8451a568 | 14782 | |
cf4a9129 LC |
14783 | @node Installing Debugging Files |
14784 | @section Installing Debugging Files | |
8451a568 | 14785 | |
cf4a9129 LC |
14786 | @cindex debugging files |
14787 | Program binaries, as produced by the GCC compilers for instance, are | |
14788 | typically written in the ELF format, with a section containing | |
14789 | @dfn{debugging information}. Debugging information is what allows the | |
14790 | debugger, GDB, to map binary code to source code; it is required to | |
14791 | debug a compiled program in good conditions. | |
8451a568 | 14792 | |
cf4a9129 LC |
14793 | The problem with debugging information is that is takes up a fair amount |
14794 | of disk space. For example, debugging information for the GNU C Library | |
14795 | weighs in at more than 60 MiB. Thus, as a user, keeping all the | |
14796 | debugging info of all the installed programs is usually not an option. | |
14797 | Yet, space savings should not come at the cost of an impediment to | |
14798 | debugging---especially in the GNU system, which should make it easier | |
14799 | for users to exert their computing freedom (@pxref{GNU Distribution}). | |
8451a568 | 14800 | |
cf4a9129 LC |
14801 | Thankfully, the GNU Binary Utilities (Binutils) and GDB provide a |
14802 | mechanism that allows users to get the best of both worlds: debugging | |
14803 | information can be stripped from the binaries and stored in separate | |
14804 | files. GDB is then able to load debugging information from those files, | |
14805 | when they are available (@pxref{Separate Debug Files,,, gdb, Debugging | |
14806 | with GDB}). | |
8451a568 | 14807 | |
cf4a9129 LC |
14808 | The GNU distribution takes advantage of this by storing debugging |
14809 | information in the @code{lib/debug} sub-directory of a separate package | |
14810 | output unimaginatively called @code{debug} (@pxref{Packages with | |
14811 | Multiple Outputs}). Users can choose to install the @code{debug} output | |
14812 | of a package when they need it. For instance, the following command | |
14813 | installs the debugging information for the GNU C Library and for GNU | |
14814 | Guile: | |
8451a568 LC |
14815 | |
14816 | @example | |
cf4a9129 | 14817 | guix package -i glibc:debug guile:debug |
8451a568 LC |
14818 | @end example |
14819 | ||
cf4a9129 LC |
14820 | GDB must then be told to look for debug files in the user's profile, by |
14821 | setting the @code{debug-file-directory} variable (consider setting it | |
14822 | from the @file{~/.gdbinit} file, @pxref{Startup,,, gdb, Debugging with | |
14823 | GDB}): | |
8451a568 | 14824 | |
cf4a9129 LC |
14825 | @example |
14826 | (gdb) set debug-file-directory ~/.guix-profile/lib/debug | |
14827 | @end example | |
8451a568 | 14828 | |
cf4a9129 LC |
14829 | From there on, GDB will pick up debugging information from the |
14830 | @code{.debug} files under @file{~/.guix-profile/lib/debug}. | |
8451a568 | 14831 | |
cf4a9129 LC |
14832 | In addition, you will most likely want GDB to be able to show the source |
14833 | code being debugged. To do that, you will have to unpack the source | |
14834 | code of the package of interest (obtained with @code{guix build | |
14835 | --source}, @pxref{Invoking guix build}), and to point GDB to that source | |
14836 | directory using the @code{directory} command (@pxref{Source Path, | |
14837 | @code{directory},, gdb, Debugging with GDB}). | |
8451a568 | 14838 | |
cf4a9129 LC |
14839 | @c XXX: keep me up-to-date |
14840 | The @code{debug} output mechanism in Guix is implemented by the | |
14841 | @code{gnu-build-system} (@pxref{Build Systems}). Currently, it is | |
1068f26b AE |
14842 | opt-in---debugging information is available only for the packages |
14843 | with definitions explicitly declaring a @code{debug} output. This may be | |
14844 | changed to opt-out in the future if our build farm servers can handle | |
cf4a9129 LC |
14845 | the load. To check whether a package has a @code{debug} output, use |
14846 | @command{guix package --list-available} (@pxref{Invoking guix package}). | |
8451a568 | 14847 | |
8451a568 | 14848 | |
05962f29 LC |
14849 | @node Security Updates |
14850 | @section Security Updates | |
14851 | ||
09866b39 LC |
14852 | @cindex security updates |
14853 | @cindex security vulnerabilities | |
14854 | Occasionally, important security vulnerabilities are discovered in software | |
14855 | packages and must be patched. Guix developers try hard to keep track of | |
14856 | known vulnerabilities and to apply fixes as soon as possible in the | |
14857 | @code{master} branch of Guix (we do not yet provide a ``stable'' branch | |
14858 | containing only security updates.) The @command{guix lint} tool helps | |
14859 | developers find out about vulnerable versions of software packages in the | |
14860 | distribution: | |
14861 | ||
14862 | @smallexample | |
14863 | $ guix lint -c cve | |
14864 | gnu/packages/base.scm:652:2: glibc-2.21: probably vulnerable to CVE-2015-1781, CVE-2015-7547 | |
14865 | gnu/packages/gcc.scm:334:2: gcc-4.9.3: probably vulnerable to CVE-2015-5276 | |
14866 | gnu/packages/image.scm:312:2: openjpeg-2.1.0: probably vulnerable to CVE-2016-1923, CVE-2016-1924 | |
14867 | @dots{} | |
14868 | @end smallexample | |
14869 | ||
14870 | @xref{Invoking guix lint}, for more information. | |
14871 | ||
843858b8 | 14872 | @quotation Note |
09866b39 LC |
14873 | As of version @value{VERSION}, the feature described below is considered |
14874 | ``beta''. | |
843858b8 | 14875 | @end quotation |
05962f29 | 14876 | |
09866b39 | 14877 | Guix follows a functional |
05962f29 LC |
14878 | package management discipline (@pxref{Introduction}), which implies |
14879 | that, when a package is changed, @emph{every package that depends on it} | |
14880 | must be rebuilt. This can significantly slow down the deployment of | |
14881 | fixes in core packages such as libc or Bash, since basically the whole | |
14882 | distribution would need to be rebuilt. Using pre-built binaries helps | |
14883 | (@pxref{Substitutes}), but deployment may still take more time than | |
14884 | desired. | |
14885 | ||
14886 | @cindex grafts | |
1068f26b | 14887 | To address this, Guix implements @dfn{grafts}, a mechanism that allows |
05962f29 LC |
14888 | for fast deployment of critical updates without the costs associated |
14889 | with a whole-distribution rebuild. The idea is to rebuild only the | |
14890 | package that needs to be patched, and then to ``graft'' it onto packages | |
14891 | explicitly installed by the user and that were previously referring to | |
14892 | the original package. The cost of grafting is typically very low, and | |
14893 | order of magnitudes lower than a full rebuild of the dependency chain. | |
14894 | ||
14895 | @cindex replacements of packages, for grafts | |
14896 | For instance, suppose a security update needs to be applied to Bash. | |
14897 | Guix developers will provide a package definition for the ``fixed'' | |
14898 | Bash, say @var{bash-fixed}, in the usual way (@pxref{Defining | |
14899 | Packages}). Then, the original package definition is augmented with a | |
14900 | @code{replacement} field pointing to the package containing the bug fix: | |
14901 | ||
14902 | @example | |
14903 | (define bash | |
14904 | (package | |
14905 | (name "bash") | |
14906 | ;; @dots{} | |
14907 | (replacement bash-fixed))) | |
14908 | @end example | |
14909 | ||
c22a1324 LC |
14910 | From there on, any package depending directly or indirectly on Bash---as |
14911 | reported by @command{guix gc --requisites} (@pxref{Invoking guix | |
14912 | gc})---that is installed is automatically ``rewritten'' to refer to | |
05962f29 | 14913 | @var{bash-fixed} instead of @var{bash}. This grafting process takes |
1068f26b | 14914 | time proportional to the size of the package, usually less than a |
c22a1324 LC |
14915 | minute for an ``average'' package on a recent machine. Grafting is |
14916 | recursive: when an indirect dependency requires grafting, then grafting | |
14917 | ``propagates'' up to the package that the user is installing. | |
05962f29 | 14918 | |
57bdd79e LC |
14919 | Currently, the length of the name and version of the graft and that of |
14920 | the package it replaces (@var{bash-fixed} and @var{bash} in the example | |
14921 | above) must be equal. This restriction mostly comes from the fact that | |
14922 | grafting works by patching files, including binary files, directly. | |
05962f29 LC |
14923 | Other restrictions may apply: for instance, when adding a graft to a |
14924 | package providing a shared library, the original shared library and its | |
14925 | replacement must have the same @code{SONAME} and be binary-compatible. | |
14926 | ||
59a4dd50 LC |
14927 | The @option{--no-grafts} command-line option allows you to forcefully |
14928 | avoid grafting (@pxref{Common Build Options, @option{--no-grafts}}). | |
14929 | Thus, the command: | |
14930 | ||
14931 | @example | |
14932 | guix build bash --no-grafts | |
14933 | @end example | |
14934 | ||
14935 | @noindent | |
14936 | returns the store file name of the original Bash, whereas: | |
14937 | ||
14938 | @example | |
14939 | guix build bash | |
14940 | @end example | |
14941 | ||
14942 | @noindent | |
14943 | returns the store file name of the ``fixed'', replacement Bash. This | |
14944 | allows you to distinguish between the two variants of Bash. | |
14945 | ||
14946 | To verify which Bash your whole profile refers to, you can run | |
14947 | (@pxref{Invoking guix gc}): | |
14948 | ||
14949 | @example | |
14950 | guix gc -R `readlink -f ~/.guix-profile` | grep bash | |
14951 | @end example | |
14952 | ||
14953 | @noindent | |
14954 | @dots{} and compare the store file names that you get with those above. | |
14955 | Likewise for a complete GuixSD system generation: | |
14956 | ||
14957 | @example | |
14958 | guix gc -R `guix system build my-config.scm` | grep bash | |
14959 | @end example | |
14960 | ||
14961 | Lastly, to check which Bash running processes are using, you can use the | |
14962 | @command{lsof} command: | |
14963 | ||
14964 | @example | |
14965 | lsof | grep /gnu/store/.*bash | |
14966 | @end example | |
14967 | ||
05962f29 | 14968 | |
cf4a9129 LC |
14969 | @node Package Modules |
14970 | @section Package Modules | |
8451a568 | 14971 | |
cf4a9129 LC |
14972 | From a programming viewpoint, the package definitions of the |
14973 | GNU distribution are provided by Guile modules in the @code{(gnu packages | |
14974 | @dots{})} name space@footnote{Note that packages under the @code{(gnu | |
14975 | packages @dots{})} module name space are not necessarily ``GNU | |
14976 | packages''. This module naming scheme follows the usual Guile module | |
14977 | naming convention: @code{gnu} means that these modules are distributed | |
14978 | as part of the GNU system, and @code{packages} identifies modules that | |
14979 | define packages.} (@pxref{Modules, Guile modules,, guile, GNU Guile | |
14980 | Reference Manual}). For instance, the @code{(gnu packages emacs)} | |
14981 | module exports a variable named @code{emacs}, which is bound to a | |
14982 | @code{<package>} object (@pxref{Defining Packages}). | |
113daf62 | 14983 | |
300868ba | 14984 | The @code{(gnu packages @dots{})} module name space is |
cf4a9129 LC |
14985 | automatically scanned for packages by the command-line tools. For |
14986 | instance, when running @code{guix package -i emacs}, all the @code{(gnu | |
14987 | packages @dots{})} modules are scanned until one that exports a package | |
14988 | object whose name is @code{emacs} is found. This package search | |
14989 | facility is implemented in the @code{(gnu packages)} module. | |
113daf62 | 14990 | |
300868ba | 14991 | @cindex customization, of packages |
8689901f | 14992 | @cindex package module search path |
cf4a9129 | 14993 | Users can store package definitions in modules with different |
60142854 | 14994 | names---e.g., @code{(my-packages emacs)}@footnote{Note that the file |
c95ded7e LC |
14995 | name and module name must match. For instance, the @code{(my-packages |
14996 | emacs)} module must be stored in a @file{my-packages/emacs.scm} file | |
14997 | relative to the load path specified with @option{--load-path} or | |
14998 | @code{GUIX_PACKAGE_PATH}. @xref{Modules and the File System,,, | |
14999 | guile, GNU Guile Reference Manual}, for details.}. These package definitions | |
1068f26b AE |
15000 | will not be visible by default. Users can invoke commands such as |
15001 | @command{guix package} and @command{guix build} with the | |
c95ded7e LC |
15002 | @code{-e} option so that they know where to find the package. Better |
15003 | yet, they can use the | |
300868ba | 15004 | @code{-L} option of these commands to make those modules visible |
8689901f LC |
15005 | (@pxref{Invoking guix build, @code{--load-path}}), or define the |
15006 | @code{GUIX_PACKAGE_PATH} environment variable. This environment | |
15007 | variable makes it easy to extend or customize the distribution and is | |
15008 | honored by all the user interfaces. | |
15009 | ||
15010 | @defvr {Environment Variable} GUIX_PACKAGE_PATH | |
1068f26b AE |
15011 | This is a colon-separated list of directories to search for additional |
15012 | package modules. Directories listed in this variable take precedence | |
15013 | over the own modules of the distribution. | |
8689901f | 15014 | @end defvr |
ef5dd60a | 15015 | |
cf4a9129 LC |
15016 | The distribution is fully @dfn{bootstrapped} and @dfn{self-contained}: |
15017 | each package is built based solely on other packages in the | |
15018 | distribution. The root of this dependency graph is a small set of | |
15019 | @dfn{bootstrap binaries}, provided by the @code{(gnu packages | |
15020 | bootstrap)} module. For more information on bootstrapping, | |
081145cf | 15021 | @pxref{Bootstrapping}. |
ef5dd60a | 15022 | |
cf4a9129 LC |
15023 | @node Packaging Guidelines |
15024 | @section Packaging Guidelines | |
ef5dd60a | 15025 | |
e32171ee | 15026 | @cindex packages, creating |
cf4a9129 LC |
15027 | The GNU distribution is nascent and may well lack some of your favorite |
15028 | packages. This section describes how you can help make the distribution | |
15029 | grow. @xref{Contributing}, for additional information on how you can | |
15030 | help. | |
ef5dd60a | 15031 | |
cf4a9129 LC |
15032 | Free software packages are usually distributed in the form of |
15033 | @dfn{source code tarballs}---typically @file{tar.gz} files that contain | |
15034 | all the source files. Adding a package to the distribution means | |
15035 | essentially two things: adding a @dfn{recipe} that describes how to | |
15036 | build the package, including a list of other packages required to build | |
f97c9175 | 15037 | it, and adding @dfn{package metadata} along with that recipe, such as a |
cf4a9129 | 15038 | description and licensing information. |
ef5dd60a | 15039 | |
cf4a9129 LC |
15040 | In Guix all this information is embodied in @dfn{package definitions}. |
15041 | Package definitions provide a high-level view of the package. They are | |
15042 | written using the syntax of the Scheme programming language; in fact, | |
15043 | for each package we define a variable bound to the package definition, | |
15044 | and export that variable from a module (@pxref{Package Modules}). | |
15045 | However, in-depth Scheme knowledge is @emph{not} a prerequisite for | |
15046 | creating packages. For more information on package definitions, | |
081145cf | 15047 | @pxref{Defining Packages}. |
ef5dd60a | 15048 | |
cf4a9129 LC |
15049 | Once a package definition is in place, stored in a file in the Guix |
15050 | source tree, it can be tested using the @command{guix build} command | |
15051 | (@pxref{Invoking guix build}). For example, assuming the new package is | |
c71979f4 LC |
15052 | called @code{gnew}, you may run this command from the Guix build tree |
15053 | (@pxref{Running Guix Before It Is Installed}): | |
ef5dd60a LC |
15054 | |
15055 | @example | |
cf4a9129 | 15056 | ./pre-inst-env guix build gnew --keep-failed |
ef5dd60a | 15057 | @end example |
ef5dd60a | 15058 | |
cf4a9129 LC |
15059 | Using @code{--keep-failed} makes it easier to debug build failures since |
15060 | it provides access to the failed build tree. Another useful | |
15061 | command-line option when debugging is @code{--log-file}, to access the | |
15062 | build log. | |
ef5dd60a | 15063 | |
cf4a9129 LC |
15064 | If the package is unknown to the @command{guix} command, it may be that |
15065 | the source file contains a syntax error, or lacks a @code{define-public} | |
15066 | clause to export the package variable. To figure it out, you may load | |
15067 | the module from Guile to get more information about the actual error: | |
ef5dd60a | 15068 | |
cf4a9129 LC |
15069 | @example |
15070 | ./pre-inst-env guile -c '(use-modules (gnu packages gnew))' | |
15071 | @end example | |
ef5dd60a | 15072 | |
cf4a9129 LC |
15073 | Once your package builds correctly, please send us a patch |
15074 | (@pxref{Contributing}). Well, if you need help, we will be happy to | |
15075 | help you too. Once the patch is committed in the Guix repository, the | |
15076 | new package automatically gets built on the supported platforms by | |
2b1cee21 | 15077 | @url{http://hydra.gnu.org/jobset/gnu/master, our continuous integration |
cf4a9129 | 15078 | system}. |
ef5dd60a | 15079 | |
cf4a9129 LC |
15080 | @cindex substituter |
15081 | Users can obtain the new package definition simply by running | |
15082 | @command{guix pull} (@pxref{Invoking guix pull}). When | |
15083 | @code{hydra.gnu.org} is done building the package, installing the | |
15084 | package automatically downloads binaries from there | |
15085 | (@pxref{Substitutes}). The only place where human intervention is | |
15086 | needed is to review and apply the patch. | |
ef5dd60a | 15087 | |
ef5dd60a | 15088 | |
cf4a9129 | 15089 | @menu |
ec0339cd LC |
15090 | * Software Freedom:: What may go into the distribution. |
15091 | * Package Naming:: What's in a name? | |
15092 | * Version Numbers:: When the name is not enough. | |
cbd02397 | 15093 | * Synopses and Descriptions:: Helping users find the right package. |
ec0339cd LC |
15094 | * Python Modules:: Taming the snake. |
15095 | * Perl Modules:: Little pearls. | |
e1c963bf | 15096 | * Java Packages:: Coffee break. |
ec0339cd | 15097 | * Fonts:: Fond of fonts. |
cf4a9129 | 15098 | @end menu |
ef5dd60a | 15099 | |
cf4a9129 LC |
15100 | @node Software Freedom |
15101 | @subsection Software Freedom | |
ef5dd60a | 15102 | |
cf4a9129 | 15103 | @c Adapted from http://www.gnu.org/philosophy/philosophy.html. |
e32171ee | 15104 | @cindex free software |
cf4a9129 LC |
15105 | The GNU operating system has been developed so that users can have |
15106 | freedom in their computing. GNU is @dfn{free software}, meaning that | |
15107 | users have the @url{http://www.gnu.org/philosophy/free-sw.html,four | |
15108 | essential freedoms}: to run the program, to study and change the program | |
15109 | in source code form, to redistribute exact copies, and to distribute | |
15110 | modified versions. Packages found in the GNU distribution provide only | |
15111 | software that conveys these four freedoms. | |
c11a6eb1 | 15112 | |
cf4a9129 LC |
15113 | In addition, the GNU distribution follow the |
15114 | @url{http://www.gnu.org/distros/free-system-distribution-guidelines.html,free | |
15115 | software distribution guidelines}. Among other things, these guidelines | |
15116 | reject non-free firmware, recommendations of non-free software, and | |
15117 | discuss ways to deal with trademarks and patents. | |
ef5dd60a | 15118 | |
1068f26b AE |
15119 | Some otherwise free upstream package sources contain a small and optional |
15120 | subset that violates the above guidelines, for instance because this subset | |
15121 | is itself non-free code. When that happens, the offending items are removed | |
15122 | with appropriate patches or code snippets in the @code{origin} form of the | |
15123 | package (@pxref{Defining Packages}). This way, @code{guix | |
cf4a9129 LC |
15124 | build --source} returns the ``freed'' source rather than the unmodified |
15125 | upstream source. | |
ef5dd60a | 15126 | |
ef5dd60a | 15127 | |
cf4a9129 LC |
15128 | @node Package Naming |
15129 | @subsection Package Naming | |
ef5dd60a | 15130 | |
e32171ee | 15131 | @cindex package name |
cf4a9129 LC |
15132 | A package has actually two names associated with it: |
15133 | First, there is the name of the @emph{Scheme variable}, the one following | |
15134 | @code{define-public}. By this name, the package can be made known in the | |
15135 | Scheme code, for instance as input to another package. Second, there is | |
15136 | the string in the @code{name} field of a package definition. This name | |
15137 | is used by package management commands such as | |
15138 | @command{guix package} and @command{guix build}. | |
ef5dd60a | 15139 | |
cf4a9129 LC |
15140 | Both are usually the same and correspond to the lowercase conversion of |
15141 | the project name chosen upstream, with underscores replaced with | |
15142 | hyphens. For instance, GNUnet is available as @code{gnunet}, and | |
15143 | SDL_net as @code{sdl-net}. | |
927097ef | 15144 | |
cf4a9129 | 15145 | We do not add @code{lib} prefixes for library packages, unless these are |
081145cf | 15146 | already part of the official project name. But @pxref{Python |
cf4a9129 LC |
15147 | Modules} and @ref{Perl Modules} for special rules concerning modules for |
15148 | the Python and Perl languages. | |
927097ef | 15149 | |
1b366ee4 | 15150 | Font package names are handled differently, @pxref{Fonts}. |
7fec52b7 | 15151 | |
ef5dd60a | 15152 | |
cf4a9129 LC |
15153 | @node Version Numbers |
15154 | @subsection Version Numbers | |
ef5dd60a | 15155 | |
e32171ee | 15156 | @cindex package version |
cf4a9129 LC |
15157 | We usually package only the latest version of a given free software |
15158 | project. But sometimes, for instance for incompatible library versions, | |
15159 | two (or more) versions of the same package are needed. These require | |
15160 | different Scheme variable names. We use the name as defined | |
15161 | in @ref{Package Naming} | |
15162 | for the most recent version; previous versions use the same name, suffixed | |
15163 | by @code{-} and the smallest prefix of the version number that may | |
15164 | distinguish the two versions. | |
ef5dd60a | 15165 | |
cf4a9129 LC |
15166 | The name inside the package definition is the same for all versions of a |
15167 | package and does not contain any version number. | |
ef5dd60a | 15168 | |
cf4a9129 | 15169 | For instance, the versions 2.24.20 and 3.9.12 of GTK+ may be packaged as follows: |
ef5dd60a | 15170 | |
cf4a9129 LC |
15171 | @example |
15172 | (define-public gtk+ | |
15173 | (package | |
17d8e33f ML |
15174 | (name "gtk+") |
15175 | (version "3.9.12") | |
15176 | ...)) | |
cf4a9129 LC |
15177 | (define-public gtk+-2 |
15178 | (package | |
17d8e33f ML |
15179 | (name "gtk+") |
15180 | (version "2.24.20") | |
15181 | ...)) | |
cf4a9129 LC |
15182 | @end example |
15183 | If we also wanted GTK+ 3.8.2, this would be packaged as | |
15184 | @example | |
15185 | (define-public gtk+-3.8 | |
15186 | (package | |
17d8e33f ML |
15187 | (name "gtk+") |
15188 | (version "3.8.2") | |
15189 | ...)) | |
cf4a9129 | 15190 | @end example |
ef5dd60a | 15191 | |
880d647d LC |
15192 | @c See <https://lists.gnu.org/archive/html/guix-devel/2016-01/msg00425.html>, |
15193 | @c for a discussion of what follows. | |
15194 | @cindex version number, for VCS snapshots | |
15195 | Occasionally, we package snapshots of upstream's version control system | |
15196 | (VCS) instead of formal releases. This should remain exceptional, | |
15197 | because it is up to upstream developers to clarify what the stable | |
15198 | release is. Yet, it is sometimes necessary. So, what should we put in | |
15199 | the @code{version} field? | |
15200 | ||
15201 | Clearly, we need to make the commit identifier of the VCS snapshot | |
15202 | visible in the version string, but we also need to make sure that the | |
15203 | version string is monotonically increasing so that @command{guix package | |
15204 | --upgrade} can determine which version is newer. Since commit | |
15205 | identifiers, notably with Git, are not monotonically increasing, we add | |
15206 | a revision number that we increase each time we upgrade to a newer | |
15207 | snapshot. The resulting version string looks like this: | |
15208 | ||
15209 | @example | |
15210 | 2.0.11-3.cabba9e | |
15211 | ^ ^ ^ | |
15212 | | | `-- upstream commit ID | |
15213 | | | | |
15214 | | `--- Guix package revision | |
15215 | | | |
15216 | latest upstream version | |
15217 | @end example | |
15218 | ||
15219 | It is a good idea to strip commit identifiers in the @code{version} | |
15220 | field to, say, 7 digits. It avoids an aesthetic annoyance (assuming | |
15221 | aesthetics have a role to play here) as well as problems related to OS | |
15222 | limits such as the maximum shebang length (127 bytes for the Linux | |
15223 | kernel.) It is best to use the full commit identifiers in | |
561360a5 LC |
15224 | @code{origin}s, though, to avoid ambiguities. A typical package |
15225 | definition may look like this: | |
15226 | ||
15227 | @example | |
15228 | (define my-package | |
6e42660b | 15229 | (let ((commit "c3f29bc928d5900971f65965feaae59e1272a3f7") |
15230 | (revision "1")) ;Guix package revision | |
561360a5 | 15231 | (package |
6e42660b | 15232 | (version (string-append "0.9-" revision "." |
561360a5 LC |
15233 | (string-take commit 7))) |
15234 | (source (origin | |
15235 | (method git-fetch) | |
15236 | (uri (git-reference | |
15237 | (url "git://example.org/my-package.git") | |
15238 | (commit commit))) | |
15239 | (sha256 (base32 "1mbikn@dots{}")) | |
15240 | (file-name (string-append "my-package-" version | |
15241 | "-checkout")))) | |
15242 | ;; @dots{} | |
15243 | ))) | |
15244 | @end example | |
880d647d | 15245 | |
cbd02397 LC |
15246 | @node Synopses and Descriptions |
15247 | @subsection Synopses and Descriptions | |
15248 | ||
e32171ee JD |
15249 | @cindex package description |
15250 | @cindex package synopsis | |
cbd02397 LC |
15251 | As we have seen before, each package in GNU@tie{}Guix includes a |
15252 | synopsis and a description (@pxref{Defining Packages}). Synopses and | |
15253 | descriptions are important: They are what @command{guix package | |
15254 | --search} searches, and a crucial piece of information to help users | |
15255 | determine whether a given package suits their needs. Consequently, | |
15256 | packagers should pay attention to what goes into them. | |
15257 | ||
15258 | Synopses must start with a capital letter and must not end with a | |
15259 | period. They must not start with ``a'' or ``the'', which usually does | |
15260 | not bring anything; for instance, prefer ``File-frobbing tool'' over ``A | |
15261 | tool that frobs files''. The synopsis should say what the package | |
15262 | is---e.g., ``Core GNU utilities (file, text, shell)''---or what it is | |
15263 | used for---e.g., the synopsis for GNU@tie{}grep is ``Print lines | |
15264 | matching a pattern''. | |
15265 | ||
15266 | Keep in mind that the synopsis must be meaningful for a very wide | |
15267 | audience. For example, ``Manipulate alignments in the SAM format'' | |
15268 | might make sense for a seasoned bioinformatics researcher, but might be | |
15269 | fairly unhelpful or even misleading to a non-specialized audience. It | |
15270 | is a good idea to come up with a synopsis that gives an idea of the | |
15271 | application domain of the package. In this example, this might give | |
15272 | something like ``Manipulate nucleotide sequence alignments'', which | |
15273 | hopefully gives the user a better idea of whether this is what they are | |
15274 | looking for. | |
15275 | ||
cbd02397 LC |
15276 | Descriptions should take between five and ten lines. Use full |
15277 | sentences, and avoid using acronyms without first introducing them. | |
762e54b7 LC |
15278 | Please avoid marketing phrases such as ``world-leading'', |
15279 | ``industrial-strength'', and ``next-generation'', and avoid superlatives | |
15280 | like ``the most advanced''---they are not helpful to users looking for a | |
15281 | package and may even sound suspicious. Instead, try to be factual, | |
15282 | mentioning use cases and features. | |
15283 | ||
15284 | @cindex Texinfo markup, in package descriptions | |
cbd02397 LC |
15285 | Descriptions can include Texinfo markup, which is useful to introduce |
15286 | ornaments such as @code{@@code} or @code{@@dfn}, bullet lists, or | |
ba7d6c76 ML |
15287 | hyperlinks (@pxref{Overview,,, texinfo, GNU Texinfo}). However you |
15288 | should be careful when using some characters for example @samp{@@} and | |
15289 | curly braces which are the basic special characters in Texinfo | |
15290 | (@pxref{Special Characters,,, texinfo, GNU Texinfo}). User interfaces | |
15291 | such as @command{guix package --show} take care of rendering it | |
15292 | appropriately. | |
cbd02397 LC |
15293 | |
15294 | Synopses and descriptions are translated by volunteers | |
15295 | @uref{http://translationproject.org/domain/guix-packages.html, at the | |
15296 | Translation Project} so that as many users as possible can read them in | |
15297 | their native language. User interfaces search them and display them in | |
15298 | the language specified by the current locale. | |
15299 | ||
15300 | Translation is a lot of work so, as a packager, please pay even more | |
15301 | attention to your synopses and descriptions as every change may entail | |
ba7d6c76 | 15302 | additional work for translators. In order to help them, it is possible |
36743e71 | 15303 | to make recommendations or instructions visible to them by inserting |
ba7d6c76 ML |
15304 | special comments like this (@pxref{xgettext Invocation,,, gettext, GNU |
15305 | Gettext}): | |
15306 | ||
15307 | @example | |
15308 | ;; TRANSLATORS: "X11 resize-and-rotate" should not be translated. | |
15309 | (description "ARandR is designed to provide a simple visual front end | |
15310 | for the X11 resize-and-rotate (RandR) extension. @dots{}") | |
15311 | @end example | |
cbd02397 | 15312 | |
ef5dd60a | 15313 | |
cf4a9129 LC |
15314 | @node Python Modules |
15315 | @subsection Python Modules | |
ef5dd60a | 15316 | |
e32171ee | 15317 | @cindex python |
cf4a9129 LC |
15318 | We currently package Python 2 and Python 3, under the Scheme variable names |
15319 | @code{python-2} and @code{python} as explained in @ref{Version Numbers}. | |
15320 | To avoid confusion and naming clashes with other programming languages, it | |
15321 | seems desirable that the name of a package for a Python module contains | |
15322 | the word @code{python}. | |
ef5dd60a | 15323 | |
cf4a9129 LC |
15324 | Some modules are compatible with only one version of Python, others with both. |
15325 | If the package Foo compiles only with Python 3, we name it | |
15326 | @code{python-foo}; if it compiles only with Python 2, we name it | |
15327 | @code{python2-foo}. If it is compatible with both versions, we create two | |
15328 | packages with the corresponding names. | |
ef5dd60a | 15329 | |
cf4a9129 LC |
15330 | If a project already contains the word @code{python}, we drop this; |
15331 | for instance, the module python-dateutil is packaged under the names | |
99c866a0 HG |
15332 | @code{python-dateutil} and @code{python2-dateutil}. If the project name |
15333 | starts with @code{py} (e.g. @code{pytz}), we keep it and prefix it as | |
15334 | described above. | |
113daf62 | 15335 | |
e940a271 HG |
15336 | @subsubsection Specifying Dependencies |
15337 | @cindex inputs, for Python packages | |
15338 | ||
15339 | Dependency information for Python packages is usually available in the | |
15340 | package source tree, with varying degrees of accuracy: in the | |
15341 | @file{setup.py} file, in @file{requirements.txt}, or in @file{tox.ini}. | |
15342 | ||
15343 | Your mission, when writing a recipe for a Python package, is to map | |
15344 | these dependencies to the appropriate type of ``input'' (@pxref{package | |
15345 | Reference, inputs}). Although the @code{pypi} importer normally does a | |
15346 | good job (@pxref{Invoking guix import}), you may want to check the | |
15347 | following check list to determine which dependency goes where. | |
15348 | ||
15349 | @itemize | |
15350 | ||
aaf75c89 HG |
15351 | @item |
15352 | We currently package Python 2 with @code{setuptools} and @code{pip} | |
15353 | installed like Python 3.4 has per default. Thus you don't need to | |
891a843d HG |
15354 | specify either of these as an input. @command{guix lint} will warn you |
15355 | if you do. | |
aaf75c89 | 15356 | |
e940a271 HG |
15357 | @item |
15358 | Python dependencies required at run time go into | |
15359 | @code{propagated-inputs}. They are typically defined with the | |
15360 | @code{install_requires} keyword in @file{setup.py}, or in the | |
15361 | @file{requirements.txt} file. | |
15362 | ||
15363 | @item | |
15364 | Python packages required only at build time---e.g., those listed with | |
15365 | the @code{setup_requires} keyword in @file{setup.py}---or only for | |
15366 | testing---e.g., those in @code{tests_require}---go into | |
15367 | @code{native-inputs}. The rationale is that (1) they do not need to be | |
15368 | propagated because they are not needed at run time, and (2) in a | |
15369 | cross-compilation context, it's the ``native'' input that we'd want. | |
15370 | ||
aaf75c89 | 15371 | Examples are the @code{pytest}, @code{mock}, and @code{nose} test |
e940a271 HG |
15372 | frameworks. Of course if any of these packages is also required at |
15373 | run-time, it needs to go to @code{propagated-inputs}. | |
15374 | ||
15375 | @item | |
15376 | Anything that does not fall in the previous categories goes to | |
15377 | @code{inputs}, for example programs or C libraries required for building | |
15378 | Python packages containing C extensions. | |
15379 | ||
15380 | @item | |
15381 | If a Python package has optional dependencies (@code{extras_require}), | |
15382 | it is up to you to decide whether to add them or not, based on their | |
15383 | usefulness/overhead ratio (@pxref{Submitting Patches, @command{guix | |
15384 | size}}). | |
15385 | ||
15386 | @end itemize | |
15387 | ||
15388 | ||
cf4a9129 LC |
15389 | @node Perl Modules |
15390 | @subsection Perl Modules | |
523e4896 | 15391 | |
e32171ee | 15392 | @cindex perl |
cf4a9129 LC |
15393 | Perl programs standing for themselves are named as any other package, |
15394 | using the lowercase upstream name. | |
15395 | For Perl packages containing a single class, we use the lowercase class name, | |
15396 | replace all occurrences of @code{::} by dashes and prepend the prefix | |
15397 | @code{perl-}. | |
15398 | So the class @code{XML::Parser} becomes @code{perl-xml-parser}. | |
15399 | Modules containing several classes keep their lowercase upstream name and | |
15400 | are also prepended by @code{perl-}. Such modules tend to have the word | |
15401 | @code{perl} somewhere in their name, which gets dropped in favor of the | |
15402 | prefix. For instance, @code{libwww-perl} becomes @code{perl-libwww}. | |
523e4896 | 15403 | |
523e4896 | 15404 | |
e1c963bf HG |
15405 | @node Java Packages |
15406 | @subsection Java Packages | |
15407 | ||
e32171ee | 15408 | @cindex java |
e1c963bf HG |
15409 | Java programs standing for themselves are named as any other package, |
15410 | using the lowercase upstream name. | |
15411 | ||
15412 | To avoid confusion and naming clashes with other programming languages, | |
15413 | it is desirable that the name of a package for a Java package is | |
15414 | prefixed with @code{java-}. If a project already contains the word | |
15415 | @code{java}, we drop this; for instance, the package @code{ngsjava} is | |
15416 | packaged under the name @code{java-ngs}. | |
15417 | ||
15418 | For Java packages containing a single class or a small class hierarchy, | |
15419 | we use the lowercase class name, replace all occurrences of @code{.} by | |
15420 | dashes and prepend the prefix @code{java-}. So the class | |
15421 | @code{apache.commons.cli} becomes package | |
15422 | @code{java-apache-commons-cli}. | |
15423 | ||
15424 | ||
7fec52b7 AE |
15425 | @node Fonts |
15426 | @subsection Fonts | |
15427 | ||
e32171ee | 15428 | @cindex fonts |
7fec52b7 AE |
15429 | For fonts that are in general not installed by a user for typesetting |
15430 | purposes, or that are distributed as part of a larger software package, | |
15431 | we rely on the general packaging rules for software; for instance, this | |
15432 | applies to the fonts delivered as part of the X.Org system or fonts that | |
15433 | are part of TeX Live. | |
15434 | ||
15435 | To make it easier for a user to search for fonts, names for other packages | |
15436 | containing only fonts are constructed as follows, independently of the | |
15437 | upstream package name. | |
15438 | ||
15439 | The name of a package containing only one font family starts with | |
15440 | @code{font-}; it is followed by the foundry name and a dash @code{-} | |
15441 | if the foundry is known, and the font family name, in which spaces are | |
15442 | replaced by dashes (and as usual, all upper case letters are transformed | |
15443 | to lower case). | |
15444 | For example, the Gentium font family by SIL is packaged under the name | |
15445 | @code{font-sil-gentium}. | |
15446 | ||
15447 | For a package containing several font families, the name of the collection | |
15448 | is used in the place of the font family name. | |
15449 | For instance, the Liberation fonts consist of three families, | |
15450 | Liberation Sans, Liberation Serif and Liberation Mono. | |
15451 | These could be packaged separately under the names | |
15452 | @code{font-liberation-sans} and so on; but as they are distributed together | |
15453 | under a common name, we prefer to package them together as | |
15454 | @code{font-liberation}. | |
15455 | ||
15456 | In the case where several formats of the same font family or font collection | |
15457 | are packaged separately, a short form of the format, prepended by a dash, | |
15458 | is added to the package name. We use @code{-ttf} for TrueType fonts, | |
1b366ee4 | 15459 | @code{-otf} for OpenType fonts and @code{-type1} for PostScript Type 1 |
7fec52b7 AE |
15460 | fonts. |
15461 | ||
15462 | ||
b25937e3 | 15463 | |
cf4a9129 LC |
15464 | @node Bootstrapping |
15465 | @section Bootstrapping | |
b25937e3 | 15466 | |
cf4a9129 | 15467 | @c Adapted from the ELS 2013 paper. |
b25937e3 | 15468 | |
cf4a9129 | 15469 | @cindex bootstrapping |
7889394e | 15470 | |
cf4a9129 LC |
15471 | Bootstrapping in our context refers to how the distribution gets built |
15472 | ``from nothing''. Remember that the build environment of a derivation | |
15473 | contains nothing but its declared inputs (@pxref{Introduction}). So | |
15474 | there's an obvious chicken-and-egg problem: how does the first package | |
15475 | get built? How does the first compiler get compiled? Note that this is | |
15476 | a question of interest only to the curious hacker, not to the regular | |
15477 | user, so you can shamelessly skip this section if you consider yourself | |
15478 | a ``regular user''. | |
72b9d60d | 15479 | |
cf4a9129 LC |
15480 | @cindex bootstrap binaries |
15481 | The GNU system is primarily made of C code, with libc at its core. The | |
15482 | GNU build system itself assumes the availability of a Bourne shell and | |
15483 | command-line tools provided by GNU Coreutils, Awk, Findutils, `sed', and | |
15484 | `grep'. Furthermore, build programs---programs that run | |
15485 | @code{./configure}, @code{make}, etc.---are written in Guile Scheme | |
15486 | (@pxref{Derivations}). Consequently, to be able to build anything at | |
15487 | all, from scratch, Guix relies on pre-built binaries of Guile, GCC, | |
15488 | Binutils, libc, and the other packages mentioned above---the | |
15489 | @dfn{bootstrap binaries}. | |
72b9d60d | 15490 | |
cf4a9129 LC |
15491 | These bootstrap binaries are ``taken for granted'', though we can also |
15492 | re-create them if needed (more on that later). | |
72b9d60d | 15493 | |
cf4a9129 | 15494 | @unnumberedsubsec Preparing to Use the Bootstrap Binaries |
c79d54fe | 15495 | |
cf4a9129 LC |
15496 | @c As of Emacs 24.3, Info-mode displays the image, but since it's a |
15497 | @c large image, it's hard to scroll. Oh well. | |
15498 | @image{images/bootstrap-graph,6in,,Dependency graph of the early bootstrap derivations} | |
523e4896 | 15499 | |
cf4a9129 LC |
15500 | The figure above shows the very beginning of the dependency graph of the |
15501 | distribution, corresponding to the package definitions of the @code{(gnu | |
d33fa0c7 LC |
15502 | packages bootstrap)} module. A similar figure can be generated with |
15503 | @command{guix graph} (@pxref{Invoking guix graph}), along the lines of: | |
15504 | ||
15505 | @example | |
15506 | guix graph -t derivation \ | |
15507 | -e '(@@@@ (gnu packages bootstrap) %bootstrap-gcc)' \ | |
15508 | | dot -Tps > t.ps | |
15509 | @end example | |
15510 | ||
15511 | At this level of detail, things are | |
cf4a9129 LC |
15512 | slightly complex. First, Guile itself consists of an ELF executable, |
15513 | along with many source and compiled Scheme files that are dynamically | |
15514 | loaded when it runs. This gets stored in the @file{guile-2.0.7.tar.xz} | |
15515 | tarball shown in this graph. This tarball is part of Guix's ``source'' | |
15516 | distribution, and gets inserted into the store with @code{add-to-store} | |
15517 | (@pxref{The Store}). | |
2e7b5cea | 15518 | |
cf4a9129 LC |
15519 | But how do we write a derivation that unpacks this tarball and adds it |
15520 | to the store? To solve this problem, the @code{guile-bootstrap-2.0.drv} | |
15521 | derivation---the first one that gets built---uses @code{bash} as its | |
15522 | builder, which runs @code{build-bootstrap-guile.sh}, which in turn calls | |
15523 | @code{tar} to unpack the tarball. Thus, @file{bash}, @file{tar}, | |
15524 | @file{xz}, and @file{mkdir} are statically-linked binaries, also part of | |
15525 | the Guix source distribution, whose sole purpose is to allow the Guile | |
15526 | tarball to be unpacked. | |
fb729425 | 15527 | |
cf4a9129 LC |
15528 | Once @code{guile-bootstrap-2.0.drv} is built, we have a functioning |
15529 | Guile that can be used to run subsequent build programs. Its first task | |
15530 | is to download tarballs containing the other pre-built binaries---this | |
15531 | is what the @code{.tar.xz.drv} derivations do. Guix modules such as | |
15532 | @code{ftp-client.scm} are used for this purpose. The | |
15533 | @code{module-import.drv} derivations import those modules in a directory | |
15534 | in the store, using the original layout. The | |
15535 | @code{module-import-compiled.drv} derivations compile those modules, and | |
15536 | write them in an output directory with the right layout. This | |
15537 | corresponds to the @code{#:modules} argument of | |
15538 | @code{build-expression->derivation} (@pxref{Derivations}). | |
fb729425 | 15539 | |
cf4a9129 LC |
15540 | Finally, the various tarballs are unpacked by the |
15541 | derivations @code{gcc-bootstrap-0.drv}, @code{glibc-bootstrap-0.drv}, | |
15542 | etc., at which point we have a working C tool chain. | |
fb729425 | 15543 | |
fb729425 | 15544 | |
cf4a9129 | 15545 | @unnumberedsubsec Building the Build Tools |
523e4896 | 15546 | |
cf4a9129 LC |
15547 | Bootstrapping is complete when we have a full tool chain that does not |
15548 | depend on the pre-built bootstrap tools discussed above. This | |
15549 | no-dependency requirement is verified by checking whether the files of | |
15550 | the final tool chain contain references to the @file{/gnu/store} | |
15551 | directories of the bootstrap inputs. The process that leads to this | |
15552 | ``final'' tool chain is described by the package definitions found in | |
1f6f57df | 15553 | the @code{(gnu packages commencement)} module. |
df2ce343 | 15554 | |
d33fa0c7 LC |
15555 | The @command{guix graph} command allows us to ``zoom out'' compared to |
15556 | the graph above, by looking at the level of package objects instead of | |
15557 | individual derivations---remember that a package may translate to | |
15558 | several derivations, typically one derivation to download its source, | |
15559 | one to build the Guile modules it needs, and one to actually build the | |
15560 | package from source. The command: | |
15561 | ||
15562 | @example | |
15563 | guix graph -t bag \ | |
15564 | -e '(@@@@ (gnu packages commencement) | |
15565 | glibc-final-with-bootstrap-bash)' | dot -Tps > t.ps | |
15566 | @end example | |
15567 | ||
15568 | @noindent | |
15569 | produces the dependency graph leading to the ``final'' C | |
15570 | library@footnote{You may notice the @code{glibc-intermediate} label, | |
15571 | suggesting that it is not @emph{quite} final, but as a good | |
15572 | approximation, we will consider it final.}, depicted below. | |
15573 | ||
15574 | @image{images/bootstrap-packages,6in,,Dependency graph of the early packages} | |
15575 | ||
cf4a9129 LC |
15576 | @c See <http://lists.gnu.org/archive/html/gnu-system-discuss/2012-10/msg00000.html>. |
15577 | The first tool that gets built with the bootstrap binaries is | |
d33fa0c7 LC |
15578 | GNU@tie{}Make---noted @code{make-boot0} above---which is a prerequisite |
15579 | for all the following packages. From there Findutils and Diffutils get | |
15580 | built. | |
523e4896 | 15581 | |
cf4a9129 LC |
15582 | Then come the first-stage Binutils and GCC, built as pseudo cross |
15583 | tools---i.e., with @code{--target} equal to @code{--host}. They are | |
15584 | used to build libc. Thanks to this cross-build trick, this libc is | |
15585 | guaranteed not to hold any reference to the initial tool chain. | |
4af2447e | 15586 | |
d33fa0c7 LC |
15587 | From there the final Binutils and GCC (not shown above) are built. |
15588 | GCC uses @code{ld} | |
cf4a9129 LC |
15589 | from the final Binutils, and links programs against the just-built libc. |
15590 | This tool chain is used to build the other packages used by Guix and by | |
15591 | the GNU Build System: Guile, Bash, Coreutils, etc. | |
4af2447e | 15592 | |
cf4a9129 LC |
15593 | And voilà! At this point we have the complete set of build tools that |
15594 | the GNU Build System expects. These are in the @code{%final-inputs} | |
dd164244 MW |
15595 | variable of the @code{(gnu packages commencement)} module, and are |
15596 | implicitly used by any package that uses @code{gnu-build-system} | |
1f6f57df | 15597 | (@pxref{Build Systems, @code{gnu-build-system}}). |
4af2447e | 15598 | |
4af2447e | 15599 | |
cf4a9129 | 15600 | @unnumberedsubsec Building the Bootstrap Binaries |
4af2447e | 15601 | |
e32171ee | 15602 | @cindex bootstrap binaries |
cf4a9129 LC |
15603 | Because the final tool chain does not depend on the bootstrap binaries, |
15604 | those rarely need to be updated. Nevertheless, it is useful to have an | |
15605 | automated way to produce them, should an update occur, and this is what | |
15606 | the @code{(gnu packages make-bootstrap)} module provides. | |
4af2447e | 15607 | |
cf4a9129 LC |
15608 | The following command builds the tarballs containing the bootstrap |
15609 | binaries (Guile, Binutils, GCC, libc, and a tarball containing a mixture | |
15610 | of Coreutils and other basic command-line tools): | |
4b2615e1 | 15611 | |
cf4a9129 LC |
15612 | @example |
15613 | guix build bootstrap-tarballs | |
15614 | @end example | |
15615 | ||
15616 | The generated tarballs are those that should be referred to in the | |
15617 | @code{(gnu packages bootstrap)} module mentioned at the beginning of | |
15618 | this section. | |
15619 | ||
15620 | Still here? Then perhaps by now you've started to wonder: when do we | |
15621 | reach a fixed point? That is an interesting question! The answer is | |
15622 | unknown, but if you would like to investigate further (and have | |
15623 | significant computational and storage resources to do so), then let us | |
15624 | know. | |
15625 | ||
15626 | @node Porting | |
15627 | @section Porting to a New Platform | |
15628 | ||
15629 | As discussed above, the GNU distribution is self-contained, and | |
15630 | self-containment is achieved by relying on pre-built ``bootstrap | |
15631 | binaries'' (@pxref{Bootstrapping}). These binaries are specific to an | |
15632 | operating system kernel, CPU architecture, and application binary | |
15633 | interface (ABI). Thus, to port the distribution to a platform that is | |
15634 | not yet supported, one must build those bootstrap binaries, and update | |
15635 | the @code{(gnu packages bootstrap)} module to use them on that platform. | |
15636 | ||
15637 | Fortunately, Guix can @emph{cross compile} those bootstrap binaries. | |
15638 | When everything goes well, and assuming the GNU tool chain supports the | |
15639 | target platform, this can be as simple as running a command like this | |
15640 | one: | |
15641 | ||
15642 | @example | |
15643 | guix build --target=armv5tel-linux-gnueabi bootstrap-tarballs | |
15644 | @end example | |
15645 | ||
1c0c417d LC |
15646 | For this to work, the @code{glibc-dynamic-linker} procedure in |
15647 | @code{(gnu packages bootstrap)} must be augmented to return the right | |
15648 | file name for libc's dynamic linker on that platform; likewise, | |
15649 | @code{system->linux-architecture} in @code{(gnu packages linux)} must be | |
15650 | taught about the new platform. | |
15651 | ||
cf4a9129 | 15652 | Once these are built, the @code{(gnu packages bootstrap)} module needs |
1c0c417d LC |
15653 | to be updated to refer to these binaries on the target platform. That |
15654 | is, the hashes and URLs of the bootstrap tarballs for the new platform | |
15655 | must be added alongside those of the currently supported platforms. The | |
15656 | bootstrap Guile tarball is treated specially: it is expected to be | |
03d0e2d2 | 15657 | available locally, and @file{gnu/local.mk} has rules do download it for |
1c0c417d LC |
15658 | the supported architectures; a rule for the new platform must be added |
15659 | as well. | |
cf4a9129 LC |
15660 | |
15661 | In practice, there may be some complications. First, it may be that the | |
15662 | extended GNU triplet that specifies an ABI (like the @code{eabi} suffix | |
15663 | above) is not recognized by all the GNU tools. Typically, glibc | |
15664 | recognizes some of these, whereas GCC uses an extra @code{--with-abi} | |
15665 | configure flag (see @code{gcc.scm} for examples of how to handle this). | |
15666 | Second, some of the required packages could fail to build for that | |
15667 | platform. Lastly, the generated binaries could be broken for some | |
15668 | reason. | |
4af2447e | 15669 | |
9bf3c1a7 | 15670 | @c ********************************************************************* |
8c01b9d0 | 15671 | @include contributing.texi |
c78bd12b | 15672 | |
568717fd LC |
15673 | @c ********************************************************************* |
15674 | @node Acknowledgments | |
15675 | @chapter Acknowledgments | |
15676 | ||
136787cb LC |
15677 | Guix is based on the @uref{http://nixos.org/nix/, Nix package manager}, |
15678 | which was designed and | |
4c7ac9aa LC |
15679 | implemented by Eelco Dolstra, with contributions from other people (see |
15680 | the @file{nix/AUTHORS} file in Guix.) Nix pioneered functional package | |
568717fd LC |
15681 | management, and promoted unprecedented features, such as transactional |
15682 | package upgrades and rollbacks, per-user profiles, and referentially | |
15683 | transparent build processes. Without this work, Guix would not exist. | |
15684 | ||
15685 | The Nix-based software distributions, Nixpkgs and NixOS, have also been | |
15686 | an inspiration for Guix. | |
15687 | ||
4c7ac9aa LC |
15688 | GNU@tie{}Guix itself is a collective work with contributions from a |
15689 | number of people. See the @file{AUTHORS} file in Guix for more | |
15690 | information on these fine people. The @file{THANKS} file lists people | |
15691 | who have helped by reporting bugs, taking care of the infrastructure, | |
15692 | providing artwork and themes, making suggestions, and more---thank you! | |
15693 | ||
15694 | ||
568717fd LC |
15695 | @c ********************************************************************* |
15696 | @node GNU Free Documentation License | |
15697 | @appendix GNU Free Documentation License | |
e32171ee | 15698 | @cindex license, GNU Free Documentation License |
568717fd LC |
15699 | @include fdl-1.3.texi |
15700 | ||
15701 | @c ********************************************************************* | |
15702 | @node Concept Index | |
15703 | @unnumbered Concept Index | |
15704 | @printindex cp | |
15705 | ||
a85b83d2 LC |
15706 | @node Programming Index |
15707 | @unnumbered Programming Index | |
15708 | @syncodeindex tp fn | |
15709 | @syncodeindex vr fn | |
568717fd LC |
15710 | @printindex fn |
15711 | ||
15712 | @bye | |
15713 | ||
15714 | @c Local Variables: | |
15715 | @c ispell-local-dictionary: "american"; | |
15716 | @c End: |